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

Unified Diff: Source/core/paint/DeprecatedPaintLayer.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/paint/DeprecatedPaintLayer.cpp
diff --git a/Source/core/paint/DeprecatedPaintLayer.cpp b/Source/core/paint/DeprecatedPaintLayer.cpp
index df5e4e0e0d7c89755b6f7f0906f0d214079927ea..3d84c773a84a364792774ee73d57ea6154c28c33 100644
--- a/Source/core/paint/DeprecatedPaintLayer.cpp
+++ b/Source/core/paint/DeprecatedPaintLayer.cpp
@@ -1660,23 +1660,22 @@ static inline LayoutRect frameVisibleRect(LayoutObject* layoutObject)
bool DeprecatedPaintLayer::hitTest(HitTestResult& result)
{
- return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
-}
-
-bool DeprecatedPaintLayer::hitTest(const HitTestRequest& request, const HitTestLocation& hitTestLocation, HitTestResult& result)
-{
ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant());
// LayoutView should make sure to update layout before entering hit testing
ASSERT(!layoutObject()->frame()->view()->layoutPending());
ASSERT(!layoutObject()->document().layoutView()->needsLayout());
+ const HitTestRequest& request = result.hitTestRequest();
+ const HitTestLocation& hitTestLocation = result.hitTestLocation();
+
// Start with frameVisibleRect to ensure we include the scrollbars.
LayoutRect hitTestArea = frameVisibleRect(layoutObject());
if (request.ignoreClipping())
hitTestArea.unite(LayoutRect(layoutObject()->view()->documentRect()));
+ result.setValidityRect(hitTestArea);
- DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestArea, hitTestLocation, false);
+ DeprecatedPaintLayer* insideLayer = hitTestLayer(this, 0, result, hitTestArea, result.hitTestLocation(), false);
if (!insideLayer) {
// We didn't hit any layer. If we are the root layer and the mouse is -- or just was -- down,
// return ourselves. We do this so mouse events continue getting delivered after a drag has
@@ -1685,7 +1684,7 @@ bool DeprecatedPaintLayer::hitTest(const HitTestRequest& request, const HitTestL
// At that time, the events of the mouse should be fired.
LayoutPoint hitPoint = hitTestLocation.point();
if (!request.isChildFrameHitTest() && ((request.active() || request.release()) || (request.move() && hitTestArea.contains(hitPoint.x(), hitPoint.y()))) && isRootLayer()) {
- layoutObject()->updateHitTestResult(result, toLayoutView(layoutObject())->flipForWritingMode(hitTestLocation.point()));
+ layoutObject()->updateHitTestResult(result, toLayoutView(layoutObject())->flipForWritingMode(hitTestLocation.point()), LayoutRect(hitTestLocation.point(), LayoutSize(IntSize(1, 1))));
insideLayer = this;
}
}
@@ -1901,7 +1900,7 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestLayer(DeprecatedPaintLayer* r
collectFragments(layerFragments, rootLayer, hitTestRect, RootRelativeClipRects, IncludeOverlayScrollbarSize);
if (m_scrollableArea && m_scrollableArea->hitTestResizerInFragments(layerFragments, hitTestLocation)) {
- layoutObject()->updateHitTestResult(result, hitTestLocation.point());
+ layoutObject()->updateHitTestResult(result, hitTestLocation.point(), boundingRect(hitTestLocation.point()));
return this;
}
@@ -1910,6 +1909,7 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestLayer(DeprecatedPaintLayer* r
if (isSelfPaintingLayer()) {
// Hit test with a temporary HitTestResult, because we only want to commit to 'result' if we know we're frontmost.
HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
+ tempResult.setValidityRect(result.validityRect());
bool insideFragmentForegroundRect = false;
if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocation, HitTestDescendants, insideFragmentForegroundRect)
&& isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) {
@@ -1923,6 +1923,8 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestLayer(DeprecatedPaintLayer* r
candidateLayer = this;
} else if (insideFragmentForegroundRect && result.hitTestRequest().listBased()) {
result.append(tempResult);
+ } else {
+ result.setValidityRect(result.validityRect());
}
}
@@ -1941,6 +1943,7 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestLayer(DeprecatedPaintLayer* r
if (isSelfPaintingLayer()) {
HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
+ tempResult.setValidityRect(result.validityRect());
bool insideFragmentBackgroundRect = false;
if (hitTestContentsForFragments(layerFragments, tempResult, hitTestLocation, HitTestSelf, insideFragmentBackgroundRect)
&& isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) {
@@ -1949,9 +1952,11 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestLayer(DeprecatedPaintLayer* r
else
result = tempResult;
return this;
- }
- if (insideFragmentBackgroundRect && result.hitTestRequest().listBased())
+ } else if (insideFragmentBackgroundRect && result.hitTestRequest().listBased()) {
result.append(tempResult);
+ } else {
+ result.setValidityRect(tempResult.validityRect());
+ }
}
return 0;
@@ -2095,6 +2100,7 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestChildren(ChildrenIteration ch
DeprecatedPaintLayer* childLayer = child->layer();
DeprecatedPaintLayer* hitLayer = 0;
HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation());
+ tempResult.setValidityRect(result.validityRect());
if (childLayer->isPaginated())
hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, tempResult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendants);
else
@@ -2112,6 +2118,8 @@ DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestChildren(ChildrenIteration ch
result = tempResult;
if (!depthSortDescendants)
break;
+ } else if (!hitLayer) {
+ result.setValidityRect(tempResult.validityRect());
}
}

Powered by Google App Engine
This is Rietveld 408576698