Changeset 271171 in webkit
- Timestamp:
- Jan 5, 2021, 12:37:38 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 22 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/C/WKPage.cpp (modified) (1 diff)
-
UIProcess/ViewGestureController.cpp (modified) (1 diff)
-
UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
UIProcess/WebPageProxy.h (modified) (1 diff)
-
UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm (modified) (5 diffs)
-
UIProcess/mac/WKFullScreenWindowController.h (modified) (1 diff)
-
UIProcess/mac/WKFullScreenWindowController.mm (modified) (3 diffs)
-
WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (modified) (1 diff)
-
WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h (modified) (1 diff)
-
WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (modified) (5 diffs)
-
WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h (modified) (3 diffs)
-
WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp (modified) (1 diff)
-
WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.h (modified) (1 diff)
-
WebProcess/WebPage/DrawingArea.h (modified) (1 diff)
-
WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (modified) (1 diff)
-
WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (modified) (1 diff)
-
WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (modified) (1 diff)
-
WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r271169 r271171 1 2021-01-05 Alex Christensen <achristensen@webkit.org> 2 3 Make WebPage::ForceRepaint use CompletionHandler instead of VoidCallback 4 https://bugs.webkit.org/show_bug.cgi?id=212269 5 6 Reviewed by Chris Dumez. 7 8 Fix a few unsafe pointer uses along the way. 9 No change in behavior. 10 11 * UIProcess/API/C/WKPage.cpp: 12 (WKPageForceRepaint): 13 * UIProcess/ViewGestureController.cpp: 14 (WebKit::ViewGestureController::forceRepaintIfNeeded): 15 * UIProcess/WebPageProxy.cpp: 16 (WebKit::WebPageProxy::forceRepaint): 17 * UIProcess/WebPageProxy.h: 18 * UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm: 19 (-[WKFullScreenWindowController enterFullScreen]): 20 (-[WKFullScreenWindowController _completedExitFullScreen]): 21 * UIProcess/mac/WKFullScreenWindowController.h: 22 * UIProcess/mac/WKFullScreenWindowController.mm: 23 (-[WKFullScreenWindowController dealloc]): 24 (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): 25 (-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]): 26 * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: 27 (WebKit::DrawingAreaCoordinatedGraphics::forceRepaintAsync): 28 * WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h: 29 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: 30 (WebKit::LayerTreeHost::layerFlushTimerFired): 31 (WebKit::LayerTreeHost::forceRepaintAsync): 32 (WebKit::LayerTreeHost::renderNextFrame): 33 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h: 34 (WebKit::LayerTreeHost::forceRepaintAsync): 35 * WebProcess/WebPage/DrawingArea.h: 36 (WebKit::DrawingArea::forceRepaintAsync): 37 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h: 38 * WebProcess/WebPage/WebPage.cpp: 39 (WebKit::WebPage::forceRepaint): 40 * WebProcess/WebPage/WebPage.h: 41 * WebProcess/WebPage/WebPage.messages.in: 42 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h: 43 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 44 (WebKit::TiledCoreAnimationDrawingArea::forceRepaintAsync): 45 1 46 2021-01-05 Sihui Liu <sihui_liu@appe.com> 2 47 -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r271162 r271171 2574 2574 void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback) 2575 2575 { 2576 toImpl(pageRef)->forceRepaint( VoidCallback::create([context, callback](WebKit::CallbackBase::Error error) {2577 callback( error == WebKit::CallbackBase::Error::None ? nullptr : toAPI(API::Error::create().ptr()), context);2578 }) );2576 toImpl(pageRef)->forceRepaint([context, callback]() { 2577 callback(nullptr, context); 2578 }); 2579 2579 } 2580 2580 -
trunk/Source/WebKit/UIProcess/ViewGestureController.cpp
r263825 r271171 561 561 auto pageID = m_webPageProxy.identifier(); 562 562 GestureID gestureID = m_currentGestureID; 563 m_webPageProxy.forceRepaint( VoidCallback::create([pageID, gestureID] (CallbackBase::Error error) {563 m_webPageProxy.forceRepaint([pageID, gestureID] () { 564 564 if (auto gestureController = controllerForGesture(pageID, gestureID)) 565 565 gestureController->removeSwipeSnapshot(); 566 }) );566 }); 567 567 } 568 568 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r271169 r271171 4193 4193 } 4194 4194 4195 void WebPageProxy::forceRepaint(RefPtr<VoidCallback>&& callback) 4196 { 4197 if (!hasRunningProcess()) { 4198 // FIXME: If the page is invalid we should not call the callback. It'd be better to just return false from forceRepaint. 4199 callback->invalidate(CallbackBase::Error::OwnerWasInvalidated); 4200 return; 4201 } 4202 4203 Function<void(CallbackBase::Error)> didForceRepaintCallback = [this, callback = WTFMove(callback)](CallbackBase::Error error) mutable { 4204 if (error != CallbackBase::Error::None) { 4205 callback->invalidate(error); 4206 return; 4207 } 4208 4209 if (!hasRunningProcess()) { 4210 callback->invalidate(CallbackBase::Error::OwnerWasInvalidated); 4211 return; 4212 } 4213 4214 callAfterNextPresentationUpdate([callback = WTFMove(callback)](CallbackBase::Error error) { 4215 if (error != CallbackBase::Error::None) { 4216 callback->invalidate(error); 4217 return; 4218 } 4219 4220 callback->performCallback(); 4195 void WebPageProxy::forceRepaint(CompletionHandler<void()>&& callback) 4196 { 4197 if (!hasRunningProcess()) 4198 return callback(); 4199 4200 m_drawingArea->waitForBackingStoreUpdateOnNextPaint(); 4201 4202 sendWithAsyncReply(Messages::WebPage::ForceRepaint(), [this, protectedThis = makeRef(*this), callback = WTFMove(callback)] () mutable { 4203 callAfterNextPresentationUpdate([callback = WTFMove(callback)] (auto) mutable { 4204 callback(); 4221 4205 }); 4222 }; 4223 4224 auto callbackID = m_callbacks.put(WTFMove(didForceRepaintCallback), m_process->throttler().backgroundActivity("WebPageProxy::forceRepaint"_s)); 4225 m_drawingArea->waitForBackingStoreUpdateOnNextPaint(); 4226 send(Messages::WebPage::ForceRepaint(callbackID)); 4206 }); 4227 4207 } 4228 4208 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r271162 r271171 1149 1149 void runJavaScriptInMainFrame(WebCore::RunJavaScriptParameters&&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&); 1150 1150 void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, API::ContentWorld&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&); 1151 void forceRepaint( RefPtr<VoidCallback>&&);1151 void forceRepaint(CompletionHandler<void()>&&); 1152 1152 1153 1153 float headerHeight(WebFrameProxy&); -
trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
r269557 r271171 461 461 RetainPtr<UIViewController> _rootViewController; 462 462 463 RefPtr<WebKit::VoidCallback> _repaintCallback;464 463 RetainPtr<UIViewController> _viewControllerForPresentation; 465 464 RetainPtr<WKFullScreenViewController> _fullscreenViewController; … … 625 624 page->setOverrideViewportArguments(arguments); 626 625 627 _repaintCallback = WebKit::VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) { 628 _repaintCallback = nullptr; 629 626 page->forceRepaint([protectedSelf = retainPtr(self), self] { 630 627 if (_exitRequested) { 631 628 _exitRequested = NO; … … 642 639 [self _exitFullscreenImmediately]; 643 640 }); 644 page->forceRepaint(_repaintCallback.copyRef());645 641 646 642 [CATransaction commit]; … … 834 830 _window = nil; 835 831 836 if (_repaintCallback) { 837 _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated); 838 ASSERT(!_repaintCallback); 839 } 840 841 _repaintCallback = WebKit::VoidCallback::create([protectedSelf = retainPtr(self), self](WebKit::CallbackBase::Error) { 842 _repaintCallback = nullptr; 832 CompletionHandler<void()> completionHandler([protectedSelf = retainPtr(self), self] { 843 833 _webViewPlaceholder.get().parent = nil; 844 834 [_webViewPlaceholder removeFromSuperview]; … … 859 849 auto* page = [self._webView _page].get(); 860 850 if (page && page->isViewFocused()) 861 page->forceRepaint( _repaintCallback.copyRef());851 page->forceRepaint(WTFMove(completionHandler)); 862 852 else 863 _repaintCallback->performCallback();853 completionHandler(); 864 854 865 855 [_fullscreenViewController setPrefersStatusBarHidden:YES]; -
trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h
r267053 r271171 63 63 64 64 double _savedScale; 65 RefPtr<WebKit::VoidCallback> _repaintCallback;66 65 float _savedTopContentInset; 67 66 } -
trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm
r270069 r271171 156 156 [[NSNotificationCenter defaultCenter] removeObserver:self]; 157 157 158 if (_repaintCallback) {159 _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated);160 // invalidate() calls completeFinishExitFullScreenAnimationAfterRepaint, which161 // clears _repaintCallback.162 ASSERT(!_repaintCallback);163 }164 165 158 _videoFullscreenManagerProxyClient.setParent(nullptr); 166 159 … … 575 568 _page->setTopContentInset(_savedTopContentInset); 576 569 577 if (_repaintCallback) { 578 _repaintCallback->invalidate(WebKit::CallbackBase::Error::OwnerWasInvalidated); 579 // invalidate() calls completeFinishExitFullScreenAnimationAfterRepaint, which 580 // clears _repaintCallback. 581 ASSERT(!_repaintCallback); 582 } 583 _repaintCallback = WebKit::VoidCallback::create([self](WebKit::CallbackBase::Error) { 584 [self completeFinishExitFullScreenAnimationAfterRepaint]; 570 _page->forceRepaint([weakSelf = WeakObjCPtr<WKFullScreenWindowController>(self)] { 571 [weakSelf completeFinishExitFullScreenAnimationAfterRepaint]; 585 572 }); 586 _page->forceRepaint(_repaintCallback.copyRef());587 573 588 574 [CATransaction commit]; … … 606 592 _webViewPlaceholder = nil; 607 593 608 _repaintCallback = nullptr;609 594 _page->setSuppressVisibilityUpdates(false); 610 595 _page->setNeedsDOMWindowResizeEvent(); -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
r268014 r271171 214 214 } 215 215 216 bool DrawingAreaCoordinatedGraphics::forceRepaintAsync(CallbackID callbackID) 217 { 218 if (m_layerTreeStateIsFrozen) 219 return false; 220 221 return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID); 216 void DrawingAreaCoordinatedGraphics::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler) 217 { 218 if (m_layerTreeStateIsFrozen) { 219 page.forceRepaintWithoutCallback(); 220 return completionHandler(); 221 } 222 223 if (m_layerTreeHost) 224 m_layerTreeHost->forceRepaintAsync(WTFMove(completionHandler)); 225 else 226 completionHandler(); 222 227 } 223 228 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h
r268014 r271171 52 52 void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta) override; 53 53 void forceRepaint() override; 54 bool forceRepaintAsync(CallbackID) override;54 void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override; 55 55 56 56 void setLayerTreeStateIsFrozen(bool) override; -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
r261616 r271171 142 142 // If a force-repaint callback was registered, we should force a 'frame sync' that 143 143 // will guarantee us a call to renderNextFrame() once the update is complete. 144 if (m_forceRepaintAsync.callback ID)144 if (m_forceRepaintAsync.callback) 145 145 m_coordinator.forceFrameSync(); 146 146 … … 191 191 } 192 192 193 bool LayerTreeHost::forceRepaintAsync(CallbackID callbackID)193 void LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&& callback) 194 194 { 195 195 scheduleLayerFlush(); … … 197 197 // We want a clean repaint, meaning that if we're currently waiting for the renderer 198 198 // to finish an update, we'll have to schedule another flush when it's done. 199 ASSERT(!m_forceRepaintAsync.callback ID);200 m_forceRepaintAsync.callback ID = OptionalCallbackID(callbackID);199 ASSERT(!m_forceRepaintAsync.callback); 200 m_forceRepaintAsync.callback = WTFMove(callback); 201 201 m_forceRepaintAsync.needsFreshFlush = m_scheduledWhileWaitingForRenderer; 202 return true;203 202 } 204 203 … … 406 405 m_coordinator.renderNextFrame(); 407 406 408 if (m_forceRepaintAsync.callback ID) {407 if (m_forceRepaintAsync.callback) { 409 408 // If the asynchronous force-repaint needs a separate fresh flush, it was due to 410 409 // the force-repaint request being registered while CoordinatedLayerTreeHost was … … 415 414 // aren't needed. If they are, the callback will be executed when this function 416 415 // is called after the next update. 417 if (!m_forceRepaintAsync.needsFreshFlush) { 418 m_webPage.send(Messages::WebPageProxy::VoidCallback(m_forceRepaintAsync.callbackID.callbackID())); 419 m_forceRepaintAsync.callbackID = OptionalCallbackID(); 420 } 416 if (!m_forceRepaintAsync.needsFreshFlush) 417 m_forceRepaintAsync.callback(); 421 418 m_forceRepaintAsync.needsFreshFlush = false; 422 419 } -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h
r262158 r271171 80 80 void scrollNonCompositedContents(const WebCore::IntRect&); 81 81 void forceRepaint(); 82 bool forceRepaintAsync(CallbackID);82 void forceRepaintAsync(CompletionHandler<void()>&&); 83 83 void sizeDidChange(const WebCore::IntSize& newSize); 84 84 … … 194 194 SimpleViewportController m_viewportController; 195 195 struct { 196 OptionalCallbackID callbackID;196 CompletionHandler<void()> callback; 197 197 bool needsFreshFlush { false }; 198 198 } m_forceRepaintAsync; … … 214 214 inline void LayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&) { } 215 215 inline void LayerTreeHost::forceRepaint() { } 216 inline bool LayerTreeHost::forceRepaintAsync(C allbackID) { return false; }216 inline bool LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&) { return false; } 217 217 inline void LayerTreeHost::sizeDidChange(const WebCore::IntSize&) { } 218 218 inline void LayerTreeHost::pauseRendering() { } -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.cpp
r270699 r271171 209 209 } 210 210 211 bool LayerTreeHost::forceRepaintAsync(CallbackID)212 { 213 return false;211 void LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&& completionHandler) 212 { 213 completionHandler(); 214 214 } 215 215 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHostTextureMapper.h
r262172 r271171 68 68 void scrollNonCompositedContents(const WebCore::IntRect&); 69 69 void forceRepaint(); 70 bool forceRepaintAsync(CallbackID);70 void forceRepaintAsync(CompletionHandler<void()>&&); 71 71 void sizeDidChange(const WebCore::IntSize& newSize); 72 72 void pauseRendering(); -
trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h
r270387 r271171 86 86 // FIXME: These should be pure virtual. 87 87 virtual void forceRepaint() { } 88 virtual bool forceRepaintAsync(CallbackID) { return false; }88 virtual void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) = 0; 89 89 virtual void setLayerTreeStateIsFrozen(bool) { } 90 90 virtual bool layerTreeStateIsFrozen() const { return false; } -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
r269824 r271171 88 88 89 89 void forceRepaint() override; 90 bool forceRepaintAsync(CallbackID) override { return false; }90 void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override; 91 91 92 92 void setViewExposedRect(Optional<WebCore::FloatRect>) override; -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
r269824 r271171 185 185 } 186 186 187 void RemoteLayerTreeDrawingArea::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler) 188 { 189 page.forceRepaintWithoutCallback(); 190 completionHandler(); 191 } 192 187 193 #if PLATFORM(IOS_FAMILY) 188 194 void RemoteLayerTreeDrawingArea::setDeviceScaleFactor(float deviceScaleFactor) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r271162 r271171 3719 3719 } 3720 3720 3721 void WebPage::forceRepaint(CallbackID callbackID) 3722 { 3723 if (m_drawingArea->forceRepaintAsync(callbackID)) 3724 return; 3725 3726 forceRepaintWithoutCallback(); 3727 send(Messages::WebPageProxy::VoidCallback(callbackID)); 3721 void WebPage::forceRepaint(CompletionHandler<void()>&& completionHandler) 3722 { 3723 m_drawingArea->forceRepaintAsync(*this, WTFMove(completionHandler)); 3728 3724 } 3729 3725 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r271162 r271171 1568 1568 void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&); 1569 1569 void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&); 1570 void forceRepaint(C allbackID);1570 void forceRepaint(CompletionHandler<void()>&&); 1571 1571 void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, CallbackID); 1572 1572 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r271162 r271171 223 223 RunJavaScriptInFrameInScriptWorld(struct WebCore::RunJavaScriptParameters parameters, Optional<WebCore::FrameIdentifier> frameID, std::pair<WebKit::ContentWorldIdentifier, String> world) -> (IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details) Async 224 224 225 ForceRepaint( WebKit::CallbackID callbackID)225 ForceRepaint() -> () Async 226 226 SelectAll() 227 227 ScheduleFullEditorStateUpdate() -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
r268014 r271171 62 62 63 63 void forceRepaint() override; 64 bool forceRepaintAsync(CallbackID) override;64 void forceRepaintAsync(WebPage&, CompletionHandler<void()>&&) override; 65 65 void setLayerTreeStateIsFrozen(bool) override; 66 66 bool layerTreeStateIsFrozen() const override; -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r270557 r271171 174 174 } 175 175 176 bool TiledCoreAnimationDrawingArea::forceRepaintAsync(CallbackID callbackID) 177 { 178 if (m_layerTreeStateIsFrozen) 179 return false; 180 181 dispatchAfterEnsuringUpdatedScrollPosition([this, callbackID] { 176 void TiledCoreAnimationDrawingArea::forceRepaintAsync(WebPage& page, CompletionHandler<void()>&& completionHandler) 177 { 178 if (m_layerTreeStateIsFrozen) { 179 page.forceRepaintWithoutCallback(); 180 return completionHandler(); 181 } 182 183 dispatchAfterEnsuringUpdatedScrollPosition([this, weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)] () mutable { 184 if (!weakThis) 185 return completionHandler(); 182 186 m_webPage.drawingArea()->forceRepaint(); 183 m_webPage.send(Messages::WebPageProxy::VoidCallback(callbackID));187 completionHandler(); 184 188 }); 185 return true;186 189 } 187 190
Note:
See TracChangeset
for help on using the changeset viewer.