| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 34 #include "core/dom/NodeTraversal.h" | 34 #include "core/dom/NodeTraversal.h" |
| 35 #include "core/dom/QualifiedName.h" | 35 #include "core/dom/QualifiedName.h" |
| 36 #include "core/dom/Text.h" | 36 #include "core/dom/Text.h" |
| 37 #include "core/dom/shadow/FlatTreeTraversal.h" | 37 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 38 #include "core/editing/EditingUtilities.h" | 38 #include "core/editing/EditingUtilities.h" |
| 39 #include "core/editing/markers/DocumentMarkerController.h" | 39 #include "core/editing/markers/DocumentMarkerController.h" |
| 40 #include "core/frame/FrameView.h" | 40 #include "core/frame/FrameView.h" |
| 41 #include "core/html/HTMLAnchorElement.h" | 41 #include "core/html/HTMLAnchorElement.h" |
| 42 #include "core/html/HTMLDListElement.h" | 42 #include "core/html/HTMLDListElement.h" |
| 43 #include "core/html/HTMLDivElement.h" |
| 43 #include "core/html/HTMLFieldSetElement.h" | 44 #include "core/html/HTMLFieldSetElement.h" |
| 44 #include "core/html/HTMLFrameElementBase.h" | 45 #include "core/html/HTMLFrameElementBase.h" |
| 45 #include "core/html/HTMLImageElement.h" | 46 #include "core/html/HTMLImageElement.h" |
| 46 #include "core/html/HTMLInputElement.h" | 47 #include "core/html/HTMLInputElement.h" |
| 47 #include "core/html/HTMLLabelElement.h" | 48 #include "core/html/HTMLLabelElement.h" |
| 48 #include "core/html/HTMLLegendElement.h" | 49 #include "core/html/HTMLLegendElement.h" |
| 49 #include "core/html/HTMLMediaElement.h" | 50 #include "core/html/HTMLMediaElement.h" |
| 50 #include "core/html/HTMLMeterElement.h" | 51 #include "core/html/HTMLMeterElement.h" |
| 51 #include "core/html/HTMLPlugInElement.h" | 52 #include "core/html/HTMLPlugInElement.h" |
| 52 #include "core/html/HTMLSelectElement.h" | 53 #include "core/html/HTMLSelectElement.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 if (tagNames.contains(parent->tagQName())) | 455 if (tagNames.contains(parent->tagQName())) |
| 455 return true; | 456 return true; |
| 456 } | 457 } |
| 457 return false; | 458 return false; |
| 458 } | 459 } |
| 459 | 460 |
| 460 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { | 461 AccessibilityRole AXNodeObject::nativeAccessibilityRoleIgnoringAria() const { |
| 461 if (!getNode()) | 462 if (!getNode()) |
| 462 return UnknownRole; | 463 return UnknownRole; |
| 463 | 464 |
| 464 // HTMLAnchorElement sets isLink only when it has hrefAttr. | 465 // |HTMLAnchorElement| sets isLink only when it has hrefAttr. |
| 465 // We assume that it is also LinkRole if it has event listners even though it | 466 if (getNode()->isLink()) |
| 466 // doesn't have hrefAttr. | |
| 467 if (getNode()->isLink() || (isHTMLAnchorElement(*getNode()) && isClickable())) | |
| 468 return LinkRole; | 467 return LinkRole; |
| 469 | 468 |
| 469 if (isHTMLAnchorElement(*getNode())) { |
| 470 // We assume that an anchor element is LinkRole if it has event listners |
| 471 // even though it doesn't have hrefAttr. |
| 472 if (isClickable()) |
| 473 return LinkRole; |
| 474 return AnchorRole; |
| 475 } |
| 476 |
| 470 if (isHTMLButtonElement(*getNode())) | 477 if (isHTMLButtonElement(*getNode())) |
| 471 return buttonRoleType(); | 478 return buttonRoleType(); |
| 472 | 479 |
| 473 if (isHTMLDetailsElement(*getNode())) | 480 if (isHTMLDetailsElement(*getNode())) |
| 474 return DetailsRole; | 481 return DetailsRole; |
| 475 | 482 |
| 476 if (isHTMLSummaryElement(*getNode())) { | 483 if (isHTMLSummaryElement(*getNode())) { |
| 477 ContainerNode* parent = FlatTreeTraversal::parent(*getNode()); | 484 ContainerNode* parent = FlatTreeTraversal::parent(*getNode()); |
| 478 if (parent && isHTMLDetailsElement(parent)) | 485 if (parent && isHTMLDetailsElement(parent)) |
| 479 return DisclosureTriangleRole; | 486 return DisclosureTriangleRole; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 660 |
| 654 if (getNode()->nodeName() == "TIME") | 661 if (getNode()->nodeName() == "TIME") |
| 655 return TimeRole; | 662 return TimeRole; |
| 656 | 663 |
| 657 if (isEmbeddedObject()) | 664 if (isEmbeddedObject()) |
| 658 return EmbeddedObjectRole; | 665 return EmbeddedObjectRole; |
| 659 | 666 |
| 660 if (isHTMLHRElement(*getNode())) | 667 if (isHTMLHRElement(*getNode())) |
| 661 return SplitterRole; | 668 return SplitterRole; |
| 662 | 669 |
| 663 if (isFieldset()) { | 670 if (isFieldset()) |
| 664 return GroupRole; | 671 return GroupRole; |
| 665 } | |
| 666 | 672 |
| 667 return UnknownRole; | 673 return UnknownRole; |
| 668 } | 674 } |
| 669 | 675 |
| 670 AccessibilityRole AXNodeObject::determineAccessibilityRole() { | 676 AccessibilityRole AXNodeObject::determineAccessibilityRole() { |
| 671 if (!getNode()) | 677 if (!getNode()) |
| 672 return UnknownRole; | 678 return UnknownRole; |
| 673 | 679 |
| 674 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) | 680 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) |
| 675 return m_ariaRole; | 681 return m_ariaRole; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 if (roleValue() == ButtonRole && isHTMLInputElement(node)) | 979 if (roleValue() == ButtonRole && isHTMLInputElement(node)) |
| 974 return toHTMLInputElement(*node).type() == InputTypeNames::image; | 980 return toHTMLInputElement(*node).type() == InputTypeNames::image; |
| 975 | 981 |
| 976 return false; | 982 return false; |
| 977 } | 983 } |
| 978 | 984 |
| 979 bool AXNodeObject::isLink() const { | 985 bool AXNodeObject::isLink() const { |
| 980 return roleValue() == LinkRole; | 986 return roleValue() == LinkRole; |
| 981 } | 987 } |
| 982 | 988 |
| 989 // It is not easily possible to find out if an element is the target of an |
| 990 // in-page link. |
| 991 // As a workaround, we check if the element is a sectioning element with an ID, |
| 992 // or an anchor with a name. |
| 993 bool AXNodeObject::isInPageLinkTarget() const { |
| 994 if (!m_node || !m_node->isElementNode()) |
| 995 return false; |
| 996 Element* element = toElement(m_node); |
| 997 // We exclude elements that are in the shadow DOM. |
| 998 if (element->containingShadowRoot()) |
| 999 return false; |
| 1000 |
| 1001 if (isHTMLAnchorElement(element)) { |
| 1002 HTMLAnchorElement* htmlElement = toHTMLAnchorElement(element); |
| 1003 return htmlElement->hasName() || htmlElement->hasID(); |
| 1004 } |
| 1005 |
| 1006 if (element->hasID() && (isLandmarkRelated() || isHTMLDivElement(element))) |
| 1007 return true; |
| 1008 return false; |
| 1009 } |
| 1010 |
| 983 bool AXNodeObject::isMenu() const { | 1011 bool AXNodeObject::isMenu() const { |
| 984 return roleValue() == MenuRole; | 1012 return roleValue() == MenuRole; |
| 985 } | 1013 } |
| 986 | 1014 |
| 987 bool AXNodeObject::isMenuButton() const { | 1015 bool AXNodeObject::isMenuButton() const { |
| 988 return roleValue() == MenuButtonRole; | 1016 return roleValue() == MenuButtonRole; |
| 989 } | 1017 } |
| 990 | 1018 |
| 991 bool AXNodeObject::isMeter() const { | 1019 bool AXNodeObject::isMeter() const { |
| 992 return roleValue() == MeterRole; | 1020 return roleValue() == MeterRole; |
| (...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3206 return String(); | 3234 return String(); |
| 3207 return toTextControlElement(node)->strippedPlaceholder(); | 3235 return toTextControlElement(node)->strippedPlaceholder(); |
| 3208 } | 3236 } |
| 3209 | 3237 |
| 3210 DEFINE_TRACE(AXNodeObject) { | 3238 DEFINE_TRACE(AXNodeObject) { |
| 3211 visitor->trace(m_node); | 3239 visitor->trace(m_node); |
| 3212 AXObject::trace(visitor); | 3240 AXObject::trace(visitor); |
| 3213 } | 3241 } |
| 3214 | 3242 |
| 3215 } // namespace blink | 3243 } // namespace blink |
| OLD | NEW |