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

Unified Diff: Source/core/layout/HitTestResult.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/HitTestResult.cpp
diff --git a/Source/core/layout/HitTestResult.cpp b/Source/core/layout/HitTestResult.cpp
index 691aa80fac24882799319fcb571b455ce7d17792..e7edf0c828ec458bbe621bbd4a53039b082718b5 100644
--- a/Source/core/layout/HitTestResult.cpp
+++ b/Source/core/layout/HitTestResult.cpp
@@ -108,6 +108,7 @@ HitTestResult& HitTestResult::operator=(const HitTestResult& other)
m_innerURLElement = other.URLElement();
m_scrollbar = other.scrollbar();
m_isOverWidget = other.isOverWidget();
+ m_validityRect = other.m_validityRect;
// Only copy the NodeSet in case of list hit test.
m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0);
@@ -115,9 +116,35 @@ HitTestResult& HitTestResult::operator=(const HitTestResult& other)
return *this;
}
+bool HitTestResult::equalForCacheability(const HitTestResult& other) const
+{
+ bool res = m_hitTestRequest.equalForCacheability(other.m_hitTestRequest)
+ && m_innerNode == other.innerNode()
+ && m_innerPossiblyPseudoNode == other.innerPossiblyPseudoNode()
+ // && m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame
+ // && m_localPoint == other.localPoint()
+ && m_innerURLElement == other.URLElement()
+ && m_scrollbar == other.scrollbar()
+ && m_isOverWidget == other.isOverWidget();
+ // && m_listBasedTestResult == other.m_listBasedTestResult;
+
+ if (!res) {
+ WTF_LOG_ERROR("%d %d %d %d %d %d %d %d", m_hitTestRequest.equalForCacheability(other.m_hitTestRequest),
+ m_innerNode == other.m_innerNode,
+ m_innerPossiblyPseudoNode == other.m_innerPossiblyPseudoNode,
+ m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame,
+ m_localPoint == other.m_localPoint,
+ m_innerURLElement == other.m_innerURLElement,
+ m_scrollbar == other.m_scrollbar,
+ m_isOverWidget == other.m_isOverWidget);
+ }
+ return res;
+}
+
DEFINE_TRACE(HitTestResult)
{
visitor->trace(m_innerNode);
+
visitor->trace(m_innerPossiblyPseudoNode);
visitor->trace(m_innerURLElement);
visitor->trace(m_scrollbar);
@@ -219,6 +246,55 @@ bool HitTestResult::isSelected() const
return false;
}
+void HitTestResult::setValidityRect(const LayoutRect& rect)
+{
+ ASSERT(!rect.isEmpty());
+ if (!rect.isEmpty())
+ m_validityRect = rect;
+}
+
+void HitTestResult::shrinkValidityRect(const LayoutRect& rect)
+{
+ LayoutRect tempValidityRect = m_validityRect;
+ if (rect.maxY() <= m_hitTestLocation.point().y() && rect.maxY() > tempValidityRect.y()) {
+ tempValidityRect.shiftYEdgeTo(rect.maxY());
+ }
+ if (rect.y() > m_hitTestLocation.point().y() && rect.y() < tempValidityRect.maxY()) {
+ tempValidityRect.shiftMaxYEdgeTo(rect.y());
+ }
+ if (rect.maxX() <= m_hitTestLocation.point().x() && rect.maxX() > tempValidityRect.x()) {
+ tempValidityRect.shiftXEdgeTo(rect.maxX());
+ }
+ if (rect.x() > m_hitTestLocation.point().x() && rect.x() < tempValidityRect.maxX()) {
+ tempValidityRect.shiftMaxXEdgeTo(rect.x());
+ }
+
+ if (!tempValidityRect.contains(m_hitTestLocation.point())) {
+ tempValidityRect.show(false);
+ rect.show(false);
+ WTF_LOG_ERROR("Layout point %lf %lf", m_hitTestLocation.point().x().toDouble(), m_hitTestLocation.point().y().toDouble());
+
+ // ASSERT(false);
+ return;
+ }
+ m_validityRect = tempValidityRect;
+}
+
+void HitTestResult::intersectValidityRect(const LayoutRect& rect)
+{
+ LayoutRect tempValidityRect = m_validityRect;
+ tempValidityRect.intersect(rect);
+ if (!tempValidityRect.contains(m_hitTestLocation.point())) {
+ tempValidityRect.show(false);
+ m_validityRect.show(false);
+ WTF_LOG_ERROR("Layout point %lf %lf", m_hitTestLocation.point().x().toDouble(), m_hitTestLocation.point().y().toDouble());
+
+ // ASSERT(false);
+ return;
+ }
+ m_validityRect = tempValidityRect;
+}
+
String HitTestResult::spellingToolTip(TextDirection& dir) const
{
dir = LTR;
@@ -484,7 +560,7 @@ void HitTestResult::resolveRectBasedTest(Node* resolvedInnerNode, const LayoutPo
// Update the HitTestResult as if the supplied node had been hit in normal point-based hit-test.
// Note that we don't know the local point after a rect-based hit-test, but we never use
// it so shouldn't bother with the cost of computing it.
- resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint());
+ resolvedInnerNode->layoutObject()->updateHitTestResult(*this, LayoutPoint(), m_validityRect);
ASSERT(!isRectBasedTest());
}

Powered by Google App Engine
This is Rietveld 408576698