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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXObject.cpp

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 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, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 case MenuItemCheckBoxRole: 458 case MenuItemCheckBoxRole:
459 case MenuItemRadioRole: 459 case MenuItemRadioRole:
460 return true; 460 return true;
461 default: 461 default:
462 return false; 462 return false;
463 } 463 }
464 } 464 }
465 465
466 bool AXObject::isPasswordFieldAndShouldHideValue() const 466 bool AXObject::isPasswordFieldAndShouldHideValue() const
467 { 467 {
468 Settings* settings = document()->settings(); 468 Settings* settings = getDocument()->settings();
469 if (!settings || settings->accessibilityPasswordValuesEnabled()) 469 if (!settings || settings->accessibilityPasswordValuesEnabled())
470 return false; 470 return false;
471 471
472 return isPasswordField(); 472 return isPasswordField();
473 } 473 }
474 474
475 bool AXObject::isClickable() const 475 bool AXObject::isClickable() const
476 { 476 {
477 switch (roleValue()) { 477 switch (roleValue()) {
478 case ButtonRole: 478 case ButtonRole:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 557
558 bool AXObject::isInertOrAriaHidden() const 558 bool AXObject::isInertOrAriaHidden() const
559 { 559 {
560 updateCachedAttributeValuesIfNeeded(); 560 updateCachedAttributeValuesIfNeeded();
561 return m_cachedIsInertOrAriaHidden; 561 return m_cachedIsInertOrAriaHidden;
562 } 562 }
563 563
564 bool AXObject::computeIsInertOrAriaHidden(IgnoredReasons* ignoredReasons) const 564 bool AXObject::computeIsInertOrAriaHidden(IgnoredReasons* ignoredReasons) const
565 { 565 {
566 if (node()) { 566 if (getNode()) {
567 if (node()->isInert()) { 567 if (getNode()->isInert()) {
568 if (ignoredReasons) { 568 if (ignoredReasons) {
569 HTMLDialogElement* dialog = getActiveDialogElement(node()); 569 HTMLDialogElement* dialog = getActiveDialogElement(getNode());
570 if (dialog) { 570 if (dialog) {
571 AXObject* dialogObject = axObjectCache().getOrCreate(dialog) ; 571 AXObject* dialogObject = axObjectCache().getOrCreate(dialog) ;
572 if (dialogObject) 572 if (dialogObject)
573 ignoredReasons->append(IgnoredReason(AXActiveModalDialog , dialogObject)); 573 ignoredReasons->append(IgnoredReason(AXActiveModalDialog , dialogObject));
574 else 574 else
575 ignoredReasons->append(IgnoredReason(AXInert)); 575 ignoredReasons->append(IgnoredReason(AXInert));
576 } else { 576 } else {
577 // TODO(aboxhall): handle inert attribute if it eventuates 577 // TODO(aboxhall): handle inert attribute if it eventuates
578 ignoredReasons->append(IgnoredReason(AXInert)); 578 ignoredReasons->append(IgnoredReason(AXInert));
579 } 579 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 return name(nameFrom, &nameObjects); 696 return name(nameFrom, &nameObjects);
697 } 697 }
698 698
699 String AXObject::name(AXNameFrom& nameFrom, AXObject::AXObjectVector* nameObject s) const 699 String AXObject::name(AXNameFrom& nameFrom, AXObject::AXObjectVector* nameObject s) const
700 { 700 {
701 HeapHashSet<Member<const AXObject>> visited; 701 HeapHashSet<Member<const AXObject>> visited;
702 AXRelatedObjectVector relatedObjects; 702 AXRelatedObjectVector relatedObjects;
703 String text = textAlternative(false, false, visited, nameFrom, &relatedObjec ts, nullptr); 703 String text = textAlternative(false, false, visited, nameFrom, &relatedObjec ts, nullptr);
704 704
705 AccessibilityRole role = roleValue(); 705 AccessibilityRole role = roleValue();
706 if (!node() || (!isHTMLBRElement(node()) && role != StaticTextRole && role ! = InlineTextBoxRole)) 706 if (!getNode() || (!isHTMLBRElement(getNode()) && role != StaticTextRole && role != InlineTextBoxRole))
707 text = collapseWhitespace(text); 707 text = collapseWhitespace(text);
708 708
709 if (nameObjects) { 709 if (nameObjects) {
710 nameObjects->clear(); 710 nameObjects->clear();
711 for (size_t i = 0; i < relatedObjects.size(); i++) 711 for (size_t i = 0; i < relatedObjects.size(); i++)
712 nameObjects->append(relatedObjects[i]->object); 712 nameObjects->append(relatedObjects[i]->object);
713 } 713 }
714 714
715 return text; 715 return text;
716 } 716 }
(...skipping 12 matching lines...) Expand all
729 { 729 {
730 AXNameFrom tmpNameFrom; 730 AXNameFrom tmpNameFrom;
731 return axObj.textAlternative(true, inAriaLabelledByTraversal, visited, tmpNa meFrom, nullptr, nullptr); 731 return axObj.textAlternative(true, inAriaLabelledByTraversal, visited, tmpNa meFrom, nullptr, nullptr);
732 } 732 }
733 733
734 bool AXObject::isHiddenForTextAlternativeCalculation() const 734 bool AXObject::isHiddenForTextAlternativeCalculation() const
735 { 735 {
736 if (equalIgnoringCase(getAttribute(aria_hiddenAttr), "false")) 736 if (equalIgnoringCase(getAttribute(aria_hiddenAttr), "false"))
737 return false; 737 return false;
738 738
739 if (layoutObject()) 739 if (getLayoutObject())
740 return layoutObject()->style()->visibility() != VISIBLE; 740 return getLayoutObject()->style()->visibility() != VISIBLE;
741 741
742 // This is an obscure corner case: if a node has no LayoutObject, that means it's not rendered, 742 // This is an obscure corner case: if a node has no LayoutObject, that means it's not rendered,
743 // but we still may be exploring it as part of a text alternative calculatio n, for example if it 743 // but we still may be exploring it as part of a text alternative calculatio n, for example if it
744 // was explicitly referenced by aria-labelledby. So we need to explicitly ca ll the style resolver 744 // was explicitly referenced by aria-labelledby. So we need to explicitly ca ll the style resolver
745 // to check whether it's invisible or display:none, rather than relying on t he style cached in the 745 // to check whether it's invisible or display:none, rather than relying on t he style cached in the
746 // LayoutObject. 746 // LayoutObject.
747 Document* doc = document(); 747 Document* doc = getDocument();
748 if (doc && doc->frame() && node() && node()->isElementNode()) { 748 if (doc && doc->frame() && getNode() && getNode()->isElementNode()) {
749 RefPtr<ComputedStyle> style = doc->ensureStyleResolver().styleForElement (toElement(node())); 749 RefPtr<ComputedStyle> style = doc->ensureStyleResolver().styleForElement (toElement(getNode()));
750 return style->display() == NONE || style->visibility() != VISIBLE; 750 return style->display() == NONE || style->visibility() != VISIBLE;
751 } 751 }
752 752
753 return false; 753 return false;
754 } 754 }
755 755
756 String AXObject::ariaTextAlternative(bool recursive, bool inAriaLabelledByTraver sal, AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relatedO bjects, NameSources* nameSources, bool* foundTextAlternative) const 756 String AXObject::ariaTextAlternative(bool recursive, bool inAriaLabelledByTraver sal, AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relatedO bjects, NameSources* nameSources, bool* foundTextAlternative) const
757 { 757 {
758 String textAlternative; 758 String textAlternative;
759 bool alreadyVisited = visited.contains(this); 759 bool alreadyVisited = visited.contains(this);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 847 }
848 if (!foundValidElement) 848 if (!foundValidElement)
849 return String(); 849 return String();
850 if (relatedObjects) 850 if (relatedObjects)
851 *relatedObjects = localRelatedObjects; 851 *relatedObjects = localRelatedObjects;
852 return accumulatedText.toString(); 852 return accumulatedText.toString();
853 } 853 }
854 854
855 void AXObject::tokenVectorFromAttribute(Vector<String>& tokens, const QualifiedN ame& attribute) const 855 void AXObject::tokenVectorFromAttribute(Vector<String>& tokens, const QualifiedN ame& attribute) const
856 { 856 {
857 Node* node = this->node(); 857 Node* node = this->getNode();
858 if (!node || !node->isElementNode()) 858 if (!node || !node->isElementNode())
859 return; 859 return;
860 860
861 String attributeValue = getAttribute(attribute).string(); 861 String attributeValue = getAttribute(attribute).string();
862 if (attributeValue.isEmpty()) 862 if (attributeValue.isEmpty())
863 return; 863 return;
864 864
865 attributeValue.simplifyWhiteSpace(); 865 attributeValue.simplifyWhiteSpace();
866 attributeValue.split(' ', tokens); 866 attributeValue.split(' ', tokens);
867 } 867 }
868 868
869 void AXObject::elementsFromAttribute(WillBeHeapVector<RawPtrWillBeMember<Element >>& elements, const QualifiedName& attribute) const 869 void AXObject::elementsFromAttribute(WillBeHeapVector<RawPtrWillBeMember<Element >>& elements, const QualifiedName& attribute) const
870 { 870 {
871 Vector<String> ids; 871 Vector<String> ids;
872 tokenVectorFromAttribute(ids, attribute); 872 tokenVectorFromAttribute(ids, attribute);
873 if (ids.isEmpty()) 873 if (ids.isEmpty())
874 return; 874 return;
875 875
876 TreeScope& scope = node()->treeScope(); 876 TreeScope& scope = getNode()->treeScope();
877 for (const auto& id : ids) { 877 for (const auto& id : ids) {
878 if (Element* idElement = scope.getElementById(AtomicString(id))) 878 if (Element* idElement = scope.getElementById(AtomicString(id)))
879 elements.append(idElement); 879 elements.append(idElement);
880 } 880 }
881 } 881 }
882 882
883 void AXObject::ariaLabelledbyElementVector(WillBeHeapVector<RawPtrWillBeMember<E lement>>& elements) const 883 void AXObject::ariaLabelledbyElementVector(WillBeHeapVector<RawPtrWillBeMember<E lement>>& elements) const
884 { 884 {
885 // Try both spellings, but prefer aria-labelledby, which is the official spe c. 885 // Try both spellings, but prefer aria-labelledby, which is the official spe c.
886 elementsFromAttribute(elements, aria_labelledbyAttr); 886 elementsFromAttribute(elements, aria_labelledbyAttr);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 AccessibilityRole role = ariaRoleAttribute(); 954 AccessibilityRole role = ariaRoleAttribute();
955 if (role == CheckBoxRole || role == MenuItemCheckBoxRole) 955 if (role == CheckBoxRole || role == MenuItemCheckBoxRole)
956 return ButtonStateMixed; 956 return ButtonStateMixed;
957 } 957 }
958 958
959 return ButtonStateOff; 959 return ButtonStateOff;
960 } 960 }
961 961
962 bool AXObject::isMultiline() const 962 bool AXObject::isMultiline() const
963 { 963 {
964 Node* node = this->node(); 964 Node* node = this->getNode();
965 if (!node) 965 if (!node)
966 return false; 966 return false;
967 967
968 if (isHTMLTextAreaElement(*node)) 968 if (isHTMLTextAreaElement(*node))
969 return true; 969 return true;
970 970
971 if (node->hasEditableStyle()) 971 if (node->hasEditableStyle())
972 return true; 972 return true;
973 973
974 if (!isNativeTextControl() && !isNonNativeTextControl()) 974 if (!isNativeTextControl() && !isNonNativeTextControl())
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 void AXObject::clearChildren() 1175 void AXObject::clearChildren()
1176 { 1176 {
1177 // Detach all weak pointers from objects to their parents. 1177 // Detach all weak pointers from objects to their parents.
1178 for (const auto& child : m_children) 1178 for (const auto& child : m_children)
1179 child->detachFromParent(); 1179 child->detachFromParent();
1180 1180
1181 m_children.clear(); 1181 m_children.clear();
1182 m_haveChildren = false; 1182 m_haveChildren = false;
1183 } 1183 }
1184 1184
1185 Document* AXObject::document() const 1185 Document* AXObject::getDocument() const
1186 { 1186 {
1187 FrameView* frameView = documentFrameView(); 1187 FrameView* frameView = documentFrameView();
1188 if (!frameView) 1188 if (!frameView)
1189 return 0; 1189 return 0;
1190 1190
1191 return frameView->frame().document(); 1191 return frameView->frame().document();
1192 } 1192 }
1193 1193
1194 FrameView* AXObject::documentFrameView() const 1194 FrameView* AXObject::documentFrameView() const
1195 { 1195 {
(...skipping 10 matching lines...) Expand all
1206 String AXObject::language() const 1206 String AXObject::language() const
1207 { 1207 {
1208 const AtomicString& lang = getAttribute(langAttr); 1208 const AtomicString& lang = getAttribute(langAttr);
1209 if (!lang.isEmpty()) 1209 if (!lang.isEmpty())
1210 return lang; 1210 return lang;
1211 1211
1212 AXObject* parent = parentObject(); 1212 AXObject* parent = parentObject();
1213 1213
1214 // as a last resort, fall back to the content language specified in the meta tag 1214 // as a last resort, fall back to the content language specified in the meta tag
1215 if (!parent) { 1215 if (!parent) {
1216 Document* doc = document(); 1216 Document* doc = getDocument();
1217 if (doc) 1217 if (doc)
1218 return doc->contentLanguage(); 1218 return doc->contentLanguage();
1219 return nullAtom; 1219 return nullAtom;
1220 } 1220 }
1221 1221
1222 return parent->language(); 1222 return parent->language();
1223 } 1223 }
1224 1224
1225 bool AXObject::hasAttribute(const QualifiedName& attribute) const 1225 bool AXObject::hasAttribute(const QualifiedName& attribute) const
1226 { 1226 {
1227 Node* elementNode = node(); 1227 Node* elementNode = getNode();
1228 if (!elementNode) 1228 if (!elementNode)
1229 return false; 1229 return false;
1230 1230
1231 if (!elementNode->isElementNode()) 1231 if (!elementNode->isElementNode())
1232 return false; 1232 return false;
1233 1233
1234 Element* element = toElement(elementNode); 1234 Element* element = toElement(elementNode);
1235 return element->fastHasAttribute(attribute); 1235 return element->fastHasAttribute(attribute);
1236 } 1236 }
1237 1237
1238 const AtomicString& AXObject::getAttribute(const QualifiedName& attribute) const 1238 const AtomicString& AXObject::getAttribute(const QualifiedName& attribute) const
1239 { 1239 {
1240 Node* elementNode = node(); 1240 Node* elementNode = getNode();
1241 if (!elementNode) 1241 if (!elementNode)
1242 return nullAtom; 1242 return nullAtom;
1243 1243
1244 if (!elementNode->isElementNode()) 1244 if (!elementNode->isElementNode())
1245 return nullAtom; 1245 return nullAtom;
1246 1246
1247 Element* element = toElement(elementNode); 1247 Element* element = toElement(elementNode);
1248 return element->fastGetAttribute(attribute); 1248 return element->fastGetAttribute(attribute);
1249 } 1249 }
1250 1250
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 } 1524 }
1525 1525
1526 void AXObject::selectionChanged() 1526 void AXObject::selectionChanged()
1527 { 1527 {
1528 if (AXObject* parent = parentObjectIfExists()) 1528 if (AXObject* parent = parentObjectIfExists())
1529 parent->selectionChanged(); 1529 parent->selectionChanged();
1530 } 1530 }
1531 1531
1532 int AXObject::lineForPosition(const VisiblePosition& position) const 1532 int AXObject::lineForPosition(const VisiblePosition& position) const
1533 { 1533 {
1534 if (position.isNull() || !node()) 1534 if (position.isNull() || !getNode())
1535 return -1; 1535 return -1;
1536 1536
1537 // If the position is not in the same editable region as this AX object, ret urn -1. 1537 // If the position is not in the same editable region as this AX object, ret urn -1.
1538 Node* containerNode = position.deepEquivalent().computeContainerNode(); 1538 Node* containerNode = position.deepEquivalent().computeContainerNode();
1539 if (!containerNode->containsIncludingShadowDOM(node()) && !node()->containsI ncludingShadowDOM(containerNode)) 1539 if (!containerNode->containsIncludingShadowDOM(getNode()) && !getNode()->con tainsIncludingShadowDOM(containerNode))
1540 return -1; 1540 return -1;
1541 1541
1542 int lineCount = -1; 1542 int lineCount = -1;
1543 VisiblePosition currentPosition = position; 1543 VisiblePosition currentPosition = position;
1544 VisiblePosition previousPosition; 1544 VisiblePosition previousPosition;
1545 1545
1546 // move up until we get to the top 1546 // move up until we get to the top
1547 // FIXME: This only takes us to the top of the rootEditableElement, not the top of the 1547 // FIXME: This only takes us to the top of the rootEditableElement, not the top of the
1548 // top document. 1548 // top document.
1549 do { 1549 do {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 1688
1689 DEFINE_TRACE(AXObject) 1689 DEFINE_TRACE(AXObject)
1690 { 1690 {
1691 visitor->trace(m_children); 1691 visitor->trace(m_children);
1692 visitor->trace(m_parent); 1692 visitor->trace(m_parent);
1693 visitor->trace(m_cachedLiveRegionRoot); 1693 visitor->trace(m_cachedLiveRegionRoot);
1694 visitor->trace(m_axObjectCache); 1694 visitor->trace(m_axObjectCache);
1695 } 1695 }
1696 1696
1697 } // namespace blink 1697 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698