Title: [271171] trunk/Source/WebKit
Revision
271171
Author
[email protected]
Date
2021-01-05 12:37:38 -0800 (Tue, 05 Jan 2021)

Log Message

Make WebPage::ForceRepaint use CompletionHandler instead of VoidCallback
https://bugs.webkit.org/show_bug.cgi?id=212269

Patch by Alex Christensen <[email protected]> on 2021-01-05
Reviewed by Chris Dumez.

Fix a few unsafe pointer uses along the way.
No change in behavior.

* UIProcess/API/C/WKPage.cpp:
(WKPageForceRepaint):
* UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::forceRepaintIfNeeded):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::forceRepaint):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(-[WKFullScreenWindowController enterFullScreen]):
(-[WKFullScreenWindowController _completedExitFullScreen]):
* UIProcess/mac/WKFullScreenWindowController.h:
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController dealloc]):
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
(-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
* WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
(WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync):
* WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
(WebKit::LayerTreeHost::layerFlushTimerFired):
(WebKit::LayerTreeHost::forceRepaintAsync):
(WebKit::LayerTreeHost::renderNextFrame):
* WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
(WebKit::LayerTreeHost::forceRepaintAsync):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::forceRepaintAsync):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::forceRepaint):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::forceRepaintAsync):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (271170 => 271171)


--- trunk/Source/WebKit/ChangeLog	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/ChangeLog	2021-01-05 20:37:38 UTC (rev 271171)
@@ -1,3 +1,48 @@
+2021-01-05  Alex Christensen  <[email protected]>
+
+        Make WebPage::ForceRepaint use CompletionHandler instead of VoidCallback
+        https://bugs.webkit.org/show_bug.cgi?id=212269
+
+        Reviewed by Chris Dumez.
+
+        Fix a few unsafe pointer uses along the way.
+        No change in behavior.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageForceRepaint):
+        * UIProcess/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::forceRepaintIfNeeded):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::forceRepaint):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
+        (-[WKFullScreenWindowController enterFullScreen]):
+        (-[WKFullScreenWindowController _completedExitFullScreen]):
+        * UIProcess/mac/WKFullScreenWindowController.h:
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController dealloc]):
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
+        (-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
+        * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
+        (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync):
+        * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h:
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp:
+        (WebKit::LayerTreeHost::layerFlushTimerFired):
+        (WebKit::LayerTreeHost::forceRepaintAsync):
+        (WebKit::LayerTreeHost::renderNextFrame):
+        * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h:
+        (WebKit::LayerTreeHost::forceRepaintAsync):
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::forceRepaintAsync):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::forceRepaint):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::forceRepaintAsync):
+
 2021-01-05  Sihui Liu  <[email protected]>
 
         Stop speech recognition if page becomes invisible

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -2573,9 +2573,9 @@
 
 void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
 {
-    toImpl(pageRef)->forceRepaint(VoidCallback::create([context, callback](WebKit::CallbackBase::Error error) {
-        callback(error == WebKit::CallbackBase::Error::None ? nullptr : toAPI(API::Error::create().ptr()), context);
-    }));
+    toImpl(pageRef)->forceRepaint([context, callback]() {
+        callback(nullptr, context);
+    });
 }
 
 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)

Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.cpp (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -560,10 +560,10 @@
 
     auto pageID = m_webPageProxy.identifier();
     GestureID gestureID = m_currentGestureID;
-    m_webPageProxy.forceRepaint(VoidCallback::create([pageID, gestureID] (CallbackBase::Error error) {
+    m_webPageProxy.forceRepaint([pageID, gestureID] () {
         if (auto gestureController = controllerForGesture(pageID, gestureID))
             gestureController->removeSwipeSnapshot();
-    }));
+    });
 }
 
 void ViewGestureController::willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -4192,38 +4192,18 @@
     send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID));
 }
 
-void WebPageProxy::forceRepaint(RefPtr<VoidCallback>&& callback)
+void WebPageProxy::forceRepaint(CompletionHandler<void()>&& callback)
 {
-    if (!hasRunningProcess()) {
-        // FIXME: If the page is invalid we should not call the callback. It'd be better to just return false from forceRepaint.
-        callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
-        return;
-    }
+    if (!hasRunningProcess())
+        return callback();
 
-    Function<void(CallbackBase::Error)> didForceRepaintCallback = [this, callback = WTFMove(callback)](CallbackBase::Error error) mutable {
-        if (error != CallbackBase::Error::None) {
-            callback->invalidate(error);
-            return;
-        }
+    m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
 
-        if (!hasRunningProcess()) {
-            callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
-            return;
-        }
-    
-        callAfterNextPresentationUpdate([callback = WTFMove(callback)](CallbackBase::Error error) {
-            if (error != CallbackBase::Error::None) {
-                callback->invalidate(error);
-                return;
-            }
-
-            callback->performCallback();
+    sendWithAsyncReply(Messages::WebPage::ForceRepaint(), [this, protectedThis = makeRef(*this), callback = WTFMove(callback)] () mutable {
+        callAfterNextPresentationUpdate([callback = WTFMove(callback)] (auto) mutable {
+            callback();
         });
-    };
-
-    auto callbackID = m_callbacks.put(WTFMove(didForceRepaintCallback), m_process->throttler().backgroundActivity("WebPageProxy::forceRepaint"_s));
-    m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
-    send(Messages::WebPage::ForceRepaint(callbackID));
+    });
 }
 
 static OptionSet<IPC::SendOption> printingSendOptions(bool isPerformingDOMPrintOperation)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -1148,7 +1148,7 @@
     void getWebArchiveOfFrame(WebFrameProxy*, Function<void (API::Data*, CallbackBase::Error)>&&);
     void runJavaScriptInMainFrame(WebCore::RunJavaScriptParameters&&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
     void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, API::ContentWorld&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
-    void forceRepaint(RefPtr<VoidCallback>&&);
+    void forceRepaint(CompletionHandler<void()>&&);
 
     float headerHeight(WebFrameProxy&);
     float footerHeight(WebFrameProxy&);

Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm	2021-01-05 20:37:38 UTC (rev 271171)
@@ -460,7 +460,6 @@
     RetainPtr<UIWindow> _window;
     RetainPtr<UIViewController> _rootViewController;
 
-    RefPtr<WebKit::VoidCallback> _repaintCallback;
     RetainPtr<UIViewController> _viewControllerForPresentation;
     RetainPtr<WKFullScreenViewController> _fullscreenViewController;
     RetainPtr<UISwipeGestureRecognizer> _startDismissGestureRecognizer;
@@ -624,9 +623,7 @@
         arguments.userZoom = 1;
         page->setOverrideViewportArguments(arguments);
 
-        _repaintCallback = WebKit::VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) {
-            _repaintCallback = nullptr;
-
+        page->forceRepaint([protectedSelf = retainPtr(self), self] {
             if (_exitRequested) {
                 _exitRequested = NO;
                 [self _exitFullscreenImmediately];
@@ -641,7 +638,6 @@
             ASSERT_NOT_REACHED();
             [self _exitFullscreenImmediately];
         });
-        page->forceRepaint(_repaintCallback.copyRef());
 
         [CATransaction commit];
     }];
@@ -833,13 +829,7 @@
     [_window setHidden:YES];
     _window = nil;
 
-    if (_repaintCallback) {
-        _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);
-        ASSERT(!_repaintCallback);
-    }
-
-    _repaintCallback = WebKit::VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) {
-        _repaintCallback = nullptr;
+    CompletionHandler<void()> completionHandler([protectedSelf = retainPtr(self), self] {
         _webViewPlaceholder.get().parent = nil;
         [_webViewPlaceholder removeFromSuperview];
 
@@ -858,9 +848,9 @@
 
     auto* page = [self._webView _page].get();
     if (page && page->isViewFocused())
-        page->forceRepaint(_repaintCallback.copyRef());
+        page->forceRepaint(WTFMove(completionHandler));
     else
-        _repaintCallback->performCallback();
+        completionHandler();
 
     [_fullscreenViewController setPrefersStatusBarHidden:YES];
     _fullscreenViewController = nil;

Modified: trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -62,7 +62,6 @@
     FullScreenState _fullScreenState;
 
     double _savedScale;
-    RefPtr<WebKit::VoidCallback> _repaintCallback;
     float _savedTopContentInset;
 }
 

Modified: trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (271170 => 271171)


--- trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2021-01-05 20:37:38 UTC (rev 271171)
@@ -155,13 +155,6 @@
     
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 
-    if (_repaintCallback) {
-        _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);
-        // invalidate() calls completeFinishExitFullScreenAnimationAfterRepaint, which
-        // clears _repaintCallback.
-        ASSERT(!_repaintCallback);
-    }
-
     _videoFullscreenManagerProxyClient.setParent(nullptr);
 
     [super dealloc];
@@ -574,16 +567,9 @@
     [self _manager]->restoreScrollPosition();
     _page->setTopContentInset(_savedTopContentInset);
 
-    if (_repaintCallback) {
-        _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);
-        // invalidate() calls completeFinishExitFullScreenAnimationAfterRepaint, which
-        // clears _repaintCallback.
-        ASSERT(!_repaintCallback);
-    }
-    _repaintCallback = WebKit::VoidCallback::create([self](WebKit::CallbackBase::Error) {
-        [self completeFinishExitFullScreenAnimationAfterRepaint];
+    _page->forceRepaint([weakSelf = WeakObjCPtr<WKFullScreenWindowController>(self)] {
+        [weakSelf completeFinishExitFullScreenAnimationAfterRepaint];
     });
-    _page->forceRepaint(_repaintCallback.copyRef());
 
     [CATransaction commit];
     [CATransaction flush];
@@ -605,7 +591,6 @@
     [[_webView window] makeKeyAndOrderFront:self];
     _webViewPlaceholder = nil;
     
-    _repaintCallback = nullptr;
     _page->setSuppressVisibilityUpdates(false);
     _page->setNeedsDOMWindowResizeEvent();
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -213,12 +213,17 @@
         }
 }
 
-bool DrawingAreaCoordinatedGraphics::forceRepaintAsync(CallbackID callbackID)
+void DrawingAreaCoordinatedGraphics::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler)
 {
-    if (m_layerTreeStateIsFrozen)
-        return false;
+    if (m_layerTreeStateIsFrozen) {
+        page.forceRepaintWithoutCallback();
+        return completionHandler();
+    }
 
-    return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);
+    if (m_layerTreeHost)
+        m_layerTreeHost->forceRepaintAsync(WTFMove(completionHandler));
+    else
+        completionHandler();
 }
 
 void DrawingAreaCoordinatedGraphics::setLayerTreeStateIsFrozen(bool isFrozen)

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -51,7 +51,7 @@
     void setNeedsDisplayInRect(const WebCore::IntRect&) override;
     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override;
     void forceRepaint() override;
-    bool forceRepaintAsync(CallbackID) override;
+    void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override;
 
     void setLayerTreeStateIsFrozen(bool) override;
     bool layerTreeStateIsFrozen() const override { return m_layerTreeStateIsFrozen; }

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -141,7 +141,7 @@
 
     // If a force-repaint callback was registered, we should force a 'frame sync' that
     // will guarantee us a call to renderNextFrame() once the update is complete.
-    if (m_forceRepaintAsync.callbackID)
+    if (m_forceRepaintAsync.callback)
         m_coordinator.forceFrameSync();
 
     bool didSync = m_coordinator.flushPendingLayerChanges();
@@ -190,16 +190,15 @@
     m_compositor->forceRepaint();
 }
 
-bool LayerTreeHost::forceRepaintAsync(CallbackID callbackID)
+void LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&& callback)
 {
     scheduleLayerFlush();
 
     // We want a clean repaint, meaning that if we're currently waiting for the renderer
     // to finish an update, we'll have to schedule another flush when it's done.
-    ASSERT(!m_forceRepaintAsync.callbackID);
-    m_forceRepaintAsync.callbackID = OptionalCallbackID(callbackID);
+    ASSERT(!m_forceRepaintAsync.callback);
+    m_forceRepaintAsync.callback = WTFMove(callback);
     m_forceRepaintAsync.needsFreshFlush = m_scheduledWhileWaitingForRenderer;
-    return true;
 }
 
 void LayerTreeHost::sizeDidChange(const IntSize& size)
@@ -405,7 +404,7 @@
     bool scheduledWhileWaitingForRenderer = std::exchange(m_scheduledWhileWaitingForRenderer, false);
     m_coordinator.renderNextFrame();
 
-    if (m_forceRepaintAsync.callbackID) {
+    if (m_forceRepaintAsync.callback) {
         // If the asynchronous force-repaint needs a separate fresh flush, it was due to
         // the force-repaint request being registered while CoordinatedLayerTreeHost was
         // waiting for the renderer to finish an update.
@@ -414,10 +413,8 @@
         // Execute the callback if another layer flush and the subsequent state update
         // aren't needed. If they are, the callback will be executed when this function
         // is called after the next update.
-        if (!m_forceRepaintAsync.needsFreshFlush) {
-            m_webPage.send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsync.callbackID.callbackID()));
-            m_forceRepaintAsync.callbackID = OptionalCallbackID();
-        }
+        if (!m_forceRepaintAsync.needsFreshFlush)
+            m_forceRepaintAsync.callback();
         m_forceRepaintAsync.needsFreshFlush = false;
     }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -79,7 +79,7 @@
 
     void scrollNonCompositedContents(const WebCore::IntRect&);
     void forceRepaint();
-    bool forceRepaintAsync(CallbackID);
+    void forceRepaintAsync(CompletionHandler<void()>&&);
     void sizeDidChange(const WebCore::IntSize& newSize);
 
     void pauseRendering();
@@ -193,7 +193,7 @@
     RefPtr<ThreadedCompositor> m_compositor;
     SimpleViewportController m_viewportController;
     struct {
-        OptionalCallbackID callbackID;
+        CompletionHandler<void()> callback;
         bool needsFreshFlush { false };
     } m_forceRepaintAsync;
     RunLoop::Timer<LayerTreeHost> m_layerFlushTimer;
@@ -213,7 +213,7 @@
 inline void LayerTreeHost::setViewOverlayRootLayer(WebCore::GraphicsLayer*) { }
 inline void LayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&) { }
 inline void LayerTreeHost::forceRepaint() { }
-inline bool LayerTreeHost::forceRepaintAsync(CallbackID) { return false; }
+inline bool LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&) { return false; }
 inline void LayerTreeHost::sizeDidChange(const WebCore::IntSize&) { }
 inline void LayerTreeHost::pauseRendering() { }
 inline void LayerTreeHost::resumeRendering() { }

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -208,9 +208,9 @@
     flushAndRenderLayers();
 }
 
-bool LayerTreeHost::forceRepaintAsync(CallbackID)
+void LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&& completionHandler)
 {
-    return false;
+    completionHandler();
 }
 
 void LayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)

Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -67,7 +67,7 @@
     void setNonCompositedContentsNeedDisplay(const WebCore::IntRect&);
     void scrollNonCompositedContents(const WebCore::IntRect&);
     void forceRepaint();
-    bool forceRepaintAsync(CallbackID);
+    void forceRepaintAsync(CompletionHandler<void()>&&);
     void sizeDidChange(const WebCore::IntSize& newSize);
     void pauseRendering();
     void resumeRendering();

Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -85,7 +85,7 @@
 
     // FIXME: These should be pure virtual.
     virtual void forceRepaint() { }
-    virtual bool forceRepaintAsync(CallbackID) { return false; }
+    virtual void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) = 0;
     virtual void setLayerTreeStateIsFrozen(bool) { }
     virtual bool layerTreeStateIsFrozen() const { return false; }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -87,7 +87,7 @@
     bool layerTreeStateIsFrozen() const override { return m_isRenderingSuspended; }
 
     void forceRepaint() override;
-    bool forceRepaintAsync(CallbackID) override { return false; }
+    void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override;
 
     void setViewExposedRect(Optional<WebCore::FloatRect>) override;
     Optional<WebCore::FloatRect> viewExposedRect() const override { return m_viewExposedRect; }

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-01-05 20:37:38 UTC (rev 271171)
@@ -184,6 +184,12 @@
     DebugPageOverlays::settingsChanged(*m_webPage.corePage());
 }
 
+void RemoteLayerTreeDrawingArea::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler)
+{
+    page.forceRepaintWithoutCallback();
+    completionHandler();
+}
+
 #if PLATFORM(IOS_FAMILY)
 void RemoteLayerTreeDrawingArea::setDeviceScaleFactor(float deviceScaleFactor)
 {

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-01-05 20:37:38 UTC (rev 271171)
@@ -3718,13 +3718,9 @@
     m_drawingArea->forceRepaint();
 }
 
-void WebPage::forceRepaint(CallbackID callbackID)
+void WebPage::forceRepaint(CompletionHandler<void()>&& completionHandler)
 {
-    if (m_drawingArea->forceRepaintAsync(callbackID))
-        return;
-
-    forceRepaintWithoutCallback();
-    send(Messages::WebPageProxy::VoidCallback(callbackID));
+    m_drawingArea->forceRepaintAsync(*this, WTFMove(completionHandler));
 }
 
 void WebPage::preferencesDidChange(const WebPreferencesStore& store)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -1567,7 +1567,7 @@
     void getWebArchiveOfFrame(WebCore::FrameIdentifier, CallbackID);
     void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
     void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
-    void forceRepaint(CallbackID);
+    void forceRepaint(CompletionHandler<void()>&&);
     void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, CallbackID);
 
     void preferencesDidChange(const WebPreferencesStore&);

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-01-05 20:37:38 UTC (rev 271171)
@@ -222,7 +222,7 @@
 
     RunJavaScriptInFrameInScriptWorld(struct WebCore::RunJavaScriptParameters parameters, Optional<WebCore::FrameIdentifier> frameID, std::pair<WebKit::ContentWorldIdentifier, String> world) -> (IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details) Async
 
-    ForceRepaint(WebKit::CallbackID callbackID)
+    ForceRepaint() -> () Async
     SelectAll()
     ScheduleFullEditorStateUpdate()
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h	2021-01-05 20:37:38 UTC (rev 271171)
@@ -61,7 +61,7 @@
     void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override { }
 
     void forceRepaint() override;
-    bool forceRepaintAsync(CallbackID) override;
+    void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override;
     void setLayerTreeStateIsFrozen(bool) override;
     bool layerTreeStateIsFrozen() const override;
     void setRootCompositingLayer(WebCore::GraphicsLayer*) override;

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (271170 => 271171)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-01-05 20:33:21 UTC (rev 271170)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-01-05 20:37:38 UTC (rev 271171)
@@ -173,16 +173,19 @@
     [CATransaction synchronize];
 }
 
-bool TiledCoreAnimationDrawingArea::forceRepaintAsync(CallbackID callbackID)
+void TiledCoreAnimationDrawingArea::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler)
 {
-    if (m_layerTreeStateIsFrozen)
-        return false;
+    if (m_layerTreeStateIsFrozen) {
+        page.forceRepaintWithoutCallback();
+        return completionHandler();
+    }
 
-    dispatchAfterEnsuringUpdatedScrollPosition([this, callbackID] {
+    dispatchAfterEnsuringUpdatedScrollPosition([this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)] () mutable {
+        if (!weakThis)
+            return completionHandler();
         m_webPage.drawingArea()->forceRepaint();
-        m_webPage.send(Messages::WebPageProxy::VoidCallback(callbackID));
+        completionHandler();
     });
-    return true;
 }
 
 void TiledCoreAnimationDrawingArea::setLayerTreeStateIsFrozen(bool layerTreeStateIsFrozen)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to