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

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

Issue 1435113003: Make use of new AX name calc in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeVox and Automation API tests Created 5 years, 1 month 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 * Copyright (C) 2008 Nuanti Ltd. 3 * Copyright (C) 2008 Nuanti Ltd.
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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // The potential native HTML-based text (name, description or placeholder) sourc es for an element. 330 // The potential native HTML-based text (name, description or placeholder) sourc es for an element.
331 // See http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name- and-description-calculation 331 // See http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name- and-description-calculation
332 enum AXTextFromNativeHTML { 332 enum AXTextFromNativeHTML {
333 AXTextFromNativeHTMLUninitialized = -1, 333 AXTextFromNativeHTMLUninitialized = -1,
334 AXTextFromNativeHTMLFigcaption, 334 AXTextFromNativeHTMLFigcaption,
335 AXTextFromNativeHTMLLabel, 335 AXTextFromNativeHTMLLabel,
336 AXTextFromNativeHTMLLabelFor, 336 AXTextFromNativeHTMLLabelFor,
337 AXTextFromNativeHTMLLabelWrapped, 337 AXTextFromNativeHTMLLabelWrapped,
338 AXTextFromNativeHTMLLegend, 338 AXTextFromNativeHTMLLegend,
339 AXTextFromNativeHTMLTableCaption, 339 AXTextFromNativeHTMLTableCaption,
340 AXTextFromNativeHTMLTitleElement,
340 }; 341 };
341 342
342 // The source of the accessible description of an element. This is needed 343 // The source of the accessible description of an element. This is needed
343 // because on some platforms this determines how the accessible description 344 // because on some platforms this determines how the accessible description
344 // is exposed. 345 // is exposed.
345 enum AXDescriptionFrom { 346 enum AXDescriptionFrom {
346 AXDescriptionFromUninitialized = -1, 347 AXDescriptionFromUninitialized = -1,
347 AXDescriptionFromAttribute = 0, 348 AXDescriptionFromAttribute = 0,
348 AXDescriptionFromContents, 349 AXDescriptionFromContents,
349 AXDescriptionFromPlaceholder, 350 AXDescriptionFromPlaceholder,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 bool isDescendantOfLeafNode() const; 662 bool isDescendantOfLeafNode() const;
662 AXObject* leafNodeAncestor() const; 663 AXObject* leafNodeAncestor() const;
663 bool isDescendantOfDisabledNode() const; 664 bool isDescendantOfDisabledNode() const;
664 const AXObject* disabledAncestor() const; 665 const AXObject* disabledAncestor() const;
665 bool lastKnownIsIgnoredValue(); 666 bool lastKnownIsIgnoredValue();
666 void setLastKnownIsIgnoredValue(bool); 667 void setLastKnownIsIgnoredValue(bool);
667 bool hasInheritedPresentationalRole() const; 668 bool hasInheritedPresentationalRole() const;
668 bool isPresentationalChild() const; 669 bool isPresentationalChild() const;
669 670
670 // 671 //
671 // Deprecated text alternative calculation API. All of these will be replace d 672 // Accessible name calculation
672 // with the new API, below (under "New text alternative calculation API".
673 //
674
675 virtual bool deprecatedExposesTitleUIElement() const { return true; }
676 virtual AXObject* deprecatedTitleUIElement() const { return 0; }
677 virtual String deprecatedPlaceholder() const { return String(); }
678 virtual void deprecatedAriaDescribedbyElements(AXObjectVector& describedby) const { }
679 virtual void deprecatedAriaLabelledbyElements(AXObjectVector& labelledby) co nst { }
680 virtual String deprecatedAccessibilityDescription() const { return String(); }
681 virtual String deprecatedTitle(TextUnderElementMode mode = TextUnderElementA ll) const { return String(); }
682 virtual String deprecatedHelpText() const { return String(); }
683 virtual String deprecatedTextUnderElement(TextUnderElementMode mode = TextUn derElementAll) const { return String(); }
684
685 //
686 // New text alternative calculation API (under development).
687 // 673 //
688 674
689 // Retrieves the accessible name of the object, an enum indicating where the name 675 // Retrieves the accessible name of the object, an enum indicating where the name
690 // was derived from, and a list of objects that were used to derive the name , if any. 676 // was derived from, and a list of objects that were used to derive the name , if any.
691 virtual String name(AXNameFrom&, AXObjectVector* nameObjects) const; 677 virtual String name(AXNameFrom&, AXObjectVector* nameObjects) const;
692 678
693 typedef HeapVector<NameSource> NameSources; 679 typedef HeapVector<NameSource> NameSources;
694 // Retrieves the accessible name of the object and a list of all potential s ources 680 // Retrieves the accessible name of the object and a list of all potential s ources
695 // for the name, indicating which were used. 681 // for the name, indicating which were used.
696 virtual String name(NameSources*) const; 682 virtual String name(NameSources*) const;
697 683
698 typedef HeapVector<DescriptionSource> DescriptionSources; 684 typedef HeapVector<DescriptionSource> DescriptionSources;
699 // Takes the result of nameFrom from calling |name|, above, and retrieves th e 685 // Takes the result of nameFrom from calling |name|, above, and retrieves th e
700 // accessible description of the object, which is secondary to |name|, an en um indicating 686 // accessible description of the object, which is secondary to |name|, an en um indicating
701 // where the description was derived from, and a list of objects that were u sed to 687 // where the description was derived from, and a list of objects that were u sed to
702 // derive the description, if any. 688 // derive the description, if any.
703 virtual String description(AXNameFrom, AXDescriptionFrom&, AXObjectVector* d escriptionObjects) const { return String(); } 689 virtual String description(AXNameFrom, AXDescriptionFrom&, AXObjectVector* d escriptionObjects) const { return String(); }
704 690
705 // Same as above, but returns a list of all potential sources for the descri ption, indicating which were used. 691 // Same as above, but returns a list of all potential sources for the descri ption, indicating which were used.
706 virtual String description(AXNameFrom, AXDescriptionFrom&, DescriptionSource s*, AXRelatedObjectVector*) const { return String(); } 692 virtual String description(AXNameFrom, AXDescriptionFrom&, DescriptionSource s*, AXRelatedObjectVector*) const { return String(); }
707 693
708 // Takes the result of nameFrom and descriptionFrom from calling |name| and |description|, 694 // Takes the result of nameFrom and descriptionFrom from calling |name| and |description|,
709 // above, and retrieves the placeholder of the object, if present and if it wasn't already 695 // above, and retrieves the placeholder of the object, if present and if it wasn't already
710 // exposed by one of the two functions above. 696 // exposed by one of the two functions above.
711 virtual String placeholder(AXNameFrom, AXDescriptionFrom) { return String(); } 697 virtual String placeholder(AXNameFrom, AXDescriptionFrom) const { return Str ing(); }
712 698
713 // Internal function used by name and description, above. 699 // Internal function used by name and description, above.
714 typedef HeapHashSet<Member<const AXObject>> AXObjectSet; 700 typedef HeapHashSet<Member<const AXObject>> AXObjectSet;
715 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa l, AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relatedObj ects, NameSources* nameSources) const { return String(); } 701 virtual String textAlternative(bool recursive, bool inAriaLabelledByTraversa l, AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relatedObj ects, NameSources* nameSources) const { return String(); }
716 702
717 // Returns result of Accessible Name Calculation algorithm. 703 // Returns result of Accessible Name Calculation algorithm.
718 // This is a simpler high-level interface to |name| used by Inspector. 704 // This is a simpler high-level interface to |name| used by Inspector.
719 virtual String computedName() const { return String(); } 705 String computedName() const;
720 706
721 // 707 //
722 // Properties of static elements. 708 // Properties of static elements.
723 // 709 //
724 710
725 virtual const AtomicString& accessKey() const { return nullAtom; } 711 virtual const AtomicString& accessKey() const { return nullAtom; }
726 virtual RGBA32 backgroundColor() const { return Color::transparent; } 712 virtual RGBA32 backgroundColor() const { return Color::transparent; }
727 virtual RGBA32 color() const { return Color::black; } 713 virtual RGBA32 color() const { return Color::black; }
728 // Used by objects of role ColorWellRole. 714 // Used by objects of role ColorWellRole.
729 virtual RGBA32 colorValue() const { return Color::transparent; } 715 virtual RGBA32 colorValue() const { return Color::transparent; }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 virtual float minValueForRange() const { return 0.0f; } 753 virtual float minValueForRange() const { return 0.0f; }
768 virtual String stringValue() const { return String(); } 754 virtual String stringValue() const { return String(); }
769 755
770 // ARIA attributes. 756 // ARIA attributes.
771 virtual AXObject* activeDescendant() const { return 0; } 757 virtual AXObject* activeDescendant() const { return 0; }
772 virtual String ariaAutoComplete() const { return String(); } 758 virtual String ariaAutoComplete() const { return String(); }
773 virtual String ariaDescribedByAttribute() const { return String(); } 759 virtual String ariaDescribedByAttribute() const { return String(); }
774 virtual void ariaFlowToElements(AXObjectVector&) const { } 760 virtual void ariaFlowToElements(AXObjectVector&) const { }
775 virtual void ariaControlsElements(AXObjectVector&) const { } 761 virtual void ariaControlsElements(AXObjectVector&) const { }
776 virtual void ariaOwnsElements(AXObjectVector& owns) const { } 762 virtual void ariaOwnsElements(AXObjectVector& owns) const { }
763 virtual void ariaDescribedbyElements(AXObjectVector&) const { }
764 virtual void ariaLabelledbyElements(AXObjectVector&) const { }
777 virtual bool ariaHasPopup() const { return false; } 765 virtual bool ariaHasPopup() const { return false; }
778 virtual bool isEditable() const { return false; } 766 virtual bool isEditable() const { return false; }
779 bool isMultiline() const; 767 bool isMultiline() const;
780 virtual bool isRichlyEditable() const { return false; } 768 virtual bool isRichlyEditable() const { return false; }
781 virtual String ariaLabelledbyAttribute() const { return String(); } 769 virtual String ariaLabelledbyAttribute() const { return String(); }
782 bool ariaPressedIsPresent() const; 770 bool ariaPressedIsPresent() const;
783 virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; } 771 virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; }
784 virtual bool ariaRoleHasPresentationalChildren() const { return false; } 772 virtual bool ariaRoleHasPresentationalChildren() const { return false; }
785 virtual AXObject* ancestorForWhichThisIsAPresentationalChild() const { retur n 0; } 773 virtual AXObject* ancestorForWhichThisIsAPresentationalChild() const { retur n 0; }
786 virtual bool shouldFocusActiveDescendant() const { return false; } 774 virtual bool shouldFocusActiveDescendant() const { return false; }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 mutable bool m_haveChildren; 923 mutable bool m_haveChildren;
936 AccessibilityRole m_role; 924 AccessibilityRole m_role;
937 AXObjectInclusion m_lastKnownIsIgnoredValue; 925 AXObjectInclusion m_lastKnownIsIgnoredValue;
938 LayoutRect m_explicitElementRect; 926 LayoutRect m_explicitElementRect;
939 927
940 // Used only in recursive calls from textAlternative() 928 // Used only in recursive calls from textAlternative()
941 static String recursiveTextAlternative(const AXObject&, bool inAriaLabelledB yTraversal, AXObjectSet& visited); 929 static String recursiveTextAlternative(const AXObject&, bool inAriaLabelledB yTraversal, AXObjectSet& visited);
942 930
943 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; } 931 virtual const AXObject* inheritsPresentationalRoleFrom() const { return 0; }
944 932
945 bool nameFromContents() const; 933 virtual bool nameFromContents() const;
946 934
947 AccessibilityRole buttonRoleType() const; 935 AccessibilityRole buttonRoleType() const;
948 936
949 unsigned getLengthForTextRange() const { return text().length(); } 937 unsigned getLengthForTextRange() const { return text().length(); }
950 938
951 bool m_detached; 939 bool m_detached;
952 940
953 mutable Member<AXObject> m_parent; 941 mutable Member<AXObject> m_parent;
954 942
955 // The following cached attribute values (the ones starting with m_cached*) 943 // The following cached attribute values (the ones starting with m_cached*)
(...skipping 23 matching lines...) Expand all
979 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ 967 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \
980 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate) 968 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, object.pred icate)
981 969
982 } // namespace blink 970 } // namespace blink
983 971
984 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::IgnoredReason); 972 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::IgnoredReason);
985 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NameSource); 973 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NameSource);
986 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource); 974 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource);
987 975
988 #endif // AXObject_h 976 #endif // AXObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698