hitTest should take care if the location is inside rounded border if border-radius is specified

BUG=100004, 105447

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175094 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7f14b776
This test checks that div block should not get events on clicking outside the rounded border but within the bounding box of the block.
PASS successfullyParsed is true
TEST COMPLETE
PASS document.elementFromPoint(x + 5, y + 5).id is 'container'
PASS document.elementFromPoint(x + 195, y + 5).id is 'container'
PASS document.elementFromPoint(x + 5, y + 195).id is 'container'
PASS document.elementFromPoint(x + 195, y + 195).id is 'container'
PASS document.elementFromPoint(x + 100, y + 100).id is 'roundedBox'
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
var x, y;
function test() {
var innerBox = document.getElementById('roundedBox');
var rect = innerBox.getBoundingClientRect();
x = rect.left;
y = rect.top;
// At top-left corner.
shouldBe("document.elementFromPoint(x + 5, y + 5).id", "'container'");
// At top-right corner.
shouldBe("document.elementFromPoint(x + 195, y + 5).id", "'container'");
// At bottom-left corner.
shouldBe("document.elementFromPoint(x + 5, y + 195).id", "'container'");
// At bottom-right corner.
shouldBe("document.elementFromPoint(x + 195, y + 195).id", "'container'");
// At the center.
shouldBe("document.elementFromPoint(x + 100, y + 100).id", "'roundedBox'");
}
</script>
<style>
#container {
width: 200px;
height: 200px;
background-color: lightgray;
}
#roundedBox {
width: 200px;
height: 200px;
border-radius: 50px;
background-color: lightgreen;
}
</style>
<body onload="test()">
<p>This test checks that div block should not get events on clicking outside the rounded border but within the bounding box of the block.</p>
<div id="container">
<div id="roundedBox"></div>
</div>
<div id="console"></div>
</body>
......@@ -2802,7 +2802,18 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
// If we have clipping, then we can't have any spillout.
bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer();
bool useClip = (hasControlClip() || useOverflowClip);
bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.intersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(overflowClipRect(adjustedLocation, IncludeOverlayScrollbarSize)));
bool checkChildren = !useClip;
if (!checkChildren) {
if (hasControlClip()) {
checkChildren = locationInContainer.intersects(controlClipRect(adjustedLocation));
} else {
LayoutRect clipRect = overflowClipRect(adjustedLocation, IncludeOverlayScrollbarSize);
if (style()->hasBorderRadius())
checkChildren = locationInContainer.intersects(style()->getRoundedBorderFor(clipRect));
else
checkChildren = locationInContainer.intersects(clipRect);
}
}
if (checkChildren) {
// Hit test descendants first.
LayoutSize scrolledOffset(localOffset);
......@@ -2824,7 +2835,7 @@ bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
}
// Check if the point is outside radii.
if (!isRenderView() && style()->hasBorderRadius()) {
if (style()->hasBorderRadius()) {
LayoutRect borderRect = borderBoxRect();
borderRect.moveBy(adjustedLocation);
RoundedRect border = style()->getRoundedBorderFor(borderRect);
......
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