[wk2] Synchronously wait a short time for a layer tree update after bringing a web...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2014 21:32:03 +0000 (21:32 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2014 21:32:03 +0000 (21:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134189

Reviewed by Simon Fraser.

Make the old behavior of -[WKView endDeferringViewInWindowChangesSync] the default; synchronously wait
for a fraction of a second when a page that was previously in-window but currently isn't comes back in-window,
until new content is painted (or we hit a timeout).

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::waitForDidUpdateViewState):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateViewState):
Delegate waitForDidUpdateViewState to the DrawingAreaProxys, because behavior is very dependent on them.

* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::coreAnimationDidCommitLayers):
(WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateViewState):
Implement waitForDidUpdateViewState for the RemoteLayerTree; it waits for CommitLayerTree.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::updateViewState):
(WebKit::WebPageProxy::viewStateDidChange):
(WebKit::WebPageProxy::dispatchViewStateChange):
(WebKit::WebPageProxy::waitForDidUpdateViewState):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
(WebKit::WebPageProxy::viewSize): Deleted.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::didUpdateViewState):
* UIProcess/API/mac/WKView.mm:
(-[WKView endDeferringViewInWindowChangesSync]):
Always waitForDidUpdateViewState when a page that was previously in-window but currently isn't comes back in-window.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::viewStateDidChange):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setViewState):
(WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
(WebKit::RemoteLayerTreeDrawingArea::viewStateDidChange):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::viewStateDidChange):
(WebKit::TiledCoreAnimationDrawingArea::didUpdateViewStateTimerFired):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
Delegate sending of didUpdateViewState to the DrawingAreas (RemoteLayerTreeDrawingArea won't send it,
    because the UI process waits for CommitLayerTree instead).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170319 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

index d428d66da0b1990ba96f53671c0182a4b4bb6397..cdd1661547a064b7bbf884091d98fc4aadb72d33 100644 (file)
@@ -1,3 +1,62 @@
+2014-06-23  Tim Horton  <timothy_horton@apple.com>
+
+        [wk2] Synchronously wait a short time for a layer tree update after bringing a web view in-window
+        https://bugs.webkit.org/show_bug.cgi?id=134189
+
+        Reviewed by Simon Fraser.
+
+        Make the old behavior of -[WKView endDeferringViewInWindowChangesSync] the default; synchronously wait
+        for a fraction of a second when a page that was previously in-window but currently isn't comes back in-window,
+        until new content is painted (or we hit a timeout).
+        
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::waitForDidUpdateViewState):
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateViewState):
+        Delegate waitForDidUpdateViewState to the DrawingAreaProxys, because behavior is very dependent on them.
+
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::coreAnimationDidCommitLayers):
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateViewState):
+        Implement waitForDidUpdateViewState for the RemoteLayerTree; it waits for CommitLayerTree.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::updateViewState):
+        (WebKit::WebPageProxy::viewStateDidChange):
+        (WebKit::WebPageProxy::dispatchViewStateChange):
+        (WebKit::WebPageProxy::waitForDidUpdateViewState):
+        (WebKit::WebPageProxy::resetStateAfterProcessExited):
+        (WebKit::WebPageProxy::viewSize): Deleted.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::didUpdateViewState):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView endDeferringViewInWindowChangesSync]):
+        Always waitForDidUpdateViewState when a page that was previously in-window but currently isn't comes back in-window.
+
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::viewStateDidChange):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::setViewState):
+        (WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        (WebKit::RemoteLayerTreeDrawingArea::viewStateDidChange):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        (WebKit::TiledCoreAnimationDrawingArea::viewStateDidChange):
+        (WebKit::TiledCoreAnimationDrawingArea::didUpdateViewStateTimerFired):
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
+        Delegate sending of didUpdateViewState to the DrawingAreas (RemoteLayerTreeDrawingArea won't send it,
+            because the UI process waits for CommitLayerTree instead).
+
 2014-06-23  Timothy Horton  <timothy_horton@apple.com>
 
         [iOS][wk2] Ensure that layers are marked volatile before allowing the process to suspend
index 1641c0e7822ae678cb6c923affbd957b8ce3122c..df497ad0ae9be1350df7f5d8e65bc2e0e63e9673 100644 (file)
@@ -3756,6 +3756,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
 #endif
 }
 
+// FIXME: All of these "DeferringViewInWindowChanges" methods should be able to be removed once clients are weaned off of them.
 - (void)beginDeferringViewInWindowChanges
 {
     if (_data->_shouldDeferViewInWindowChanges) {
@@ -3788,18 +3789,12 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
         return;
     }
 
-    PageClient* pageClient = _data->_pageClient.get();
-    bool hasPendingViewInWindowChange = _data->_viewInWindowChangeWasDeferred && _data->_page->isInWindow() != pageClient->isViewInWindow();
-
     _data->_shouldDeferViewInWindowChanges = NO;
 
     if (_data->_viewInWindowChangeWasDeferred) {
-        _data->_page->viewStateDidChange(ViewState::IsInWindow, hasPendingViewInWindowChange ? WebPageProxy::WantsReplyOrNot::DoesWantReply : WebPageProxy::WantsReplyOrNot::DoesNotWantReply);
+        _data->_page->viewStateDidChange(ViewState::IsInWindow);
         _data->_viewInWindowChangeWasDeferred = NO;
     }
-
-    if (hasPendingViewInWindowChange)
-        _data->_page->waitForDidUpdateViewState();
 }
 
 - (BOOL)isDeferringViewInWindowChanges
index 7a5b7ac6fe3ea84da9b8ba5c6db492c5645f4b44..8685d672ff9c4d7022a7c01ea42ebed828baec23 100644 (file)
@@ -87,6 +87,8 @@ public:
 
     virtual uint64_t lastVisibleTransactionID() const { ASSERT_NOT_REACHED(); return 0; }
 
+    virtual void waitForDidUpdateViewState() { }
+
 protected:
     explicit DrawingAreaProxy(DrawingAreaType, WebPageProxy*);
 
index 921565585e0113ba89342f4cd259c50721987092..d39aeb75e013e7b2a5ee18fdd91742c0a1df7400 100644 (file)
@@ -280,6 +280,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_geolocationPermissionRequestManager(*this)
     , m_notificationPermissionRequestManager(*this)
     , m_viewState(ViewState::NoFlags)
+    , m_viewWasEverInWindow(false)
     , m_backForwardList(WebBackForwardList::create(*this))
     , m_loadStateAtProcessExit(FrameLoadState::State::Finished)
 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
@@ -362,7 +363,6 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_autoSizingShouldExpandToViewHeight(false)
     , m_mediaVolume(1)
     , m_mayStartMediaWhenInWindow(true)
-    , m_waitingForDidUpdateViewState(false)
     , m_scrollPinningBehavior(DoNotPin)
     , m_navigationID(0)
     , m_configurationPreferenceValues(configuration.preferenceValues)
@@ -1094,19 +1094,22 @@ void WebPageProxy::updateViewState(ViewState::Flags flagsToUpdate)
         m_viewState |= ViewState::IsVisible;
     if (flagsToUpdate & ViewState::IsVisibleOrOccluded && m_pageClient.isViewVisibleOrOccluded())
         m_viewState |= ViewState::IsVisibleOrOccluded;
-    if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow())
+    if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow()) {
         m_viewState |= ViewState::IsInWindow;
+        m_viewWasEverInWindow = true;
+    }
     if (flagsToUpdate & ViewState::IsVisuallyIdle && m_pageClient.isVisuallyIdle())
         m_viewState |= ViewState::IsVisuallyIdle;
 }
 
-void WebPageProxy::viewStateDidChange(ViewState::Flags mayHaveChanged, WantsReplyOrNot wantsReply)
+void WebPageProxy::viewStateDidChange(ViewState::Flags mayHaveChanged)
 {
+    bool isNewlyInWindow = !isInWindow() && (mayHaveChanged & ViewState::IsInWindow) && m_pageClient.isViewInWindow();
+
     m_potentiallyChangedViewStateFlags |= mayHaveChanged;
-    m_viewStateChangeWantsReply = (wantsReply == WantsReplyOrNot::DoesWantReply || m_viewStateChangeWantsReply == WantsReplyOrNot::DoesWantReply) ? WantsReplyOrNot::DoesWantReply : WantsReplyOrNot::DoesNotWantReply;
+    m_viewStateChangeWantsReply = ((m_viewWasEverInWindow && isNewlyInWindow) || m_viewStateChangeWantsReply == WantsReplyOrNot::DoesWantReply) ? WantsReplyOrNot::DoesWantReply : WantsReplyOrNot::DoesNotWantReply;
 
 #if PLATFORM(COCOA)
-    bool isNewlyInWindow = !(m_viewState & ViewState::IsInWindow) && (mayHaveChanged & ViewState::IsInWindow) && m_pageClient.isViewInWindow();
     if (isNewlyInWindow) {
         dispatchViewStateChange();
         return;
@@ -1174,6 +1177,9 @@ void WebPageProxy::dispatchViewStateChange()
 
     updateBackingStoreDiscardableState();
 
+    if (m_viewStateChangeWantsReply == WantsReplyOrNot::DoesWantReply)
+        waitForDidUpdateViewState();
+
     m_potentiallyChangedViewStateFlags = ViewState::NoFlags;
     m_viewStateChangeWantsReply = WantsReplyOrNot::DoesNotWantReply;
 }
@@ -1203,19 +1209,19 @@ void WebPageProxy::layerHostingModeDidChange()
 
 void WebPageProxy::waitForDidUpdateViewState()
 {
-    // If we have previously timed out with no response from the WebProcess, don't block the UIProcess again until it starts responding.
-    if (m_waitingForDidUpdateViewState)
+    if (!isValid())
         return;
 
-    if (!isValid())
+    if (m_process->state() != WebProcessProxy::State::Running)
+        return;
+
+    // If we have previously timed out with no response from the WebProcess, don't block the UIProcess again until it starts responding.
+    if (m_waitingForDidUpdateViewState)
         return;
 
     m_waitingForDidUpdateViewState = true;
 
-    if (m_process->state() != WebProcessProxy::State::Launching) {
-        auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
-        m_process->connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DidUpdateViewState>(m_pageID, viewStateUpdateTimeout);
-    }
+    m_drawingArea->waitForDidUpdateViewState();
 }
 
 IntSize WebPageProxy::viewSize() const
@@ -4295,7 +4301,6 @@ void WebPageProxy::resetStateAfterProcessExited()
 
     m_isValid = false;
     m_isPageSuspended = false;
-    m_waitingForDidUpdateViewState = false;
 
     if (m_mainFrame) {
         m_urlAtProcessExit = m_mainFrame->url();
index da91570137809965992bc07d5bab9af60cf41bbf..7f90f5d27d9ee750f41d644dc94539fdc54b86bc 100644 (file)
@@ -361,9 +361,10 @@ public:
     bool delegatesScrolling() const { return m_delegatesScrolling; }
 
     enum class WantsReplyOrNot { DoesNotWantReply, DoesWantReply };
-    void viewStateDidChange(WebCore::ViewState::Flags mayHaveChanged, WantsReplyOrNot = WantsReplyOrNot::DoesNotWantReply);
+    void viewStateDidChange(WebCore::ViewState::Flags mayHaveChanged);
     bool isInWindow() const { return m_viewState & WebCore::ViewState::IsInWindow; }
     void waitForDidUpdateViewState();
+    void didUpdateViewState() { m_waitingForDidUpdateViewState = false; }
 
     void layerHostingModeDidChange();
 
@@ -575,8 +576,6 @@ public:
 
     void listenForLayoutMilestones(WebCore::LayoutMilestones);
 
-    void didUpdateViewState() { m_waitingForDidUpdateViewState = false; }
-
     bool hasHorizontalScrollbar() const { return m_mainFrameHasHorizontalScrollbar; }
     bool hasVerticalScrollbar() const { return m_mainFrameHasVerticalScrollbar; }
 
@@ -1321,6 +1320,7 @@ private:
     NotificationPermissionRequestManagerProxy m_notificationPermissionRequestManager;
 
     WebCore::ViewState::Flags m_viewState;
+    bool m_viewWasEverInWindow;
 
 #if PLATFORM(IOS)
     std::unique_ptr<ProcessThrottler::ForegroundActivityToken> m_activityToken;
index 44a69a9b70d76f636763d475c8dfeb7eb7e9e780..3787728a31a9a709ed91142fa1742f424af1718a 100644 (file)
@@ -67,6 +67,8 @@ private:
     virtual void updateDebugIndicator() override;
     void updateDebugIndicator(WebCore::IntSize contentsSize, bool rootLayerChanged, float scale);
     void updateDebugIndicatorPosition();
+
+    virtual void waitForDidUpdateViewState() override;
     
     WebCore::FloatPoint indicatorLocation() const;
 
index a5a716706ed3050c904c2cc9afc42d19d48e8dfc..1cef7ce79dc2d164ef5db35b8c587b5ea0eba750 100644 (file)
@@ -37,6 +37,7 @@
 #import <WebCore/IOSurfacePool.h>
 #import <WebCore/WebActionDisablingCALayerDelegate.h>
 
+using namespace IPC;
 using namespace WebCore;
 
 static const CFIndex didCommitLayersRunLoopOrder = (CFIndex)RunLoopObserver::WellKnownRunLoopOrders::CoreAnimationCommit + 1;
@@ -317,6 +318,18 @@ void RemoteLayerTreeDrawingAreaProxy::coreAnimationDidCommitLayers()
     m_webPageProxy->process().send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID());
 
     m_lastVisibleTransactionID = m_transactionIDForPendingCACommit;
+
+    m_webPageProxy->didUpdateViewState();
+}
+
+void RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateViewState()
+{
+#if PLATFORM(IOS)
+    auto viewStateUpdateTimeout = std::chrono::milliseconds(500);
+#else
+    auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
+#endif
+    m_webPageProxy->process().connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_webPageProxy->pageID(), viewStateUpdateTimeout, InterruptWaitingIfSyncMessageArrives);
 }
 
 } // namespace WebKit
index 49e984277687f6d25faf195d5448c5e80ffb0770..d5842e6681c9488c0f8455a6d6f20f7143d44d79 100644 (file)
@@ -52,6 +52,8 @@ private:
     virtual void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
     virtual void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
 
+    virtual void waitForDidUpdateViewState() override;
+
     // Message handlers.
     virtual void didUpdateGeometry() override;
     virtual void intrinsicContentSizeDidChange(const WebCore::IntSize& newIntrinsicContentSize) override;
index ae06cd3dd2f089653fedcf7c83d399e428a1cebf..081dfc6907fedab4edbe0433cf7e2bb31d984157 100644 (file)
@@ -35,6 +35,7 @@
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 
+using namespace IPC;
 using namespace WebCore;
 
 namespace WebKit {
@@ -126,6 +127,12 @@ void TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry()
         sendUpdateGeometry();
 }
 
+void TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateViewState()
+{
+    auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
+    m_webPageProxy->process().connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DidUpdateViewState>(m_webPageProxy->pageID(), viewStateUpdateTimeout, InterruptWaitingIfSyncMessageArrives);
+}
+
 void TiledCoreAnimationDrawingAreaProxy::intrinsicContentSizeDidChange(const IntSize& newIntrinsicContentSize)
 {
     if (m_webPageProxy->minimumLayoutSize().width() > 0)
index f6b0d25eb8b9caec4db159cf10d04b38c3b1667f..0fe9943792053d000b83c14b349d36bd6e7c9fc5 100644 (file)
@@ -114,7 +114,7 @@ public:
 
     virtual void dispatchAfterEnsuringUpdatedScrollPosition(std::function<void ()>);
 
-    virtual void viewStateDidChange(WebCore::ViewState::Flags) { }
+    virtual void viewStateDidChange(WebCore::ViewState::Flags, bool wantsDidUpdateViewState) { }
     virtual void setLayerHostingMode(LayerHostingMode) { }
 
     virtual bool markLayersVolatileImmediatelyIfPossible() { return true; }
index 2bb1be53e5c5d34e66ff965c75d4ebe08597f5fe..37dadad85f2d1ce73c131863c21fb29f86decdee 100644 (file)
@@ -266,7 +266,6 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_accessibilityObject(0)
 #endif
     , m_setCanStartMediaTimer(RunLoop::main(), this, &WebPage::setCanStartMediaTimerFired)
-    , m_sendDidUpdateViewStateTimer(RunLoop::main(), this, &WebPage::didUpdateViewStateTimerFired)
     , m_formClient(std::make_unique<API::InjectedBundle::FormClient>())
     , m_uiClient(std::make_unique<API::InjectedBundle::PageUIClient>())
     , m_findController(this)
@@ -2174,13 +2173,6 @@ void WebPage::setCanStartMediaTimerFired()
         m_page->setCanStartMedia(true);
 }
 
-#if !PLATFORM(MAC)
-void WebPage::didUpdateViewStateTimerFired()
-{
-    send(Messages::WebPageProxy::DidUpdateViewState());
-}
-#endif
-
 inline bool WebPage::canHandleUserEvents() const
 {
 #if USE(TILED_BACKING_STORE)
@@ -2220,16 +2212,14 @@ void WebPage::setViewState(ViewState::Flags viewState, bool wantsDidUpdateViewSt
     ViewState::Flags changed = m_viewState ^ viewState;
     m_viewState = viewState;
 
-    m_drawingArea->viewStateDidChange(changed);
     m_page->setViewState(viewState);
     for (auto* pluginView : m_pluginViews)
         pluginView->viewStateDidChange(changed);
 
+    m_drawingArea->viewStateDidChange(changed, wantsDidUpdateViewState);
+
     if (changed & ViewState::IsInWindow)
         updateIsInWindow();
-
-    if (wantsDidUpdateViewState)
-        m_sendDidUpdateViewStateTimer.startOneShot(0);
 }
 
 void WebPage::setLayerHostingMode(unsigned layerHostingMode)
index b0e83b7733d9c74e698d414010ca4bba3880c0fd..dd64f1a2396cd73e31302c51c8d2bb518950ed74 100644 (file)
@@ -1024,7 +1024,6 @@ private:
 
     void changeSelectedIndex(int32_t index);
     void setCanStartMediaTimerFired();
-    void didUpdateViewStateTimerFired();
 
     bool canHandleUserEvents() const;
 
@@ -1128,7 +1127,6 @@ private:
 #endif // !PLATFORM(IOS)
 
     RunLoop::Timer<WebPage> m_setCanStartMediaTimer;
-    RunLoop::Timer<WebPage> m_sendDidUpdateViewStateTimer;
     bool m_mayStartMediaWhenInWindow;
 
     HashMap<uint64_t, RefPtr<WebUndoStep>> m_undoStepMap;
index a2059ca5a3de4016e61205f1f7c0bd09881ab54f..1158f78ba9684d8178b8f9f9035b4717b9d9d9d0 100644 (file)
@@ -95,6 +95,8 @@ private:
 
     virtual void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
 
+    virtual void viewStateDidChange(WebCore::ViewState::Flags changed, bool wantsDidUpdateViewState) override;
+
     // GraphicsLayerClient
     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) override { }
     virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) override { }
index cb8775e2450f7b80869f01846d738eb65340d7e7..254954d41fd557173f70329bddb7c5b801ddad10 100644 (file)
@@ -384,4 +384,9 @@ void RemoteLayerTreeDrawingArea::BackingStoreFlusher::flush()
     m_connection->sendMessage(std::move(m_commitEncoder));
 }
 
+void RemoteLayerTreeDrawingArea::viewStateDidChange(ViewState::Flags, bool wantsDidUpdateViewState)
+{
+    // FIXME: Should we suspend painting while not visible, like TiledCoreAnimationDrawingArea? Probably.
+}
+
 } // namespace WebKit
index 8c1cfd88cbf2ca7cff6b2de0d77014d60f3e7e50..db02f4b134c78dccc6483c0baa328e6a4e2fc257 100644 (file)
@@ -36,6 +36,7 @@
 #include <WebCore/TransformationMatrix.h>
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/RunLoop.h>
 
 OBJC_CLASS CALayer;
 
@@ -54,8 +55,6 @@ public:
     TiledCoreAnimationDrawingArea(WebPage&, const WebPageCreationParameters&);
     virtual ~TiledCoreAnimationDrawingArea();
 
-    virtual void viewStateDidChange(WebCore::ViewState::Flags changed) override;
-
 private:
     // DrawingArea
     virtual void setNeedsDisplay() override;
@@ -81,6 +80,9 @@ private:
 
     virtual bool shouldUseTiledBackingForFrameView(const WebCore::FrameView*) override;
 
+    virtual void viewStateDidChange(WebCore::ViewState::Flags changed, bool wantsDidUpdateViewState) override;
+    void didUpdateViewStateTimerFired();
+
     // WebCore::LayerFlushSchedulerClient
     virtual bool flushLayers() override;
 
@@ -136,6 +138,8 @@ private:
     WebCore::FloatPoint m_transientZoomOrigin;
 
     WebCore::TransformationMatrix m_transform;
+
+    RunLoop::Timer<TiledCoreAnimationDrawingArea> m_sendDidUpdateViewStateTimer;
 };
 
 DRAWING_AREA_TYPE_CASTS(TiledCoreAnimationDrawingArea, type() == DrawingAreaTypeTiledCoreAnimation);
index 0bc60a7b383ec4f3b5f1b3ee48ff0afffad4fe14..e3056589d2b01b2607da5b3461fe2de0a195fbe6 100644 (file)
@@ -75,6 +75,7 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage& webPage, c
     , m_exposedRect(FloatRect::infiniteRect())
     , m_scrolledExposedRect(FloatRect::infiniteRect())
     , m_transientZoomScale(1)
+    , m_sendDidUpdateViewStateTimer(RunLoop::main(), this, &TiledCoreAnimationDrawingArea::didUpdateViewStateTimerFired)
 {
     m_webPage.corePage()->settings().setForceCompositingMode(true);
 
@@ -294,7 +295,7 @@ bool TiledCoreAnimationDrawingArea::flushLayers()
     return returnValue;
 }
 
-void TiledCoreAnimationDrawingArea::viewStateDidChange(ViewState::Flags changed)
+void TiledCoreAnimationDrawingArea::viewStateDidChange(ViewState::Flags changed, bool wantsDidUpdateViewState)
 {
     if (changed & ViewState::IsVisible) {
         if (m_webPage.isVisible())
@@ -302,6 +303,15 @@ void TiledCoreAnimationDrawingArea::viewStateDidChange(ViewState::Flags changed)
         else
             suspendPainting();
     }
+
+    if (wantsDidUpdateViewState)
+        m_sendDidUpdateViewStateTimer.startOneShot(0);
+}
+
+void TiledCoreAnimationDrawingArea::didUpdateViewStateTimerFired()
+{
+    [CATransaction flush];
+    m_webPage.send(Messages::WebPageProxy::DidUpdateViewState());
 }
 
 void TiledCoreAnimationDrawingArea::suspendPainting()
index d8cc59abdf56d46188cfe6ab2afa276d35449112..0172038b1955271aa343c05b12d77758a2235e32 100644 (file)
@@ -989,12 +989,6 @@ void WebPage::drawPagesToPDFFromPDFDocument(CGContextRef context, PDFDocument *p
     }
 }
 
-void WebPage::didUpdateViewStateTimerFired()
-{
-    [CATransaction flush];
-    send(Messages::WebPageProxy::DidUpdateViewState());
-}
-
 #if ENABLE(WEBGL)
 WebCore::WebGLLoadPolicy WebPage::webGLPolicyForURL(WebFrame* frame, const String& url)
 {