Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1957673002: Less duplicated code between nodeAtPoint() in LayoutBox and LayoutBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 1c72db18a5e3d889ed463b69574fc7d61d53be61..5a33bd0da0e8ce664076b437ec7e9aa20a4623cc 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -1191,29 +1191,36 @@ bool LayoutBox::nodeAtPoint(HitTestResult& result, const HitTestLocation& locati
{
LayoutPoint adjustedLocation = accumulatedOffset + location();
- // Exit early if no children can be hit.
- LayoutRect overflowRect = visualOverflowRect();
- overflowRect.moveBy(adjustedLocation);
- if (!locationInContainer.intersects(overflowRect))
- return false;
+ if (!isLayoutView()) {
+ // Check if we need to do anything at all.
+ // If we have clipping, then we can't have any spillout.
+ LayoutRect overflowBox = hasOverflowClip() ? borderBoxRect() : visualOverflowRect();
+ flipForWritingMode(overflowBox);
+ overflowBox.moveBy(adjustedLocation);
+ if (!locationInContainer.intersects(overflowBox))
+ return false;
+ }
// TODO(pdr): We should also check for css clip in the !isSelfPaintingLayer
// case, similar to overflow clip in LayoutBlock::nodeAtPoint.
+ // TODO(pdr): We should also include checks for hit testing border radius at
+ // the layer level (see: crbug.com/568904).
+
if (hitTestChildren(result, locationInContainer, adjustedLocation, action))
return true;
if (hitTestClippedOutByRoundedBorder(locationInContainer, adjustedLocation))
return false;
- // Check our bounds next. For this purpose always assume that we can only be hit in the
- // foreground phase (which is true for replaced elements like images).
- LayoutRect boundsRect = borderBoxRect();
- boundsRect.moveBy(adjustedLocation);
- if (visibleToHitTestRequest(result.hitTestRequest()) && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {
- updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
- if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting)
- return true;
+ // Now hit test ourselves.
+ if (isInSelfHitTestingPhase(action) && visibleToHitTestRequest(result.hitTestRequest())) {
+ LayoutRect boundsRect(adjustedLocation, size());
+ if (locationInContainer.intersects(boundsRect)) {
+ updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(adjustedLocation)));
+ if (result.addNodeToListBasedTestResult(nodeForHitTest(), locationInContainer, boundsRect) == StopHitTesting)
+ return true;
+ }
}
return false;
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698