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

Unified Diff: Source/core/layout/LayoutBlock.cpp

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
Index: Source/core/layout/LayoutBlock.cpp
diff --git a/Source/core/layout/LayoutBlock.cpp b/Source/core/layout/LayoutBlock.cpp
index d1a61fd3345cb31e0d994a61f1afe1da5ef30bfa..fe86cd64c2006622879af6ce5e39ee6d6f95237c 100644
--- a/Source/core/layout/LayoutBlock.cpp
+++ b/Source/core/layout/LayoutBlock.cpp
@@ -2158,14 +2158,18 @@ bool LayoutBlock::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
LayoutRect overflowBox = hasOverflowClip() ? borderBoxRect() : visualOverflowRect();
flipForWritingMode(overflowBox);
overflowBox.moveBy(adjustedLocation);
- if (!locationInContainer.intersects(overflowBox))
+ if (!locationInContainer.intersects(overflowBox)) {
+ result.shrinkValidityRect(overflowBox);
return false;
+ }
}
if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground)
&& visibleToHitTestRequest(result.hitTestRequest())
&& isPointInOverflowControl(result, locationInContainer.point(), adjustedLocation)) {
- updateHitTestResult(result, locationInContainer.point() - localOffset);
+ // TODO(dtapuska): calculate the layout rect
+
+ updateHitTestResult(result, locationInContainer.point() - localOffset, result.validityRect());
// FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet.
if (!result.addNodeToListBasedTestResult(nodeForHitTest(), locationInContainer))
return true;
@@ -2191,15 +2195,21 @@ bool LayoutBlock::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
bool useClip = (hasControlClip() || useOverflowClip);
bool checkChildren = !useClip;
if (!checkChildren) {
+ LayoutRect clipRect;
if (hasControlClip()) {
- checkChildren = locationInContainer.intersects(controlClipRect(adjustedLocation));
+ clipRect = controlClipRect(adjustedLocation);
+ checkChildren = locationInContainer.intersects(clipRect);
} else {
- LayoutRect clipRect = overflowClipRect(adjustedLocation, IncludeOverlayScrollbarSize);
+ clipRect = overflowClipRect(adjustedLocation, IncludeOverlayScrollbarSize);
if (style()->hasBorderRadius())
checkChildren = locationInContainer.intersects(style()->getRoundedBorderFor(clipRect));
else
checkChildren = locationInContainer.intersects(clipRect);
}
+ if (!checkChildren)
+ result.shrinkValidityRect(clipRect);
+ else
+ result.intersectValidityRect(clipRect);
}
if (checkChildren) {
// Hit test descendants first.
@@ -2210,13 +2220,16 @@ bool LayoutBlock::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
// Hit test contents if we don't have columns.
if (!hasColumns()) {
if (hitTestContents(result, locationInContainer, toLayoutPoint(scrolledOffset), hitTestAction)) {
- updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset));
+ // TODO(dtapuska): calculate the layout rect
+
+ updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset), result.validityRect());
return true;
}
if (hitTestAction == HitTestFloat && hitTestFloats(result, locationInContainer, toLayoutPoint(scrolledOffset)))
return true;
} else if (hitTestColumns(result, locationInContainer, toLayoutPoint(scrolledOffset), hitTestAction)) {
- updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset));
+ // TODO(dtapuska): calculate the layout rect
+ updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset), result.validityRect());
return true;
}
}
@@ -2226,18 +2239,21 @@ bool LayoutBlock::nodeAtPoint(HitTestResult& result, const HitTestLocation& loca
LayoutRect borderRect = borderBoxRect();
borderRect.moveBy(adjustedLocation);
FloatRoundedRect border = style()->getRoundedBorderFor(borderRect);
- if (!locationInContainer.intersects(border))
+ if (!locationInContainer.intersects(border)) {
+ result.shrinkValidityRect(borderRect);
return false;
+ }
}
// Now hit test our background
if (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) {
LayoutRect boundsRect(adjustedLocation, size());
if (visibleToHitTestRequest(result.hitTestRequest()) && locationInContainer.intersects(boundsRect)) {
- updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset));
+ updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - localOffset), boundsRect);
if (!result.addNodeToListBasedTestResult(nodeForHitTest(), locationInContainer, boundsRect))
return true;
}
+ result.shrinkValidityRect(boundsRect);
}
return false;
@@ -3487,11 +3503,12 @@ void LayoutBlock::childBecameNonInline(LayoutObject*)
// |this| may be dead here
}
-void LayoutBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
+void LayoutBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint& point, const LayoutRect& rect)
{
if (result.innerNode())
return;
+ result.intersectValidityRect(rect);
if (Node* n = nodeForHitTest())
result.setNodeAndPosition(n, point);
}

Powered by Google App Engine
This is Rietveld 408576698