Title: [160451] trunk
Revision
160451
Author
[email protected]
Date
2013-12-11 13:33:08 -0800 (Wed, 11 Dec 2013)

Log Message

Web Inspector: [CSS Shapes] Highlight margin-shape for shape-outside
https://bugs.webkit.org/show_bug.cgi?id=125175

Reviewed by Darin Adler.

Source/WebCore:

In addition to highlighting the shape, also highlight the shape created
by shape-margin with a slightly more transparent color. This patch modifies
the shape info passed to the Inspector Overlay to include a path for both
the raw shape and the shape with margin.

Test: inspector-protocol/model/highlight-shape-outside-margin.html

* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForShapeOutside): Call Shape::buildDisplayPaths rather than
Shape::buildPath, and pass along any relevant paths to the Inspector overlay.
* inspector/InspectorOverlayPage.js:
(_drawShapeHighlight): Draw the margin shape in addition to the raw shape.
* rendering/shapes/BoxShape.cpp:
(WebCore::addRoundedRect): Add a rounded rect to the path.
(WebCore::BoxShape::buildDisplayPaths): Create the applicable [margin/padding/raw] shapes.
* rendering/shapes/BoxShape.h:
* rendering/shapes/PolygonShape.cpp:
(WebCore::addPolygon): Add a set of vertices as a polygon to the path.
(WebCore::PolygonShape::buildDisplayPaths): Create the applicable [margin/padding/raw] shapes.
* rendering/shapes/PolygonShape.h:
* rendering/shapes/RasterShape.h:
(WebCore::RasterShape::buildDisplayPaths): Ditto.
* rendering/shapes/RectangleShape.cpp:
(WebCore::RectangleShape::buildDisplayPaths): Ditto.
* rendering/shapes/RectangleShape.h:
* rendering/shapes/Shape.h:

LayoutTests:

Test that the shape and margin-shape are properly passed to the Inspector Overlay.
Arcs for rounded rectangles, circles, and ellipses are approximated using the same
bezier curve method present in Path.cpp.

* inspector-protocol/model/highlight-shape-outside-margin.html: Added.
* inspector-protocol/model/highlight-shape-outside.html: Updating shape-outside info model.
* inspector-protocol/resources/shape-info-helper.js: Adding utilities to compare alternate
  path formats.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160450 => 160451)


--- trunk/LayoutTests/ChangeLog	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/LayoutTests/ChangeLog	2013-12-11 21:33:08 UTC (rev 160451)
@@ -1,3 +1,19 @@
+2013-12-11  Bear Travis  <[email protected]>
+
+        Web Inspector: [CSS Shapes] Highlight margin-shape for shape-outside
+        https://bugs.webkit.org/show_bug.cgi?id=125175
+
+        Reviewed by Darin Adler.
+
+        Test that the shape and margin-shape are properly passed to the Inspector Overlay.
+        Arcs for rounded rectangles, circles, and ellipses are approximated using the same
+        bezier curve method present in Path.cpp.
+
+        * inspector-protocol/model/highlight-shape-outside-margin.html: Added.
+        * inspector-protocol/model/highlight-shape-outside.html: Updating shape-outside info model.
+        * inspector-protocol/resources/shape-info-helper.js: Adding utilities to compare alternate
+          path formats.
+
 2013-12-11  Mario Sanchez Prada  <[email protected]>
 
         [ATK] Expose accessibility objects WAI-ARIA landmark roles

Added: trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin-expected.txt (0 => 160451)


--- trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin-expected.txt	2013-12-11 21:33:08 UTC (rev 160451)
@@ -0,0 +1,7 @@
+PASS: Shape roughly equals [M 60 50 L 90 50 C 95.52 50 100 54.48 100 60 L 100 90 C 100 95.52 95.52 100 90 100 L 60 100 C 54.48 100 50 95.52 50 90 L 50 60 C 50 54.48 54.48 50 60 50 Z]
+PASS: Margin shape roughly equals [M 60 40 L 90 40 C 101.05 40 110 48.95 110 60 L 110 90 C 110 101.05 101.05 110 90 110 L 60 110 C 48.95 110 40 101.05 40 90 L 40 60 C 40 48.95 48.95 40 60 40 Z]
+PASS: Shape roughly equals [M 75 25 L 75 25 C 102.61 25 125 47.39 125 75 L 125 75 C 125 102.61 102.61 125 75 125 L 75 125 C 47.39 125 25 102.61 25 75 L 25 75 C 25 47.39 47.39 25 75 25 Z]
+PASS: Margin shape roughly equals [M 75 15 L 75 15 C 108.14 15 135 41.86 135 75 L 135 75 C 135 108.14 108.14 135 75 135 L 75 135 C 41.86 135 15 108.14 15 75 L 15 75 C 15 41.86 41.86 15 75 15 Z]
+PASS: Shape roughly equals [M 50 50 L 100 50 L 100 100 L 50 100 L 50 50 Z]
+PASS: Margin shape roughly equals [M 50 49 L 100 49 L 100 50 L 50 50 L 50 49 Z M 49 50 L 101 50 L 101 100 L 49 100 L 49 50 Z M 50 100 L 100 100 L 100 101 L 50 101 L 50 100 Z]
+

Added: trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin.html (0 => 160451)


--- trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside-margin.html	2013-12-11 21:33:08 UTC (rev 160451)
@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+}
+.shape {
+    float: left;
+    width: 100px;
+    height: 100px;
+    padding: 25px 75px 75px 25px;
+    margin-right: -200px;
+    -webkit-shape-margin: 10px;
+}
+.inset {
+    -webkit-shape-outside: inset(25px 25px 25px 25px round 10px 10px) content-box;
+}
+.circle {
+    -webkit-shape-outside: circle(50px) content-box;
+}
+.svg {
+    -webkit-shape-outside: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none' width='100px' height='100px'><rect x='25' y='25' width='50' height='50' fill='blue' /></svg>");
+    -webkit-shape-margin: 1px;
+}
+</style>
+<script type="text/_javascript_" src=""
+<script type="text/_javascript_" src=""
+<script>
+function shapeTests() {
+    var tests = [
+    {
+        'selector' : '.inset',
+        'shape' : roundedRectCommands(50, 50, 50, 50, 10),
+        'marginShape' : roundedRectCommands(40, 40, 70, 70, 20)
+    },
+    {
+        'selector' : '.circle',
+        'shape' : roundedRectCommands(25, 25, 100, 100, 50),
+        'marginShape' : roundedRectCommands(15, 15, 120, 120, 60)
+    },
+    {
+        'selector' : '.svg',
+        'shape' : roundedRectCommands(50, 50, 50, 50, 0),
+        'marginShape' : [].concat(roundedRectCommands(50, 49, 50, 1, 0),
+            roundedRectCommands(49, 50, 52, 50, 0),
+            roundedRectCommands(50, 100, 50, 1, 0))
+    }
+    ];
+
+    function roundedRectCommands(x, y, w, h, r) {
+        if (!r)
+            return ['M', x, y, 'L', x + w, y, 'L', x + w, y + h, 'L', x, y + h, 'L', x, y, 'Z'];
+
+        // Approximate 1 - kappa, see Path.cpp
+        var control = .447715;
+
+        var commands = [];
+
+        commands.push('M', x + r, y);
+        commands.push('L', x + w - r, y);
+        commands.push('C', x + w - control * r, y, x + w, y + control * r, x + w, y + r);
+
+        commands.push('L', x + w, y + h - r);
+        commands.push('C', x + w, y + h - control * r, x + w - control * r, y + h, x + w - r, y + h);
+
+        commands.push('L', x + r, y + h);
+        commands.push('C', x + control * r, y + h, x, y + h - control * r, x, y + h - r);
+
+        commands.push('L', x, y + r);
+        commands.push('C', x, y + control * r, x + control * r, y, x + r, y);
+        commands.push('Z');
+
+        return commands;
+    }
+
+    function testPath(actual, expected, msg) {
+        var result = InspectorTest.pathsRoughlyEqual(actual, expected);
+        expectedString = expected.map(function(item) {
+            if (typeof item === 'number')
+                return +item.toFixed(2);
+            return item;
+        }).join(' ');
+        InspectorTest.assert(result, msg + " [" + expectedString + "]");
+        if (!result)
+            InspectorTest.log("Actual shape was [" + actual.join(" ") + "]");
+    }
+
+    function doTests(tests) {
+        if (!tests.length) {
+            InspectorTest.completeTest();
+            return;
+        }
+        var test = tests[0];
+        tests = tests.splice(1);
+        InspectorTest.shapeOutsideInfo(test.selector, function(shapeOutside) {
+            testPath(shapeOutside.shape, test.shape, "Shape roughly equals");
+            testPath(shapeOutside.marginShape, test.marginShape, "Margin shape roughly equals");
+
+            doTests(tests);
+        });
+    }
+
+    doTests(tests);
+}
+window._onload_ = function() { ShapeInfoHelper.runShapeTest(shapeTests); }
+</script>
+</head>
+<body>
+    <div class='shape inset'></div>
+    <div class='shape circle'></div>
+    <div class='shape svg'></div>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside.html (160450 => 160451)


--- trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside.html	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/LayoutTests/inspector-protocol/model/highlight-shape-outside.html	2013-12-11 21:33:08 UTC (rev 160451)
@@ -113,7 +113,7 @@
         var test = tests[0];
         tests = tests.splice(1);
         InspectorTest.shapeOutsideInfo(test.selector, function(shapeOutside) {
-            var actual = shapeOutside.path.join(' ');
+            var actual = shapeOutside.shape.join(' ');
             var expected = test.path.join(' ');
             InspectorTest.assert(actual === expected, "Actual [" + actual + "] Expected [" + expected + "]");
             doTests(tests);

Modified: trunk/LayoutTests/inspector-protocol/resources/shape-info-helper.js (160450 => 160451)


--- trunk/LayoutTests/inspector-protocol/resources/shape-info-helper.js	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/LayoutTests/inspector-protocol/resources/shape-info-helper.js	2013-12-11 21:33:08 UTC (rev 160451)
@@ -47,9 +47,44 @@
         }
     }
 
+    function pathsRoughlyEqual(actual, expected) {
+        function coordinatesRoughlyEqual(actual, expected) {
+            // Some platforms may only store integer path points, so the potential
+            // differences between correct paths can be roughly half a unit
+            return (typeof actual === 'number'
+                && typeof expected === 'number'
+                && Math.abs(actual - expected) < 0.5);
+        }
+
+        var expectedSubpathStart = 0, ei, ai;
+        for (var ei = 0, ai = 0; ai < actual.length && ei < expected.length; ai++, ei++) {
+            if (expected[ei] === 'M')
+                expectedSubpathStart = ei;
+
+            if (actual[ai] === expected[ei]
+                || coordinatesRoughlyEqual(actual[ai], expected[ei]))
+                continue;
+
+            // Extrapolate the missing line to command if it is missing from actual.
+            // The choice to close the path with an explicit line to command is
+            // platform dependent.
+            if (actual[ai] === 'Z'
+                && expected[ei] === 'L'
+                && coordinatesRoughlyEqual(expected[expectedSubpathStart + 1], expected[ei + 1])
+                && coordinatesRoughlyEqual(expected[expectedSubpathStart + 2], expected[ei + 2])) {
+                ei += 2;
+                ai--;
+                continue;
+            }
+            return false;
+        }
+        return true;
+    }
+
     function runShapeTest(testfn) {
         var body = [
             "InspectorTest.shapeOutsideInfo = " + shapeOutsideInfo.toString(),
+            "InspectorTest.pathsRoughlyEqual = " + pathsRoughlyEqual.toString(),
             "(" + testfn.toString() + ")()"
         ];
         window.test = new Function(

Modified: trunk/Source/WebCore/ChangeLog (160450 => 160451)


--- trunk/Source/WebCore/ChangeLog	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/ChangeLog	2013-12-11 21:33:08 UTC (rev 160451)
@@ -1,3 +1,37 @@
+2013-12-11  Bear Travis  <[email protected]>
+
+        Web Inspector: [CSS Shapes] Highlight margin-shape for shape-outside
+        https://bugs.webkit.org/show_bug.cgi?id=125175
+
+        Reviewed by Darin Adler.
+
+        In addition to highlighting the shape, also highlight the shape created
+        by shape-margin with a slightly more transparent color. This patch modifies
+        the shape info passed to the Inspector Overlay to include a path for both
+        the raw shape and the shape with margin.
+
+        Test: inspector-protocol/model/highlight-shape-outside-margin.html
+
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::buildObjectForShapeOutside): Call Shape::buildDisplayPaths rather than
+        Shape::buildPath, and pass along any relevant paths to the Inspector overlay.
+        * inspector/InspectorOverlayPage.js:
+        (_drawShapeHighlight): Draw the margin shape in addition to the raw shape.
+        * rendering/shapes/BoxShape.cpp:
+        (WebCore::addRoundedRect): Add a rounded rect to the path.
+        (WebCore::BoxShape::buildDisplayPaths): Create the applicable [margin/padding/raw] shapes.
+        * rendering/shapes/BoxShape.h:
+        * rendering/shapes/PolygonShape.cpp:
+        (WebCore::addPolygon): Add a set of vertices as a polygon to the path.
+        (WebCore::PolygonShape::buildDisplayPaths): Create the applicable [margin/padding/raw] shapes.
+        * rendering/shapes/PolygonShape.h:
+        * rendering/shapes/RasterShape.h:
+        (WebCore::RasterShape::buildDisplayPaths): Ditto.
+        * rendering/shapes/RectangleShape.cpp:
+        (WebCore::RectangleShape::buildDisplayPaths): Ditto.
+        * rendering/shapes/RectangleShape.h:
+        * rendering/shapes/Shape.h:
+
 2013-12-11  Mario Sanchez Prada  <[email protected]>
 
         [ATK] Expose accessibility objects WAI-ARIA landmark roles

Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (160450 => 160451)


--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp	2013-12-11 21:33:08 UTC (rev 160451)
@@ -595,12 +595,12 @@
     LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox();
     FloatQuad shapeQuad = renderer->localToAbsoluteQuad(FloatRect(shapeBounds));
     contentsQuadToPage(containingFrame->page()->mainFrame().view(), containingFrame->view(), shapeQuad);
-    shapeObject->setArray("bounds", buildArrayForQuad(shapeQuad));
+    shapeObject->setArray(ASCIILiteral("bounds"), buildArrayForQuad(shapeQuad));
 
-    Path path;
-    shapeOutsideInfo->computedShape().buildPath(path);
+    Shape::DisplayPaths paths;
+    shapeOutsideInfo->computedShape().buildDisplayPaths(paths);
 
-    if (path.length()) {
+    if (paths.shape.length()) {
         RefPtr<InspectorArray> shapePath = InspectorArray::create();
         PathApplyInfo info;
         info.rootView = containingFrame->page()->mainFrame().view();
@@ -609,9 +609,18 @@
         info.renderer = renderer;
         info.shapeOutsideInfo = shapeOutsideInfo;
 
-        path.apply(&info, &appendPathSegment);
+        paths.shape.apply(&info, &appendPathSegment);
 
-        shapeObject->setArray("path", shapePath.release());
+        shapeObject->setArray(ASCIILiteral("shape"), shapePath.release());
+
+        if (paths.marginShape.length()) {
+            shapePath = InspectorArray::create();
+            info.array = shapePath.get();
+
+            paths.marginShape.apply(&info, &appendPathSegment);
+
+            shapeObject->setArray(ASCIILiteral("marginShape"), shapePath.release());
+        }
     }
 
     return shapeObject.release();

Modified: trunk/Source/WebCore/inspector/InspectorOverlayPage.js (160450 => 160451)


--- trunk/Source/WebCore/inspector/InspectorOverlayPage.js	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/inspector/InspectorOverlayPage.js	2013-12-11 21:33:08 UTC (rev 160451)
@@ -19,7 +19,8 @@
 const regionNumberStrokeColor = "rgb(61, 127, 204)";
 
 // CSS Shapes highlight colors
-const shapeHighlightColor = "rgb(255, 105, 180)";
+const shapeHighlightColor = "rgba(96, 82, 127, 0.8)";
+const shapeMarginHighlightColor = "rgba(96, 82, 127, 0.6)";
 
 function drawPausedInDebuggerMessage(message)
 {
@@ -562,9 +563,13 @@
 }
 
 function _drawShapeHighlight(shapeInfo) {
-    if (shapeInfo.path)
-        drawPath(context, shapeInfo.path, shapeHighlightColor);
-    else
+    if (shapeInfo.marginShape)
+        drawPath(context, shapeInfo.marginShape, shapeMarginHighlightColor);
+
+    if (shapeInfo.shape)
+        drawPath(context, shapeInfo.shape, shapeHighlightColor);
+
+    if (!(shapeInfo.shape || shapeInfo.marginShape))
         drawOutlinedQuad(shapeInfo.bounds, shapeHighlightColor, shapeHighlightColor);
 }
 

Modified: trunk/Source/WebCore/rendering/shapes/BoxShape.cpp (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/BoxShape.cpp	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/BoxShape.cpp	2013-12-11 21:33:08 UTC (rev 160451)
@@ -108,11 +108,16 @@
     return true;
 }
 
-void BoxShape::buildPath(Path& path) const
+static void addRoundedRect(Path& path, const FloatRect& rect, const FloatRoundedRect::Radii& radii)
 {
-    const FloatRect& rect = m_bounds.rect();
-    const FloatRoundedRect::Radii& radii = m_bounds.radii();
     path.addRoundedRect(rect, radii.topLeft(), radii.topRight(), radii.bottomLeft(), radii.bottomRight(), Path::PreferBezierRoundedRect);
 }
 
+void BoxShape::buildDisplayPaths(DisplayPaths& paths) const
+{
+    addRoundedRect(paths.shape, m_bounds.rect(), m_bounds.radii());
+    if (shapeMargin())
+        addRoundedRect(paths.marginShape, m_marginBounds.rect(), m_marginBounds.radii());
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/shapes/BoxShape.h (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/BoxShape.h	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/BoxShape.h	2013-12-11 21:33:08 UTC (rev 160451)
@@ -46,7 +46,7 @@
     virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
     virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit&) const OVERRIDE;
 
-    virtual void buildPath(Path&) const OVERRIDE;
+    virtual void buildDisplayPaths(DisplayPaths&) const OVERRIDE;
 
 private:
     FloatRoundedRect m_bounds;

Modified: trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/PolygonShape.cpp	2013-12-11 21:33:08 UTC (rev 160451)
@@ -523,19 +523,24 @@
     return firstFitFound;
 }
 
-void PolygonShape::buildPath(Path& path) const
+static void addPolygon(Path& path, const FloatPolygon& polygon)
 {
-    FloatPoint vertex;
-
-    if (!m_polygon.numberOfVertices())
+    if (!polygon.numberOfVertices())
         return;
 
-    path.moveTo(m_polygon.vertexAt(0));
+    path.moveTo(polygon.vertexAt(0));
 
-    for (size_t i = 1; i < m_polygon.numberOfVertices(); i++)
-        path.addLineTo(m_polygon.vertexAt(i));
+    for (size_t i = 1; i < polygon.numberOfVertices(); i++)
+        path.addLineTo(polygon.vertexAt(i));
 
     path.closeSubpath();
 }
 
+void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const
+{
+    addPolygon(paths.shape, m_polygon);
+    if (shapeMargin())
+        addPolygon(paths.marginShape, shapeMarginBounds());
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/shapes/PolygonShape.h (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/PolygonShape.h	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/PolygonShape.h	2013-12-11 21:33:08 UTC (rev 160451)
@@ -97,7 +97,7 @@
     virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
     virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit&) const OVERRIDE;
 
-    virtual void buildPath(Path&) const OVERRIDE;
+    virtual void buildDisplayPaths(DisplayPaths&) const OVERRIDE;
 
 private:
     const FloatPolygon& shapeMarginBounds() const;

Modified: trunk/Source/WebCore/rendering/shapes/RasterShape.h (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/RasterShape.h	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/RasterShape.h	2013-12-11 21:33:08 UTC (rev 160451)
@@ -103,7 +103,12 @@
     virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
     virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit&) const OVERRIDE;
 
-    virtual void buildPath(Path& path) const OVERRIDE { m_intervals->buildBoundsPath(path); }
+    virtual void buildDisplayPaths(DisplayPaths& paths) const OVERRIDE
+    {
+        m_intervals->buildBoundsPath(paths.shape);
+        if (shapeMargin())
+            marginIntervals().buildBoundsPath(paths.marginShape);
+    }
 
 private:
     const RasterShapeIntervals& marginIntervals() const;

Modified: trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/RectangleShape.cpp	2013-12-11 21:33:08 UTC (rev 160451)
@@ -228,9 +228,11 @@
     return false;
 }
 
-void RectangleShape::buildPath(Path& path) const
+void RectangleShape::buildDisplayPaths(DisplayPaths& paths) const
 {
-    path.addRoundedRect(m_bounds, FloatSize(m_bounds.rx(), m_bounds.ry()), Path::PreferBezierRoundedRect);
+    paths.shape.addRoundedRect(m_bounds, FloatSize(m_bounds.rx(), m_bounds.ry()), Path::PreferBezierRoundedRect);
+    if (shapeMargin())
+        paths.marginShape.addRoundedRect(shapeMarginBounds(), FloatSize(shapeMarginBounds().rx(), shapeMarginBounds().ry()), Path::PreferBezierRoundedRect);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/shapes/RectangleShape.h (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/RectangleShape.h	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/RectangleShape.h	2013-12-11 21:33:08 UTC (rev 160451)
@@ -56,7 +56,7 @@
     virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHeight, SegmentList&) const OVERRIDE;
     virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit&) const OVERRIDE;
 
-    virtual void buildPath(Path&) const OVERRIDE;
+    virtual void buildDisplayPaths(DisplayPaths&) const OVERRIDE;
 
 private:
     class ShapeBounds : public FloatRect {

Modified: trunk/Source/WebCore/rendering/shapes/Shape.h (160450 => 160451)


--- trunk/Source/WebCore/rendering/shapes/Shape.h	2013-12-11 19:49:39 UTC (rev 160450)
+++ trunk/Source/WebCore/rendering/shapes/Shape.h	2013-12-11 21:33:08 UTC (rev 160451)
@@ -62,6 +62,11 @@
 
 class Shape {
 public:
+    struct DisplayPaths {
+        Path shape;
+        Path marginShape;
+    };
+
     static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& logicalBoxSize, WritingMode, Length margin, Length padding);
     static PassOwnPtr<Shape> createShape(const StyleImage*, float threshold, const LayoutSize& logicalBoxSize, WritingMode, Length margin, Length padding);
     static PassOwnPtr<Shape> createShape(const RoundedRect&, WritingMode, Length margin, Length padding);
@@ -77,7 +82,7 @@
     bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogicalBoundingBox()); }
     bool lineOverlapsShapePaddingBounds(LayoutUnit lineTop, LayoutUnit lineHeight) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapePaddingLogicalBoundingBox()); }
 
-    virtual void buildPath(Path&) const = 0;
+    virtual void buildDisplayPaths(DisplayPaths&) const = 0;
 
 protected:
     float shapeMargin() const { return m_margin; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to