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

Side by Side Diff: Source/core/dom/TreeScope.cpp

Issue 1177123003: Revert "Implement a Hit Test Cache for same point hits." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/frame/FrameView.cpp » ('j') | 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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 pointInDocument.moveBy(frameView->scrollPosition()); 255 pointInDocument.moveBy(frameView->scrollPosition());
256 IntPoint roundedPointInDocument = roundedIntPoint(pointInDocument); 256 IntPoint roundedPointInDocument = roundedIntPoint(pointInDocument);
257 257
258 if (!frameView->visibleContentRect().contains(roundedPointInDocument)) 258 if (!frameView->visibleContentRect().contains(roundedPointInDocument))
259 return false; 259 return false;
260 260
261 point = roundedPointInDocument; 261 point = roundedPointInDocument;
262 return true; 262 return true;
263 } 263 }
264 264
265 HitTestResult hitTestInDocument(const Document* document, int x, int y, const Hi tTestRequest& request) 265 HitTestResult hitTestInDocument(const Document* document, int x, int y)
266 { 266 {
267 IntPoint hitPoint(x, y); 267 IntPoint hitPoint(x, y);
268 if (!pointWithScrollAndZoomIfPossible(*document, hitPoint)) 268 if (!pointWithScrollAndZoomIfPossible(*document, hitPoint))
269 return HitTestResult(); 269 return HitTestResult();
270 270
271 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
271 HitTestResult result(request, hitPoint); 272 HitTestResult result(request, hitPoint);
272 document->layoutView()->hitTest(result); 273 document->layoutView()->hitTest(result);
273 return result; 274 return result;
274 } 275 }
275 276
276 Element* TreeScope::elementFromPoint(int x, int y) const 277 Element* TreeScope::elementFromPoint(int x, int y) const
277 { 278 {
278 return hitTestPoint(x, y, HitTestRequest::ReadOnly | HitTestRequest::Active) ; 279 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y);
279 }
280
281 Element* TreeScope::elementFromPointNoCache(int x, int y) const
282 {
283 return hitTestPoint(x, y, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AvoidCache);
284 }
285
286 Element* TreeScope::hitTestPoint(int x, int y, const HitTestRequest& request) co nst
287 {
288 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y, reque st);
289 Node* node = result.innerNode(); 280 Node* node = result.innerNode();
290 if (!node || node->isDocumentNode()) 281 if (!node || node->isDocumentNode())
291 return 0; 282 return 0;
292 if (node->isPseudoElement() || node->isTextNode()) 283 if (node->isPseudoElement() || node->isTextNode())
293 node = node->parentOrShadowHostNode(); 284 node = node->parentOrShadowHostNode();
294 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); 285 ASSERT(!node || node->isElementNode() || node->isShadowRoot());
295 node = ancestorInThisScope(node); 286 node = ancestorInThisScope(node);
296 if (!node || !node->isElementNode()) 287 if (!node || !node->isElementNode())
297 return 0; 288 return 0;
298 return toElement(node); 289 return toElement(node);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 visitor->trace(m_parentTreeScope); 575 visitor->trace(m_parentTreeScope);
585 visitor->trace(m_idTargetObserverRegistry); 576 visitor->trace(m_idTargetObserverRegistry);
586 visitor->trace(m_selection); 577 visitor->trace(m_selection);
587 visitor->trace(m_elementsById); 578 visitor->trace(m_elementsById);
588 visitor->trace(m_imageMapsByName); 579 visitor->trace(m_imageMapsByName);
589 visitor->trace(m_labelsByForAttribute); 580 visitor->trace(m_labelsByForAttribute);
590 visitor->trace(m_scopedStyleResolver); 581 visitor->trace(m_scopedStyleResolver);
591 } 582 }
592 583
593 } // namespace blink 584 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698