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

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

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove validity rect as per Elliott's request Created 5 years, 6 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 | « Source/core/layout/LayoutView.h ('k') | Source/core/paint/DeprecatedPaintLayer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutView.cpp
diff --git a/Source/core/layout/LayoutView.cpp b/Source/core/layout/LayoutView.cpp
index 859e6ae3546397e624cb2089f4837c23e65d201e..5e23df84c7df259ca348d2fc1a3affc5f916711c 100644
--- a/Source/core/layout/LayoutView.cpp
+++ b/Source/core/layout/LayoutView.cpp
@@ -62,6 +62,8 @@ LayoutView::LayoutView(Document* document)
, m_layoutQuoteHead(nullptr)
, m_layoutCounterCount(0)
, m_hitTestCount(0)
+ , m_hitTestCacheHits(0)
+ , m_hitTestCache(HitTestCache::create())
, m_pendingSelection(PendingSelection::create())
{
// init LayoutObject attributes
@@ -81,15 +83,10 @@ LayoutView::~LayoutView()
bool LayoutView::hitTest(HitTestResult& result)
{
- return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
-}
-
-bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& location, HitTestResult& result)
-{
TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest");
m_hitTestCount++;
- ASSERT(!location.isRectBasedTest() || request.listBased());
+ ASSERT(!result.hitTestLocation().isRectBasedTest() || result.hitTestRequest().listBased());
// We have to recursively update layout/style here because otherwise, when the hit test recurses
// into a child document, it could trigger a layout on the parent document, which can destroy DeprecatedPaintLayer
@@ -99,16 +96,27 @@ bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l
frameView()->updateLayoutAndStyleForPainting();
commitPendingSelection();
- bool hitLayer = layer()->hitTest(request, location, result);
+ uint64_t domTreeVersion = document().domTreeVersion();
+ HitTestResult cacheResult = result;
+ bool cacheHit = m_hitTestCache->lookupCachedResult(cacheResult, domTreeVersion);
+ bool hitLayer = layer()->hitTest(result);
// FrameView scrollbars are not the same as Layer scrollbars tested by Layer::hitTestOverflowControls,
// so we need to test FrameView scrollbars separately here. Note that it's important we do this after
// the hit test above, because that may overwrite the entire HitTestResult when it finds a hit.
- IntPoint framePoint = frameView()->contentsToFrame(location.roundedPoint());
+ IntPoint framePoint = frameView()->contentsToFrame(result.hitTestLocation().roundedPoint());
if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoint))
result.setScrollbar(frameScrollbar);
- TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorHitTestEvent::endData(request, location, result));
+ if (cacheHit) {
+ m_hitTestCacheHits++;
+ m_hitTestCache->verifyCachedResult(result, cacheResult);
+ }
+
+ if (hitLayer)
+ m_hitTestCache->addCachedResult(result, domTreeVersion);
+
+ TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorHitTestEvent::endData(result.hitTestRequest(), result.hitTestLocation(), result));
return hitLayer;
}
« no previous file with comments | « Source/core/layout/LayoutView.h ('k') | Source/core/paint/DeprecatedPaintLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698