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

Side by Side Diff: Source/core/layout/LayoutView.cpp

Issue 1294913004: Enable HitTestCache by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix layout test Created 5 years, 4 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
« no previous file with comments | « Source/core/layout/HitTestResult.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 { 95 {
96 TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest"); 96 TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest");
97 m_hitTestCount++; 97 m_hitTestCount++;
98 98
99 ASSERT(!result.hitTestLocation().isRectBasedTest() || result.hitTestRequest( ).listBased()); 99 ASSERT(!result.hitTestLocation().isRectBasedTest() || result.hitTestRequest( ).listBased());
100 100
101 commitPendingSelection(); 101 commitPendingSelection();
102 102
103 uint64_t domTreeVersion = document().domTreeVersion(); 103 uint64_t domTreeVersion = document().domTreeVersion();
104 HitTestResult cacheResult = result; 104 HitTestResult cacheResult = result;
105 bool cacheHit = m_hitTestCache->lookupCachedResult(cacheResult, domTreeVersi on); 105 bool hitLayer = false;
106 bool hitLayer = layer()->hitTest(result); 106 if (m_hitTestCache->lookupCachedResult(cacheResult, domTreeVersion)) {
107 m_hitTestCacheHits++;
108 hitLayer = true;
109 result = cacheResult;
110 } else {
111 hitLayer = layer()->hitTest(result);
107 112
108 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer ::hitTestOverflowControls, 113 // FrameView scrollbars are not the same as Layer scrollbars tested by L ayer::hitTestOverflowControls,
109 // so we need to test FrameView scrollbars separately here. Note that it's i mportant we do this after 114 // so we need to test FrameView scrollbars separately here. Note that it 's important we do this after
110 // the hit test above, because that may overwrite the entire HitTestResult w hen it finds a hit. 115 // the hit test above, because that may overwrite the entire HitTestResu lt when it finds a hit.
111 IntPoint framePoint = frameView()->contentsToFrame(result.hitTestLocation(). roundedPoint()); 116 IntPoint framePoint = frameView()->contentsToFrame(result.hitTestLocatio n().roundedPoint());
112 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin t)) 117 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(frame Point))
113 result.setScrollbar(frameScrollbar); 118 result.setScrollbar(frameScrollbar);
114 119
115 if (cacheHit) { 120 if (hitLayer)
116 m_hitTestCacheHits++; 121 m_hitTestCache->addCachedResult(result, domTreeVersion);
117 m_hitTestCache->verifyCachedResult(result, cacheResult);
118 } 122 }
119 123
120 if (hitLayer)
121 m_hitTestCache->addCachedResult(result, domTreeVersion);
122
123 TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorH itTestEvent::endData(result.hitTestRequest(), result.hitTestLocation(), result)) ; 124 TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorH itTestEvent::endData(result.hitTestRequest(), result.hitTestLocation(), result)) ;
124 return hitLayer; 125 return hitLayer;
125 } 126 }
126 127
127 void LayoutView::clearHitTestCache() 128 void LayoutView::clearHitTestCache()
128 { 129 {
129 m_hitTestCache->clear(); 130 m_hitTestCache->clear();
130 if (LayoutPart* frameLayoutObject = frame()->ownerLayoutObject()) 131 if (LayoutPart* frameLayoutObject = frame()->ownerLayoutObject())
131 frameLayoutObject->view()->clearHitTestCache(); 132 frameLayoutObject->view()->clearHitTestCache();
132 } 133 }
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 return viewHeight(IncludeScrollbars) / scale; 1006 return viewHeight(IncludeScrollbars) / scale;
1006 } 1007 }
1007 1008
1008 void LayoutView::willBeDestroyed() 1009 void LayoutView::willBeDestroyed()
1009 { 1010 {
1010 LayoutBlockFlow::willBeDestroyed(); 1011 LayoutBlockFlow::willBeDestroyed();
1011 m_compositor.clear(); 1012 m_compositor.clear();
1012 } 1013 }
1013 1014
1014 } // namespace blink 1015 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/HitTestResult.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698