Title: [147422] trunk
Revision
147422
Author
ca...@chromium.org
Date
2013-04-02 06:19:31 -0700 (Tue, 02 Apr 2013)

Log Message

Web Inspector: display the number of dirty render objects in Layout timeline event
https://bugs.webkit.org/show_bug.cgi?id=95331

Reviewed by Pavel Feldman.

Source/WebCore:

Count the render objects that need layout in InspectorTimelineAgent::willLayout()
and display the number in popover over Layout record in Timeline panel.

* English.lproj/localizedStrings.js:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::willLayout):
(WebCore::InspectorTimelineAgent::didLayout):
* inspector/TimelineRecordFactory.cpp:
(WebCore):
(WebCore::TimelineRecordFactory::createLayoutData):
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* inspector/TimelineRecordFactory.h:
(TimelineRecordFactory):
* inspector/front-end/TimelinePresentationModel.js:
(WebInspector.TimelinePresentationModel.Record.prototype._generatePopupContentWithImagePreview):

LayoutTests:

* inspector/timeline/timeline-layout-expected.txt: rebaselined to include new properties;

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147421 => 147422)


--- trunk/LayoutTests/ChangeLog	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/LayoutTests/ChangeLog	2013-04-02 13:19:31 UTC (rev 147422)
@@ -1,3 +1,12 @@
+2012-03-29  Andrey Kosyakov  <ca...@chromium.org>
+
+        Web Inspector: display the number of dirty render objects in Layout timeline event
+        https://bugs.webkit.org/show_bug.cgi?id=95331
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/timeline/timeline-layout-expected.txt: rebaselined to include new properties;
+
 2013-04-02  Thiago Marcos P. Santos  <thiago.san...@intel.com>
 
         [EFL] Unreviewed gardening.

Modified: trunk/LayoutTests/inspector/timeline/timeline-layout-expected.txt (147421 => 147422)


--- trunk/LayoutTests/inspector/timeline/timeline-layout-expected.txt	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/LayoutTests/inspector/timeline/timeline-layout-expected.txt	2013-04-02 13:19:31 UTC (rev 147422)
@@ -1,12 +1,19 @@
 Tests the Timeline API instrumentation of a Layout event
 
-Test data
+text
+text
+text
+text
+text
 Layout Properties:
 {
     children : <object>
     counters : <object>
     data : {
+        dirtyObjects : 3
+        partialLayout : true
         root : <object>
+        totalObjects : 8
     }
     endTime : <number>
     frameId : <string>
@@ -15,4 +22,21 @@
     type : "Layout"
     usedHeapSize : <number>
 }
+Layout Properties:
+{
+    children : <object>
+    counters : <object>
+    data : {
+        dirtyObjects : 2
+        partialLayout : true
+        root : <object>
+        totalObjects : 11
+    }
+    endTime : <number>
+    frameId : <string>
+    stackTrace : <object>
+    startTime : <number>
+    type : "Layout"
+    usedHeapSize : <number>
+}
 

Modified: trunk/LayoutTests/inspector/timeline/timeline-layout.html (147421 => 147422)


--- trunk/LayoutTests/inspector/timeline/timeline-layout.html	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/LayoutTests/inspector/timeline/timeline-layout.html	2013-04-02 13:19:31 UTC (rev 147422)
@@ -2,20 +2,32 @@
 <head>
 <script src=""
 <script src=""
+<style>
+.relayout-boundary {
+    overflow: hidden;
+    width: 100px;
+    height: 100px;
+}
+</style>
 <script>
 
+function invalidateAndForceLayout(element)
+{
+    element.style.marginTop = "10px";
+    var unused = element.offsetHeight;
+}
+
 function performActions()
 {
-    var element = document.createElement("div");
-    element.innerHTML = "Test data";
-    document.body.appendChild(element);
-    // Force layout.
-    var foo = element.offsetHeight;
+    invalidateAndForceLayout(document.getElementById("invalidate1"));
+    invalidateAndForceLayout(document.getElementById("invalidate2"));
 }
 
 function test()
 {
-    InspectorTest.performActionsAndPrint("performActions()", "Layout");
+    InspectorTest.evaluateInPage("testRunner.display()", function() {
+        InspectorTest.performActionsAndPrint("performActions()", "Layout");
+    });
 }
 
 </script>
@@ -25,6 +37,21 @@
 <p>
 Tests the Timeline API instrumentation of a Layout event
 </p>
+<div class="relayout-boundary">
+    <div>text</div>
+    <div></div>
+    <div>
+        <div id="invalidate1"><div>text</div></div>
+    </div>
+</div>
+<div class="relayout-boundary">
+    <div></div>
+    <div>text</div>
+    <div id="invalidate2"><div>text</div></div>
+    <div></div>
+    <div></div>
+    <div>text</div>
+</div>
 
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (147421 => 147422)


--- trunk/Source/WebCore/ChangeLog	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/ChangeLog	2013-04-02 13:19:31 UTC (rev 147422)
@@ -1,3 +1,26 @@
+2013-03-29  Andrey Kosyakov  <ca...@chromium.org>
+
+        Web Inspector: display the number of dirty render objects in Layout timeline event
+        https://bugs.webkit.org/show_bug.cgi?id=95331
+
+        Reviewed by Pavel Feldman.
+
+        Count the render objects that need layout in InspectorTimelineAgent::willLayout()
+        and display the number in popover over Layout record in Timeline panel.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willLayout):
+        (WebCore::InspectorTimelineAgent::didLayout):
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore):
+        (WebCore::TimelineRecordFactory::createLayoutData):
+        (WebCore::TimelineRecordFactory::appendLayoutRoot):
+        * inspector/TimelineRecordFactory.h:
+        (TimelineRecordFactory):
+        * inspector/front-end/TimelinePresentationModel.js:
+        (WebInspector.TimelinePresentationModel.Record.prototype._generatePopupContentWithImagePreview):
+
 2013-04-02  Andrey Lushnikov  <lushni...@chromium.org>
 
         Web Inspector: [CodeMirror] Popover for codemirror

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js (147421 => 147422)


--- trunk/Source/WebCore/English.lproj/localizedStrings.js	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/English.lproj/localizedStrings.js	2013-04-02 13:19:31 UTC (rev 147422)
@@ -917,3 +917,8 @@
 localizedStrings["Limit number of captured JS stack frames"] = "Limit number of captured JS stack frames";
 localizedStrings["Frames to capture"] = "Frames to capture";
 localizedStrings["Select node to inspect"] = "Select node to inspect";
+localizedStrings["Nodes that need layout"] = "Nodes that need layout";
+localizedStrings["Layout tree size"] = "Layout tree size";
+localizedStrings["Layout scope"] = "Layout scope";
+localizedStrings["Partial"] = "Partial";
+localizedStrings["Whole document"] = "Whole document";

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (147421 => 147422)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2013-04-02 13:19:31 UTC (rev 147422)
@@ -263,7 +263,20 @@
 
 void InspectorTimelineAgent::willLayout(Frame* frame)
 {
-    pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Layout, true, frame);
+    RenderObject* root = frame->view()->layoutRoot();
+    bool partialLayout = !!root;
+
+    if (!partialLayout)
+        root = frame->contentRenderer();
+
+    unsigned dirtyObjects = 0;
+    unsigned totalObjects = 0;
+    for (RenderObject* o = root; o; o = o->nextInPreOrder(root)) {
+        ++totalObjects;
+        if (o->needsLayout())
+            ++dirtyObjects;
+    }
+    pushCurrentRecord(TimelineRecordFactory::createLayoutData(dirtyObjects, totalObjects, partialLayout), TimelineRecordType::Layout, true, frame);
 }
 
 void InspectorTimelineAgent::didLayout(RenderObject* root)
@@ -275,7 +288,7 @@
     Vector<FloatQuad> quads;
     root->absoluteQuads(quads);
     if (quads.size() >= 1)
-        entry.data = ""
+        TimelineRecordFactory::appendLayoutRoot(entry.data.get(), quads[0]);
     else
         ASSERT_NOT_REACHED();
     didCompleteCurrentRecord(TimelineRecordType::Layout);

Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp (147421 => 147422)


--- trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp	2013-04-02 13:19:31 UTC (rev 147422)
@@ -178,6 +178,15 @@
     data->setNumber("encodedDataLength", length);
     return data.release();
 }
+
+PassRefPtr<InspectorObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
+{
+    RefPtr<InspectorObject> data = ""
+    data->setNumber("dirtyObjects", dirtyObjects);
+    data->setNumber("totalObjects", totalObjects);
+    data->setBoolean("partialLayout", partialLayout);
+    return data.release();
+}
     
 PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
 {
@@ -235,11 +244,9 @@
     return data.release();
 }
 
-PassRefPtr<InspectorObject> TimelineRecordFactory::createLayoutData(const FloatQuad& quad)
+void TimelineRecordFactory::appendLayoutRoot(InspectorObject* data, const FloatQuad& quad)
 {
-    RefPtr<InspectorObject> data = ""
     data->setArray("root", createQuad(quad));
-    return data.release();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/TimelineRecordFactory.h (147421 => 147422)


--- trunk/Source/WebCore/inspector/TimelineRecordFactory.h	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/inspector/TimelineRecordFactory.h	2013-04-02 13:19:31 UTC (rev 147422)
@@ -80,7 +80,7 @@
 
         static PassRefPtr<InspectorObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
 
-        static void addRectData(InspectorObject*, const LayoutRect&);
+        static PassRefPtr<InspectorObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
 
         static PassRefPtr<InspectorObject> createDecodeImageData(const String& imageType);
 
@@ -94,7 +94,7 @@
 
         static PassRefPtr<InspectorObject> createPaintData(const FloatQuad&);
 
-        static PassRefPtr<InspectorObject> createLayoutData(const FloatQuad&);
+        static void appendLayoutRoot(InspectorObject* data, const FloatQuad&);
 
 #if ENABLE(WEB_SOCKETS)
         static inline PassRefPtr<InspectorObject> createWebSocketCreateData(unsigned long identifier, const KURL& url, const String& protocol)

Modified: trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js (147421 => 147422)


--- trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js	2013-04-02 13:15:35 UTC (rev 147421)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js	2013-04-02 13:19:31 UTC (rev 147422)
@@ -1045,6 +1045,14 @@
                 callStackLabel = WebInspector.UIString("Styles recalculation forced");
                 break;
             case recordTypes.Layout:
+                if (this.data["dirtyObjects"])
+                    contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layout"), this.data["dirtyObjects"]);
+                if (this.data["totalObjects"])
+                    contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), this.data["totalObjects"]);
+                if (typeof this.data["partialLayout"] === "boolean") {
+                    contentHelper.appendTextRow(WebInspector.UIString("Layout scope"),
+                       this.data["partialLayout"] ? WebInspector.UIString("Partial") : WebInspector.UIString("Whole document"));
+                }
                 callSiteStackTraceLabel = WebInspector.UIString("Layout invalidated");
                 if (this.stackTrace) {
                     callStackLabel = WebInspector.UIString("Layout forced");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to