-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add callback for document element creation #1454
Comments
Original comment by Anonymous. Comment 1. originally posted by czarek.tomczak on 2014-11-26T11:47:13.000Z: I'm +1 to restore user stylesheet option to CefSettings. Regarding "limitation of OnLoadStart being asynchronous" issue. CefLoadHandler with OnLoadStart callback is exposed to both the browser process and the renderer process. It's available in the renderer process handler since branch 1650, see issue #1077. |
Comment 2. originally posted by magreenblatt on 2014-11-26T19:47:18.000Z: @ finn: Please try OnLoadStart in the render process and see if that satisfies your use case. |
Original comment by Anonymous. Comment 3. originally posted by finn.hughes1 on 2014-11-30T21:53:44.000Z: Thanks for the feedback, I wasn't aware the handler was available in the render process. I didn't take the time to understand the delegates in cefclient instead I implemented this in cefpython since that's what I use anyway. The javascript I injected started: And the log showed "boo" then: So it seems that there is no DOM if you call this function in the render process, it's possible I've done something wrong but that seems to be the case. Any more ideas? Finn |
Comment 4. originally posted by magreenblatt on 2014-12-04T09:29:51.000Z: @ comment 3.: How did you inject the JavaScript? You're correct that there is no DOM when OnLoadStart is called. |
Original comment by Anonymous. Comment 5. originally posted by finn.hughes1 on 2014-12-04T11:07:06.000Z: Hi Marshall, I'm not aware of any way to inject css before the dom exists? I used "frame->ExecuteJavaScript" exactly the same as in the previously attached diff. That fails as there's no head to append to. If there's a way to inject css before the DOM exists then I'd also have the option of using CefRegisterExtension in the render process, not sure if that would have any advantages or disadvantages over OnLoadStart. |
Comment 6. originally posted by magreenblatt on 2015-01-08T18:01:00.000Z: |
|
|
In the browser process we can expose WebContentsObserver::DocumentAvailableInMainFrame. |
Original comment by Alex Maitland (Bitbucket: a-maitland). Would it also be possible to add WebContentsObserver:: DOMContentLoaded at the same time? That would be quite useful also. Happy to create a new issue rather than hijack this one. |
Add support for direct DevTools protocol messaging (fixes issue #2961). This change allows the client to directly send and receive DevTools This change includes additional supporting changes:
This change also adds a cefclient demo for configuring offline mode → <<cset 39aed35644dc (bb)>> |
@{557058:5abcbcf9-b372-4ecb-830e-ddb451b76481} Can you explain the use case for DOMContentLoaded? How does it differ from the timing of OnLoadEnd (which is triggered from RenderFrameObserver::DidFinishLoad)? Thanks. |
Add support for direct DevTools protocol messaging (fixes issue #2961). This change allows the client to directly send and receive DevTools This change includes additional supporting changes:
This change also adds a cefclient demo for configuring offline mode → <<cset 0fb8a5f1eada (bb)>> |
Add support for direct DevTools protocol messaging (fixes issue #2961). This change allows the client to directly send and receive DevTools This change includes additional supporting changes:
This change also adds a cefclient demo for configuring offline mode → <<cset fd6631bd1812 (bb)>> |
Original comment by Alex Maitland (Bitbucket: a-maitland).
Sorry for the slow reply. I understand that technically the difference between OnLoadEnd and DOMContentLoaded in terms of timing is potentially quite small. The reason for the request to add The cost of implementation looks quite low and the maintenance burden would appear to be small, adding it seems like an easy win in many ways. I think it falls into the category of nice to have as obviously you can execute javascript in OnLoadStart to hook the event in javascript and use the native javascript event. It’s not the end of the world if it’s not implemented or you choose to delegate (via PR) to someone else. Thanks for taking the time to follow up. |
Marking issues that we're unlikely to address as WontFix. If it still applies with currently supported CEF versions, and someone would like to submit a PR fix, then we can reopen. |
|
…iumembedded#2961). This change allows the client to directly send and receive DevTools protocol messages (send method calls, and receive method results and events) without requiring a DevTools front-end or remote-debugging session. This change includes additional supporting changes: - Add a new CefRequestHandler::OnDocumentAvailableInMainFrame callback (see issue chromiumembedded#1454). - Add a CefParseJSON variant that accepts a UTF8-encoded buffer. - Add a `--devtools-protocol-log-file=<path>` command-line flag for logging protocol messages sent to/from the DevTools front-end while it is displayed. This is useful for understanding existing DevTools protocol usage. - Add a new "libcef_static_unittests" executable target to support light-weight unit tests of libcef_static internals (e.g. without requiring exposure via the CEF API). Files to be unittested are placed in the new "libcef_static_unittested" source_set which is then included by both the existing libcef_static library and the new unittests executable target. - Linux: Remove use_bundled_fontconfig=false, which is no longer required and causes unittest build errors (see issue chromiumembedded#2424). This change also adds a cefclient demo for configuring offline mode using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled by the "Offline mode" context menu option and the `--offline` command-line switch which will launch cefclient in offline mode. When cefclient is offline all network requests will fail with ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when called from JavaScript in any frame. This mode is per-browser so newly created browser windows will have the default mode. Note that configuring offline mode in this way will not update the Network tab UI ("Throtting" option) in a displayed DevTools front-end instance.
…iumembedded#2961). This change allows the client to directly send and receive DevTools protocol messages (send method calls, and receive method results and events) without requiring a DevTools front-end or remote-debugging session. This change includes additional supporting changes: - Add a new CefRequestHandler::OnDocumentAvailableInMainFrame callback (see issue chromiumembedded#1454). - Add a CefParseJSON variant that accepts a UTF8-encoded buffer. - Add a `--devtools-protocol-log-file=<path>` command-line flag for logging protocol messages sent to/from the DevTools front-end while it is displayed. This is useful for understanding existing DevTools protocol usage. - Add a new "libcef_static_unittests" executable target to support light-weight unit tests of libcef_static internals (e.g. without requiring exposure via the CEF API). Files to be unittested are placed in the new "libcef_static_unittested" source_set which is then included by both the existing libcef_static library and the new unittests executable target. - Linux: Remove use_bundled_fontconfig=false, which is no longer required and causes unittest build errors (see issue chromiumembedded#2424). This change also adds a cefclient demo for configuring offline mode using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled by the "Offline mode" context menu option and the `--offline` command-line switch which will launch cefclient in offline mode. When cefclient is offline all network requests will fail with ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when called from JavaScript in any frame. This mode is per-browser so newly created browser windows will have the default mode. Note that configuring offline mode in this way will not update the Network tab UI ("Throtting" option) in a displayed DevTools front-end instance.
…iumembedded#2961). This change allows the client to directly send and receive DevTools protocol messages (send method calls, and receive method results and events) without requiring a DevTools front-end or remote-debugging session. This change includes additional supporting changes: - Add a new CefRequestHandler::OnDocumentAvailableInMainFrame callback (see issue chromiumembedded#1454). - Add a CefParseJSON variant that accepts a UTF8-encoded buffer. - Add a `--devtools-protocol-log-file=<path>` command-line flag for logging protocol messages sent to/from the DevTools front-end while it is displayed. This is useful for understanding existing DevTools protocol usage. - Add a new "libcef_static_unittests" executable target to support light-weight unit tests of libcef_static internals (e.g. without requiring exposure via the CEF API). Files to be unittested are placed in the new "libcef_static_unittested" source_set which is then included by both the existing libcef_static library and the new unittests executable target. - Linux: Remove use_bundled_fontconfig=false, which is no longer required and causes unittest build errors (see issue chromiumembedded#2424). This change also adds a cefclient demo for configuring offline mode using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled by the "Offline mode" context menu option and the `--offline` command-line switch which will launch cefclient in offline mode. When cefclient is offline all network requests will fail with ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when called from JavaScript in any frame. This mode is per-browser so newly created browser windows will have the default mode. Note that configuring offline mode in this way will not update the Network tab UI ("Throtting" option) in a displayed DevTools front-end instance.
Original report by Anonymous.
Original issue 1454 created by finn.hughes1 on 2014-11-26T10:58:02.000Z:
What steps will reproduce the problem?
What is the expected output? What do you see instead?
On simple but long pages e.g.
http://munsterdirectory.com/aboutus.htm
Sometimes the red styling isn't applied.
What version of the product are you using? On what operating system?
1750 on fedora/ubuntu 32bit.
Please provide any additional information below.
I've attached a patch to cefclient to demonstrate the problem (scrollbar_style_test.diff)
I imagine this is a fundemental limitation of OnLoadStart being asynchronous and to reliably inject css to style the main window scrollbar we'll have to do it in the render process.
Reading through the chrome issues from when they dropped support for the user style sheet it seems chrome extensions are the replacement. To inject css in a chrome extension you use 'content_scripts'. Looking at the source for that I tracked the injection to:
chrome/renderer/extensions/user_script_scheduler.cc
Triggered by UserScriptScheduler::DidCreateDocumentElement it uses the insertUserStyleSheet call that used to be used for user style sheet injection.
When removing user style sheets they created a insertStyleSheet function and made it so the second parameter setting the type of style sheet would be ignored so all sheets are author sheets. I had a look at instertStyleSheet in trunk and found it unchanged so this interface has remained stable from 33-40+.
I created a very simple patch to emulate the css injection of the extension, but only took it far enough for my needs. If there are specific steps required to make this something cef can accept upstream I'll see if I can find time.
I patched:
content/renderer/render_view_impl.cc
adding one simple call to RenderViewImpl::didCreateDocumentElement
'frame->document().insertStyleSheet(WebString::fromUTF8(css_));'
where css_ was initialized by reading a css file.
The text was updated successfully, but these errors were encountered: