Web Inspector: Paint rectangles shown on hover over Timeline's paint records occasion...
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 15:57:31 +0000 (15:57 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2013 15:57:31 +0000 (15:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112371

Reviewed by Pavel Feldman.

Source/WebCore:

- pass frame to InspectorTimelineAgent::didPaint();
- convert paint coordinates to root view.

* inspector/InspectorInstrumentation.cpp:
(WebCore):
(WebCore::InspectorInstrumentation::willPaintImpl):
(WebCore::InspectorInstrumentation::didPaintImpl):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
(WebCore::InspectorInstrumentation::willPaint):
(WebCore::InspectorInstrumentation::didPaint):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didPaint):
* inspector/InspectorTimelineAgent.h:
(InspectorTimelineAgent):

LayoutTests:

* http/tests/inspector/timeline-test.js:
(initialize_Timeline.InspectorTest.startTimeline.InspectorTest._addTimelineEvent):
(initialize_Timeline.InspectorTest.startTimeline):
(initialize_Timeline.addEvent):
(initialize_Timeline.addRecord):
(initialize_Timeline.InspectorTest.waitForRecordType):
(initialize_Timeline.InspectorTest.stopTimeline):
* inspector/timeline/timeline-paint-expected.txt:
* inspector/timeline/timeline-paint.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@146476 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/timeline-test.js
LayoutTests/inspector/timeline/resources/timeline-iframe-paint.html [new file with mode: 0644]
LayoutTests/inspector/timeline/timeline-paint-expected.txt
LayoutTests/inspector/timeline/timeline-paint.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h

index 213d15e..c03b6a1 100644 (file)
@@ -1,3 +1,20 @@
+2013-03-19  Andrey Kosyakov  <caseq@chromium.org>
+
+        Web Inspector: Paint rectangles shown on hover over Timeline's paint records occasionally have wrong offsets
+        https://bugs.webkit.org/show_bug.cgi?id=112371
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/timeline-test.js:
+        (initialize_Timeline.InspectorTest.startTimeline.InspectorTest._addTimelineEvent):
+        (initialize_Timeline.InspectorTest.startTimeline):
+        (initialize_Timeline.addEvent):
+        (initialize_Timeline.addRecord):
+        (initialize_Timeline.InspectorTest.waitForRecordType):
+        (initialize_Timeline.InspectorTest.stopTimeline):
+        * inspector/timeline/timeline-paint-expected.txt:
+        * inspector/timeline/timeline-paint.html:
+
 2013-03-21  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening.
index efef111..2cef86d 100644 (file)
@@ -36,25 +36,30 @@ InspectorTest.startTimeline = function(callback)
         for (var i = 0; record.children && i < record.children.length; ++i)
             addRecord(record.children[i]);
     }
-    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, function(event) {
+    InspectorTest._addTimelineEvent = function(event)
+    {
         addRecord(event.data);
-    });
+    }
+    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
 };
 
 
 InspectorTest.waitForRecordType = function(recordType, callback)
 {
-    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, function(event) {
-            addRecord(event.data);
-    });
+    WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addEvent);
 
+    function addEvent(event)
+    {
+        addRecord(event.data);
+    }
     function addRecord(record)
     {
         if (record.type !== WebInspector.TimelineModel.RecordType[recordType]) {
             for (var i = 0; record.children && i < record.children.length; ++i)
                 addRecord(record.children[i]);
-            return ;
+            return;
         }
+        WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, addEvent);
         callback(record);
     }
 }
@@ -63,6 +68,7 @@ InspectorTest.stopTimeline = function(callback)
 {
     function didStop()
     {
+        WebInspector.timelineManager.removeEventListener(WebInspector.TimelineManager.EventTypes.TimelineEventRecorded, InspectorTest._addTimelineEvent);
         WebInspector.panel("timeline").toggleTimelineButton.toggled = false;
         WebInspector.panel("timeline")._model._collectionEnabled = false;
         callback(InspectorTest._timelineRecords);
diff --git a/LayoutTests/inspector/timeline/resources/timeline-iframe-paint.html b/LayoutTests/inspector/timeline/resources/timeline-iframe-paint.html
new file mode 100644 (file)
index 0000000..2ea17c9
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head>
+<body style="margin: 0">
+    <div style="display: block; position: absolute; left: 15px; top: 15px; width: 20px; height: 20px; background-color: blue"></div>
+</body>
+</html>
index 9580fda..c145cd5 100644 (file)
@@ -1,5 +1,6 @@
 Tests the Timeline API instrumentation of a paint event
 
+
 Paint Properties:
 {
     children : <object>
index 1a3fd96..a762800 100644 (file)
@@ -4,18 +4,25 @@
 <script src="../../http/tests/inspector/timeline-test.js"></script>
 <script>
 
-function performActions()
+function display()
 {
     if (window.testRunner)
         testRunner.display();
 }
 
+function updateSubframeAndDisplay()
+{
+    frames[0].document.body.children[0].style.backgroundColor = "green";
+    if (window.testRunner)
+        testRunner.displayInvalidatedRegion();
+}
+
 function test()
 {
     InspectorTest.startTimeline(step1);
     function step1()
     {
-        InspectorTest.evaluateInPage("performActions()", step2);
+        InspectorTest.evaluateInPage("display()", step2);
     }
 
     function step2()
@@ -32,6 +39,35 @@ function test()
                 break;
             }
         }
+        InspectorTest.startTimeline(step4);
+    }
+
+    function step4()
+    {
+        InspectorTest.evaluateInPage("updateSubframeAndDisplay()", step5);
+    }
+
+    function step5()
+    {
+        InspectorTest.stopTimeline(step6);
+    }
+
+    function step6(records)
+    {
+        var paintRecord;
+        for (var i = 0; i < records.length; ++i) {
+            var record = records[i];
+            if (record.type === WebInspector.TimelineModel.RecordType.Paint && record.children && record.children.length) {
+                paintRecord = record;
+                break;
+            }
+        }
+        InspectorTest.assertTrue(paintRecord, "Paint record with subframe paint not found");
+        var subframePaint = paintRecord.children[0];
+        InspectorTest.assertGreaterOrEqual(subframePaint.data.x, paintRecord.data.x);
+        InspectorTest.assertGreaterOrEqual(subframePaint.data.y, paintRecord.data.y);
+        InspectorTest.assertGreaterOrEqual(paintRecord.data.x + paintRecord.data.width, subframePaint.data.x + subframePaint.data.width);
+        InspectorTest.assertGreaterOrEqual(paintRecord.data.y + paintRecord.data.height, subframePaint.data.y + subframePaint.data.height);
         InspectorTest.completeTest();
     }
 }
@@ -43,6 +79,6 @@ function test()
 <p>
 Tests the Timeline API instrumentation of a paint event
 </p>
-
+<iframe src="resources/timeline-iframe-paint.html" style="position: absolute; left: 40px; top: 40px; width: 100px; height: 100px; border: none"></iframe>
 </body>
 </html>
index 2a52014..fdd5e66 100644 (file)
@@ -1,3 +1,26 @@
+2013-03-18  Andrey Kosyakov  <caseq@chromium.org>
+
+        Web Inspector: Paint rectangles shown on hover over Timeline's paint records occasionally have wrong offsets
+        https://bugs.webkit.org/show_bug.cgi?id=112371
+
+        Reviewed by Pavel Feldman.
+
+        - pass frame to InspectorTimelineAgent::didPaint();
+        - convert paint coordinates to root view.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore):
+        (WebCore::InspectorInstrumentation::willPaintImpl):
+        (WebCore::InspectorInstrumentation::didPaintImpl):
+        * inspector/InspectorInstrumentation.h:
+        (InspectorInstrumentation):
+        (WebCore::InspectorInstrumentation::willPaint):
+        (WebCore::InspectorInstrumentation::didPaint):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didPaint):
+        * inspector/InspectorTimelineAgent.h:
+        (InspectorTimelineAgent):
+
 2013-03-20  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: do not use inspector cookie in InspectorInstrumentation::{will,did}Paint
index 1b392c3..cccbfe9 100644 (file)
@@ -535,10 +535,10 @@ void InspectorInstrumentation::willPaintImpl(InstrumentingAgents* instrumentingA
         timelineAgent->willPaint(frame);
 }
 
-void InspectorInstrumentation::didPaintImpl(InstrumentingAgents*  instrumentingAgents, GraphicsContext* context, const LayoutRect& rect)
+void InspectorInstrumentation::didPaintImpl(InstrumentingAgents*  instrumentingAgents, Frame* frame, GraphicsContext* context, const LayoutRect& rect)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents->inspectorTimelineAgent())
-        timelineAgent->didPaint(rect);
+        timelineAgent->didPaint(frame, rect);
     if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
         pageAgent->didPaint(context, rect);
 }
index 8d582aa..56e5e0d 100644 (file)
@@ -374,7 +374,7 @@ private:
     static void willScrollLayerImpl(InstrumentingAgents*, Frame*);
     static void didScrollLayerImpl(InstrumentingAgents*);
     static void willPaintImpl(InstrumentingAgents*, Frame*);
-    static void didPaintImpl(InstrumentingAgents*, GraphicsContext*, const LayoutRect&);
+    static void didPaintImpl(InstrumentingAgents*, Frame*, GraphicsContext*, const LayoutRect&);
     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*, Frame*);
     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
     static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*);
@@ -1117,7 +1117,7 @@ inline void InspectorInstrumentation::didPaint(Frame* frame, GraphicsContext* co
 #if ENABLE(INSPECTOR)
     FAST_RETURN_IF_NO_FRONTENDS(void());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
-        didPaintImpl(instrumentingAgents, context, rect);
+        didPaintImpl(instrumentingAgents, frame, context, rect);
 #else
     UNUSED_PARAM(frame);
     UNUSED_PARAM(context);
index a56445f..f7bda6c 100644 (file)
@@ -297,11 +297,12 @@ void InspectorTimelineAgent::willPaint(Frame* frame)
     pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Paint, true, frame, true);
 }
 
-void InspectorTimelineAgent::didPaint(const LayoutRect& rect)
+void InspectorTimelineAgent::didPaint(Frame* frame, const LayoutRect& rect)
 {
     TimelineRecordEntry entry = m_recordStack.last();
     ASSERT(entry.type == TimelineRecordType::Paint);
-    TimelineRecordFactory::addRectData(entry.data.get(), rect);
+    LayoutRect rectInRootCoordinates = frame->view()->contentsToRootView(pixelSnappedIntRect(rect));
+    TimelineRecordFactory::addRectData(entry.data.get(), rectInRootCoordinates);
     didCompleteCurrentRecord(TimelineRecordType::Paint);
 }
 
index 2e4015f..b0da35f 100644 (file)
@@ -129,7 +129,7 @@ public:
     void didRecalculateStyle();
 
     void willPaint(Frame*);
-    void didPaint(const LayoutRect&);
+    void didPaint(Frame*, const LayoutRect&);
 
     void willScroll(Frame*);
     void didScroll();