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

Side by Side Diff: third_party/WebKit/Source/core/layout/HitTestCache.cpp

Issue 1647883004: Support caching histograms so that a lookup isn't done in each iteration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add explicit to protected ctor as well Created 4 years, 10 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
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 #include "core/layout/HitTestCache.h" 5 #include "core/layout/HitTestCache.h"
6 6
7 #include "platform/Histogram.h"
7 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
8 9
9 namespace blink { 10 namespace blink {
10 11
11 bool HitTestCache::lookupCachedResult(HitTestResult& hitResult, uint64_t domTree Version) 12 bool HitTestCache::lookupCachedResult(HitTestResult& hitResult, uint64_t domTree Version)
12 { 13 {
13 bool result = false; 14 bool result = false;
14 HitHistogramMetric metric = HitHistogramMetric::MISS; 15 HitHistogramMetric metric = HitHistogramMetric::MISS;
15 if (hitResult.hitTestRequest().avoidCache()) { 16 if (hitResult.hitTestRequest().avoidCache()) {
16 metric = HitHistogramMetric::MISS_EXPLICIT_AVOID; 17 metric = HitHistogramMetric::MISS_EXPLICIT_AVOID;
17 // For now we don't support rect based hit results. 18 // For now we don't support rect based hit results.
18 } else if (domTreeVersion == m_domTreeVersion && !hitResult.hitTestLocation( ).isRectBasedTest()) { 19 } else if (domTreeVersion == m_domTreeVersion && !hitResult.hitTestLocation( ).isRectBasedTest()) {
19 for (const auto& cachedItem : m_items) { 20 for (const auto& cachedItem : m_items) {
20 if (cachedItem.hitTestLocation().point() == hitResult.hitTestLocatio n().point()) { 21 if (cachedItem.hitTestLocation().point() == hitResult.hitTestLocatio n().point()) {
21 if (hitResult.hitTestRequest().equalForCacheability(cachedItem.h itTestRequest())) { 22 if (hitResult.hitTestRequest().equalForCacheability(cachedItem.h itTestRequest())) {
22 metric = HitHistogramMetric::HIT_EXACT_MATCH; 23 metric = HitHistogramMetric::HIT_EXACT_MATCH;
23 result = true; 24 result = true;
24 hitResult = cachedItem; 25 hitResult = cachedItem;
25 break; 26 break;
26 } 27 }
27 metric = HitHistogramMetric::MISS_VALIDITY_RECT_MATCHES; 28 metric = HitHistogramMetric::MISS_VALIDITY_RECT_MATCHES;
28 } 29 }
29 } 30 }
30 } 31 }
31 Platform::current()->histogramEnumeration("Event.HitTest", static_cast<int>( metric), static_cast<int>(HitHistogramMetric::MAX_HIT_METRIC)); 32 DEFINE_STATIC_LOCAL(EnumerationHistogram, hitTestHistogram, ("Event.HitTest" , static_cast<int32_t>(HitHistogramMetric::MAX_HIT_METRIC)));
33 hitTestHistogram.count(static_cast<int32_t>(metric));
32 return result; 34 return result;
33 } 35 }
34 36
35 void HitTestCache::addCachedResult(const HitTestResult& result, uint64_t domTree Version) 37 void HitTestCache::addCachedResult(const HitTestResult& result, uint64_t domTree Version)
36 { 38 {
37 if (!result.isCacheable()) 39 if (!result.isCacheable())
38 return; 40 return;
39 41
40 // If the result was a hit test on an LayoutPart and the request allowed 42 // If the result was a hit test on an LayoutPart and the request allowed
41 // querying of the layout part; then the part hasn't been loaded yet. 43 // querying of the layout part; then the part hasn't been loaded yet.
(...skipping 21 matching lines...) Expand all
63 m_updateIndex = 0; 65 m_updateIndex = 0;
64 m_items.clear(); 66 m_items.clear();
65 } 67 }
66 68
67 DEFINE_TRACE(HitTestCache) 69 DEFINE_TRACE(HitTestCache)
68 { 70 {
69 visitor->trace(m_items); 71 visitor->trace(m_items);
70 } 72 }
71 73
72 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutView.cpp » ('j') | third_party/WebKit/Source/platform/Histogram.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698