[iOS] Flash when swiping back to Google search result page
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2019 22:31:36 +0000 (22:31 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2019 22:31:36 +0000 (22:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193668
<rdar://problem/47071684>

Reviewed by Simon Fraser.

If the google page is scrolled, there is sometimes a short flash.

When restoring the page state we also restore exposedContentRect which is used to determine
which part of the page to create layers for. Scroll position is restored by the UI process
later so we rely on this to get the right layers for the initial view update.

A viewport configuration update may sometimes trample over the restored exposedContentRect,
moving it to top left. In this case the initial layer tree unfreeze commit may not have
layers to cover the actual visible view position.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::restorePageState):

Set a bit to indicate we have already restored the exposedContentRect.

(WebKit::WebPage::viewportConfigurationChanged):

Only reset exposedContentRect if wasn't already set by restorePageState.

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 89afd9d..1a3bfa2 100644 (file)
@@ -1,3 +1,33 @@
+2019-01-22  Antti Koivisto  <antti@apple.com>
+
+        [iOS] Flash when swiping back to Google search result page
+        https://bugs.webkit.org/show_bug.cgi?id=193668
+        <rdar://problem/47071684>
+
+        Reviewed by Simon Fraser.
+
+        If the google page is scrolled, there is sometimes a short flash.
+
+        When restoring the page state we also restore exposedContentRect which is used to determine
+        which part of the page to create layers for. Scroll position is restored by the UI process
+        later so we rely on this to get the right layers for the initial view update.
+
+        A viewport configuration update may sometimes trample over the restored exposedContentRect,
+        moving it to top left. In this case the initial layer tree unfreeze commit may not have
+        layers to cover the actual visible view position.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::didCommitLoad):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::restorePageState):
+
+        Set a bit to indicate we have already restored the exposedContentRect.
+
+        (WebKit::WebPage::viewportConfigurationChanged):
+
+        Only reset exposedContentRect if wasn't already set by restorePageState.
+
 2019-01-22  Alex Christensen  <achristensen@webkit.org>
 
         Fix more builds.
index 5e2d521..9f8bb91 100644 (file)
@@ -5604,6 +5604,7 @@ void WebPage::didCommitLoad(WebFrame* frame)
     }
 #if PLATFORM(IOS_FAMILY)
     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false;
+    m_hasRestoredExposedContentRectAfterDidCommitLoad = false;
     m_scaleWasSetByUIProcess = false;
     m_userHasChangedPageScaleFactor = false;
     m_estimatedLatency = Seconds(1.0 / 60);
index d4d21d3..4a40ae0 100644 (file)
@@ -1710,7 +1710,9 @@ private:
     RefPtr<WebCore::SecurityOrigin> m_potentialTapSecurityOrigin;
 
     WebCore::ViewportConfiguration m_viewportConfiguration;
+
     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad { false };
+    bool m_hasRestoredExposedContentRectAfterDidCommitLoad { false };
     bool m_scaleWasSetByUIProcess { false };
     bool m_userHasChangedPageScaleFactor { false };
     bool m_hasStablePageScaleFactor { true };
index f391b56..87d1be1 100644 (file)
@@ -346,6 +346,7 @@ void WebPage::restorePageState(const HistoryItem& historyItem)
         Optional<FloatPoint> scrollPosition;
         if (historyItem.shouldRestoreScrollPosition()) {
             m_drawingArea->setExposedContentRect(historyItem.exposedContentRect());
+            m_hasRestoredExposedContentRectAfterDidCommitLoad = true;
             scrollPosition = FloatPoint(historyItem.scrollPosition());
         }
         send(Messages::WebPageProxy::RestorePageState(scrollPosition, frameView.scrollOrigin(), historyItem.obscuredInsets(), boundedScale));
@@ -2840,7 +2841,8 @@ void WebPage::viewportConfigurationChanged(ZoomToInitialScale zoomToInitialScale
 
         // FIXME: We could send down the obscured margins to find a better exposed rect and unobscured rect.
         // It is not a big deal at the moment because the tile coverage will always extend past the obscured bottom inset.
-        m_drawingArea->setExposedContentRect(FloatRect(scrollPosition, minimumLayoutSizeInDocumentCoordinates));
+        if (!m_hasRestoredExposedContentRectAfterDidCommitLoad)
+            m_drawingArea->setExposedContentRect(FloatRect(scrollPosition, minimumLayoutSizeInDocumentCoordinates));
     }
     scalePage(scale, scrollPosition);