Changeset 147422 in webkit


Ignore:
Timestamp:
Apr 2, 2013 6:19:31 AM (11 years ago)
Author:
caseq@chromium.org
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;
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147420 r147422  
     12012-03-29  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: display the number of dirty render objects in Layout timeline event
     4        https://bugs.webkit.org/show_bug.cgi?id=95331
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/timeline/timeline-layout-expected.txt: rebaselined to include new properties;
     9
    1102013-04-02  Thiago Marcos P. Santos  <thiago.santos@intel.com>
    211
  • trunk/LayoutTests/inspector/timeline/timeline-layout-expected.txt

    r147204 r147422  
    11Tests the Timeline API instrumentation of a Layout event
    22
    3 Test data
     3text
     4text
     5text
     6text
     7text
    48Layout Properties:
    59{
     
    711    counters : <object>
    812    data : {
     13        dirtyObjects : 3
     14        partialLayout : true
    915        root : <object>
     16        totalObjects : 8
     17    }
     18    endTime : <number>
     19    frameId : <string>
     20    stackTrace : <object>
     21    startTime : <number>
     22    type : "Layout"
     23    usedHeapSize : <number>
     24}
     25Layout Properties:
     26{
     27    children : <object>
     28    counters : <object>
     29    data : {
     30        dirtyObjects : 2
     31        partialLayout : true
     32        root : <object>
     33        totalObjects : 11
    1034    }
    1135    endTime : <number>
  • trunk/LayoutTests/inspector/timeline/timeline-layout.html

    r143573 r147422  
    33<script src="../../http/tests/inspector/inspector-test.js"></script>
    44<script src="../../http/tests/inspector/timeline-test.js"></script>
     5<style>
     6.relayout-boundary {
     7    overflow: hidden;
     8    width: 100px;
     9    height: 100px;
     10}
     11</style>
    512<script>
     13
     14function invalidateAndForceLayout(element)
     15{
     16    element.style.marginTop = "10px";
     17    var unused = element.offsetHeight;
     18}
    619
    720function performActions()
    821{
    9     var element = document.createElement("div");
    10     element.innerHTML = "Test data";
    11     document.body.appendChild(element);
    12     // Force layout.
    13     var foo = element.offsetHeight;
     22    invalidateAndForceLayout(document.getElementById("invalidate1"));
     23    invalidateAndForceLayout(document.getElementById("invalidate2"));
    1424}
    1525
    1626function test()
    1727{
    18     InspectorTest.performActionsAndPrint("performActions()", "Layout");
     28    InspectorTest.evaluateInPage("testRunner.display()", function() {
     29        InspectorTest.performActionsAndPrint("performActions()", "Layout");
     30    });
    1931}
    2032
     
    2638Tests the Timeline API instrumentation of a Layout event
    2739</p>
     40<div class="relayout-boundary">
     41    <div>text</div>
     42    <div></div>
     43    <div>
     44        <div id="invalidate1"><div>text</div></div>
     45    </div>
     46</div>
     47<div class="relayout-boundary">
     48    <div></div>
     49    <div>text</div>
     50    <div id="invalidate2"><div>text</div></div>
     51    <div></div>
     52    <div></div>
     53    <div>text</div>
     54</div>
    2855
    2956</body>
  • trunk/Source/WebCore/ChangeLog

    r147421 r147422  
     12013-03-29  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: display the number of dirty render objects in Layout timeline event
     4        https://bugs.webkit.org/show_bug.cgi?id=95331
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Count the render objects that need layout in InspectorTimelineAgent::willLayout()
     9        and display the number in popover over Layout record in Timeline panel.
     10
     11        * English.lproj/localizedStrings.js:
     12        * inspector/InspectorTimelineAgent.cpp:
     13        (WebCore::InspectorTimelineAgent::willLayout):
     14        (WebCore::InspectorTimelineAgent::didLayout):
     15        * inspector/TimelineRecordFactory.cpp:
     16        (WebCore):
     17        (WebCore::TimelineRecordFactory::createLayoutData):
     18        (WebCore::TimelineRecordFactory::appendLayoutRoot):
     19        * inspector/TimelineRecordFactory.h:
     20        (TimelineRecordFactory):
     21        * inspector/front-end/TimelinePresentationModel.js:
     22        (WebInspector.TimelinePresentationModel.Record.prototype._generatePopupContentWithImagePreview):
     23
    1242013-04-02  Andrey Lushnikov  <lushnikov@chromium.org>
    225
  • trunk/Source/WebCore/English.lproj/localizedStrings.js

    r147321 r147422  
    918918localizedStrings["Frames to capture"] = "Frames to capture";
    919919localizedStrings["Select node to inspect"] = "Select node to inspect";
     920localizedStrings["Nodes that need layout"] = "Nodes that need layout";
     921localizedStrings["Layout tree size"] = "Layout tree size";
     922localizedStrings["Layout scope"] = "Layout scope";
     923localizedStrings["Partial"] = "Partial";
     924localizedStrings["Whole document"] = "Whole document";
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r147204 r147422  
    264264void InspectorTimelineAgent::willLayout(Frame* frame)
    265265{
    266     pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Layout, true, frame);
     266    RenderObject* root = frame->view()->layoutRoot();
     267    bool partialLayout = !!root;
     268
     269    if (!partialLayout)
     270        root = frame->contentRenderer();
     271
     272    unsigned dirtyObjects = 0;
     273    unsigned totalObjects = 0;
     274    for (RenderObject* o = root; o; o = o->nextInPreOrder(root)) {
     275        ++totalObjects;
     276        if (o->needsLayout())
     277            ++dirtyObjects;
     278    }
     279    pushCurrentRecord(TimelineRecordFactory::createLayoutData(dirtyObjects, totalObjects, partialLayout), TimelineRecordType::Layout, true, frame);
    267280}
    268281
     
    276289    root->absoluteQuads(quads);
    277290    if (quads.size() >= 1)
    278         entry.data = TimelineRecordFactory::createLayoutData(quads[0]);
     291        TimelineRecordFactory::appendLayoutRoot(entry.data.get(), quads[0]);
    279292    else
    280293        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r147204 r147422  
    179179    return data.release();
    180180}
     181
     182PassRefPtr<InspectorObject> TimelineRecordFactory::createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout)
     183{
     184    RefPtr<InspectorObject> data = InspectorObject::create();
     185    data->setNumber("dirtyObjects", dirtyObjects);
     186    data->setNumber("totalObjects", totalObjects);
     187    data->setBoolean("partialLayout", partialLayout);
     188    return data.release();
     189}
    181190   
    182191PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
     
    236245}
    237246
    238 PassRefPtr<InspectorObject> TimelineRecordFactory::createLayoutData(const FloatQuad& quad)
    239 {
    240     RefPtr<InspectorObject> data = InspectorObject::create();
     247void TimelineRecordFactory::appendLayoutRoot(InspectorObject* data, const FloatQuad& quad)
     248{
    241249    data->setArray("root", createQuad(quad));
    242     return data.release();
    243250}
    244251
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r147204 r147422  
    8181        static PassRefPtr<InspectorObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
    8282
    83         static void addRectData(InspectorObject*, const LayoutRect&);
     83        static PassRefPtr<InspectorObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
    8484
    8585        static PassRefPtr<InspectorObject> createDecodeImageData(const String& imageType);
     
    9595        static PassRefPtr<InspectorObject> createPaintData(const FloatQuad&);
    9696
    97         static PassRefPtr<InspectorObject> createLayoutData(const FloatQuad&);
     97        static void appendLayoutRoot(InspectorObject* data, const FloatQuad&);
    9898
    9999#if ENABLE(WEB_SOCKETS)
  • trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js

    r147208 r147422  
    10461046                break;
    10471047            case recordTypes.Layout:
     1048                if (this.data["dirtyObjects"])
     1049                    contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layout"), this.data["dirtyObjects"]);
     1050                if (this.data["totalObjects"])
     1051                    contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), this.data["totalObjects"]);
     1052                if (typeof this.data["partialLayout"] === "boolean") {
     1053                    contentHelper.appendTextRow(WebInspector.UIString("Layout scope"),
     1054                       this.data["partialLayout"] ? WebInspector.UIString("Partial") : WebInspector.UIString("Whole document"));
     1055                }
    10481056                callSiteStackTraceLabel = WebInspector.UIString("Layout invalidated");
    10491057                if (this.stackTrace) {
Note: See TracChangeset for help on using the changeset viewer.