Title: [141850] trunk/Source
Revision
141850
Author
[email protected]
Date
2013-02-04 20:23:17 -0800 (Mon, 04 Feb 2013)

Log Message

[Chromium] Add a signal for when the body is inserted in the document
https://bugs.webkit.org/show_bug.cgi?id=108725

Reviewed by Adam Barth.

Source/WebCore:

This is an important signal for resource scheduling. We know we have enough to paint something,
so we can start kicking off image preloads.

Test: Chromium webkit_unit_tests

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertHTMLBodyElement):
* loader/FrameLoaderClient.h:
(FrameLoaderClient):
(WebCore::FrameLoaderClient::dispatchWillInsertBody):

Source/WebKit/chromium:

* public/WebFrameClient.h:
(WebFrameClient):
(WebKit::WebFrameClient::willInsertBody):
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchWillInsertBody):
(WebKit):
* src/FrameLoaderClientImpl.h:
(FrameLoaderClientImpl):
* tests/WebFrameTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (141849 => 141850)


--- trunk/Source/WebCore/ChangeLog	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebCore/ChangeLog	2013-02-05 04:23:17 UTC (rev 141850)
@@ -1,3 +1,21 @@
+2013-02-04  James Simonsen  <[email protected]>
+
+        [Chromium] Add a signal for when the body is inserted in the document
+        https://bugs.webkit.org/show_bug.cgi?id=108725
+
+        Reviewed by Adam Barth.
+
+        This is an important signal for resource scheduling. We know we have enough to paint something,
+        so we can start kicking off image preloads.
+
+        Test: Chromium webkit_unit_tests
+
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertHTMLBodyElement):
+        * loader/FrameLoaderClient.h:
+        (FrameLoaderClient):
+        (WebCore::FrameLoaderClient::dispatchWillInsertBody):
+
 2013-02-04  Benjamin Poulain  <[email protected]>
 
         Kill suspendAnimation(), resumeAnimation() and numberOfActiveAnimations() from DRT/WTR; use Internals

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (141849 => 141850)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-02-05 04:23:17 UTC (rev 141850)
@@ -32,6 +32,7 @@
 #include "DocumentType.h"
 #include "Element.h"
 #include "Frame.h"
+#include "FrameLoaderClient.h"
 #include "HTMLDocument.h"
 #include "HTMLElementFactory.h"
 #include "HTMLFormElement.h"
@@ -395,6 +396,8 @@
     RefPtr<Element> body = createHTMLElement(token);
     attachLater(currentNode(), body);
     m_openElements.pushHTMLBodyElement(HTMLStackItem::create(body.release(), token));
+    if (Frame* frame = m_document->frame())
+        frame->loader()->client()->dispatchWillInsertBody();
 }
 
 void HTMLConstructionSite::insertHTMLFormElement(AtomicHTMLToken* token, bool isDemoted)

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (141849 => 141850)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-02-05 04:23:17 UTC (rev 141850)
@@ -371,6 +371,9 @@
         // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
         virtual void didLoseWebGLContext(int) { }
 #endif
+
+        // If an HTML document is being loaded, informs the embedder that the document will have its <body> attached soon.
+        virtual void dispatchWillInsertBody() { }
     };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit/chromium/ChangeLog (141849 => 141850)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-02-05 04:23:17 UTC (rev 141850)
@@ -1,3 +1,20 @@
+2013-02-04  James Simonsen  <[email protected]>
+
+        [Chromium] Add a signal for when the body is inserted in the document
+        https://bugs.webkit.org/show_bug.cgi?id=108725
+
+        Reviewed by Adam Barth.
+
+        * public/WebFrameClient.h:
+        (WebFrameClient):
+        (WebKit::WebFrameClient::willInsertBody):
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::dispatchWillInsertBody):
+        (WebKit):
+        * src/FrameLoaderClientImpl.h:
+        (FrameLoaderClientImpl):
+        * tests/WebFrameTest.cpp:
+
 2013-02-04  Chris Hopman  <[email protected]>
 
         Make moveCaretTowardsWindowPoint not snap to the beginning/end when moved above/below editable

Modified: trunk/Source/WebKit/chromium/public/WebFrameClient.h (141849 => 141850)


--- trunk/Source/WebKit/chromium/public/WebFrameClient.h	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebKit/chromium/public/WebFrameClient.h	2013-02-05 04:23:17 UTC (rev 141850)
@@ -328,6 +328,9 @@
     // The main frame scrolled.
     virtual void didChangeScrollOffset(WebFrame*) { }
 
+    // If the frame is loading an HTML document, this will be called to
+    // notify that the <body> will be attached soon.
+    virtual void willInsertBody(WebFrame*) { }
 
     // Find-in-page notifications ------------------------------------------
 

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp (141849 => 141850)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2013-02-05 04:23:17 UTC (rev 141850)
@@ -1700,4 +1700,10 @@
 }
 #endif
 
+void FrameLoaderClientImpl::dispatchWillInsertBody()
+{
+    if (m_webFrame->client())
+        m_webFrame->client()->willInsertBody(m_webFrame);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h (141849 => 141850)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2013-02-05 04:23:17 UTC (rev 141850)
@@ -237,6 +237,8 @@
     virtual void didLoseWebGLContext(int arbRobustnessContextLostReason) OVERRIDE;
 #endif
 
+    virtual void dispatchWillInsertBody() OVERRIDE;
+
 private:
     void makeDocumentView();
 

Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (141849 => 141850)


--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-02-05 04:21:13 UTC (rev 141849)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp	2013-02-05 04:23:17 UTC (rev 141850)
@@ -2078,4 +2078,54 @@
     EXPECT_TRUE(webFrameClient.commitCalled());
 }
 
+class TestWillInsertBodyWebFrameClient : public WebFrameClient {
+public:
+    TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false)
+    {
+    }
+
+    virtual void didCommitProvisionalLoad(WebFrame*, bool) OVERRIDE
+    {
+        m_numBodies = 0;
+        m_didLoad = true;
+    }
+
+    virtual void didCreateDocumentElement(WebFrame*) OVERRIDE
+    {
+        EXPECT_EQ(0, m_numBodies);
+    }
+
+    virtual void willInsertBody(WebFrame*) OVERRIDE
+    {
+        m_numBodies++;
+    }
+
+    int m_numBodies;
+    bool m_didLoad;
+};
+
+TEST_F(WebFrameTest, HTMLDocument)
+{
+    registerMockedHttpURLLoad("clipped-body.html");
+
+    TestWillInsertBodyWebFrameClient webFrameClient;
+    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "clipped-body.html", false, &webFrameClient);
+
+    EXPECT_TRUE(webFrameClient.m_didLoad);
+    EXPECT_EQ(1, webFrameClient.m_numBodies);
+    webView->close();
+}
+
+TEST_F(WebFrameTest, EmptyDocument)
+{
+    registerMockedHttpURLLoad("pageserializer/green_rectangle.svg");
+
+    TestWillInsertBodyWebFrameClient webFrameClient;
+    WebView* webView = FrameTestHelpers::createWebView(false, &webFrameClient);
+
+    EXPECT_FALSE(webFrameClient.m_didLoad);
+    EXPECT_EQ(1, webFrameClient.m_numBodies); // The empty document that a new frame starts with triggers this.
+    webView->close();
+}
+
 } // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to