DidFirstVisuallyNonEmptyLayout milestone should always fire at some point.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2019 22:58:09 +0000 (22:58 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2019 22:58:09 +0000 (22:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193741
<rdar://problem/47135030>

Reviewed by Antti Koivisto and Simon Fraser.

Source/WebCore:

fireLayoutRelatedMilestonesIfNeeded() is part of the post-layout tasks. In certain cases when
    1. the received data is not "contentful" yet
    2. and we are expecting some more (loading is not complete yet)
    3. but no layout is initiated anymore
nothing triggers the milestone firing.

This patch ensures that we fire the DidFirstVisuallyNonEmptyLayout when the frame load is complete unless we already did.

* page/FrameView.cpp:
(WebCore::FrameView::FrameView):
(WebCore::FrameView::loadProgressingStatusChanged):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp:
(TestWebKitAPI::TEST):

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

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp
Tools/TestWebKitAPI/Tests/WebKit/async-script-load.html [new file with mode: 0644]

index bf22699..7ae6929 100644 (file)
@@ -1,3 +1,23 @@
+2019-01-24  Zalan Bujtas  <zalan@apple.com>
+
+        DidFirstVisuallyNonEmptyLayout milestone should always fire at some point.
+        https://bugs.webkit.org/show_bug.cgi?id=193741
+        <rdar://problem/47135030>
+
+        Reviewed by Antti Koivisto and Simon Fraser.
+
+        fireLayoutRelatedMilestonesIfNeeded() is part of the post-layout tasks. In certain cases when
+            1. the received data is not "contentful" yet
+            2. and we are expecting some more (loading is not complete yet)
+            3. but no layout is initiated anymore
+        nothing triggers the milestone firing.
+
+        This patch ensures that we fire the DidFirstVisuallyNonEmptyLayout when the frame load is complete unless we already did.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::FrameView):
+        (WebCore::FrameView::loadProgressingStatusChanged):
+
 2019-01-24  Brent Fulgham  <bfulgham@apple.com>
 
         Activate the WebResourceLoadStatisticsStore in the NetworkProcess and deactivate it in the UIProcess.
index cc93114..7ca56c1 100644 (file)
@@ -2851,6 +2851,9 @@ void FrameView::disableLayerFlushThrottlingTemporarilyForInteraction()
 
 void FrameView::loadProgressingStatusChanged()
 {
+    auto hasPendingVisuallyNonEmptyCallback = m_firstVisuallyNonEmptyLayoutCallbackPending && !m_isVisuallyNonEmpty;
+    if (hasPendingVisuallyNonEmptyCallback && frame().loader().isComplete())
+        fireLayoutRelatedMilestonesIfNeeded();
     updateLayerFlushThrottling();
     adjustTiledBackingCoverage();
 }
@@ -5166,8 +5169,11 @@ void FrameView::fireLayoutRelatedMilestonesIfNeeded()
             milestonesAchieved.add(DidRenderSignificantAmountOfText);
     }
 
-    if (milestonesAchieved && frame().isMainFrame())
+    if (milestonesAchieved && frame().isMainFrame()) {
+        if (milestonesAchieved.contains(DidFirstVisuallyNonEmptyLayout))
+            RELEASE_LOG_IF_ALLOWED("fireLayoutRelatedMilestonesIfNeeded() - firing first visually non-empty layout milestone on the main frame");
         frame().loader().didReachLayoutMilestone(milestonesAchieved);
+    }
 }
 
 void FrameView::firePaintRelatedMilestonesIfNeeded()
index 81ac8e5..a6c3d7a 100644 (file)
@@ -1,3 +1,15 @@
+2019-01-24  Zalan Bujtas  <zalan@apple.com>
+
+        DidFirstVisuallyNonEmptyLayout milestone should always fire at some point.
+        https://bugs.webkit.org/show_bug.cgi?id=193741
+        <rdar://problem/47135030>
+
+        Reviewed by Antti Koivisto and Simon Fraser.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/LayoutMilestonesWithAllContentInFrame.cpp:
+        (TestWebKitAPI::TEST):
+
 2019-01-24  Brent Fulgham  <bfulgham@apple.com>
 
         Activate the WebResourceLoadStatisticsStore in the NetworkProcess and deactivate it in the UIProcess.
index 63068e3..9486f98 100644 (file)
@@ -51,6 +51,7 @@
                115EB3431EE0BA03003C2C0A /* ViewportSizeForViewportUnits.mm in Sources */ = {isa = PBXBuildFile; fileRef = 115EB3421EE0B720003C2C0A /* ViewportSizeForViewportUnits.mm */; };
                1171B24F219F49CD00CB897D /* FirstMeaningfulPaintMilestone_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 11B7FD21219F46DD0069B27F /* FirstMeaningfulPaintMilestone_Bundle.cpp */; };
                11B7FD28219F47110069B27F /* FirstMeaningfulPaintMilestone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 11B7FD22219F46DD0069B27F /* FirstMeaningfulPaintMilestone.cpp */; };
+               11C2598D21FA6324004C9E23 /* async-script-load.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 11C2598C21FA618D004C9E23 /* async-script-load.html */; };
                143DDE9820C9018B007F76FA /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 574F55D0204D471C002948C6 /* Security.framework */; };
                1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1A02C84B125D4A5E00E3F4BD /* find.html */; };
                1A3524AE1D63A4FB0031729B /* Scope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3524AC1D63A4FB0031729B /* Scope.cpp */; };
                                5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */,
                                5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */,
                                F6B7BE9717469B96008A3445 /* associate-form-controls.html in Copy Resources */,
+                               11C2598D21FA6324004C9E23 /* async-script-load.html in Copy Resources */,
                                F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */,
                                B55F11B71517D03300915916 /* attributedStringCustomFont.html in Copy Resources */,
                                7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */,
                115EB3421EE0B720003C2C0A /* ViewportSizeForViewportUnits.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewportSizeForViewportUnits.mm; sourceTree = "<group>"; };
                11B7FD21219F46DD0069B27F /* FirstMeaningfulPaintMilestone_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirstMeaningfulPaintMilestone_Bundle.cpp; sourceTree = "<group>"; };
                11B7FD22219F46DD0069B27F /* FirstMeaningfulPaintMilestone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FirstMeaningfulPaintMilestone.cpp; sourceTree = "<group>"; };
+               11C2598C21FA618D004C9E23 /* async-script-load.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "async-script-load.html"; sourceTree = "<group>"; };
                14464012167A8305000BD218 /* LayoutUnit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutUnit.cpp; sourceTree = "<group>"; };
                14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SaturatedArithmeticOperations.cpp; sourceTree = "<group>"; };
                1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; };
                                1C2B81851C89252300A5529F /* Ahem.ttf */,
                                93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */,
                                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
+                               11C2598C21FA618D004C9E23 /* async-script-load.html */,
                                C9C9A91A21DED24D00FDE96E /* audio-with-play-button.html */,
                                76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
                                C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */,
index 47cdd4b..5cf8260 100644 (file)
@@ -117,6 +117,28 @@ TEST(WebKit, FirstVisuallyNonEmptyLayoutAfterPageCacheRestore)
     didNavigate = false;
 }
 
+TEST(WebKit, FirstVisuallyNonEmptyMilestoneWithLoadComplete)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreateWithConfiguration(nullptr));
+    PlatformWebView webView(context.get());
+
+    WKPageNavigationClientV3 loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+
+    loaderClient.base.version = 3;
+    loaderClient.base.clientInfo = &webView;
+    loaderClient.renderingProgressDidChange = renderingProgressDidChange;
+
+    WKPageSetPageNavigationClient(webView.page(), &loaderClient.base);
+    didFirstVisuallyNonEmptyLayout = false;
+
+    WKPageListenForLayoutMilestones(webView.page(), WKPageRenderingProgressEventFirstVisuallyNonEmptyLayout);
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("async-script-load", "html")).get());
+
+    Util::run(&didFirstVisuallyNonEmptyLayout);
+    EXPECT_TRUE(didFirstVisuallyNonEmptyLayout);
+}
+
 } // namespace TestWebKitAPI
 
 #endif
diff --git a/Tools/TestWebKitAPI/Tests/WebKit/async-script-load.html b/Tools/TestWebKitAPI/Tests/WebKit/async-script-load.html
new file mode 100644 (file)
index 0000000..a38f858
--- /dev/null
@@ -0,0 +1,16 @@
+<head>
+<style>
+@font-face {
+    font-family: 'FontAwesome';
+    src: url("font1.woff2") format("woff2");
+    font-weight: normal;
+    font-style: normal
+}
+
+.foobar {
+    font: normal normal normal 14px / 1 FontAwesome;
+}
+</style>
+</head>
+<body>foobar<script>document.body.offsetHeight</script>
+<script async="true" src="foobar.js"></script>
\ No newline at end of file