RESOLVED FIXED 236510
Inject custom styles into PDF.js to make it look like PDFKit
https://bugs.webkit.org/show_bug.cgi?id=236510
Summary Inject custom styles into PDF.js to make it look like PDFKit
Tim Nguyen (:ntim)
Reported 2022-02-11 07:49:54 PST
Attachments
Patch (17.54 KB, patch)
2022-02-11 07:57 PST, Tim Nguyen (:ntim)
no flags
Patch (23.87 KB, patch)
2022-02-11 08:02 PST, Tim Nguyen (:ntim)
no flags
Patch (24.21 KB, patch)
2022-02-11 08:51 PST, Tim Nguyen (:ntim)
thorton: review+
Patch (24.20 KB, patch)
2022-02-11 09:19 PST, Tim Nguyen (:ntim)
no flags
[fast-cq] Patch for landing (24.20 KB, patch)
2022-02-11 09:25 PST, Tim Nguyen (:ntim)
no flags
[fast-cq] Patch for landing (24.19 KB, patch)
2022-02-11 09:31 PST, Tim Nguyen (:ntim)
no flags
Tim Nguyen (:ntim)
Comment 1 2022-02-11 07:50:01 PST
Tim Nguyen (:ntim)
Comment 2 2022-02-11 07:57:12 PST
Tim Nguyen (:ntim)
Comment 3 2022-02-11 08:02:34 PST
youenn fablet
Comment 4 2022-02-11 08:31:25 PST
Comment on attachment 451698 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451698&action=review > Source/WebCore/ChangeLog:12 > + (e.g. loading a blob, hooking with find-in-page messages, etc.). There are other changes in this patch, is it expected? > Source/WebCore/html/PDFDocument.cpp:58 > + PDFDocumentEventListener(PDFDocument& document) explicit. > Source/WebCore/html/PDFDocument.cpp:67 > + PDFDocument& m_document; This is not safe, there is no guarantee m_document is alive during PDFDocumentEventListener lifetime
Tim Nguyen (:ntim)
Comment 5 2022-02-11 08:51:29 PST
Tim Horton
Comment 6 2022-02-11 09:07:04 PST
Comment on attachment 451703 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451703&action=review > Source/WebCore/html/PDFDocument.h:51 > + RefPtr<HTMLIFrameElement> m_iframe; “m_iFrame” I would imagine given the type’s capitalization, but check what we use elsewhere.
Chris Dumez
Comment 7 2022-02-11 09:14:31 PST
(In reply to Tim Horton from comment #6) > Comment on attachment 451703 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=451703&action=review > > > Source/WebCore/html/PDFDocument.h:51 > > + RefPtr<HTMLIFrameElement> m_iframe; > > “m_iFrame” I would imagine given the type’s capitalization, but check what > we use elsewhere. I have never seen m_iFrame in our code base. I think we consistently use "iframe".
youenn fablet
Comment 8 2022-02-11 09:15:54 PST
Comment on attachment 451703 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451703&action=review > Source/WebCore/html/PDFDocument.cpp:153 > + m_iframe = iframe.ptr(); m_iframe = WTFMove(iframe) > Source/WebCore/html/PDFDocument.cpp:170 > + auto script = HTMLScriptElement::create(scriptTag, *this, false, false); It is a bit weird to create an element with *this while it will be added to another document. You can probably pass a Document& to injectContentScript from the event handler, in which case no need to store m_frame at all.
Tim Nguyen (:ntim)
Comment 9 2022-02-11 09:19:39 PST
Tim Nguyen (:ntim)
Comment 10 2022-02-11 09:25:39 PST
Created attachment 451707 [details] [fast-cq] Patch for landing
Tim Nguyen (:ntim)
Comment 11 2022-02-11 09:28:08 PST
(In reply to youenn fablet from comment #8) > Comment on attachment 451703 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=451703&action=review > > > Source/WebCore/html/PDFDocument.cpp:153 > > + m_iframe = iframe.ptr(); > > m_iframe = WTFMove(iframe) > > > Source/WebCore/html/PDFDocument.cpp:170 > > + auto script = HTMLScriptElement::create(scriptTag, *this, false, false); > > It is a bit weird to create an element with *this while it will be added to > another document. > You can probably pass a Document& to injectContentScript from the event > handler, in which case no need to store m_frame at all. Done, I've used the contentDocument instead of *this. The m_iframe can't be removed since injectContentScript is called from the event listener. Besides that, it's useful to have it to send messages to the iframe if we need to in the future (for find in page for instance)
Tim Nguyen (:ntim)
Comment 12 2022-02-11 09:30:21 PST
Comment on attachment 451707 [details] [fast-cq] Patch for landing whoops not up to date
Tim Nguyen (:ntim)
Comment 13 2022-02-11 09:31:08 PST
Created attachment 451708 [details] [fast-cq] Patch for landing
EWS
Comment 14 2022-02-11 09:32:02 PST
Committed r289627 (247137@main): <https://commits.webkit.org/247137@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 451707 [details].
Radar WebKit Bug Importer
Comment 15 2022-02-11 09:33:18 PST
Tim Nguyen (:ntim)
Comment 16 2022-02-11 09:33:38 PST
Comment on attachment 451708 [details] [fast-cq] Patch for landing Welp, fast-cq was faster than me, will address comments manually
youenn fablet
Comment 17 2022-02-11 09:34:42 PST
> Done, I've used the contentDocument instead of *this. The m_iframe can't be > removed since injectContentScript is called from the event listener. The event listener has a ScriptExecutionContext& which is probably the Document& you want to use. In that case, why would we need m_iframe?
Tim Nguyen (:ntim)
Comment 18 2022-02-11 09:54:05 PST
(In reply to youenn fablet from comment #17) > > Done, I've used the contentDocument instead of *this. The m_iframe can't be > > removed since injectContentScript is called from the event listener. > > The event listener has a ScriptExecutionContext& which is probably the > Document& you want to use. > In that case, why would we need m_iframe? Addressed in https://commits.webkit.org/r289630
Note You need to log in before you can comment on or make changes to this bug.