Changeset 128184 in webkit


Ignore:
Timestamp:
Sep 11, 2012 7:34:35 AM (12 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: visualize layout root in Timeline
https://bugs.webkit.org/show_bug.cgi?id=96279

Reviewed by Pavel Feldman.

  • pass layout root to InspectorTimelineAgent::didLayout
  • show rectangles of the layout root upon hover over the Layout record;
  • inspector/InspectorInstrumentation.cpp:

(WebCore):
(WebCore::InspectorInstrumentation::didLayoutImpl):

  • inspector/InspectorInstrumentation.h:

(WebCore):
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::didLayout):

  • inspector/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::didLayout):

  • inspector/InspectorTimelineAgent.h:

(WebCore):
(InspectorTimelineAgent):

  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::createPaintData):
(WebCore::TimelineRecordFactory::addRectData):
(WebCore):

  • inspector/TimelineRecordFactory.h:

(TimelineRecordFactory):

  • inspector/front-end/TimelinePanel.js:

(WebInspector.TimelinePanel.prototype._mouseMove):

  • page/FrameView.cpp:

(WebCore::FrameView::layout):

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/inspector/timeline/timeline-layout-expected.txt

    r128057 r128184  
    77    counters : <object>
    88    data : {
     9        height : <number>
     10        width : <number>
     11        x : 0
     12        y : 0
    913    }
    1014    endTime : <number>
  • trunk/Source/WebCore/ChangeLog

    r128182 r128184  
     12012-09-10  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Web Inspector: visualize layout root in Timeline
     4        https://bugs.webkit.org/show_bug.cgi?id=96279
     5
     6        Reviewed by Pavel Feldman.
     7
     8        - pass layout root to InspectorTimelineAgent::didLayout
     9        - show rectangles of the layout root upon hover over the Layout record;
     10
     11        * inspector/InspectorInstrumentation.cpp:
     12        (WebCore):
     13        (WebCore::InspectorInstrumentation::didLayoutImpl):
     14        * inspector/InspectorInstrumentation.h:
     15        (WebCore):
     16        (InspectorInstrumentation):
     17        (WebCore::InspectorInstrumentation::didLayout):
     18        * inspector/InspectorTimelineAgent.cpp:
     19        (WebCore::InspectorTimelineAgent::didLayout):
     20        * inspector/InspectorTimelineAgent.h:
     21        (WebCore):
     22        (InspectorTimelineAgent):
     23        * inspector/TimelineRecordFactory.cpp:
     24        (WebCore::TimelineRecordFactory::createPaintData):
     25        (WebCore::TimelineRecordFactory::addRectData):
     26        (WebCore):
     27        * inspector/TimelineRecordFactory.h:
     28        (TimelineRecordFactory):
     29        * inspector/front-end/TimelinePanel.js:
     30        (WebInspector.TimelinePanel.prototype._mouseMove):
     31        * page/FrameView.cpp:
     32        (WebCore::FrameView::layout):
     33
     342012-09-10  Andrey Kosyakov  <caseq@chromium.org>
     35
     36        Web Inspector: highlight of paint rectangles is broken
     37        https://bugs.webkit.org/show_bug.cgi?id=96276
     38
     39        Reviewed by Pavel Feldman.
     40
     41        * inspector/InspectorOverlay.cpp:
     42        (WebCore::InspectorOverlay::drawRectHighlight): Fix JS method name to match the one in InspectorOverlayPage.html
     43
    1442012-09-11  Chris Guan  <chris.guan@torchmobile.com.cn>
    245
  • trunk/Source/WebCore/English.lproj/localizedStrings.js

    r128057 r128184  
    732732localizedStrings["Override Device Orientation"] = "Override Device Orientation";
    733733localizedStrings["Note"] = "Note";
    734 localizedStrings["Forced synchronous layout is a possible performance bottlenck."] = "Forced synchronous layout is a possible performance bottlenck.";
     734localizedStrings["Forced synchronous layout is a possible performance bottleneck."] = "Forced synchronous layout is a possible performance bottleneck.";
    735735localizedStrings["Styles invalidated"] = "Styles invalidated";
    736736localizedStrings["Styles recalculation forced"] = "Styles recalculation forced";
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r127867 r128184  
    452452}
    453453
    454 void InspectorInstrumentation::didLayoutImpl(const InspectorInstrumentationCookie& cookie)
     454void InspectorInstrumentation::didLayoutImpl(const InspectorInstrumentationCookie& cookie, RenderObject* root)
    455455{
    456456    if (!cookie.first)
     
    458458
    459459    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    460         timelineAgent->didLayout();
     460        timelineAgent->didLayout(root);
    461461
    462462    if (InspectorPageAgent* pageAgent = cookie.first->inspectorPageAgent())
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r127867 r128184  
    6666class KURL;
    6767class Node;
     68class RenderObject;
    6869class ResourceRequest;
    6970class ResourceResponse;
     
    145146    static void didInvalidateLayout(Frame*);
    146147    static InspectorInstrumentationCookie willLayout(Frame*);
    147     static void didLayout(const InspectorInstrumentationCookie&);
     148    static void didLayout(const InspectorInstrumentationCookie&, RenderObject*);
    148149    static void didScroll(Page*);
    149150    static InspectorInstrumentationCookie willLoadXHR(ScriptExecutionContext*, XMLHttpRequest*);
     
    322323    static void didInvalidateLayoutImpl(InstrumentingAgents*, Frame*);
    323324    static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents*, Frame*);
    324     static void didLayoutImpl(const InspectorInstrumentationCookie&);
     325    static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject*);
    325326    static void didScrollImpl(InstrumentingAgents*);
    326327    static InspectorInstrumentationCookie willLoadXHRImpl(InstrumentingAgents*, XMLHttpRequest*, ScriptExecutionContext*);
     
    834835}
    835836
    836 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie)
    837 {
    838 #if ENABLE(INSPECTOR)
    839     FAST_RETURN_IF_NO_FRONTENDS(void());
    840     if (cookie.first)
    841         didLayoutImpl(cookie);
     837inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject* root)
     838{
     839#if ENABLE(INSPECTOR)
     840    FAST_RETURN_IF_NO_FRONTENDS(void());
     841    if (cookie.first)
     842        didLayoutImpl(cookie, root);
    842843#endif
    843844}
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp

    r128057 r128184  
    4747#include "InstrumentingAgents.h"
    4848#include "IntRect.h"
     49#include "RenderObject.h"
     50#include "RenderView.h"
    4951#include "ResourceRequest.h"
    5052#include "ResourceResponse.h"
     
    243245}
    244246
    245 void InspectorTimelineAgent::didLayout()
    246 {
     247void InspectorTimelineAgent::didLayout(RenderObject* root)
     248{
     249    if (m_recordStack.isEmpty())
     250        return;
     251    LayoutRect rect = root->frame()->view()->contentsToRootView(root->absoluteBoundingBoxRect());
     252    TimelineRecordEntry entry = m_recordStack.last();
     253    ASSERT(entry.type == TimelineRecordType::Layout);
     254    TimelineRecordFactory::addRectData(entry.data.get(), rect);
    247255    didCompleteCurrentRecord(TimelineRecordType::Layout);
    248256}
  • trunk/Source/WebCore/inspector/InspectorTimelineAgent.h

    r128057 r128184  
    5353class InstrumentingAgents;
    5454class IntRect;
     55class RenderObject;
    5556class ResourceRequest;
    5657class ResourceResponse;
     
    99100    void didInvalidateLayout(Frame*);
    100101    void willLayout(Frame*);
    101     void didLayout();
     102    void didLayout(RenderObject*);
    102103
    103104    void didScheduleStyleRecalculation(Frame*);
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp

    r127752 r128184  
    174174{
    175175    RefPtr<InspectorObject> data = InspectorObject::create();
     176    addRectData(data.get(), rect);
     177    return data.release();
     178}
     179
     180PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
     181{
     182    RefPtr<InspectorObject> data = InspectorObject::create();
     183    data->setString("imageType", imageType);
     184    return data.release();
     185}
     186
     187PassRefPtr<InspectorObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
     188{
     189    RefPtr<InspectorObject> data = InspectorObject::create();
     190    data->setBoolean("cached", shouldCache);
     191    return data.release();
     192}
     193
     194PassRefPtr<InspectorObject> TimelineRecordFactory::createParseHTMLData(unsigned int length, unsigned int startLine)
     195{
     196    RefPtr<InspectorObject> data = InspectorObject::create();
     197    data->setNumber("length", length);
     198    data->setNumber("startLine", startLine);
     199    return data.release();
     200}
     201
     202PassRefPtr<InspectorObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
     203{
     204    RefPtr<InspectorObject> data = InspectorObject::create();
     205    data->setNumber("id", callbackId);
     206    return data.release();
     207}
     208
     209void TimelineRecordFactory::addRectData(InspectorObject* data, const LayoutRect& rect)
     210{
    176211    data->setNumber("x", rect.x());
    177212    data->setNumber("y", rect.y());
    178213    data->setNumber("width", rect.width());
    179214    data->setNumber("height", rect.height());
    180     return data.release();
    181 }
    182 
    183 PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
    184 {
    185     RefPtr<InspectorObject> data = InspectorObject::create();
    186     data->setString("imageType", imageType);
    187     return data.release();
    188 }
    189 
    190 PassRefPtr<InspectorObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
    191 {
    192     RefPtr<InspectorObject> data = InspectorObject::create();
    193     data->setBoolean("cached", shouldCache);
    194     return data.release();
    195 }
    196 
    197 PassRefPtr<InspectorObject> TimelineRecordFactory::createParseHTMLData(unsigned int length, unsigned int startLine)
    198 {
    199     RefPtr<InspectorObject> data = InspectorObject::create();
    200     data->setNumber("length", length);
    201     data->setNumber("startLine", startLine);
    202     return data.release();
    203 }
    204 
    205 PassRefPtr<InspectorObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
    206 {
    207     RefPtr<InspectorObject> data = InspectorObject::create();
    208     data->setNumber("id", callbackId);
    209     return data.release();
    210215}
    211216
  • trunk/Source/WebCore/inspector/TimelineRecordFactory.h

    r127757 r128184  
    7878        static PassRefPtr<InspectorObject> createPaintData(const LayoutRect&);
    7979
     80        static void addRectData(InspectorObject*, const LayoutRect&);
     81
    8082        static PassRefPtr<InspectorObject> createDecodeImageData(const String& imageType);
    8183
  • trunk/Source/WebCore/inspector/front-end/TimelinePanel.js

    r127746 r128184  
    948948        var anchor = this._getPopoverAnchor(e.target);
    949949
    950         if (anchor && anchor.row && anchor.row._record.type === "Paint")
     950        const recordType = WebInspector.TimelineModel.RecordType;
     951        if (anchor && anchor.row && (anchor.row._record.type === recordType.Paint || anchor.row._record.type === recordType.Layout))
    951952            this._highlightRect(anchor.row._record);
    952953        else
  • trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js

    r128057 r128184  
    219219}
    220220
     221WebInspector.TimelinePresentationModel._hiddenRecords = { }
     222WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkDOMContent] = 1;
     223WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.MarkLoad] = 1;
     224WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation] = 1;
     225WebInspector.TimelinePresentationModel._hiddenRecords[WebInspector.TimelineModel.RecordType.InvalidateLayout] = 1;
     226
    221227WebInspector.TimelinePresentationModel.prototype = {
    222228    /**
     
    279285    {
    280286        const recordTypes = WebInspector.TimelineModel.RecordType;
    281         const hiddenRecords = [
    282             recordTypes.MarkDOMContent,
    283             recordTypes.MarkLoad,
    284             recordTypes.ScheduleStyleRecalculation,
    285             recordTypes.InvalidateLayout
    286         ];
    287         var isHiddenRecord = hiddenRecords.indexOf(record.type) >= 0;
     287        var isHiddenRecord = record.type in WebInspector.TimelinePresentationModel._hiddenRecords;
    288288        var connectedToOldRecord = false;
    289289        if (record.type === recordTypes.Time)
     
    789789                if (this.stackTrace) {
    790790                    callStackLabel = WebInspector.UIString("Layout forced");
    791                     contentHelper._appendTextRow(WebInspector.UIString("Note"), WebInspector.UIString("Forced synchronous layout is a possible performance bottlenck."));
     791                    contentHelper._appendTextRow(WebInspector.UIString("Note"), WebInspector.UIString("Forced synchronous layout is a possible performance bottleneck."));
    792792                }
    793793                break;
  • trunk/Source/WebCore/page/FrameView.cpp

    r128134 r128184  
    12531253    }
    12541254
    1255     InspectorInstrumentation::didLayout(cookie);
     1255    InspectorInstrumentation::didLayout(cookie, root);
    12561256
    12571257    m_nestedLayoutCount--;
Note: See TracChangeset for help on using the changeset viewer.