Commit ffa7b8b7 authored by fs@opera.com's avatar fs@opera.com

Allow hitting the SVG root when its display-type is 'block'

The 'HitTestChildBlockBackground' hit test action needs to be considered
as well when detecting hits on the SVG root container itself.

BUG=379299

Review URL: https://codereview.chromium.org/318663002

git-svn-id: svn://svn.chromium.org/blink/trunk@175528 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6218d039
<!DOCTYPE html>
<title>SVG root 'display: block' hit test</title>
<style>
html, body {
padding: 0;
margin: 0;
}
svg {
display: block;
background-color: blue;
}
</style>
<body>
<svg width="200" height="200"></svg>
<p>SVG root with 'display: block' gets intersected.</p>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var svgRoot = document.querySelector('svg');
var result = (svgRoot === document.elementFromPoint(100, 100));
document.write(result ? 'PASS' : 'FAIL');
</script>
...@@ -448,11 +448,11 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re ...@@ -448,11 +448,11 @@ bool RenderSVGRoot::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
} }
// If we didn't early exit above, we've just hit the container <svg> element. Unlike SVG 1.1, 2nd Edition allows container elements to be hit. // If we didn't early exit above, we've just hit the container <svg> element. Unlike SVG 1.1, 2nd Edition allows container elements to be hit.
if (hitTestAction == HitTestBlockBackground && visibleToHitTestRequest(request)) { if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && visibleToHitTestRequest(request)) {
// Only return true here, if the last hit testing phase 'BlockBackground' is executed. If we'd return true in the 'Foreground' phase, // Only return true here, if the last hit testing phase 'BlockBackground' (or 'ChildBlockBackground' - depending on context) is executed.
// hit testing would stop immediately. For SVG only trees this doesn't matter. Though when we have a <foreignObject> subtree we need // If we'd return true in the 'Foreground' phase, hit testing would stop immediately. For SVG only trees this doesn't matter.
// to be able to detect hits on the background of a <div> element. If we'd return true here in the 'Foreground' phase, we are not able // Though when we have a <foreignObject> subtree we need to be able to detect hits on the background of a <div> element.
// to detect these hits anymore. // If we'd return true here in the 'Foreground' phase, we are not able to detect these hits anymore.
LayoutRect boundsRect(accumulatedOffset + location(), size()); LayoutRect boundsRect(accumulatedOffset + location(), size());
if (locationInContainer.intersects(boundsRect)) { if (locationInContainer.intersects(boundsRect)) {
updateHitTestResult(result, pointInBorderBox); updateHitTestResult(result, pointInBorderBox);
......
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