Chromium Code Reviews| Index: Source/core/layout/LayoutView.cpp |
| diff --git a/Source/core/layout/LayoutView.cpp b/Source/core/layout/LayoutView.cpp |
| index a8c768da00bac6053fd17a489776fd7988b7dab0..25cc329dd92e1856dbb9254c224ca92dba393d64 100644 |
| --- a/Source/core/layout/LayoutView.cpp |
| +++ b/Source/core/layout/LayoutView.cpp |
| @@ -29,7 +29,6 @@ |
| #include "core/html/HTMLFrameOwnerElement.h" |
| #include "core/html/HTMLIFrameElement.h" |
| #include "core/layout/ColumnInfo.h" |
| -#include "core/layout/HitTestResult.h" |
| #include "core/layout/LayoutFlowThread.h" |
| #include "core/layout/LayoutGeometryMap.h" |
| #include "core/layout/LayoutPart.h" |
| @@ -44,6 +43,7 @@ |
| #include "platform/TracedValue.h" |
| #include "platform/geometry/FloatQuad.h" |
| #include "platform/geometry/TransformState.h" |
| +#include "platform/graphics/GraphicsLayer.h" |
| #include "platform/graphics/paint/DisplayItemList.h" |
| #include <inttypes.h> |
| @@ -62,6 +62,7 @@ LayoutView::LayoutView(Document* document) |
| , m_layoutQuoteHead(nullptr) |
| , m_layoutCounterCount(0) |
| , m_hitTestCount(0) |
| + , m_hitTestCacheHits(0) |
| , m_pendingSelection(PendingSelection::create()) |
| { |
| // init LayoutObject attributes |
| @@ -79,15 +80,12 @@ LayoutView::~LayoutView() |
| { |
| } |
| -bool LayoutView::hitTest(HitTestResult& result) |
| -{ |
| - return hitTest(result.hitTestRequest(), result.hitTestLocation(), result); |
| -} |
| - |
| namespace { |
| -PassRefPtr<TracedValue> hitTestInfo(const HitTestRequest& request, const HitTestLocation& location, const HitTestResult& result) |
| +PassRefPtr<TracedValue> hitTestInfo(const HitTestResult& result) |
| { |
| + const HitTestRequest& request = result.hitTestRequest(); |
| + const HitTestLocation& location = result.hitTestLocation(); |
| RefPtr<TracedValue> value(TracedValue::create()); |
| value->setInteger("x", location.roundedPoint().x()); |
| value->setInteger("y", location.roundedPoint().y()); |
| @@ -113,12 +111,12 @@ PassRefPtr<TracedValue> hitTestInfo(const HitTestRequest& request, const HitTest |
| } // anonymous namespace |
| -bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& location, HitTestResult& result) |
| +bool LayoutView::hitTest(HitTestResult& result) |
| { |
| TRACE_EVENT_BEGIN0("blink", "LayoutView::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 |
| @@ -128,16 +126,31 @@ bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l |
| frameView()->updateLayoutAndStyleForPainting(); |
| commitPendingSelection(); |
| - bool hitLayer = layer()->hitTest(request, location, result); |
| + HitTestResult cacheResult = result; |
| + bool cacheHit = cacheHit = m_hitTestCache.check(cacheResult); |
|
Rick Byers
2015/06/05 20:48:59
remove extra cacheHit
dtapuska
2015/06/09 18:21:24
Done.
|
| + 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", "LayoutView::hitTest", "info", hitTestInfo(request, location, result)); |
| + if (cacheHit) { |
| + m_hitTestCacheHits++; |
| + m_hitTestCache.verify(result, cacheResult); |
| + } |
| + |
| + if (hitLayer) { |
| + m_hitTestCache.cacheValue(result); |
| + |
| + if (layer()->graphicsLayerBacking()) { |
| + layer()->graphicsLayerBacking()->platformLayer()->setHitCacheRect(enclosingIntRect(result.validityRect())); |
| + } |
| + } |
| + |
| + TRACE_EVENT_END1("blink", "LayoutView::hitTest", "info", hitTestInfo(result)); |
| return hitLayer; |
| } |