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

Side by Side Diff: Source/core/layout/HitTestCache.h

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, 6 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef HitTestCache_h
6 #define HitTestCache_h
7
8 #include "core/layout/HitTestResult.h"
9
10 namespace blink {
11
12 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.
13 public:
14 HitTestCache() = default;
15
16 // Check the cache for a possible hit and update |result| if
17 // hit encountered; returning true. Otherwise false.
18 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.
19
20 void clear();
21 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.
22 void cacheValue(const HitTestResult&);
23
24 private:
25 // These values are reported in UMA. Try not to reorder/modify.
26 enum class HitHistogramMetric {
27 MISS, // A cache miss.
28 MISS_EXPLICIT_AVOID, // Explicitly asked by caller to avoid cache.
29 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.
30 HIT_EXACT_MATCH, // Exact point/rect hit.
31 HIT_REGION_MATCH, // Region match.
32 MAX_HIT_METRIC = HIT_REGION_MATCH,
33 };
34
35 // These values are reported in UMA. Try not to reorder/modify.
36 enum class VerifyHistogramMetric {
37 VALID_EXACT_MATCH, // Correct node for exact point test.
38 VALID_REGION, // Correct node for region check.
39 INCORRECT_RECT_BASED_EXACT_MATCH, // Wrong node returned for cache hit w ith point was exact match and rect based test.
40 INCORRECT_POINT_EXACT_MATCH, // Wrong node returned for cache hit with e xact point match and was explicit point test.
41 INCORRECT_RECT_BASED_REGION, // Wrong node returned for rect with region matching and was rect based test.
42 INCORRECT_POINT_REGION, // Wrong node returned for point with region mat ching and was explicit point test.
43 MAX_VERIFY_METRIC = INCORRECT_POINT_REGION,
44 };
45
46 struct CacheItem {
47 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.
48 HitTestResult m_result;
49 };
50
51 unsigned m_updateIndex = 0;
52
53 // A cache size of 2 is used because it is relatively cheap to store;
54 // and the ping-pong behaviour of some of the HitTestRequest flags during
55 // Mouse/Touch/Pointer events can generate incrased cache misses with
56 // 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
57 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
58 };
59
60 } // namespace blink
61
62 #endif // HitTestCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698