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" |
11 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
12 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 // This object implements a cache for storing successful hit tests to DOM nodes | 16 // This object implements a cache for storing successful hit tests to DOM nodes |
17 // in the visible viewport. The cache is cleared on dom modifications, | 17 // in the visible viewport. The cache is cleared on dom modifications, |
18 // scrolling, CSS style modifications. | 18 // scrolling, CSS style modifications. |
19 // | 19 // |
20 // Multiple hit tests can occur when processing events. Typically the DOM doesn'
t | 20 // Multiple hit tests can occur when processing events. Typically the DOM |
21 // change when each event is processed so in order to decrease the time spent | 21 // doesn't change when each event is processed so in order to decrease the time |
22 // processing the events a hit cache is useful. For example a GestureTap event | 22 // spent processing the events a hit cache is useful. For example a GestureTap |
23 // will generate a series of simulated mouse events (move, down, up, click) | 23 // event will generate a series of simulated mouse events (move, down, up, |
24 // with the same co-ordinates and ideally we'd like to do the hit test once | 24 // click) with the same co-ordinates and ideally we'd like to do the hit test |
25 // and use the result for the targetting of each event. | 25 // once and use the result for the targetting of each event. |
26 // | 26 // |
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) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 72 }; |
73 | 73 |
74 unsigned m_updateIndex; | 74 unsigned m_updateIndex; |
75 HeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; | 75 HeapVector<HitTestResult, HIT_TEST_CACHE_SIZE> m_items; |
76 uint64_t m_domTreeVersion; | 76 uint64_t m_domTreeVersion; |
77 }; | 77 }; |
78 | 78 |
79 } // namespace blink | 79 } // namespace blink |
80 | 80 |
81 #endif // HitTestCache_h | 81 #endif // HitTestCache_h |
OLD | NEW |