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

Unified Diff: Source/core/dom/TreeScope.cpp

Issue 1142283004: Implement a Hit Test Cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix git cl format mangling 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/dom/TreeScope.cpp
diff --git a/Source/core/dom/TreeScope.cpp b/Source/core/dom/TreeScope.cpp
index 801eafbc6ec8c056517e19f50aa3d1c0749c8d40..417d72a317422995b58abcaf1cf4933a3f6cc91d 100644
--- a/Source/core/dom/TreeScope.cpp
+++ b/Source/core/dom/TreeScope.cpp
@@ -262,13 +262,13 @@ static bool pointWithScrollAndZoomIfPossible(const Document& document, IntPoint&
return true;
}
-HitTestResult hitTestInDocument(const Document* document, int x, int y)
+HitTestResult hitTestInDocument(const Document* document, int x, int y, bool useCache)
{
IntPoint hitPoint(x, y);
if (!pointWithScrollAndZoomIfPossible(*document, hitPoint))
return HitTestResult();
- HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
+ HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | (useCache ? 0 : HitTestRequest::AvoidCache));
HitTestResult result(request, hitPoint);
document->layoutView()->hitTest(result);
return result;
@@ -276,7 +276,17 @@ HitTestResult hitTestInDocument(const Document* document, int x, int y)
Element* TreeScope::elementFromPoint(int x, int y) const
esprehn 2015/06/06 21:14:29 elementFromPoint(int x, int y, HitTestCacheType =
dtapuska 2015/06/09 18:21:23 I'm just going to allow the HitTestRequest to be p
{
- HitTestResult result = hitTestInDocument(&rootNode().document(), x, y);
+ return hitTestPoint(x, y, true);
+}
+
+Element* TreeScope::elementFromPointNoCache(int x, int y) const
esprehn 2015/06/06 21:14:29 Use default args instead, no need for two methods.
dtapuska 2015/06/09 18:21:23 Done.
+{
+ return hitTestPoint(x, y, false);
+}
+
+Element* TreeScope::hitTestPoint(int x, int y, bool useCache) const
+{
+ HitTestResult result = hitTestInDocument(&rootNode().document(), x, y, useCache);
Node* node = result.innerNode();
if (!node || node->isDocumentNode())
return 0;

Powered by Google App Engine
This is Rietveld 408576698