Title: [236142] trunk
Revision
236142
Author
[email protected]
Date
2018-09-18 09:06:10 -0700 (Tue, 18 Sep 2018)

Log Message

"DidFirstVisuallyNonEmptyLayout" callback does not get called when restoring a page from PageCache
https://bugs.webkit.org/show_bug.cgi?id=189681
<rdar://problem/44526171>

Reviewed by Alex Christensen and Zalan Bujtas.

Source/WebCore:

The "DidFirstVisuallyNonEmptyLayout" callback was not getting called when restoring a page from PageCache
because the FrameView is restored from PageCache and we would fail to restore its flags (such as
m_firstVisuallyNonEmptyLayoutCallbackPending) when entering Page Cache. We now call reset those flags that
are related to layout miletones when entering PageCache so that layout milestone events properly get sent
again when restoring from Page Cache.

* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp:
(TestWebKitAPI::didFinishNavigation):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (236141 => 236142)


--- trunk/Source/WebCore/ChangeLog	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Source/WebCore/ChangeLog	2018-09-18 16:06:10 UTC (rev 236142)
@@ -1,3 +1,20 @@
+2018-09-18  Chris Dumez  <[email protected]>
+
+        "DidFirstVisuallyNonEmptyLayout" callback does not get called when restoring a page from PageCache
+        https://bugs.webkit.org/show_bug.cgi?id=189681
+        <rdar://problem/44526171>
+
+        Reviewed by Alex Christensen and Zalan Bujtas.
+
+        The "DidFirstVisuallyNonEmptyLayout" callback was not getting called when restoring a page from PageCache
+        because the FrameView is restored from PageCache and we would fail to restore its flags (such as
+        m_firstVisuallyNonEmptyLayoutCallbackPending) when entering Page Cache. We now call reset those flags that
+        are related to layout miletones when entering PageCache so that layout milestone events properly get sent
+        again when restoring from Page Cache.
+
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame):
+
 2018-09-18  Manuel Rego Casasnovas  <[email protected]>
 
         [css-grid] Static position should use content-box, not padding-box

Modified: trunk/Source/WebCore/history/CachedFrame.cpp (236141 => 236142)


--- trunk/Source/WebCore/history/CachedFrame.cpp	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Source/WebCore/history/CachedFrame.cpp	2018-09-18 16:06:10 UTC (rev 236142)
@@ -154,6 +154,10 @@
 
     m_document->domWindow()->suspendForDocumentSuspension();
 
+    // Clear FrameView to reset flags such as 'firstVisuallyNonEmptyLayoutCallbackPending' so that the
+    // 'DidFirstVisuallyNonEmptyLayout' callback gets called against when restoring from PageCache.
+    m_view->resetLayoutMilestones();
+
     frame.loader().client().savePlatformDataToCachedFrame(this);
 
     // documentWillSuspendForPageCache() can set up a layout timer on the FrameView, so clear timers after that.

Modified: trunk/Source/WebCore/page/FrameView.cpp (236141 => 236142)


--- trunk/Source/WebCore/page/FrameView.cpp	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Source/WebCore/page/FrameView.cpp	2018-09-18 16:06:10 UTC (rev 236142)
@@ -267,7 +267,6 @@
     m_isOverlapped = false;
     m_contentIsOpaque = false;
     m_updateEmbeddedObjectsTimer.stop();
-    m_firstLayoutCallbackPending = false;
     m_wasScrolledByUser = false;
     m_delayedScrollEventTimer.stop();
     m_shouldScrollToFocusedElement = false;
@@ -279,18 +278,24 @@
     m_lastPaintTime = MonotonicTime();
     m_paintBehavior = PaintBehavior::Normal;
     m_isPainting = false;
-    m_visuallyNonEmptyCharacterCount = 0;
-    m_visuallyNonEmptyPixelCount = 0;
-    m_isVisuallyNonEmpty = false;
-    m_firstVisuallyNonEmptyLayoutCallbackPending = true;
-    m_renderTextCountForVisuallyNonEmptyCharacters = 0;
-    m_renderedSignificantAmountOfText = false;
-    m_significantRenderedTextMilestonePending = true;
     m_needsDeferredScrollbarsUpdate = false;
     m_maintainScrollPositionAnchor = nullptr;
+    resetLayoutMilestones();
     layoutContext().reset();
 }
 
+void FrameView::resetLayoutMilestones()
+{
+    m_firstLayoutCallbackPending = false;
+    m_isVisuallyNonEmpty = false;
+    m_firstVisuallyNonEmptyLayoutCallbackPending = true;
+    m_significantRenderedTextMilestonePending = true;
+    m_renderedSignificantAmountOfText = false;
+    m_visuallyNonEmptyCharacterCount = 0;
+    m_visuallyNonEmptyPixelCount = 0;
+    m_renderTextCountForVisuallyNonEmptyCharacters = 0;
+}
+
 void FrameView::removeFromAXObjectCache()
 {
     if (AXObjectCache* cache = axObjectCache()) {

Modified: trunk/Source/WebCore/page/FrameView.h (236141 => 236142)


--- trunk/Source/WebCore/page/FrameView.h	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Source/WebCore/page/FrameView.h	2018-09-18 16:06:10 UTC (rev 236142)
@@ -180,6 +180,7 @@
     WEBCORE_EXPORT void recalculateScrollbarOverlayStyle();
 
     void clear();
+    void resetLayoutMilestones();
 
     WEBCORE_EXPORT bool isTransparent() const;
     WEBCORE_EXPORT void setTransparent(bool isTransparent);

Modified: trunk/Tools/ChangeLog (236141 => 236142)


--- trunk/Tools/ChangeLog	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Tools/ChangeLog	2018-09-18 16:06:10 UTC (rev 236142)
@@ -1,3 +1,17 @@
+2018-09-18  Chris Dumez  <[email protected]>
+
+        "DidFirstVisuallyNonEmptyLayout" callback does not get called when restoring a page from PageCache
+        https://bugs.webkit.org/show_bug.cgi?id=189681
+        <rdar://problem/44526171>
+
+        Reviewed by Alex Christensen and Zalan Bujtas.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp:
+        (TestWebKitAPI::didFinishNavigation):
+        (TestWebKitAPI::TEST):
+
 2018-09-18  Claudio Saavedra  <[email protected]>
 
         [WPE] Implement mouse event modifiers

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp (236141 => 236142)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp	2018-09-18 15:59:31 UTC (rev 236141)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp	2018-09-18 16:06:10 UTC (rev 236142)
@@ -35,7 +35,8 @@
 
 namespace TestWebKitAPI {
 
-static bool testDone;
+static bool didFirstVisuallyNonEmptyLayout;
+static bool didNavigate;
 
 static void renderingProgressDidChange(WKPageRef page, WKPageRenderingProgressEvents milestones, WKTypeRef, const void* clientInfo)
 {
@@ -42,9 +43,14 @@
     // This test ensures that the DidFirstVisuallyNonEmptyLayout will be reached for the main frame
     // even when all of the content is in a subframe.
     if (milestones & WKPageRenderingProgressEventFirstVisuallyNonEmptyLayout)
-        testDone = true;
+        didFirstVisuallyNonEmptyLayout = true;
 }
 
+static void didFinishNavigation(WKPageRef page, WKNavigationRef navigation, WKTypeRef userData, const void* clientInfo)
+{
+    didNavigate = true;
+}
+
 TEST(WebKit, LayoutMilestonesWithAllContentInFrame)
 {
     WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
@@ -62,10 +68,55 @@
     WKPageListenForLayoutMilestones(webView.page(), WKPageRenderingProgressEventFirstVisuallyNonEmptyLayout);
     WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("all-content-in-one-iframe", "html")).get());
 
-    Util::run(&testDone);
-    EXPECT_TRUE(testDone);
+    Util::run(&didFirstVisuallyNonEmptyLayout);
+    EXPECT_TRUE(didFirstVisuallyNonEmptyLayout);
 }
 
+TEST(WebKit, FirstVisuallyNonEmptyLayoutAfterPageCacheRestore)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+
+    WKContextSetCacheModel(context.get(), kWKCacheModelPrimaryWebBrowser); // Enables the Page Cache.
+
+    PlatformWebView webView(context.get());
+
+    WKPageNavigationClientV3 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 3;
+    loaderClient.base.clientInfo = &webView;
+    loaderClient.renderingProgressDidChange = renderingProgressDidChange;
+    loaderClient.didFinishNavigation = didFinishNavigation;
+
+    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+
+    WKPageListenForLayoutMilestones(webView.page(), WKPageRenderingProgressEventFirstVisuallyNonEmptyLayout);
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-tall", "html")).get());
+
+    Util::run(&didFirstVisuallyNonEmptyLayout);
+    EXPECT_TRUE(didFirstVisuallyNonEmptyLayout);
+    didFirstVisuallyNonEmptyLayout = false;
+    Util::run(&didNavigate);
+    EXPECT_TRUE(didNavigate);
+    didNavigate = false;
+
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("large-red-square-image", "html")).get());
+    Util::run(&didFirstVisuallyNonEmptyLayout);
+    EXPECT_TRUE(didFirstVisuallyNonEmptyLayout);
+    didFirstVisuallyNonEmptyLayout = false;
+    Util::run(&didNavigate);
+    EXPECT_TRUE(didNavigate);
+    didNavigate = false;
+
+    WKPageGoBack(webView.page());
+    Util::run(&didFirstVisuallyNonEmptyLayout);
+    EXPECT_TRUE(didFirstVisuallyNonEmptyLayout);
+    didFirstVisuallyNonEmptyLayout = false;
+    Util::run(&didNavigate);
+    EXPECT_TRUE(didNavigate);
+    didNavigate = false;
+}
+
 } // namespace TestWebKitAPI
 
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to