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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return 0; | 206 return 0; |
207 if (!m_imageMapsByName) | 207 if (!m_imageMapsByName) |
208 return 0; | 208 return 0; |
209 size_t hashPos = url.find('#'); | 209 size_t hashPos = url.find('#'); |
210 String name = (hashPos == kNotFound ? url : url.substring(hashPos + 1)).impl
(); | 210 String name = (hashPos == kNotFound ? url : url.substring(hashPos + 1)).impl
(); |
211 if (rootNode()->document().isHTMLDocument()) | 211 if (rootNode()->document().isHTMLDocument()) |
212 return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName
(AtomicString(name.lower()).impl(), this)); | 212 return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName
(AtomicString(name.lower()).impl(), this)); |
213 return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(
name).impl(), this)); | 213 return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(
name).impl(), this)); |
214 } | 214 } |
215 | 215 |
216 RenderObject* rendererFromPoint(Document* document, int x, int y, LayoutPoint* l
ocalPoint) | 216 HitTestResult hitTestInDocument(const Document& document, int x, int y) |
217 { | 217 { |
218 Frame* frame = document->frame(); | 218 Frame* frame = document.frame(); |
219 | 219 |
220 if (!frame) | 220 if (!frame) |
221 return 0; | 221 return HitTestResult(); |
222 FrameView* frameView = frame->view(); | 222 FrameView* frameView = frame->view(); |
223 if (!frameView) | 223 if (!frameView) |
224 return 0; | 224 return HitTestResult(); |
225 | 225 |
226 float scaleFactor = frame->pageZoomFactor(); | 226 float scaleFactor = frame->pageZoomFactor(); |
227 IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + frameView->sc
rollX(), y * scaleFactor + frameView->scrollY())); | 227 IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + frameView->sc
rollX(), y * scaleFactor + frameView->scrollY())); |
228 | 228 |
229 if (!frameView->visibleContentRect().contains(point)) | 229 if (!frameView->visibleContentRect().contains(point)) |
230 return 0; | 230 return HitTestResult(); |
231 | 231 |
232 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); | 232 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H
itTestRequest::ConfusingAndOftenMisusedDisallowShadowContent); |
233 HitTestResult result(point); | 233 HitTestResult result(point); |
234 document->renderView()->hitTest(request, result); | 234 document.renderView()->hitTest(request, result); |
235 | 235 return result; |
236 if (localPoint) | |
237 *localPoint = result.localPoint(); | |
238 | |
239 return result.renderer(); | |
240 } | 236 } |
241 | 237 |
242 Element* TreeScope::elementFromPoint(int x, int y) const | 238 Element* TreeScope::elementFromPoint(int x, int y) const |
243 { | 239 { |
244 RenderObject* renderer = rendererFromPoint(&rootNode()->document(), x, y); | 240 HitTestResult result = hitTestInDocument(rootNode()->document(), x, y); |
245 if (!renderer) | 241 Node* node = result.innerNode(); |
246 return 0; | |
247 Node* node = renderer->node(); | |
248 if (!node) | 242 if (!node) |
249 return 0; | 243 return 0; |
250 if (node->isPseudoElement() || node->isTextNode()) | 244 if (node->isPseudoElement() || node->isTextNode()) |
251 node = node->parentOrShadowHostNode(); | 245 node = node->parentOrShadowHostNode(); |
252 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); | 246 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); |
253 node = ancestorInThisScope(node); | 247 node = ancestorInThisScope(node); |
254 if (!node || !node->isElementNode()) | 248 if (!node || !node->isElementNode()) |
255 return 0; | 249 return 0; |
256 return toElement(node); | 250 return toElement(node); |
257 } | 251 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 result = element; | 486 result = element; |
493 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { | 487 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot;
shadowRoot = shadowRoot->olderShadowRoot()) { |
494 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) | 488 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) |
495 result = shadowResult; | 489 result = shadowResult; |
496 } | 490 } |
497 } | 491 } |
498 return result; | 492 return result; |
499 } | 493 } |
500 | 494 |
501 } // namespace WebCore | 495 } // namespace WebCore |
OLD | NEW |