Commit 3625eeac authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Disabled (empty) SVG shapes cannot be hit

Disabled SVG shapes [1][2][3] should not be possible to hit since they
are considered "not rendered".

[1] https://svgwg.org/svg2-draft/shapes.html#RectElement
[2] https://svgwg.org/svg2-draft/shapes.html#CircleElement
[3] https://svgwg.org/svg2-draft/shapes.html#EllipseElement

Bug: 896641
Change-Id: I5fe530722a4d60ecd416cd68f06a7555bb6a520f
Reviewed-on: https://chromium-review.googlesource.com/c/1353983Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#611840}
parent 85a5c945
...@@ -352,6 +352,8 @@ bool LayoutSVGShape::NodeAtPoint(HitTestResult& result, ...@@ -352,6 +352,8 @@ bool LayoutSVGShape::NodeAtPoint(HitTestResult& result,
// We only draw in the foreground phase, so we only hit-test then. // We only draw in the foreground phase, so we only hit-test then.
if (hit_test_action != kHitTestForeground) if (hit_test_action != kHitTestForeground)
return false; return false;
if (IsShapeEmpty())
return false;
const ComputedStyle& style = StyleRef(); const ComputedStyle& style = StyleRef();
const PointerEventsHitRules hit_rules( const PointerEventsHitRules hit_rules(
PointerEventsHitRules::SVG_GEOMETRY_HITTESTING, PointerEventsHitRules::SVG_GEOMETRY_HITTESTING,
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">
<title>Disabled shapes are not rendered</title>
<metadata>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#RectElement"/>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#CircleElement"/>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#EllipseElement"/>
<h:link rel="match" href="support/empty.svg"/>
</metadata>
<g stroke="red" stroke-width="100">
<g transform="translate(50, 50)">
<rect/>
<rect width="0" height="10"/>
<rect width="-10" height="10"/>
<rect height="0" width="10"/>
<rect height="-10" width="10"/>
<rect style="width: 0"/>
<rect style="width: 0" height="10"/>
<rect style="width: -10px"/>
<rect style="width: -10px" height="10"/>
<rect style="height: 0"/>
<rect style="height: 0" width="10"/>
<rect style="height: -10px"/>
<rect style="height: -10px" width="10"/>
</g>
<g transform="translate(150, 50)">
<circle/>
<circle r="0"/>
<circle r="-10"/>
<circle style="r: 0"/>
<circle style="r: -10px"/>
</g>
<g transform="translate(250, 50)">
<ellipse/>
<ellipse rx="0"/>
<ellipse rx="0" ry="10"/>
<ellipse rx="-10" ry="10"/>
<ellipse ry="0"/>
<ellipse ry="0" rx="10"/>
<ellipse ry="-10" rx="10"/>
<ellipse style="rx: 0"/>
<ellipse style="rx: -10px"/>
<ellipse style="rx: 0" ry="10"/>
<ellipse style="ry: 0"/>
<ellipse style="ry: -10px"/>
<ellipse style="ry: 0" rx="10"/>
</g>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">
<title>Disabled shapes are not rendered and cannot be hit</title>
<h:script src="/resources/testharness.js"/>
<h:script src="/resources/testharnessreport.js"/>
<metadata>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#RectElement"/>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#CircleElement"/>
<h:link rel="help" href="https://svgwg.org/svg2-draft/shapes.html#EllipseElement"/>
</metadata>
<g stroke="red" stroke-width="100">
<g transform="translate(50, 50)">
<rect/>
<rect width="0" height="10"/>
<rect width="-10" height="10"/>
<rect height="0" width="10"/>
<rect height="-10" width="10"/>
<rect style="width: 0"/>
<rect style="width: 0" height="10"/>
<rect style="width: -10px"/>
<rect style="width: -10px" height="10"/>
<rect style="height: 0"/>
<rect style="height: 0" width="10"/>
<rect style="height: -10px"/>
<rect style="height: -10px" width="10"/>
</g>
<g transform="translate(150, 50)">
<circle/>
<circle r="0"/>
<circle r="-10"/>
<circle style="r: 0"/>
<circle style="r: -10px"/>
</g>
<g transform="translate(250, 50)">
<ellipse/>
<ellipse rx="0"/>
<ellipse rx="0" ry="10"/>
<ellipse rx="-10" ry="10"/>
<ellipse ry="0"/>
<ellipse ry="0" rx="10"/>
<ellipse ry="-10" rx="10"/>
<ellipse style="rx: 0"/>
<ellipse style="rx: -10px"/>
<ellipse style="rx: 0" ry="10"/>
<ellipse style="ry: 0"/>
<ellipse style="ry: -10px"/>
<ellipse style="ry: 0" rx="10"/>
</g>
</g>
<script><![CDATA[
test(function() {
let element = document.elementFromPoint(50, 50);
assert_equals(element, document.documentElement, "does not hit one of the shapes");
}, document.title + ": <rect>");
test(function() {
let element = document.elementFromPoint(150, 50);
assert_equals(element, document.documentElement, "does not hit one of the shapes");
}, document.title + ": <circle>");
test(function() {
let element = document.elementFromPoint(250, 50);
assert_equals(element, document.documentElement, "does not hit one of the shapes");
}, document.title + ": <ellipse>");
]]>
</script>
</svg>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment