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

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

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
1 /* 1 /*
2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 { 101 {
102 m_hitTestLocation = other.m_hitTestLocation; 102 m_hitTestLocation = other.m_hitTestLocation;
103 m_hitTestRequest = other.m_hitTestRequest; 103 m_hitTestRequest = other.m_hitTestRequest;
104 m_innerNode = other.innerNode(); 104 m_innerNode = other.innerNode();
105 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); 105 m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode();
106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; 106 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame;
107 m_localPoint = other.localPoint(); 107 m_localPoint = other.localPoint();
108 m_innerURLElement = other.URLElement(); 108 m_innerURLElement = other.URLElement();
109 m_scrollbar = other.scrollbar(); 109 m_scrollbar = other.scrollbar();
110 m_isOverWidget = other.isOverWidget(); 110 m_isOverWidget = other.isOverWidget();
111 m_validityRect = other.m_validityRect;
111 112
112 // Only copy the NodeSet in case of list hit test. 113 // Only copy the NodeSet in case of list hit test.
113 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0); 114 m_listBasedTestResult = adoptPtrWillBeNoop(other.m_listBasedTestResult ? new NodeSet(*other.m_listBasedTestResult) : 0);
114 115
115 return *this; 116 return *this;
116 } 117 }
117 118
119 bool HitTestResult::equalForCacheability(const HitTestResult& other) const
120 {
121 return m_hitTestRequest.equalForCacheability(other.m_hitTestRequest)
122 && m_innerNode == other.innerNode()
123 && m_innerPossiblyPseudoNode == other.innerPossiblyPseudoNode()
124 && m_pointInInnerNodeFrame == other.m_pointInInnerNodeFrame
125 && m_localPoint == other.localPoint()
126 && m_innerURLElement == other.URLElement()
127 && m_scrollbar == other.scrollbar()
128 && m_isOverWidget == other.isOverWidget();
129 }
130
131 void HitTestResult::cacheValues(const HitTestResult& other)
132 {
133 *this = other;
134 m_hitTestRequest = other.m_hitTestRequest.type() & ~HitTestRequest::AvoidCac he;
135 }
136
118 DEFINE_TRACE(HitTestResult) 137 DEFINE_TRACE(HitTestResult)
119 { 138 {
120 visitor->trace(m_innerNode); 139 visitor->trace(m_innerNode);
121 visitor->trace(m_innerPossiblyPseudoNode); 140 visitor->trace(m_innerPossiblyPseudoNode);
122 visitor->trace(m_innerURLElement); 141 visitor->trace(m_innerURLElement);
123 visitor->trace(m_scrollbar); 142 visitor->trace(m_scrollbar);
124 #if ENABLE(OILPAN) 143 #if ENABLE(OILPAN)
125 visitor->trace(m_listBasedTestResult); 144 visitor->trace(m_listBasedTestResult);
126 #endif 145 #endif
127 } 146 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 bool HitTestResult::isSelected() const 231 bool HitTestResult::isSelected() const
213 { 232 {
214 if (!m_innerNode) 233 if (!m_innerNode)
215 return false; 234 return false;
216 235
217 if (LocalFrame* frame = m_innerNode->document().frame()) 236 if (LocalFrame* frame = m_innerNode->document().frame())
218 return frame->selection().contains(m_hitTestLocation.point()); 237 return frame->selection().contains(m_hitTestLocation.point());
219 return false; 238 return false;
220 } 239 }
221 240
241 void HitTestResult::setValidityRect(const LayoutRect& rect)
242 {
243 ASSERT(!rect.isEmpty());
244 m_validityRect = rect;
245 }
246
222 String HitTestResult::spellingToolTip(TextDirection& dir) const 247 String HitTestResult::spellingToolTip(TextDirection& dir) const
223 { 248 {
224 dir = LTR; 249 dir = LTR;
225 // Return the tool tip string associated with this point, if any. Only marke rs associated with bad grammar 250 // Return the tool tip string associated with this point, if any. Only marke rs associated with bad grammar
226 // currently supply strings, but maybe someday markers associated with missp elled words will also. 251 // currently supply strings, but maybe someday markers associated with missp elled words will also.
227 if (!m_innerNode) 252 if (!m_innerNode)
228 return String(); 253 return String();
229 254
230 DocumentMarker* marker = m_innerNode->document().markers().markerContainingP oint(m_hitTestLocation.point(), DocumentMarker::Grammar); 255 DocumentMarker* marker = m_innerNode->document().markers().markerContainingP oint(m_hitTestLocation.point(), DocumentMarker::Grammar);
231 if (!marker) 256 if (!marker)
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 else if (isHTMLMapElement(m_innerNode)) 534 else if (isHTMLMapElement(m_innerNode))
510 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement(); 535 imageMapImageElement = toHTMLMapElement(m_innerNode)->imageElement();
511 536
512 if (!imageMapImageElement) 537 if (!imageMapImageElement)
513 return m_innerNode.get(); 538 return m_innerNode.get();
514 539
515 return imageMapImageElement; 540 return imageMapImageElement;
516 } 541 }
517 542
518 } // namespace blink 543 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698