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