Title: [156215] trunk
Revision
156215
Author
[email protected]
Date
2013-09-20 17:35:09 -0700 (Fri, 20 Sep 2013)

Log Message

Web Inspector: [CSS Regions] Display CSS Regions chain when highlighting a CSS Region node
https://bugs.webkit.org/show_bug.cgi?id=121719

Reviewed by Joseph Pecoraro.

Source/WebCore:

Test: inspector/elements/highlight-node-regions.html

When a CSS Region node is highlighted through the WebInspector, it will also lookup all the regions
that are part of the same flow and inject enough information into InspectorOverlayPage.js to get the other
CSS Regions highlighted as well. A chain will also link the regions and a number will display the ordering
of the content.

* WebCore.exp.in:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::buildObjectForHighlightedNode):
* inspector/InspectorController.h:
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForRegionHighlight):
(WebCore::buildObjectForCSSRegionsHighlight):
(WebCore::InspectorOverlay::buildObjectForHighlightedNode):
(WebCore::InspectorOverlay::drawNodeHighlight): Separated the InspectorObject building part out of this function,
so that we can call buildObjectForHighlightedNode from the Internals APIs for testing.
* inspector/InspectorOverlay.h:
* inspector/InspectorOverlayPage.js:
(_drawRegionNumber):
(_quadMidPoint):
(_drawRegionLink):
(_fixQuadScrollPosition):
(_drawRegionsHighlight):
(drawNodeHighlight):
* testing/Internals.cpp: Exposed the generated InspectorObject to the layout test.
(WebCore::Internals::inspectorHighlightObject):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Added test to check the position of the CSS Regions part of the same flow thread with
the highlighted CSS Region node.

* http/tests/inspector/elements-test.js:
* inspector/elements/highlight-node-regions-expected.txt: Added.
* inspector/elements/highlight-node-regions.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (156214 => 156215)


--- trunk/LayoutTests/ChangeLog	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/LayoutTests/ChangeLog	2013-09-21 00:35:09 UTC (rev 156215)
@@ -1,3 +1,17 @@
+2013-09-20  Alexandru Chiculita  <[email protected]>
+
+        Web Inspector: [CSS Regions] Display CSS Regions chain when highlighting a CSS Region node
+        https://bugs.webkit.org/show_bug.cgi?id=121719
+
+        Reviewed by Joseph Pecoraro.
+
+        Added test to check the position of the CSS Regions part of the same flow thread with
+        the highlighted CSS Region node.
+
+        * http/tests/inspector/elements-test.js:
+        * inspector/elements/highlight-node-regions-expected.txt: Added.
+        * inspector/elements/highlight-node-regions.html: Added.
+
 2013-09-20  Mark Hahnenberg  <[email protected]>
 
         (un)shiftCountWithAnyIndexingType will start over in the middle of copying if it sees a hole

Modified: trunk/LayoutTests/http/tests/inspector/elements-test.js (156214 => 156215)


--- trunk/LayoutTests/http/tests/inspector/elements-test.js	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/LayoutTests/http/tests/inspector/elements-test.js	2013-09-21 00:35:09 UTC (rev 156215)
@@ -610,3 +610,19 @@
         output(rectName + " rect is " + rect.width + " x " + rect.height + " at (" + rect.left + ", " + rect.top + ")");
     }
 }
+
+function dumpInspectorHighlightedRegions()
+{
+    var highlight = window.internals.inspectorHighlightObject(document);
+    if (!highlight.length) {
+        output("No highlighted node.");
+        return;
+    }
+    // Reformat the string using JSON.stringify.
+    var json = JSON.parse(highlight);
+    if (!json.regions) {
+        output("No highlighted regions.");
+        return;
+    }
+    output(JSON.stringify(json.regions, null, 4));
+}

Added: trunk/LayoutTests/inspector/elements/highlight-node-regions-expected.txt (0 => 156215)


--- trunk/LayoutTests/inspector/elements/highlight-node-regions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/elements/highlight-node-regions-expected.txt	2013-09-21 00:35:09 UTC (rev 156215)
@@ -0,0 +1,286 @@
+This test verifies the position and size of the highlighted CSS Regions quads overlayed on the inspected div.
+
+[
+    {
+        "borderQuad": [
+            {
+                "x": 5,
+                "y": 5
+            },
+            {
+                "x": 255,
+                "y": 5
+            },
+            {
+                "x": 255,
+                "y": 255
+            },
+            {
+                "x": 5,
+                "y": 255
+            }
+        ],
+        "incomingQuad": [
+            {
+                "x": 0,
+                "y": 15
+            },
+            {
+                "x": 10,
+                "y": 15
+            },
+            {
+                "x": 10,
+                "y": 25
+            },
+            {
+                "x": 0,
+                "y": 25
+            }
+        ],
+        "outgoingQuad": [
+            {
+                "x": 250,
+                "y": 235
+            },
+            {
+                "x": 260,
+                "y": 235
+            },
+            {
+                "x": 260,
+                "y": 245
+            },
+            {
+                "x": 250,
+                "y": 245
+            }
+        ]
+    },
+    {
+        "borderQuad": [
+            {
+                "x": 265,
+                "y": 5
+            },
+            {
+                "x": 515,
+                "y": 5
+            },
+            {
+                "x": 515,
+                "y": 255
+            },
+            {
+                "x": 265,
+                "y": 255
+            }
+        ],
+        "incomingQuad": [
+            {
+                "x": 260,
+                "y": 15
+            },
+            {
+                "x": 270,
+                "y": 15
+            },
+            {
+                "x": 270,
+                "y": 25
+            },
+            {
+                "x": 260,
+                "y": 25
+            }
+        ],
+        "outgoingQuad": [
+            {
+                "x": 510,
+                "y": 235
+            },
+            {
+                "x": 520,
+                "y": 235
+            },
+            {
+                "x": 520,
+                "y": 245
+            },
+            {
+                "x": 510,
+                "y": 245
+            }
+        ],
+        "isHighlighted": true
+    },
+    {
+        "borderQuad": [
+            {
+                "x": 525,
+                "y": 5
+            },
+            {
+                "x": 775,
+                "y": 5
+            },
+            {
+                "x": 775,
+                "y": 255
+            },
+            {
+                "x": 525,
+                "y": 255
+            }
+        ],
+        "incomingQuad": [
+            {
+                "x": 520,
+                "y": 15
+            },
+            {
+                "x": 530,
+                "y": 15
+            },
+            {
+                "x": 530,
+                "y": 25
+            },
+            {
+                "x": 520,
+                "y": 25
+            }
+        ],
+        "outgoingQuad": [
+            {
+                "x": 770,
+                "y": 235
+            },
+            {
+                "x": 780,
+                "y": 235
+            },
+            {
+                "x": 780,
+                "y": 245
+            },
+            {
+                "x": 770,
+                "y": 245
+            }
+        ]
+    },
+    {
+        "borderQuad": [
+            {
+                "x": 5,
+                "y": 265
+            },
+            {
+                "x": 205,
+                "y": 265
+            },
+            {
+                "x": 205,
+                "y": 265
+            },
+            {
+                "x": 5,
+                "y": 265
+            }
+        ],
+        "incomingQuad": [
+            {
+                "x": 0,
+                "y": 260
+            },
+            {
+                "x": 10,
+                "y": 260
+            },
+            {
+                "x": 10,
+                "y": 270
+            },
+            {
+                "x": 0,
+                "y": 270
+            }
+        ],
+        "outgoingQuad": [
+            {
+                "x": 200,
+                "y": 260
+            },
+            {
+                "x": 210,
+                "y": 260
+            },
+            {
+                "x": 210,
+                "y": 270
+            },
+            {
+                "x": 200,
+                "y": 270
+            }
+        ]
+    },
+    {
+        "borderQuad": [
+            {
+                "x": 215,
+                "y": 265
+            },
+            {
+                "x": 215,
+                "y": 265
+            },
+            {
+                "x": 215,
+                "y": 265
+            },
+            {
+                "x": 215,
+                "y": 265
+            }
+        ],
+        "incomingQuad": [
+            {
+                "x": 210,
+                "y": 260
+            },
+            {
+                "x": 220,
+                "y": 260
+            },
+            {
+                "x": 220,
+                "y": 270
+            },
+            {
+                "x": 210,
+                "y": 270
+            }
+        ],
+        "outgoingQuad": [
+            {
+                "x": 210,
+                "y": 260
+            },
+            {
+                "x": 220,
+                "y": 260
+            },
+            {
+                "x": 220,
+                "y": 270
+            },
+            {
+                "x": 210,
+                "y": 270
+            }
+        ]
+    }
+]
+

Added: trunk/LayoutTests/inspector/elements/highlight-node-regions.html (0 => 156215)


--- trunk/LayoutTests/inspector/elements/highlight-node-regions.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/elements/highlight-node-regions.html	2013-09-21 00:35:09 UTC (rev 156215)
@@ -0,0 +1,77 @@
+<html>
+<head>
+
+<style>
+
+body {
+    margin: 0;
+}
+#flow {
+    -webkit-flow-into: flow;
+}
+#container {
+    width: 400px;
+    height: 400px;
+    background-color: grey;
+}
+.region {
+    margin: 5px;
+    border: solid 10px aqua;
+    padding: 15px;
+    width: 200px;
+    height: 200px;
+    background-color: blue;
+    float: left;
+    -webkit-flow-from: flow;
+}
+.zero-height {
+    border: none;
+    height: 0px;
+    padding: 0;
+}
+.zero-size {
+    border: none;
+    width: 0px;
+    height: 0px;
+    padding: 0;
+}
+.hidden {
+    display: none;
+}
+#description {
+    clear: both;
+}
+
+</style>
+
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    function nodeSelected(node)
+    {
+        RuntimeAgent.evaluate("dumpInspectorHighlightedRegions()", InspectorTest.completeTest);
+    }
+
+    InspectorTest.selectNodeWithId("inspectedElement", nodeSelected);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+
+<div id="flow"></div>
+
+<div class="region"></div>
+<div class="region" id="inspectedElement"></div>
+<div class="region"></div>
+<div class="region zero-height"></div>
+<div class="region zero-size"></div>
+<div class="region hidden"></div>
+<p id="description">This test verifies the position and size of the highlighted CSS Regions quads overlayed on the inspected div.</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (156214 => 156215)


--- trunk/Source/WebCore/ChangeLog	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/ChangeLog	2013-09-21 00:35:09 UTC (rev 156215)
@@ -1,3 +1,40 @@
+2013-09-20  Alexandru Chiculita  <[email protected]>
+
+        Web Inspector: [CSS Regions] Display CSS Regions chain when highlighting a CSS Region node
+        https://bugs.webkit.org/show_bug.cgi?id=121719
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: inspector/elements/highlight-node-regions.html
+
+        When a CSS Region node is highlighted through the WebInspector, it will also lookup all the regions
+        that are part of the same flow and inject enough information into InspectorOverlayPage.js to get the other
+        CSS Regions highlighted as well. A chain will also link the regions and a number will display the ordering
+        of the content.
+
+        * WebCore.exp.in:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::buildObjectForHighlightedNode):
+        * inspector/InspectorController.h:
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForRegionHighlight):
+        (WebCore::buildObjectForCSSRegionsHighlight):
+        (WebCore::InspectorOverlay::buildObjectForHighlightedNode):
+        (WebCore::InspectorOverlay::drawNodeHighlight): Separated the InspectorObject building part out of this function,
+        so that we can call buildObjectForHighlightedNode from the Internals APIs for testing.
+        * inspector/InspectorOverlay.h:
+        * inspector/InspectorOverlayPage.js:
+        (_drawRegionNumber):
+        (_quadMidPoint):
+        (_drawRegionLink):
+        (_fixQuadScrollPosition):
+        (_drawRegionsHighlight):
+        (drawNodeHighlight):
+        * testing/Internals.cpp: Exposed the generated InspectorObject to the layout test.
+        (WebCore::Internals::inspectorHighlightObject):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2013-09-20  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r156185.

Modified: trunk/Source/WebCore/WebCore.exp.in (156214 => 156215)


--- trunk/Source/WebCore/WebCore.exp.in	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-09-21 00:35:09 UTC (rev 156215)
@@ -1507,6 +1507,8 @@
 __ZNK7WebCore18RenderLayerBacking20compositingLayerTypeEv
 __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEPNS_8DocumentE
 __ZNK7WebCore19InspectorController12getHighlightEPNS_9HighlightE
+__ZNK7WebCore19InspectorController29buildObjectForHighlightedNodeEv
+__ZNK7WebCore14InspectorValue12toJSONStringEv
 __ZNK7WebCore19ResourceRequestBase10httpMethodEv
 __ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
 __ZNK7WebCore19ResourceRequestBase20firstPartyForCookiesEv

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (156214 => 156215)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2013-09-21 00:35:09 UTC (rev 156215)
@@ -327,6 +327,11 @@
     m_overlay->getHighlight(highlight);
 }
 
+PassRefPtr<InspectorObject> InspectorController::buildObjectForHighlightedNode() const
+{
+    return m_overlay->buildObjectForHighlightedNode();
+}
+
 void InspectorController::inspect(Node* node)
 {
     if (!enabled())

Modified: trunk/Source/WebCore/inspector/InspectorController.h (156214 => 156215)


--- trunk/Source/WebCore/inspector/InspectorController.h	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/inspector/InspectorController.h	2013-09-21 00:35:09 UTC (rev 156215)
@@ -57,6 +57,7 @@
 class InspectorFrontendChannel;
 class InspectorFrontendClient;
 class InspectorMemoryAgent;
+class InspectorObject;
 class InspectorOverlay;
 class InspectorPageAgent;
 class InspectorProfilerAgent;
@@ -105,6 +106,8 @@
     void hideHighlight();
     Node* highlightedNode() const;
 
+    PassRefPtr<InspectorObject> buildObjectForHighlightedNode() const;
+
     bool isUnderTest();
     void evaluateForTestInFrontend(long callId, const String& script);
 

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (156214 => 156215)


--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2013-09-21 00:35:09 UTC (rev 156215)
@@ -44,8 +44,11 @@
 #include "Node.h"
 #include "Page.h"
 #include "RenderBoxModelObject.h"
+#include "RenderFlowThread.h"
 #include "RenderInline.h"
 #include "RenderObject.h"
+#include "RenderRegion.h"
+#include "RenderView.h"
 #include "ScriptController.h"
 #include "ScriptSourceCode.h"
 #include "ScriptValue.h"
@@ -353,6 +356,79 @@
     return object.release();
 }
 
+static PassRefPtr<InspectorObject> buildObjectForRegionHighlight(FrameView* mainView, RenderRegion* region)
+{
+    FrameView* containingView = region->frame().view();
+    if (!containingView)
+        return 0;
+
+    LayoutRect borderBox = region->borderBoxRect();
+    borderBox.setWidth(borderBox.width() + region->verticalScrollbarWidth());
+    borderBox.setHeight(borderBox.height() + region->horizontalScrollbarHeight());
+
+    // Create incoming and outgoing boxes that we use to chain the regions toghether.
+    const LayoutSize linkBoxSize(10, 10);
+    const LayoutSize linkBoxMidpoint(linkBoxSize.width() / 2, linkBoxSize.height() / 2);
+    
+    LayoutRect incomingRectBox = LayoutRect(borderBox.location() - linkBoxMidpoint, linkBoxSize);
+    LayoutRect outgoingRectBox = LayoutRect(borderBox.location() - linkBoxMidpoint + borderBox.size(), linkBoxSize);
+
+    // Move the link boxes slightly inside the region border box.
+    LayoutUnit maxUsableHeight = std::max(LayoutUnit(), borderBox.height() - linkBoxMidpoint.height());
+    LayoutUnit linkBoxVerticalOffset = std::min(LayoutUnit(15), maxUsableHeight);
+    incomingRectBox.move(0, linkBoxVerticalOffset);
+    outgoingRectBox.move(0, -linkBoxVerticalOffset);
+
+    FloatQuad borderRectQuad = region->localToAbsoluteQuad(FloatRect(borderBox));
+    FloatQuad incomingRectQuad = region->localToAbsoluteQuad(FloatRect(incomingRectBox));
+    FloatQuad outgoingRectQuad = region->localToAbsoluteQuad(FloatRect(outgoingRectBox));
+
+    contentsQuadToPage(mainView, containingView, borderRectQuad);
+    contentsQuadToPage(mainView, containingView, incomingRectQuad);
+    contentsQuadToPage(mainView, containingView, outgoingRectQuad);
+
+    RefPtr<InspectorObject> regionObject = InspectorObject::create();
+
+    regionObject->setArray("borderQuad", buildArrayForQuad(borderRectQuad));
+    regionObject->setArray("incomingQuad", buildArrayForQuad(incomingRectQuad));
+    regionObject->setArray("outgoingQuad", buildArrayForQuad(outgoingRectQuad));
+
+    return regionObject.release();
+}
+
+static void buildObjectForCSSRegionsHighlight(Node* node, InspectorObject* highlightNodeObject)
+{
+    RenderObject* renderer = node->renderer();
+    if (!renderer || !renderer->isRenderRegion())
+        return;
+    
+    RenderRegion* region = toRenderRegion(renderer);
+    RenderFlowThread* flowThread = region->flowThread();
+    if (!flowThread)
+        return;
+
+    FrameView* mainFrameView = node->document().page()->mainFrame().view();
+
+    RefPtr<InspectorArray> array = InspectorArray::create();
+
+    const RenderRegionList& regionList = flowThread->renderRegionList();
+    for (RenderRegionList::const_iterator iter = regionList.begin(); iter != regionList.end(); ++iter) {
+        RenderRegion* iterRegion = *iter;
+        if (!iterRegion->isValid())
+            continue;
+        RefPtr<InspectorObject> regionHighlightObject = buildObjectForRegionHighlight(mainFrameView, iterRegion);
+        if (!regionHighlightObject)
+            continue;
+        if (region == iterRegion) {
+            // Let the script know that this is the currently highlighted node.
+            regionHighlightObject->setBoolean("isHighlighted", true);
+        }
+        array->pushObject(regionHighlightObject.release());
+    }
+
+    highlightNodeObject->setArray("regions", array.release());
+}
+
 static PassRefPtr<InspectorObject> buildObjectForSize(const IntSize& size)
 {
     RefPtr<InspectorObject> result = InspectorObject::create();
@@ -366,10 +442,10 @@
     evaluateInOverlay("drawGutter", "");
 }
 
-void InspectorOverlay::drawNodeHighlight()
+PassRefPtr<InspectorObject> InspectorOverlay::buildObjectForHighlightedNode() const
 {
     if (!m_highlightNode)
-        return;
+        return 0;
 
     Highlight highlight;
     buildNodeHighlight(m_highlightNode.get(), m_nodeHighlightConfig, &highlight);
@@ -407,6 +483,16 @@
         elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : boundingBox.height()));
         highlightObject->setObject("elementInfo", elementInfo.release());
     }
+    buildObjectForCSSRegionsHighlight(m_highlightNode.get(), highlightObject.get());
+    
+    return highlightObject.release();
+}
+
+void InspectorOverlay::drawNodeHighlight()
+{
+    RefPtr<InspectorObject> highlightObject = buildObjectForHighlightedNode();
+    if (!highlightObject)
+        return;
     evaluateInOverlay("drawNodeHighlight", highlightObject);
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.h (156214 => 156215)


--- trunk/Source/WebCore/inspector/InspectorOverlay.h	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.h	2013-09-21 00:35:09 UTC (rev 156215)
@@ -45,6 +45,7 @@
 class GraphicsContext;
 class InspectorClient;
 class InspectorValue;
+class InspectorObject;
 class IntRect;
 class Node;
 class Page;
@@ -122,6 +123,8 @@
 
     Node* highlightedNode() const;
 
+    PassRefPtr<InspectorObject> buildObjectForHighlightedNode() const;
+
     void freePage();
 private:
     InspectorOverlay(Page*, InspectorClient*);

Modified: trunk/Source/WebCore/inspector/InspectorOverlayPage.js (156214 => 156215)


--- trunk/Source/WebCore/inspector/InspectorOverlayPage.js	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/inspector/InspectorOverlayPage.js	2013-09-21 00:35:09 UTC (rev 156215)
@@ -3,6 +3,21 @@
 const transparentColor = "rgba(0, 0, 0, 0)";
 const gridBackgroundColor = "rgba(255, 255, 255, 0.6)";
 
+// CSS Regions highlight colors.
+const highlightedRegionBackgroundColor = "rgba(127, 211, 248, 0.1)";
+const regionBackgroundColor = "rgba(127, 211, 248, 0.45)";
+const regionStrokeColor = "rgba(98, 207, 255, 0.85)";
+
+// CSS Regions chain highlight colors.
+const regionLinkBoxBackgroundColor = "rgba(255, 255, 255, 0.71)";
+const regionLinkBoxStrokeColor = "rgba(98, 207, 255, 0.85)";
+const regionChainStrokeColor = "rgba(98, 207, 255, 0.85)";
+
+// CSS Region number style.
+const regionNumberFont = "bold 40pt sans-serif";
+const regionNumberFillColor = "rgba(255, 255, 255, 0.9)";
+const regionNumberStrokeColor = "rgb(61, 127, 204)";
+
 function drawPausedInDebuggerMessage(message)
 {
     var pausedInDebugger = document.getElementById("paused-in-debugger");
@@ -129,6 +144,21 @@
     context.restore();
 }
 
+function _drawRegionNumber(quad, number)
+{
+    context.save();
+    var midPoint = _quadMidPoint(quad);
+    context.font = regionNumberFont;
+    context.textAlign = "center";
+    context.textBaseline = "middle";
+    context.fillStyle = regionNumberFillColor;
+    context.fillText(number, midPoint.x, midPoint.y);
+    context.strokeWidth = 4;
+    context.strokeStyle = regionNumberStrokeColor;
+    context.strokeText(number, midPoint.x, midPoint.y);
+    context.restore();
+}
+
 function quadToPath(quad)
 {
     context.beginPath();
@@ -357,6 +387,61 @@
     context.restore();
 }
 
+function _quadMidPoint(quad)
+{
+    return {
+        x: (quad[0].x + quad[1].x + quad[2].x + quad[3].x) / 4,
+        y: (quad[0].y + quad[1].y + quad[2].y + quad[3].y) / 4,
+    };
+}
+
+function _drawRegionLink(pointA, pointB)
+{
+    context.save();
+    context.lineWidth = 2;
+    context.strokeStyle = regionChainStrokeColor;
+    context.beginPath();
+    context.moveTo(pointA.x, pointA.y);
+    context.lineTo(pointB.x, pointB.y);
+    context.stroke();
+    context.restore();
+}
+
+function _fixQuadScrollPosition(quad, scrollX, scrollY)
+{
+    for (var j = 0; j < quad.length; ++j) {
+        quad[j].x -= scrollX;
+        quad[j].y -= scrollY;
+    }
+}
+
+function _drawRegionsHighlight(regions, scrollX, scrollY)
+{
+    for (var i = 0; i < regions.length; ++i) {
+        var region = regions[i];
+        _fixQuadScrollPosition(region.borderQuad, scrollX, scrollY);
+        _fixQuadScrollPosition(region.incomingQuad, scrollX, scrollY);
+        _fixQuadScrollPosition(region.outgoingQuad, scrollX, scrollY);
+    
+        drawOutlinedQuad(region.borderQuad, region.isHighlighted ? highlightedRegionBackgroundColor : regionBackgroundColor, regionStrokeColor);
+        _drawRegionNumber(region.borderQuad, i + 1);
+    }
+
+    for (var i = 1; i < regions.length; ++i) {
+        var regionA = regions[i - 1],
+            regionB = regions[i];
+        _drawRegionLink(_quadMidPoint(regionA.outgoingQuad), _quadMidPoint(regionB.incomingQuad));
+    }
+
+    for (var i = 0; i < regions.length; ++i) {
+        var region = regions[i];
+        if (i > 0)
+            drawOutlinedQuad(region.incomingQuad, regionLinkBoxBackgroundColor, regionLinkBoxStrokeColor);
+        if (i !== regions.length - 1)
+            drawOutlinedQuad(region.outgoingQuad, regionLinkBoxBackgroundColor, regionLinkBoxStrokeColor);
+    }
+}
+
 function drawNodeHighlight(highlight)
 {
     if (!highlight.quads.length) {
@@ -366,13 +451,8 @@
 
     context.save();
 
-    for (var i = 0; i < highlight.quads.length; ++i) {
-        var quad = highlight.quads[i];
-        for (var j = 0; j < quad.length; ++j) {
-            quad[j].x -= highlight.scrollX;
-            quad[j].y -= highlight.scrollY;
-        }
-    }
+    for (var i = 0; i < highlight.quads.length; ++i)
+        _fixQuadScrollPosition(highlight.quads[i], highlight.scrollX, highlight.scrollY);
 
     var quads = highlight.quads.slice();
     var contentQuad = quads.pop();
@@ -419,6 +499,10 @@
 
     _drawGrid(highlight, rulerAtRight, rulerAtBottom);
     _drawRulers(highlight, rulerAtRight, rulerAtBottom);
+
+    if (highlight.regions)
+        _drawRegionsHighlight(highlight.regions, highlight.scrollX, highlight.scrollY);
+
     _drawElementTitle(highlight);
     context.restore();
 }

Modified: trunk/Source/WebCore/testing/Internals.cpp (156214 => 156215)


--- trunk/Source/WebCore/testing/Internals.cpp	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/testing/Internals.cpp	2013-09-21 00:35:09 UTC (rev 156215)
@@ -64,6 +64,7 @@
 #include "InspectorFrontendClientLocal.h"
 #include "InspectorInstrumentation.h"
 #include "InspectorOverlay.h"
+#include "InspectorValues.h"
 #include "InstrumentingAgents.h"
 #include "InternalSettings.h"
 #include "IntRect.h"
@@ -734,6 +735,22 @@
 #endif
 }
 
+String Internals::inspectorHighlightObject(Document* document, ExceptionCode& ec)
+{
+#if ENABLE(INSPECTOR)
+    if (!document || !document->page() || !document->page()->inspectorController()) {
+        ec = INVALID_ACCESS_ERR;
+        return String();
+    }
+    RefPtr<InspectorObject> object = document->page()->inspectorController()->buildObjectForHighlightedNode();
+    return object ? object->toJSONString() : String();
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(ec);
+    return String();
+#endif
+}
+
 unsigned Internals::markerCountForNode(Node* node, const String& markerType, ExceptionCode& ec)
 {
     if (!node) {

Modified: trunk/Source/WebCore/testing/Internals.h (156214 => 156215)


--- trunk/Source/WebCore/testing/Internals.h	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/testing/Internals.h	2013-09-21 00:35:09 UTC (rev 156215)
@@ -132,6 +132,7 @@
     PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
 
     PassRefPtr<ClientRectList> inspectorHighlightRects(Document*, ExceptionCode&);
+    String inspectorHighlightObject(Document*, ExceptionCode&);
 
     unsigned markerCountForNode(Node*, const String&, ExceptionCode&);
     PassRefPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (156214 => 156215)


--- trunk/Source/WebCore/testing/Internals.idl	2013-09-21 00:24:08 UTC (rev 156214)
+++ trunk/Source/WebCore/testing/Internals.idl	2013-09-21 00:35:09 UTC (rev 156215)
@@ -83,6 +83,7 @@
     [RaisesException] ClientRect boundingBox(Element element);
 
     [RaisesException] ClientRectList inspectorHighlightRects(Document document);
+    [RaisesException] DOMString inspectorHighlightObject(Document document);
 
     [RaisesException] unsigned long markerCountForNode(Node node, DOMString markerType);
     [RaisesException] Range markerRangeForNode(Node node, DOMString markerType, unsigned long index);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to