| 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 16 matching lines...) Expand all Loading... |
| 27 // Some of the related design, motivation can be found in: | 27 // Some of the related design, motivation can be found in: |
| 28 // https://docs.google.com/document/d/1b0NYAD4S9BJIpHGa4JD2HLmW28f2rUh1jlqrgpU3z
VU/ | 28 // https://docs.google.com/document/d/1b0NYAD4S9BJIpHGa4JD2HLmW28f2rUh1jlqrgpU3z
VU/ |
| 29 // | 29 // |
| 30 | 30 |
| 31 // A cache size of 2 is used because it is relatively cheap to store; | 31 // A cache size of 2 is used because it is relatively cheap to store; |
| 32 // and the ping-pong behaviour of some of the HitTestRequest flags during | 32 // and the ping-pong behaviour of some of the HitTestRequest flags during |
| 33 // Mouse/Touch/Pointer events can generate increased cache misses with | 33 // Mouse/Touch/Pointer events can generate increased cache misses with |
| 34 // size of 1. | 34 // size of 1. |
| 35 #define HIT_TEST_CACHE_SIZE (2) | 35 #define HIT_TEST_CACHE_SIZE (2) |
| 36 | 36 |
| 37 class CORE_EXPORT HitTestCache final : public NoBaseWillBeGarbageCollectedFinali
zed<HitTestCache> { | 37 class CORE_EXPORT HitTestCache final : public GarbageCollectedFinalized<HitTestC
ache> { |
| 38 USING_FAST_MALLOC_WILL_BE_REMOVED(HitTestCache); | |
| 39 WTF_MAKE_NONCOPYABLE(HitTestCache); | 38 WTF_MAKE_NONCOPYABLE(HitTestCache); |
| 40 public: | 39 public: |
| 41 static PassOwnPtrWillBeRawPtr<HitTestCache> create() | 40 static RawPtr<HitTestCache> create() |
| 42 { | 41 { |
| 43 return adoptPtrWillBeNoop(new HitTestCache); | 42 return adoptPtrWillBeNoop(new HitTestCache); |
| 44 } | 43 } |
| 45 | 44 |
| 46 // Check the cache for a possible hit and update |result| if | 45 // Check the cache for a possible hit and update |result| if |
| 47 // hit encountered; returning true. Otherwise false. | 46 // hit encountered; returning true. Otherwise false. |
| 48 bool lookupCachedResult(HitTestResult&, uint64_t domTreeVersion); | 47 bool lookupCachedResult(HitTestResult&, uint64_t domTreeVersion); |
| 49 | 48 |
| 50 void clear(); | 49 void clear(); |
| 51 | 50 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 69 enum class HitHistogramMetric { | 68 enum class HitHistogramMetric { |
| 70 MISS, // Miss, not found in cache. | 69 MISS, // Miss, not found in cache. |
| 71 MISS_EXPLICIT_AVOID, // Miss, callee asked to explicitly avoid cache. | 70 MISS_EXPLICIT_AVOID, // Miss, callee asked to explicitly avoid cache. |
| 72 MISS_VALIDITY_RECT_MATCHES, // Miss, validity region matches, type doesn
't. | 71 MISS_VALIDITY_RECT_MATCHES, // Miss, validity region matches, type doesn
't. |
| 73 HIT_EXACT_MATCH, // Hit, exact point matches. | 72 HIT_EXACT_MATCH, // Hit, exact point matches. |
| 74 HIT_REGION_MATCH, // Hit, validity region matches. | 73 HIT_REGION_MATCH, // Hit, validity region matches. |
| 75 MAX_HIT_METRIC = HIT_REGION_MATCH, | 74 MAX_HIT_METRIC = HIT_REGION_MATCH, |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 unsigned m_updateIndex; | 77 unsigned m_updateIndex; |
| 79 WillBeHeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; | 78 HeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; |
| 80 uint64_t m_domTreeVersion; | 79 uint64_t m_domTreeVersion; |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 } // namespace blink | 82 } // namespace blink |
| 84 | 83 |
| 85 #endif // HitTestCache_h | 84 #endif // HitTestCache_h |
| OLD | NEW |