Index: Source/core/layout/HitTestCache.h |
diff --git a/Source/core/layout/HitTestCache.h b/Source/core/layout/HitTestCache.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..11fd7a534484fa697619beb7d6d100c7ab416ab5 |
--- /dev/null |
+++ b/Source/core/layout/HitTestCache.h |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef HitTestCache_h |
+#define HitTestCache_h |
+ |
+#include "core/layout/HitTestResult.h" |
+ |
+namespace blink { |
+ |
+class HitTestCache { |
Rick Byers
2015/06/05 20:48:59
Please add a brief comment describing the overall
dtapuska
2015/06/09 18:21:24
Done.
|
+public: |
+ HitTestCache() = default; |
+ |
+ // Check the cache for a possible hit and update |result| if |
+ // hit encountered; returning true. Otherwise false. |
+ bool check(HitTestResult& /*result*/); |
Rick Byers
2015/06/06 16:12:54
nit: no need for /*result*/
dtapuska
2015/06/09 18:21:24
Done.
|
+ |
+ void clear(); |
+ static void verify(const HitTestResult&, const HitTestResult&); |
Rick Byers
2015/06/05 20:48:59
the other two methods seem self explanatory here,
Rick Byers
2015/06/06 16:12:54
Since the order of the arguments are important (at
dtapuska
2015/06/09 18:21:24
Done.
dtapuska
2015/06/09 18:21:24
Done.
|
+ void cacheValue(const HitTestResult&); |
+ |
+private: |
+ // These values are reported in UMA. Try not to reorder/modify. |
+ enum class HitHistogramMetric { |
+ MISS, // A cache miss. |
+ MISS_EXPLICIT_AVOID, // Explicitly asked by caller to avoid cache. |
+ MISS_VALIDITY_RECT_MATCHES, // Region matches by request type doesn't. |
Rick Byers
2015/06/05 20:48:59
s/by/but/
dtapuska
2015/06/09 18:21:24
Done.
|
+ HIT_EXACT_MATCH, // Exact point/rect hit. |
+ HIT_REGION_MATCH, // Region match. |
+ MAX_HIT_METRIC = HIT_REGION_MATCH, |
+ }; |
+ |
+ // These values are reported in UMA. Try not to reorder/modify. |
+ enum class VerifyHistogramMetric { |
+ VALID_EXACT_MATCH, // Correct node for exact point test. |
+ VALID_REGION, // Correct node for region check. |
+ INCORRECT_RECT_BASED_EXACT_MATCH, // Wrong node returned for cache hit with point was exact match and rect based test. |
+ INCORRECT_POINT_EXACT_MATCH, // Wrong node returned for cache hit with exact point match and was explicit point test. |
+ INCORRECT_RECT_BASED_REGION, // Wrong node returned for rect with region matching and was rect based test. |
+ INCORRECT_POINT_REGION, // Wrong node returned for point with region matching and was explicit point test. |
+ MAX_VERIFY_METRIC = INCORRECT_POINT_REGION, |
+ }; |
+ |
+ struct CacheItem { |
+ bool m_valid = false; |
esprehn
2015/06/06 21:14:30
no m_ prefix on public fields.
dtapuska
2015/06/09 18:21:24
Done.
|
+ HitTestResult m_result; |
+ }; |
+ |
+ unsigned m_updateIndex = 0; |
+ |
+ // A cache size of 2 is used because it is relatively cheap to store; |
+ // and the ping-pong behaviour of some of the HitTestRequest flags during |
+ // Mouse/Touch/Pointer events can generate incrased cache misses with |
+ // size of 1. |
Rick Byers
2015/06/05 20:48:59
Do you think such ping-ponging of flags that affec
dtapuska
2015/06/09 18:21:24
I don't think the ping pong can be changed. I beli
|
+ CacheItem m_items[2]; |
esprehn
2015/06/06 21:14:30
We're probably going to need to hook this up to me
Rick Byers
2015/06/07 04:34:46
I was concerned about this at first too, but thoug
dtapuska
2015/06/09 18:21:24
The refs are explicitly purged on clear; I wondere
dtapuska
2015/06/09 18:21:24
I couldn't think of any; since the fields are clea
|
+}; |
+ |
+} // namespace blink |
+ |
+#endif // HitTestCache_h |