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

Side by Side Diff: Source/core/accessibility/AccessibilityRenderObject.cpp

Issue 18888002: Introduce isHTMLAnchorElement and toHTMLAnchorElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // Mozilla considers linkable. 504 // Mozilla considers linkable.
505 return object.isLink() || object.isImage() || object.renderer()->isText(); 505 return object.isLink() || object.isImage() || object.renderer()->isText();
506 } 506 }
507 507
508 bool AccessibilityRenderObject::isLinked() const 508 bool AccessibilityRenderObject::isLinked() const
509 { 509 {
510 if (!isLinkable(*this)) 510 if (!isLinkable(*this))
511 return false; 511 return false;
512 512
513 Element* anchor = anchorElement(); 513 Element* anchor = anchorElement();
514 if (!anchor || !anchor->hasTagName(aTag)) 514 if (!anchor || !isHTMLAnchorElement(anchor))
515 return false; 515 return false;
516 516
517 return !static_cast<HTMLAnchorElement*>(anchor)->href().isEmpty(); 517 return !toHTMLAnchorElement(anchor)->href().isEmpty();
518 } 518 }
519 519
520 bool AccessibilityRenderObject::isLoaded() const 520 bool AccessibilityRenderObject::isLoaded() const
521 { 521 {
522 return !m_renderer->document()->parser(); 522 return !m_renderer->document()->parser();
523 } 523 }
524 524
525 bool AccessibilityRenderObject::isOffScreen() const 525 bool AccessibilityRenderObject::isOffScreen() const
526 { 526 {
527 ASSERT(m_renderer); 527 ASSERT(m_renderer);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 return 0; 921 return 0;
922 HTMLLabelElement* label = labelForElement(toElement(node)); 922 HTMLLabelElement* label = labelForElement(toElement(node));
923 if (label && label->renderer()) 923 if (label && label->renderer())
924 return axObjectCache()->getOrCreate(label); 924 return axObjectCache()->getOrCreate(label);
925 925
926 return 0; 926 return 0;
927 } 927 }
928 928
929 KURL AccessibilityRenderObject::url() const 929 KURL AccessibilityRenderObject::url() const
930 { 930 {
931 if (isAnchor() && m_renderer->node()->hasTagName(aTag)) { 931 if (isAnchor() && isHTMLAnchorElement(m_renderer->node())) {
932 if (HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(anchorEl ement())) 932 if (HTMLAnchorElement* anchor = toHTMLAnchorElement(anchorElement()))
933 return anchor->href(); 933 return anchor->href();
934 } 934 }
935 935
936 if (isWebArea()) 936 if (isWebArea())
937 return m_renderer->document()->url(); 937 return m_renderer->document()->url();
938 938
939 if (isImage() && m_renderer->node() && m_renderer->node()->hasTagName(imgTag )) 939 if (isImage() && m_renderer->node() && m_renderer->node()->hasTagName(imgTag ))
940 return toHTMLImageElement(m_renderer->node())->src(); 940 return toHTMLImageElement(m_renderer->node())->src();
941 941
942 if (isInputImage()) 942 if (isInputImage())
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 } 1657 }
1658 1658
1659 // bail if none found 1659 // bail if none found
1660 if (!currRenderer) 1660 if (!currRenderer)
1661 return 0; 1661 return 0;
1662 1662
1663 // search up the DOM tree for an anchor element 1663 // search up the DOM tree for an anchor element
1664 // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElem ent 1664 // NOTE: this assumes that any non-image with an anchor is an HTMLAnchorElem ent
1665 Node* node = currRenderer->node(); 1665 Node* node = currRenderer->node();
1666 for ( ; node; node = node->parentNode()) { 1666 for ( ; node; node = node->parentNode()) {
1667 if (node->hasTagName(aTag) || (node->renderer() && cache->getOrCreate(no de->renderer())->isAnchor())) 1667 if (isHTMLAnchorElement(node) || (node->renderer() && cache->getOrCreate (node->renderer())->isAnchor()))
1668 return toElement(node); 1668 return toElement(node);
1669 } 1669 }
1670 1670
1671 return 0; 1671 return 0;
1672 } 1672 }
1673 1673
1674 Widget* AccessibilityRenderObject::widgetForAttachmentView() const 1674 Widget* AccessibilityRenderObject::widgetForAttachmentView() const
1675 { 1675 {
1676 if (!isAttachment()) 1676 if (!isAttachment())
1677 return 0; 1677 return 0;
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 return false; 2076 return false;
2077 } 2077 }
2078 2078
2079 AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const 2079 AccessibilityObject* AccessibilityRenderObject::internalLinkElement() const
2080 { 2080 {
2081 Element* element = anchorElement(); 2081 Element* element = anchorElement();
2082 if (!element) 2082 if (!element)
2083 return 0; 2083 return 0;
2084 2084
2085 // Right now, we do not support ARIA links as internal link elements 2085 // Right now, we do not support ARIA links as internal link elements
2086 if (!element->hasTagName(aTag)) 2086 if (!isHTMLAnchorElement(element))
2087 return 0; 2087 return 0;
2088 HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(element); 2088 HTMLAnchorElement* anchor = toHTMLAnchorElement(element);
2089 2089
2090 KURL linkURL = anchor->href(); 2090 KURL linkURL = anchor->href();
2091 String fragmentIdentifier = linkURL.fragmentIdentifier(); 2091 String fragmentIdentifier = linkURL.fragmentIdentifier();
2092 if (fragmentIdentifier.isEmpty()) 2092 if (fragmentIdentifier.isEmpty())
2093 return 0; 2093 return 0;
2094 2094
2095 // check if URL is the same as current URL 2095 // check if URL is the same as current URL
2096 KURL documentURL = m_renderer->document()->url(); 2096 KURL documentURL = m_renderer->document()->url();
2097 if (!equalIgnoringFragmentIdentifier(documentURL, linkURL)) 2097 if (!equalIgnoringFragmentIdentifier(documentURL, linkURL))
2098 return 0; 2098 return 0;
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 if (label && label->renderer()) { 2511 if (label && label->renderer()) {
2512 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2512 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2513 result.unite(labelRect); 2513 result.unite(labelRect);
2514 } 2514 }
2515 } 2515 }
2516 2516
2517 return result; 2517 return result;
2518 } 2518 }
2519 2519
2520 } // namespace WebCore 2520 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AccessibilityNodeObject.cpp ('k') | Source/core/css/CSSDefaultStyleSheets.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698