| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/fetch/ImageResource.h" | 32 #include "core/fetch/ImageResource.h" |
| 33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 34 #include "core/html/HTMLAnchorElement.h" | 34 #include "core/html/HTMLAnchorElement.h" |
| 35 #include "core/html/HTMLImageElement.h" | 35 #include "core/html/HTMLImageElement.h" |
| 36 #include "core/html/HTMLInputElement.h" | 36 #include "core/html/HTMLInputElement.h" |
| 37 #include "core/html/HTMLMediaElement.h" | 37 #include "core/html/HTMLMediaElement.h" |
| 38 #include "core/html/parser/HTMLParserIdioms.h" | 38 #include "core/html/parser/HTMLParserIdioms.h" |
| 39 #include "core/page/FrameTree.h" | 39 #include "core/page/FrameTree.h" |
| 40 #include "core/rendering/RenderImage.h" | 40 #include "core/rendering/RenderImage.h" |
| 41 #include "core/rendering/RenderTextFragment.h" | 41 #include "core/rendering/RenderTextFragment.h" |
| 42 #include "core/svg/SVGElement.h" |
| 42 #include "platform/scroll/Scrollbar.h" | 43 #include "platform/scroll/Scrollbar.h" |
| 43 | 44 |
| 44 namespace WebCore { | 45 namespace WebCore { |
| 45 | 46 |
| 46 using namespace HTMLNames; | 47 using namespace HTMLNames; |
| 47 | 48 |
| 48 HitTestResult::HitTestResult() | 49 HitTestResult::HitTestResult() |
| 49 : m_isOverWidget(false) | 50 : m_isOverWidget(false) |
| 50 , m_isFirstLetter(false) | 51 , m_isFirstLetter(false) |
| 51 { | 52 { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 return String(); | 234 return String(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 const AtomicString& HitTestResult::altDisplayString() const | 237 const AtomicString& HitTestResult::altDisplayString() const |
| 237 { | 238 { |
| 238 if (!m_innerNonSharedNode) | 239 if (!m_innerNonSharedNode) |
| 239 return nullAtom; | 240 return nullAtom; |
| 240 | 241 |
| 241 if (m_innerNonSharedNode->hasTagName(imgTag)) { | 242 if (isHTMLImageElement(*m_innerNonSharedNode)) { |
| 242 HTMLImageElement* image = toHTMLImageElement(m_innerNonSharedNode); | 243 HTMLImageElement& image = toHTMLImageElement(*m_innerNonSharedNode); |
| 243 return image->getAttribute(altAttr); | 244 return image.getAttribute(altAttr); |
| 244 } | 245 } |
| 245 | 246 |
| 246 if (m_innerNonSharedNode->hasTagName(inputTag)) { | 247 if (isHTMLInputElement(*m_innerNonSharedNode)) { |
| 247 HTMLInputElement* input = toHTMLInputElement(m_innerNonSharedNode); | 248 HTMLInputElement& input = toHTMLInputElement(*m_innerNonSharedNode); |
| 248 return input->alt(); | 249 return input.alt(); |
| 249 } | 250 } |
| 250 | 251 |
| 251 return nullAtom; | 252 return nullAtom; |
| 252 } | 253 } |
| 253 | 254 |
| 254 Image* HitTestResult::image() const | 255 Image* HitTestResult::image() const |
| 255 { | 256 { |
| 256 if (!m_innerNonSharedNode) | 257 if (!m_innerNonSharedNode) |
| 257 return 0; | 258 return 0; |
| 258 | 259 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 275 | 276 |
| 276 KURL HitTestResult::absoluteImageURL() const | 277 KURL HitTestResult::absoluteImageURL() const |
| 277 { | 278 { |
| 278 if (!m_innerNonSharedNode) | 279 if (!m_innerNonSharedNode) |
| 279 return KURL(); | 280 return KURL(); |
| 280 | 281 |
| 281 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isImage())) | 282 if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->
isImage())) |
| 282 return KURL(); | 283 return KURL(); |
| 283 | 284 |
| 284 AtomicString urlString; | 285 AtomicString urlString; |
| 285 if (m_innerNonSharedNode->hasTagName(embedTag) | 286 if (isHTMLEmbedElement(*m_innerNonSharedNode) |
| 286 || m_innerNonSharedNode->hasTagName(imgTag) | 287 || isHTMLImageElement(*m_innerNonSharedNode) |
| 287 || m_innerNonSharedNode->hasTagName(inputTag) | 288 || isHTMLInputElement(*m_innerNonSharedNode) |
| 288 || m_innerNonSharedNode->hasTagName(objectTag) | 289 || isHTMLObjectElement(*m_innerNonSharedNode) |
| 289 || m_innerNonSharedNode->hasTagName(SVGNames::imageTag) | 290 || isSVGImageElement(*m_innerNonSharedNode) |
| 290 ) { | 291 ) { |
| 291 urlString = toElement(m_innerNonSharedNode)->imageSourceURL(); | 292 urlString = toElement(*m_innerNonSharedNode).imageSourceURL(); |
| 292 } else | 293 } else |
| 293 return KURL(); | 294 return KURL(); |
| 294 | 295 |
| 295 return m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingH
TMLSpaces(urlString)); | 296 return m_innerNonSharedNode->document().completeURL(stripLeadingAndTrailingH
TMLSpaces(urlString)); |
| 296 } | 297 } |
| 297 | 298 |
| 298 KURL HitTestResult::absoluteMediaURL() const | 299 KURL HitTestResult::absoluteMediaURL() const |
| 299 { | 300 { |
| 300 if (HTMLMediaElement* mediaElt = mediaElement()) | 301 if (HTMLMediaElement* mediaElt = mediaElement()) |
| 301 return mediaElt->currentSrc(); | 302 return mediaElt->currentSrc(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 314 return toHTMLMediaElement(m_innerNonSharedNode); | 315 return toHTMLMediaElement(m_innerNonSharedNode); |
| 315 return 0; | 316 return 0; |
| 316 } | 317 } |
| 317 | 318 |
| 318 KURL HitTestResult::absoluteLinkURL() const | 319 KURL HitTestResult::absoluteLinkURL() const |
| 319 { | 320 { |
| 320 if (!m_innerURLElement) | 321 if (!m_innerURLElement) |
| 321 return KURL(); | 322 return KURL(); |
| 322 | 323 |
| 323 AtomicString urlString; | 324 AtomicString urlString; |
| 324 if (m_innerURLElement->hasTagName(aTag) || m_innerURLElement->hasTagName(are
aTag) || m_innerURLElement->hasTagName(linkTag)) | 325 if (isHTMLAnchorElement(*m_innerURLElement) || isHTMLAreaElement(*m_innerURL
Element) || isHTMLLinkElement(*m_innerURLElement)) |
| 325 urlString = m_innerURLElement->getAttribute(hrefAttr); | 326 urlString = m_innerURLElement->getAttribute(hrefAttr); |
| 326 else if (m_innerURLElement->hasTagName(SVGNames::aTag)) | 327 else if (isSVGAElement(*m_innerURLElement)) |
| 327 urlString = m_innerURLElement->getAttribute(XLinkNames::hrefAttr); | 328 urlString = m_innerURLElement->getAttribute(XLinkNames::hrefAttr); |
| 328 else | 329 else |
| 329 return KURL(); | 330 return KURL(); |
| 330 | 331 |
| 331 return m_innerURLElement->document().completeURL(stripLeadingAndTrailingHTML
Spaces(urlString)); | 332 return m_innerURLElement->document().completeURL(stripLeadingAndTrailingHTML
Spaces(urlString)); |
| 332 } | 333 } |
| 333 | 334 |
| 334 bool HitTestResult::isLiveLink() const | 335 bool HitTestResult::isLiveLink() const |
| 335 { | 336 { |
| 336 if (!m_innerURLElement) | 337 if (!m_innerURLElement) |
| 337 return false; | 338 return false; |
| 338 | 339 |
| 339 if (m_innerURLElement->hasTagName(aTag)) | 340 if (isHTMLAnchorElement(*m_innerURLElement)) |
| 340 return toHTMLAnchorElement(m_innerURLElement)->isLiveLink(); | 341 return toHTMLAnchorElement(m_innerURLElement)->isLiveLink(); |
| 341 | 342 |
| 342 if (m_innerURLElement->hasTagName(SVGNames::aTag)) | 343 if (isSVGAElement(*m_innerURLElement)) |
| 343 return m_innerURLElement->isLink(); | 344 return m_innerURLElement->isLink(); |
| 344 | 345 |
| 345 return false; | 346 return false; |
| 346 } | 347 } |
| 347 | 348 |
| 348 bool HitTestResult::isMisspelled() const | 349 bool HitTestResult::isMisspelled() const |
| 349 { | 350 { |
| 350 if (!targetNode() || !targetNode()->renderer()) | 351 if (!targetNode() || !targetNode()->renderer()) |
| 351 return false; | 352 return false; |
| 352 VisiblePosition pos(targetNode()->renderer()->positionForPoint(localPoint())
); | 353 VisiblePosition pos(targetNode()->renderer()->positionForPoint(localPoint())
); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 378 | 379 |
| 379 // FIXME: This function needs a better name and may belong in a different class.
It's not | 380 // FIXME: This function needs a better name and may belong in a different class.
It's not |
| 380 // really isContentEditable(); it's more like needsEditingContextMenu(). In many
ways, this | 381 // really isContentEditable(); it's more like needsEditingContextMenu(). In many
ways, this |
| 381 // function would make more sense in the ContextMenu class, except that WebEleme
ntDictionary | 382 // function would make more sense in the ContextMenu class, except that WebEleme
ntDictionary |
| 382 // hooks into it. Anyway, we should architect this better. | 383 // hooks into it. Anyway, we should architect this better. |
| 383 bool HitTestResult::isContentEditable() const | 384 bool HitTestResult::isContentEditable() const |
| 384 { | 385 { |
| 385 if (!m_innerNonSharedNode) | 386 if (!m_innerNonSharedNode) |
| 386 return false; | 387 return false; |
| 387 | 388 |
| 388 if (m_innerNonSharedNode->hasTagName(textareaTag)) | 389 if (isHTMLTextAreaElement(*m_innerNonSharedNode)) |
| 389 return true; | 390 return true; |
| 390 | 391 |
| 391 if (m_innerNonSharedNode->hasTagName(inputTag)) | 392 if (isHTMLInputElement(*m_innerNonSharedNode)) |
| 392 return toHTMLInputElement(m_innerNonSharedNode)->isTextField(); | 393 return toHTMLInputElement(*m_innerNonSharedNode).isTextField(); |
| 393 | 394 |
| 394 return m_innerNonSharedNode->rendererIsEditable(); | 395 return m_innerNonSharedNode->rendererIsEditable(); |
| 395 } | 396 } |
| 396 | 397 |
| 397 bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
t& request, const HitTestLocation& locationInContainer, const LayoutRect& rect) | 398 bool HitTestResult::addNodeToRectBasedTestResult(Node* node, const HitTestReques
t& request, const HitTestLocation& locationInContainer, const LayoutRect& rect) |
| 398 { | 399 { |
| 399 // If it is not a rect-based hit test, this method has to be no-op. | 400 // If it is not a rect-based hit test, this method has to be no-op. |
| 400 // Return false, so the hit test stops. | 401 // Return false, so the hit test stops. |
| 401 if (!isRectBasedTest()) | 402 if (!isRectBasedTest()) |
| 402 return false; | 403 return false; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 { | 493 { |
| 493 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) { | 494 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) { |
| 494 if (node->isElementNode()) | 495 if (node->isElementNode()) |
| 495 return toElement(node); | 496 return toElement(node); |
| 496 } | 497 } |
| 497 | 498 |
| 498 return 0; | 499 return 0; |
| 499 } | 500 } |
| 500 | 501 |
| 501 } // namespace WebCore | 502 } // namespace WebCore |
| OLD | NEW |