OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef HitTestCache_h | 5 #ifndef HitTestCache_h |
6 #define HitTestCache_h | 6 #define HitTestCache_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/HitTestResult.h" | 9 #include "core/layout/HitTestResult.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 { | 39 { |
40 return adoptPtrWillBeNoop(new HitTestCache); | 40 return adoptPtrWillBeNoop(new HitTestCache); |
41 } | 41 } |
42 | 42 |
43 // Check the cache for a possible hit and update |result| if | 43 // Check the cache for a possible hit and update |result| if |
44 // hit encountered; returning true. Otherwise false. | 44 // hit encountered; returning true. Otherwise false. |
45 bool lookupCachedResult(HitTestResult&, uint64_t domTreeVersion); | 45 bool lookupCachedResult(HitTestResult&, uint64_t domTreeVersion); |
46 | 46 |
47 void clear(); | 47 void clear(); |
48 | 48 |
49 // Verify that the |actual| object matches the |expected| object; and | |
50 // log UMA metrics indicating the result. | |
51 static void verifyCachedResult(const HitTestResult& expected, const HitTestR
esult& actual); | |
52 | |
53 // Adds a HitTestResult to the cache. | 49 // Adds a HitTestResult to the cache. |
54 void addCachedResult(const HitTestResult&, uint64_t domTreeVersion); | 50 void addCachedResult(const HitTestResult&, uint64_t domTreeVersion); |
55 | 51 |
56 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
57 | 53 |
58 private: | 54 private: |
59 HitTestCache() | 55 HitTestCache() |
60 : m_updateIndex(0) | 56 : m_updateIndex(0) |
61 , m_domTreeVersion(0) { } | 57 , m_domTreeVersion(0) { } |
62 | 58 |
63 // The below UMA values reference a validity region. This code has not | 59 // The below UMA values reference a validity region. This code has not |
64 // been written yet; and exact matches are only supported but the | 60 // been written yet; and exact matches are only supported but the |
65 // UMA enumerations have been added for future support. | 61 // UMA enumerations have been added for future support. |
66 | 62 |
67 // These values are reported in UMA as the "EventHitTest" enumeration. | 63 // These values are reported in UMA as the "EventHitTest" enumeration. |
68 // Do not reorder, append new values at the end, deprecate old | 64 // Do not reorder, append new values at the end, deprecate old |
69 // values and update histograms.xml. | 65 // values and update histograms.xml. |
70 enum class HitHistogramMetric { | 66 enum class HitHistogramMetric { |
71 MISS, // Miss, not found in cache. | 67 MISS, // Miss, not found in cache. |
72 MISS_EXPLICIT_AVOID, // Miss, callee asked to explicitly avoid cache. | 68 MISS_EXPLICIT_AVOID, // Miss, callee asked to explicitly avoid cache. |
73 MISS_VALIDITY_RECT_MATCHES, // Miss, validity region matches, type doesn
't. | 69 MISS_VALIDITY_RECT_MATCHES, // Miss, validity region matches, type doesn
't. |
74 HIT_EXACT_MATCH, // Hit, exact point matches. | 70 HIT_EXACT_MATCH, // Hit, exact point matches. |
75 HIT_REGION_MATCH, // Hit, validity region matches. | 71 HIT_REGION_MATCH, // Hit, validity region matches. |
76 MAX_HIT_METRIC = HIT_REGION_MATCH, | 72 MAX_HIT_METRIC = HIT_REGION_MATCH, |
77 }; | 73 }; |
78 | 74 |
79 // These values are reported in UMA as the "EventHitTestValidity" | |
80 // enumeration. Do not reorder, append new values at the end, | |
81 // deprecate old values and update histograms.xml. | |
82 enum class ValidityHistogramMetric { | |
83 VALID_EXACT_MATCH, // Correct node for exact point test. | |
84 VALID_REGION, // Correct node for region check. | |
85 INCORRECT_RECT_BASED_EXACT_MATCH, // Wrong node returned for cache hit w
ith point was exact match and rect based test. | |
86 INCORRECT_POINT_EXACT_MATCH, // Wrong node returned for cache hit with e
xact point match and was explicit point test. | |
87 INCORRECT_RECT_BASED_REGION, // Wrong node returned for rect with region
matching and was rect based test. | |
88 INCORRECT_POINT_REGION, // Wrong node returned for point with region mat
ching and was explicit point test. | |
89 MAX_VALIDITY_METRIC = INCORRECT_POINT_REGION, | |
90 }; | |
91 | |
92 unsigned m_updateIndex; | 75 unsigned m_updateIndex; |
93 WillBeHeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; | 76 WillBeHeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; |
94 uint64_t m_domTreeVersion; | 77 uint64_t m_domTreeVersion; |
95 }; | 78 }; |
96 | 79 |
97 } // namespace blink | 80 } // namespace blink |
98 | 81 |
99 #endif // HitTestCache_h | 82 #endif // HitTestCache_h |
OLD | NEW |