The none smooth stroke applied to an SVG shape breaks its hit testing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Aug 2017 22:00:27 +0000 (22:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Aug 2017 22:00:27 +0000 (22:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175506

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-08-14
Reviewed by Simon Fraser.

Source/WebCore:

Clear RenderSVGShape::m_path when calling RenderSVGRect::updateShapeFromElement().
The m_path will be recalculated when RenderSVGShape::updateShapeFromElement()
is called from RenderSVGRect::shapeDependentStrokeContains().

Test: svg/stroke/stroke-linejoin-click.html

* rendering/svg/RenderSVGRect.cpp:
(WebCore::RenderSVGRect::updateShapeFromElement):
* rendering/svg/RenderSVGShape.h:
(WebCore::RenderSVGShape::clearPath):

LayoutTests:

* svg/stroke/stroke-linejoin-click-expected.html: Added.
* svg/stroke/stroke-linejoin-click.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/stroke/stroke-linejoin-click-expected.html [new file with mode: 0644]
LayoutTests/svg/stroke/stroke-linejoin-click.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGRect.cpp
Source/WebCore/rendering/svg/RenderSVGShape.h

index 49fa39afbb1fad932bd04f812eb59052de11deda..a5a1f349e2ae2801cfd14b849e7a20a03bbb250b 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        The none smooth stroke applied to an SVG shape breaks its hit testing
+        https://bugs.webkit.org/show_bug.cgi?id=175506
+
+        Reviewed by Simon Fraser.
+
+        * svg/stroke/stroke-linejoin-click-expected.html: Added.
+        * svg/stroke/stroke-linejoin-click.html: Added.
+
 2017-08-14  Daniel Bates  <dabates@apple.com>
 
         [css-ui] Implement caret-color support
diff --git a/LayoutTests/svg/stroke/stroke-linejoin-click-expected.html b/LayoutTests/svg/stroke/stroke-linejoin-click-expected.html
new file mode 100644 (file)
index 0000000..c64ccbf
--- /dev/null
@@ -0,0 +1,19 @@
+<style>
+    html, body {
+        margin: 0;
+        padding: 0;
+    }
+    rect {
+        fill: none;
+        stroke-width: 6;
+        stroke-linejoin: round;
+        stroke: green;
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<body>
+    <svg>
+        <rect x="30" y="30"/>
+    </svg>
+</body>
diff --git a/LayoutTests/svg/stroke/stroke-linejoin-click.html b/LayoutTests/svg/stroke/stroke-linejoin-click.html
new file mode 100644 (file)
index 0000000..b695794
--- /dev/null
@@ -0,0 +1,37 @@
+<style>
+    html, body {
+        margin: 0;
+        padding: 0;
+    }
+    rect {
+        fill: none;
+        stroke-width: 6;
+        stroke-linejoin: round;
+        stroke: green;
+        width: 100px;
+        height: 100px;
+    }
+</style>
+<body>
+    <svg>
+        <rect x="10" y="10"/>
+    </svg>
+    <script>
+        function moveRect(rect) {
+            var x = parseFloat(rect.getAttribute("x"));
+            var y = parseFloat(rect.getAttribute("y"));
+            rect.setAttribute('x', x + 10);
+            rect.setAttribute('y', y + 10);
+        }
+
+        (function() {
+            var element = document.elementFromPoint(10, 10);
+            if (element instanceof SVGRectElement)
+                moveRect(element);
+
+            element = document.elementFromPoint(20, 20);
+            if (element instanceof SVGRectElement)
+                moveRect(element);
+        })();
+    </script>
+</body>
index 37b565d06f7eac30ef79b76a0ffb9ce23e6a0743..250dda9f627708e8b44d2a91239ab0ce32fb2ec7 100644 (file)
@@ -1,3 +1,21 @@
+2017-08-14  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        The none smooth stroke applied to an SVG shape breaks its hit testing
+        https://bugs.webkit.org/show_bug.cgi?id=175506
+
+        Reviewed by Simon Fraser.
+
+        Clear RenderSVGShape::m_path when calling RenderSVGRect::updateShapeFromElement().
+        The m_path will be recalculated when RenderSVGShape::updateShapeFromElement()
+        is called from RenderSVGRect::shapeDependentStrokeContains().
+
+        Test: svg/stroke/stroke-linejoin-click.html
+
+        * rendering/svg/RenderSVGRect.cpp:
+        (WebCore::RenderSVGRect::updateShapeFromElement):
+        * rendering/svg/RenderSVGShape.h:
+        (WebCore::RenderSVGShape::clearPath):
+
 2017-08-14  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE] Implement WebCore::standardUserAgent()
index 2ceba5d9100eaba7bc8e2efe0eef7b37e682f144..ea5c05fba356fa0ee5e4ad5192b20ccc5aa902ca 100644 (file)
@@ -52,6 +52,7 @@ void RenderSVGRect::updateShapeFromElement()
     m_fillBoundingBox = FloatRect();
     m_innerStrokeRect = FloatRect();
     m_outerStrokeRect = FloatRect();
+    clearPath();
 
     SVGLengthContext lengthContext(&rectElement());
     FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), LengthModeWidth), lengthContext.valueForLength(style().height(), LengthModeHeight));
index f1db416e4594305bbc98c615e566845251bfac46..5adacd2bb192f9806890ffbb949c9c770f3900d9 100644 (file)
@@ -63,6 +63,7 @@ public:
         ASSERT(m_path);
         return *m_path;
     }
+    void clearPath() { m_path = nullptr; }
 
 protected:
     void element() const = delete;