Summary: | [WPE] Add API to notify about frame displayed view backend callback | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Carlos Garcia Campos <cgarcia> | ||||||||
Component: | WPE WebKit | Assignee: | Nobody <webkit-unassigned> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | aperez, berto, bugs-noreply, clopez, commit-queue, ews-watchlist, gustavo, mcatanzaro, zan | ||||||||
Priority: | P2 | ||||||||||
Version: | WebKit Nightly Build | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | Unspecified | ||||||||||
See Also: | https://github.com/Igalia/WPEBackend-fdo/pull/28 | ||||||||||
Bug Depends on: | 191906, 192627 | ||||||||||
Bug Blocks: | |||||||||||
Attachments: |
|
Description
Carlos Garcia Campos
2018-11-30 06:42:56 PST
Created attachment 356172 [details] Patch This patch doesn't work with the fdo backend, see https://github.com/Igalia/WPEBackend-fdo/pull/28 Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API Ping reviewers Comment on attachment 356172 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=356172&action=review > Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:219 > + FrameDisplayedCallback(const FrameDisplayedCallback&) = delete; > + FrameDisplayedCallback& operator=(const FrameDisplayedCallback&) = delete; Good thinking to make it uncopyable. > Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:410 > + SetForScope<bool>inFrameDisplayedGuard(m_webView->priv->inFrameDisplayed, true); Space after > > Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:4147 > + * Add a callback to be called when the backend notifies that a frame has been displayed in @web_view. I don't think you need the detail about the backend: "Add a callback to be called when the backend notifies that a frame has been displayed in @web_view." > Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:4169 > + * Removes a #WebKitFrameDisplayedCallback previously added to @web_view with > + * webkit_web_view_add_frame_displayed_callback(). Maybe we should document that the callback may be called once more after this function runs if the callbacks are currently being executed. Otherwise, applications that remove one callback during another callback and don't expect the original callback to be called again could crash. Admittedly, it would be pretty weird for an application to try this, so maybe not that important, but it seems unsafe and you do have a bunch of webView->priv->inFrameDisplayed logic trying to ensure safety here, after all. > Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:1240 > + : m_id(webkit_web_view_add_frame_displayed_callback(m_webView, [](WebKitWebView*, gpointer userData) { > + auto* test = static_cast<FrameDisplayedTest*>(userData); > + if (!test->m_maxFrames) > + return; > + > + if (++test->m_frameCounter == test->m_maxFrames) > + RunLoop::main().dispatch([test] { test->quitMainLoop(); }); > + }, this, nullptr)) Don't you think this is a bit much for a constructor initializer? I would do this in the body of the constructor. Up to you.... Comment on attachment 356172 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=356172&action=review >> Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:4147 >> + * Add a callback to be called when the backend notifies that a frame has been displayed in @web_view. > > I don't think you need the detail about the backend: > > "Add a callback to be called when the backend notifies that a frame has been displayed in @web_view." I mentioned explicitly on purpose after realizing that fdo backend was not dispatching the frame displayed signal. So, I want to make it clear that this callback depends on the backend. >> Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:4169 >> + * webkit_web_view_add_frame_displayed_callback(). > > Maybe we should document that the callback may be called once more after this function runs if the callbacks are currently being executed. Otherwise, applications that remove one callback during another callback and don't expect the original callback to be called again could crash. Admittedly, it would be pretty weird for an application to try this, so maybe not that important, but it seems unsafe and you do have a bunch of webView->priv->inFrameDisplayed logic trying to ensure safety here, after all. Not really, that's actually bug, good catch :-) We should check callback is not in frameDisplayedCallbacksToRemove before emitting the signal. I'll try to make a test case. >> Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:1240 >> + }, this, nullptr)) > > Don't you think this is a bit much for a constructor initializer? I would do this in the body of the constructor. Up to you.... This is just a test... Committed r239103: <https://trac.webkit.org/changeset/239103> Re-opened since this is blocked by bug 192627 Created attachment 357433 [details]
Patch for landing
Created attachment 357434 [details]
Patch for landing
Committed r239264: <https://trac.webkit.org/changeset/239264> |