Title: [153958] trunk
Revision
153958
Author
[email protected]
Date
2013-08-12 14:37:06 -0700 (Mon, 12 Aug 2013)

Log Message

The LayoutMilestones didLayout callback should only fire for the main frame
https://bugs.webkit.org/show_bug.cgi?id=119457

Reviewed by Sam Weinig.

Source/WebCore: 

This patch makes it so that FrameLoader::didLayout(LayoutMilestones) is only ever 
called for the main frame. Technically this will change existing API for 
didFirstVisuallyNonEmptyLayoutInFrame and didFirstLayoutInFrame. Clients used to 
be able to register for those callbacks for any frame they wanted, however, now 
they will only ever get the callback when it applies to the main frame. We think 
that this is acceptable since we don’t know of any clients that ever used those 
APIs for a non-main frame. This change also makes nothing but sense for the 
didLayout(LayoutMilestones) callback, since that is a Page-level concept, so it 
should only fire for the main frame.

Only call didLayout for the main frame.
* dom/Document.cpp:
(WebCore::Document::setVisualUpdatesAllowed):

Assert that this is the main frame.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::didLayout):

Only call didLayout for the main frame.
* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks):

Tools: 

Now that the didLayout callback only fires for the main frame, we want to make 
sure it will fire even when all of the content is in a subframe.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp: Added.
(TestWebKitAPI::didLayout):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153957 => 153958)


--- trunk/Source/WebCore/ChangeLog	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Source/WebCore/ChangeLog	2013-08-12 21:37:06 UTC (rev 153958)
@@ -1,3 +1,32 @@
+2013-08-12  Beth Dakin  <[email protected]>
+
+        The LayoutMilestones didLayout callback should only fire for the main frame
+        https://bugs.webkit.org/show_bug.cgi?id=119457
+
+        Reviewed by Sam Weinig.
+
+        This patch makes it so that FrameLoader::didLayout(LayoutMilestones) is only ever 
+        called for the main frame. Technically this will change existing API for 
+        didFirstVisuallyNonEmptyLayoutInFrame and didFirstLayoutInFrame. Clients used to 
+        be able to register for those callbacks for any frame they wanted, however, now 
+        they will only ever get the callback when it applies to the main frame. We think 
+        that this is acceptable since we don’t know of any clients that ever used those 
+        APIs for a non-main frame. This change also makes nothing but sense for the 
+        didLayout(LayoutMilestones) callback, since that is a Page-level concept, so it 
+        should only fire for the main frame.
+
+        Only call didLayout for the main frame.
+        * dom/Document.cpp:
+        (WebCore::Document::setVisualUpdatesAllowed):
+
+        Assert that this is the main frame.
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::didLayout):
+
+        Only call didLayout for the main frame.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::performPostLayoutTasks):
+
 2013-08-12  Christophe Dumez  <[email protected]>
 
         Define DOM_KEY_LOCATION_* constants on KeyboardEvent

Modified: trunk/Source/WebCore/dom/Document.cpp (153957 => 153958)


--- trunk/Source/WebCore/dom/Document.cpp	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-08-12 21:37:06 UTC (rev 153958)
@@ -1264,10 +1264,11 @@
         updateLayout();
 
     if (Page* page = this->page()) {
-        if (frame() == page->mainFrame())
+        if (frame() == page->mainFrame()) {
             frameView->addPaintPendingMilestones(DidFirstPaintAfterSuppressedIncrementalRendering);
-        if (page->requestedLayoutMilestones() & DidFirstLayoutAfterSuppressedIncrementalRendering)
-            frame()->loader()->didLayout(DidFirstLayoutAfterSuppressedIncrementalRendering);
+            if (page->requestedLayoutMilestones() & DidFirstLayoutAfterSuppressedIncrementalRendering)
+                frame()->loader()->didLayout(DidFirstLayoutAfterSuppressedIncrementalRendering);
+        }
     }
 
 #if USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (153957 => 153958)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-12 21:37:06 UTC (rev 153958)
@@ -2283,6 +2283,11 @@
 
 void FrameLoader::didLayout(LayoutMilestones milestones)
 {
+#if !ASSERT_DISABLED
+    if (Page* page = m_frame->page())
+        ASSERT(page->mainFrame() == m_frame);
+#endif
+
     m_client->dispatchDidLayout(milestones);
 }
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (153957 => 153958)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-08-12 21:37:06 UTC (rev 153958)
@@ -2787,7 +2787,7 @@
         }
     }
 
-    if (milestonesAchieved)
+    if (milestonesAchieved && page && page->mainFrame() == m_frame)
         m_frame->loader()->didLayout(milestonesAchieved);
 #if ENABLE(FONT_LOAD_EVENTS)
     if (RuntimeEnabledFeatures::fontLoadEventsEnabled())

Modified: trunk/Tools/ChangeLog (153957 => 153958)


--- trunk/Tools/ChangeLog	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Tools/ChangeLog	2013-08-12 21:37:06 UTC (rev 153958)
@@ -1,5 +1,21 @@
 2013-08-12  Beth Dakin  <[email protected]>
 
+        The LayoutMilestones didLayout callback should only fire for the main frame
+        https://bugs.webkit.org/show_bug.cgi?id=119457
+
+        Reviewed by Sam Weinig.
+
+        Now that the didLayout callback only fires for the main frame, we want to make 
+        sure it will fire even when all of the content is in a subframe.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp: Added.
+        (TestWebKitAPI::didLayout):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html: Added.
+
+2013-08-12  Beth Dakin  <[email protected]>
+
         Remove didNewFirstVisuallyNonEmptyLayout from WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=119658
 

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (153957 => 153958)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-08-12 21:02:40 UTC (rev 153957)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-08-12 21:37:06 UTC (rev 153958)
@@ -117,6 +117,8 @@
 		93AF4ECE1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */; };
 		93AF4ED01506F123007FD57E /* lots-of-images.html in Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
 		93AF4ED11506F130007FD57E /* lots-of-images.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 93AF4ECF1506F123007FD57E /* lots-of-images.html */; };
+		93D3D19C17B1A7B000C7C415 /* all-content-in-one-iframe.html in Resources */ = {isa = PBXBuildFile; fileRef = 93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */; };
+		93D3D19E17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */; };
 		93F1DB3114DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3014DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp */; };
 		93F1DB3414DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */; };
 		93F1DB5514DB1B730024C362 /* NewFirstVisuallyNonEmptyLayoutFails.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1DB5414DB1B730024C362 /* NewFirstVisuallyNonEmptyLayoutFails.cpp */; };
@@ -422,6 +424,8 @@
 		93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages.cpp; sourceTree = "<group>"; };
 		93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp; sourceTree = "<group>"; };
 		93AF4ECF1506F123007FD57E /* lots-of-images.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-images.html"; sourceTree = "<group>"; };
+		93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "all-content-in-one-iframe.html"; sourceTree = "<group>"; };
+		93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutMilestonesWithAllContentInFrame.cpp; sourceTree = "<group>"; };
 		93F1DB3014DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayout.cpp; sourceTree = "<group>"; };
 		93F1DB3314DA20870024C362 /* NewFirstVisuallyNonEmptyLayout_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayout_Bundle.cpp; sourceTree = "<group>"; };
 		93F1DB5414DB1B730024C362 /* NewFirstVisuallyNonEmptyLayoutFails.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NewFirstVisuallyNonEmptyLayoutFails.cpp; sourceTree = "<group>"; };
@@ -747,6 +751,7 @@
 				93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */,
 				93AF4ECD1506F064007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp */,
 				93F7E86B14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp */,
+				93D3D19D17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp */,
 				93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */,
 				BC909779125571AB00083756 /* PageLoadBasic.cpp */,
 				BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
@@ -835,6 +840,7 @@
 				BCBD372E125ABBE600D2C29F /* icon.png */,
 				378E647816326FDF00B6C676 /* link-with-title.html */,
 				9361002814DC957B0061379D /* lots-of-iframes.html */,
+				93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */,
 				93AF4ECF1506F123007FD57E /* lots-of-images.html */,
 				930AD401150698B30067970F /* lots-of-text.html */,
 				2DD7D3AE178227AC0026E1E3 /* lots-of-text-vertical-lr.html */,
@@ -1073,6 +1079,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				93D3D19C17B1A7B000C7C415 /* all-content-in-one-iframe.html in Resources */,
 				93AF4ED01506F123007FD57E /* lots-of-images.html in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1189,6 +1196,7 @@
 				51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
 				C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */,
 				C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */,
+				93D3D19E17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
 				E194E1BB177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm in Sources */,
 				81B50193140F232300D9EB58 /* StringBuilder.cpp in Sources */,
 				3799AD3A14120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp (0 => 153958)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/LayoutMilestonesWithAllContentInFrame.cpp	2013-08-12 21:37:06 UTC (rev 153958)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit2/WKContextPrivate.h>
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool testDone;
+
+static void didLayout(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef, const void* clientInfo)
+{
+    // 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 & kWKDidFirstVisuallyNonEmptyLayout)
+        testDone = true;
+}
+
+TEST(WebKit2, LayoutMilestonesWithAllContentInFrame)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClient loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    loaderClient.version = kWKPageLoaderClientCurrentVersion;
+    loaderClient.didLayout = didLayout;
+    loaderClient.clientInfo = &webView;
+
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient);
+    WKPageListenForLayoutMilestones(webView.page(), kWKDidFirstVisuallyNonEmptyLayout);
+    WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("all-content-in-one-iframe", "html")).get());
+
+    Util::run(&testDone);
+    EXPECT_TRUE(testDone);
+}
+
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html (0 => 153958)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/all-content-in-one-iframe.html	2013-08-12 21:37:06 UTC (rev 153958)
@@ -0,0 +1 @@
+<iframe src=""
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to