OLD | NEW |
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 Loading... |
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) | 265 HitTestResult hitTestInDocument(const Document* document, int x, int y, const Hi
tTestRequest& request) |
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); | |
272 HitTestResult result(request, hitPoint); | 271 HitTestResult result(request, hitPoint); |
273 document->layoutView()->hitTest(result); | 272 document->layoutView()->hitTest(result); |
274 return result; | 273 return result; |
275 } | 274 } |
276 | 275 |
277 Element* TreeScope::elementFromPoint(int x, int y) const | 276 Element* TreeScope::elementFromPoint(int x, int y) const |
278 { | 277 { |
279 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y); | 278 return hitTestPoint(x, y, HitTestRequest::ReadOnly | HitTestRequest::Active)
; |
| 279 } |
| 280 |
| 281 Element* TreeScope::hitTestPoint(int x, int y, const HitTestRequest& request) co
nst |
| 282 { |
| 283 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y, reque
st); |
280 Node* node = result.innerNode(); | 284 Node* node = result.innerNode(); |
281 if (!node || node->isDocumentNode()) | 285 if (!node || node->isDocumentNode()) |
282 return 0; | 286 return 0; |
283 if (node->isPseudoElement() || node->isTextNode()) | 287 if (node->isPseudoElement() || node->isTextNode()) |
284 node = node->parentOrShadowHostNode(); | 288 node = node->parentOrShadowHostNode(); |
285 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); | 289 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); |
286 node = ancestorInThisScope(node); | 290 node = ancestorInThisScope(node); |
287 if (!node || !node->isElementNode()) | 291 if (!node || !node->isElementNode()) |
288 return 0; | 292 return 0; |
289 return toElement(node); | 293 return toElement(node); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 visitor->trace(m_parentTreeScope); | 579 visitor->trace(m_parentTreeScope); |
576 visitor->trace(m_idTargetObserverRegistry); | 580 visitor->trace(m_idTargetObserverRegistry); |
577 visitor->trace(m_selection); | 581 visitor->trace(m_selection); |
578 visitor->trace(m_elementsById); | 582 visitor->trace(m_elementsById); |
579 visitor->trace(m_imageMapsByName); | 583 visitor->trace(m_imageMapsByName); |
580 visitor->trace(m_labelsByForAttribute); | 584 visitor->trace(m_labelsByForAttribute); |
581 visitor->trace(m_scopedStyleResolver); | 585 visitor->trace(m_scopedStyleResolver); |
582 } | 586 } |
583 | 587 |
584 } // namespace blink | 588 } // namespace blink |
OLD | NEW |