Title: [236200] releases/WebKitGTK/webkit-2.22
Revision
236200
Author
[email protected]
Date
2018-09-19 06:49:33 -0700 (Wed, 19 Sep 2018)

Log Message

Merge r236142 - "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: releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog	2018-09-19 13:49:33 UTC (rev 236200)
@@ -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-15  Rob Buis  <[email protected]>
 
         XMLHttpRequest::createResponseBlob() should create a Blob with type for empty response

Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/history/CachedFrame.cpp (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/history/CachedFrame.cpp	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/history/CachedFrame.cpp	2018-09-19 13:49:33 UTC (rev 236200)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.cpp (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.cpp	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.cpp	2018-09-19 13:49:33 UTC (rev 236200)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.h (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.h	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/page/FrameView.h	2018-09-19 13:49:33 UTC (rev 236200)
@@ -180,6 +180,7 @@
     WEBCORE_EXPORT void recalculateScrollbarOverlayStyle();
 
     void clear();
+    void resetLayoutMilestones();
 
     WEBCORE_EXPORT bool isTransparent() const;
     WEBCORE_EXPORT void setTransparent(bool isTransparent);

Modified: releases/WebKitGTK/webkit-2.22/Tools/ChangeLog (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Tools/ChangeLog	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Tools/ChangeLog	2018-09-19 13:49:33 UTC (rev 236200)
@@ -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: releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp (236199 => 236200)


--- releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp	2018-09-19 13:49:24 UTC (rev 236199)
+++ releases/WebKitGTK/webkit-2.22/Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp	2018-09-19 13:49:33 UTC (rev 236200)
@@ -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