1 /*
2  * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Nuanti Ltd.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.
12  * Redistributiothird_party/blink/renderer/modules/exported/web_ax_object.ccns
13  * in binary form must reproduce the above copyright notice, this list of
14  * conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution. 3.  Neither the name of Apple
16  * Computer, Inc. ("Apple") nor the names of its contributors may be used to
17  * endorse or promote products derived from this software without specific
18  * prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
21  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
24  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_ACCESSIBILITY_AX_OBJECT_H_
33 #define THIRD_PARTY_BLINK_RENDERER_MODULES_ACCESSIBILITY_AX_OBJECT_H_
34 
35 #include <ostream>
36 
37 #include "base/macros.h"
38 #include "third_party/blink/public/web/web_ax_enums.h"
39 #include "third_party/blink/renderer/core/accessibility/axid.h"
40 #include "third_party/blink/renderer/core/dom/element.h"
41 #include "third_party/blink/renderer/core/editing/markers/document_marker.h"
42 #include "third_party/blink/renderer/core/inspector/protocol/Accessibility.h"
43 #include "third_party/blink/renderer/core/scroll/scroll_alignment.h"
44 #include "third_party/blink/renderer/modules/accessibility/ax_enums.h"
45 #include "third_party/blink/renderer/modules/modules_export.h"
46 #include "third_party/blink/renderer/platform/geometry/float_quad.h"
47 #include "third_party/blink/renderer/platform/geometry/layout_rect.h"
48 #include "third_party/blink/renderer/platform/graphics/color.h"
49 #include "third_party/blink/renderer/platform/heap/handle.h"
50 #include "third_party/blink/renderer/platform/heap/persistent.h"
51 #include "third_party/blink/renderer/platform/weborigin/kurl.h"
52 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
53 #include "third_party/blink/renderer/platform/wtf/vector.h"
54 #include "ui/accessibility/ax_enums.mojom-blink.h"
55 
56 class SkMatrix44;
57 
58 namespace blink {
59 
60 class AccessibleNodeList;
61 class AXObject;
62 class AXObjectCacheImpl;
63 class AXRange;
64 class IntPoint;
65 class LayoutObject;
66 class LocalFrameView;
67 class Node;
68 class ScrollableArea;
69 
70 enum class AOMBooleanProperty;
71 enum class AOMStringProperty;
72 enum class AOMUIntProperty;
73 enum class AOMIntProperty;
74 enum class AOMFloatProperty;
75 enum class AOMRelationProperty;
76 enum class AOMRelationListProperty;
77 
78 class AXSparseAttributeClient {
79  public:
80   virtual void AddBoolAttribute(AXBoolAttribute, bool) = 0;
81   virtual void AddIntAttribute(AXIntAttribute, int32_t) = 0;
82   virtual void AddUIntAttribute(AXUIntAttribute, uint32_t) = 0;
83   virtual void AddStringAttribute(AXStringAttribute, const String&) = 0;
84   virtual void AddObjectAttribute(AXObjectAttribute, AXObject&) = 0;
85   virtual void AddObjectVectorAttribute(AXObjectVectorAttribute,
86                                         HeapVector<Member<AXObject>>&) = 0;
87 };
88 
89 class IgnoredReason {
90   DISALLOW_NEW();
91 
92  public:
93   AXIgnoredReason reason;
94   Member<const AXObject> related_object;
95 
IgnoredReason(AXIgnoredReason reason)96   explicit IgnoredReason(AXIgnoredReason reason)
97       : reason(reason), related_object(nullptr) {}
98 
IgnoredReason(AXIgnoredReason r,const AXObject * obj)99   IgnoredReason(AXIgnoredReason r, const AXObject* obj)
100       : reason(r), related_object(obj) {}
101 
Trace(Visitor * visitor)102   void Trace(Visitor* visitor) { visitor->Trace(related_object); }
103 };
104 
105 class NameSourceRelatedObject final
106     : public GarbageCollected<NameSourceRelatedObject> {
107  public:
108   WeakMember<AXObject> object;
109   String text;
110 
NameSourceRelatedObject(AXObject * object,String text)111   NameSourceRelatedObject(AXObject* object, String text)
112       : object(object), text(text) {}
113 
Trace(Visitor * visitor)114   void Trace(Visitor* visitor) { visitor->Trace(object); }
115 
116   DISALLOW_COPY_AND_ASSIGN(NameSourceRelatedObject);
117 };
118 
119 typedef HeapVector<Member<NameSourceRelatedObject>> AXRelatedObjectVector;
120 class NameSource {
121   DISALLOW_NEW();
122 
123  public:
124   String text;
125   bool superseded = false;
126   bool invalid = false;
127   ax::mojom::NameFrom type = ax::mojom::NameFrom::kUninitialized;
128   const QualifiedName& attribute;
129   AtomicString attribute_value;
130   AXTextFromNativeHTML native_source = kAXTextFromNativeHTMLUninitialized;
131   AXRelatedObjectVector related_objects;
132 
NameSource(bool superseded,const QualifiedName & attr)133   NameSource(bool superseded, const QualifiedName& attr)
134       : superseded(superseded), attribute(attr) {}
135 
NameSource(bool superseded)136   explicit NameSource(bool superseded)
137       : superseded(superseded), attribute(QualifiedName::Null()) {}
138 
Trace(Visitor * visitor)139   void Trace(Visitor* visitor) { visitor->Trace(related_objects); }
140 };
141 
142 class DescriptionSource {
143   DISALLOW_NEW();
144 
145  public:
146   String text;
147   bool superseded = false;
148   bool invalid = false;
149   ax::mojom::DescriptionFrom type = ax::mojom::DescriptionFrom::kUninitialized;
150   const QualifiedName& attribute;
151   AtomicString attribute_value;
152   AXTextFromNativeHTML native_source = kAXTextFromNativeHTMLUninitialized;
153   AXRelatedObjectVector related_objects;
154 
DescriptionSource(bool superseded,const QualifiedName & attr)155   DescriptionSource(bool superseded, const QualifiedName& attr)
156       : superseded(superseded), attribute(attr) {}
157 
DescriptionSource(bool superseded)158   explicit DescriptionSource(bool superseded)
159       : superseded(superseded), attribute(QualifiedName::Null()) {}
160 
Trace(Visitor * visitor)161   void Trace(Visitor* visitor) { visitor->Trace(related_objects); }
162 };
163 
164 }  // namespace blink
165 
166 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::IgnoredReason)
WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NameSource)167 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NameSource)
168 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource)
169 
170 namespace blink {
171 
172 class MODULES_EXPORT AXObject : public GarbageCollected<AXObject> {
173  public:
174   typedef HeapVector<Member<AXObject>> AXObjectVector;
175 
176   // Iterator for doing an in-order traversal of the accessibility tree.
177   // Includes ignored objects in the traversal.
178   class MODULES_EXPORT InOrderTraversalIterator final
179       : public GarbageCollected<InOrderTraversalIterator> {
180    public:
181     ~InOrderTraversalIterator() = default;
182 
183     InOrderTraversalIterator(const InOrderTraversalIterator& other)
184         : current_(other.current_), previous_(other.previous_) {}
185 
186     InOrderTraversalIterator& operator=(const InOrderTraversalIterator& other) {
187       current_ = other.current_;
188       previous_ = other.previous_;
189       return *this;
190     }
191 
192     InOrderTraversalIterator& operator++() {
193       previous_ = current_;
194       current_ = (current_ && !current_->IsDetached())
195                      ? current_->NextInTreeObject()
196                      : nullptr;
197       return *this;
198     }
199 
200     InOrderTraversalIterator operator++(int) {
201       InOrderTraversalIterator ret = *this;
202       ++*this;
203       return ret;
204     }
205 
206     InOrderTraversalIterator& operator--() {
207       current_ = previous_;
208       previous_ = (current_ && !current_->IsDetached())
209                       ? current_->PreviousInTreeObject()
210                       : nullptr;
211       return *this;
212     }
213 
214     InOrderTraversalIterator operator--(int) {
215       InOrderTraversalIterator ret = *this;
216       --*this;
217       return ret;
218     }
219 
220     AXObject& operator*() const {
221       DCHECK(current_);
222       return *current_;
223     }
224 
225     AXObject* operator->() const {
226       DCHECK(current_);
227       return static_cast<AXObject*>(current_);
228     }
229 
230     void Trace(Visitor* visitor) {
231       visitor->Trace(current_);
232       visitor->Trace(previous_);
233     }
234 
235     MODULES_EXPORT friend void swap(InOrderTraversalIterator& left,
236                                     InOrderTraversalIterator& right) {
237       std::swap(left.current_, right.current_);
238       std::swap(left.previous_, right.previous_);
239     }
240 
241     MODULES_EXPORT friend bool operator==(
242         const InOrderTraversalIterator& left,
243         const InOrderTraversalIterator& right) {
244       return left.current_ == right.current_;
245     }
246 
247     MODULES_EXPORT friend bool operator!=(
248         const InOrderTraversalIterator& left,
249         const InOrderTraversalIterator& right) {
250       return !(left == right);
251     }
252 
253    private:
254     InOrderTraversalIterator() = default;
255 
256     explicit InOrderTraversalIterator(AXObject& current)
257         : current_(&current), previous_(nullptr) {}
258 
259     friend class AXObject;
260     friend class AXObjectCacheImpl;
261 
262     Member<AXObject> current_;
263     Member<AXObject> previous_;
264   };
265 
266   // Iterator for the ancestors of an |AXObject|.
267   // Walks through all the unignored parents of the object up to the root.
268   // Does not include the object itself in the list of ancestors.
269   class MODULES_EXPORT AncestorsIterator final
270       : public GarbageCollected<AncestorsIterator> {
271    public:
272     ~AncestorsIterator() = default;
273 
274     AncestorsIterator(const AncestorsIterator& other)
275         : current_(other.current_) {}
276 
277     AncestorsIterator& operator=(const AncestorsIterator& other) {
278       current_ = other.current_;
279       return *this;
280     }
281 
282     AncestorsIterator& operator++() {
283       current_ = (current_ && !current_->IsDetached())
284                      ? current_->ParentObjectUnignored()
285                      : nullptr;
286       return *this;
287     }
288 
289     AncestorsIterator operator++(int) {
290       AncestorsIterator ret = *this;
291       ++*this;
292       return ret;
293     }
294 
295     AXObject& operator*() const {
296       DCHECK(current_);
297       return *current_;
298     }
299 
300     AXObject* operator->() const {
301       DCHECK(current_);
302       return static_cast<AXObject*>(current_);
303     }
304 
305     void Trace(Visitor* visitor) { visitor->Trace(current_); }
306 
307     MODULES_EXPORT friend void swap(AncestorsIterator& left,
308                                     AncestorsIterator& right) {
309       std::swap(left.current_, right.current_);
310     }
311 
312     MODULES_EXPORT friend bool operator==(const AncestorsIterator& left,
313                                           const AncestorsIterator& right) {
314       return left.current_ == right.current_;
315     }
316 
317     MODULES_EXPORT friend bool operator!=(const AncestorsIterator& left,
318                                           const AncestorsIterator& right) {
319       return !(left == right);
320     }
321 
322    private:
323     AncestorsIterator() = default;
324 
325     explicit AncestorsIterator(AXObject& current) : current_(&current) {}
326 
327     friend class AXObject;
328     friend class AXObjectCacheImpl;
329 
330     Member<AXObject> current_;
331   };
332 
333  protected:
334   AXObject(AXObjectCacheImpl&);
335 
336  public:
337   virtual ~AXObject();
338   virtual void Trace(Visitor*);
339 
340   static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; }
341 
342   // After constructing an AXObject, it must be given a
343   // unique ID, then added to AXObjectCacheImpl, and finally init() must
344   // be called last.
345   void SetAXObjectID(AXID ax_object_id) { id_ = ax_object_id; }
346   virtual void Init();
347 
348   // When the corresponding WebCore object that this AXObject
349   // wraps is deleted, it must be detached.
350   virtual void Detach();
351   virtual bool IsDetached() const;
352 
353   // If the parent of this object is known, this can be faster than using
354   // computeParent().
355   virtual void SetParent(AXObject* parent) { parent_ = parent; }
356 
357   // The AXObjectCacheImpl that owns this object, and its unique ID within this
358   // cache.
359   AXObjectCacheImpl& AXObjectCache() const {
360     DCHECK(ax_object_cache_);
361     return *ax_object_cache_;
362   }
363 
364   AXID AXObjectID() const { return id_; }
365 
366   // Wrappers that retrieve either an Accessibility Object Model property,
367   // or the equivalent ARIA attribute, in that order.
368   virtual const AtomicString& GetAOMPropertyOrARIAAttribute(
369       AOMStringProperty) const;
370   Element* GetAOMPropertyOrARIAAttribute(AOMRelationProperty) const;
371   bool HasAOMProperty(AOMRelationListProperty,
372                       HeapVector<Member<Element>>& result) const;
373   bool HasAOMPropertyOrARIAAttribute(AOMRelationListProperty,
374                                      HeapVector<Member<Element>>& result) const;
375   virtual bool HasAOMPropertyOrARIAAttribute(AOMBooleanProperty,
376                                              bool& result) const;
377   bool AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty) const;
378   bool AOMPropertyOrARIAAttributeIsFalse(AOMBooleanProperty) const;
379   bool HasAOMPropertyOrARIAAttribute(AOMUIntProperty, uint32_t& result) const;
380   bool HasAOMPropertyOrARIAAttribute(AOMIntProperty, int32_t& result) const;
381   bool HasAOMPropertyOrARIAAttribute(AOMFloatProperty, float& result) const;
382   bool HasAOMPropertyOrARIAAttribute(AOMStringProperty,
383                                      AtomicString& result) const;
384   virtual AccessibleNode* GetAccessibleNode() const;
385 
386   void TokenVectorFromAttribute(Vector<String>&, const QualifiedName&) const;
387 
388   void GetSparseAXAttributes(AXSparseAttributeClient&) const;
389 
390   // Determine subclass type.
391   virtual bool IsAXNodeObject() const { return false; }
392   virtual bool IsAXLayoutObject() const { return false; }
393   virtual bool IsAXInlineTextBox() const { return false; }
394   virtual bool IsAXListBox() const { return false; }
395   virtual bool IsAXListBoxOption() const { return false; }
396   virtual bool IsAXRadioInput() const { return false; }
397   virtual bool IsAXSVGRoot() const { return false; }
398 
399   // Check object role or purpose.
400   virtual ax::mojom::Role RoleValue() const { return role_; }
401   bool IsARIATextControl() const;
402   virtual bool IsAnchor() const { return false; }
403   bool IsButton() const;
404   bool IsCanvas() const { return RoleValue() == ax::mojom::Role::kCanvas; }
405   bool IsCheckbox() const { return RoleValue() == ax::mojom::Role::kCheckBox; }
406   bool IsCheckboxOrRadio() const { return IsCheckbox() || IsRadioButton(); }
407   bool IsColorWell() const {
408     return RoleValue() == ax::mojom::Role::kColorWell;
409   }
410   virtual bool IsControl() const { return false; }
411   virtual bool IsDefault() const { return false; }
412   virtual bool IsFieldset() const { return false; }
413   virtual bool IsHeading() const { return false; }
414   virtual bool IsImage() const { return false; }
415   virtual bool IsImageMapLink() const { return false; }
416   virtual bool IsInputImage() const { return false; }
417   bool IsLandmarkRelated() const;
418   virtual bool IsLink() const { return false; }
419   virtual bool IsInPageLinkTarget() const { return false; }
420   virtual bool IsList() const { return false; }
421   virtual bool IsMenu() const { return false; }
422   virtual bool IsMenuButton() const { return false; }
423   virtual bool IsMenuList() const { return false; }
424   virtual bool IsMenuListOption() const { return false; }
425   virtual bool IsMenuListPopup() const { return false; }
426   bool IsMenuRelated() const;
427   virtual bool IsMeter() const { return false; }
428   virtual bool IsMockObject() const { return false; }
429   virtual bool IsNativeSpinButton() const { return false; }
430   virtual bool IsNativeTextControl() const {
431     return false;
432   }  // input or textarea
433   virtual bool IsNonNativeTextControl() const {
434     return false;
435   }  // contenteditable or role=textbox
436   virtual bool IsPasswordField() const { return false; }
437   bool IsPasswordFieldAndShouldHideValue() const;
438   bool IsPresentational() const {
439     return RoleValue() == ax::mojom::Role::kNone ||
440            RoleValue() == ax::mojom::Role::kPresentational;
441   }
442   virtual bool IsProgressIndicator() const { return false; }
443   bool IsRadioButton() const {
444     return RoleValue() == ax::mojom::Role::kRadioButton;
445   }
446   bool IsRange() const {
447     return RoleValue() == ax::mojom::Role::kProgressIndicator ||
448            RoleValue() == ax::mojom::Role::kScrollBar ||
449            RoleValue() == ax::mojom::Role::kSlider ||
450            RoleValue() == ax::mojom::Role::kSpinButton || IsMoveableSplitter();
451   }
452   bool IsScrollbar() const {
453     return RoleValue() == ax::mojom::Role::kScrollBar;
454   }
455   virtual bool IsSlider() const { return false; }
456   virtual bool IsNativeSlider() const { return false; }
457   virtual bool IsMoveableSplitter() const { return false; }
458   virtual bool IsSpinButton() const {
459     return RoleValue() == ax::mojom::Role::kSpinButton;
460   }
461   bool IsTabItem() const { return RoleValue() == ax::mojom::Role::kTab; }
462   virtual bool IsTextControl() const { return false; }
463   bool IsTextObject() const;
464   bool IsTree() const { return RoleValue() == ax::mojom::Role::kTree; }
465   virtual bool IsValidationMessage() const { return false; }
466   virtual bool IsVirtualObject() const { return false; }
467   bool IsWebArea() const {
468     return RoleValue() == ax::mojom::Role::kRootWebArea;
469   }
470 
471   // Check object state.
472   virtual bool IsAutofillAvailable() const { return false; }
473   virtual bool IsClickable() const;
474   virtual AccessibilityExpanded IsExpanded() const {
475     return kExpandedUndefined;
476   }
477   virtual bool IsFocused() const { return false; }
478   // aria-grabbed is deprecated in WAI-ARIA 1.1.
479   virtual AccessibilityGrabbedState IsGrabbed() const {
480     return kGrabbedStateUndefined;
481   }
482   virtual bool IsHovered() const { return false; }
483   virtual bool IsLineBreakingObject() const { return false; }
484   virtual bool IsLinked() const { return false; }
485   virtual bool IsLoaded() const { return false; }
486   virtual bool IsModal() const { return false; }
487   virtual bool IsMultiSelectable() const { return false; }
488   virtual bool IsOffScreen() const { return false; }
489   virtual bool IsRequired() const { return false; }
490   virtual AccessibilitySelectedState IsSelected() const {
491     return kSelectedStateUndefined;
492   }
493   // Is the object selected because selection is following focus?
494   virtual bool IsSelectedFromFocus() const { return false; }
495   virtual bool IsSelectedOptionActive() const { return false; }
496   virtual bool IsVisible() const;
497   virtual bool IsVisited() const { return false; }
498 
499   // Check whether value can be modified.
500   bool CanSetValueAttribute() const;
501 
502   // Is the element focusable?
503   bool CanSetFocusAttribute() const;
504 
505   // Whether objects are ignored, i.e. hidden from the AT.
506   bool AccessibilityIsIgnored() const;
507   // Whether objects are ignored but included in the tree.
508   bool AccessibilityIsIgnoredButIncludedInTree() const;
509 
510   // Whether objects are included in the tree. Nodes that are included in the
511   // tree are serialized, even if they are ignored. This allows browser-side
512   // accessibility code to have a more accurate representation of the tree. e.g.
513   // inspect hidden nodes referenced by labeled-by, know where line breaking
514   // elements are, etc.
515   bool AccessibilityIsIncludedInTree() const;
516   typedef HeapVector<IgnoredReason> IgnoredReasons;
517   virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const {
518     return true;
519   }
520   bool AccessibilityIsIgnoredByDefault(IgnoredReasons* = nullptr) const;
521   AXObjectInclusion AccessibilityPlatformIncludesObject() const;
522   virtual AXObjectInclusion DefaultObjectInclusion(
523       IgnoredReasons* = nullptr) const;
524   bool IsInertOrAriaHidden() const;
525   const AXObject* AriaHiddenRoot() const;
526   bool ComputeIsInertOrAriaHidden(IgnoredReasons* = nullptr) const;
527   bool IsDescendantOfLeafNode() const;
528   AXObject* LeafNodeAncestor() const;
529   bool IsDescendantOfDisabledNode() const;
530   bool ComputeAccessibilityIsIgnoredButIncludedInTree() const;
531   const AXObject* DatetimeAncestor(int max_levels_to_check = 3) const;
532   const AXObject* DisabledAncestor() const;
533   bool LastKnownIsIgnoredValue() const;
534   void SetLastKnownIsIgnoredValue(bool);
535   bool LastKnownIsIgnoredButIncludedInTreeValue() const;
536   void SetLastKnownIsIgnoredButIncludedInTreeValue(bool);
537   bool HasInheritedPresentationalRole() const;
538   bool IsPresentationalChild() const;
539   bool CanBeActiveDescendant() const;
540   // Some objects, such as table cells, could be the children of more than one
541   // object but have only one primary parent.
542   bool HasIndirectChildren() const;
543 
544   //
545   // Accessible name calculation
546   //
547 
548   // Retrieves the accessible name of the object, an enum indicating where the
549   // name was derived from, and a list of objects that were used to derive the
550   // name, if any.
551   virtual String GetName(ax::mojom::NameFrom&,
552                          AXObjectVector* name_objects) const;
553 
554   typedef HeapVector<NameSource> NameSources;
555   // Retrieves the accessible name of the object and a list of all potential
556   // sources for the name, indicating which were used.
557   String GetName(NameSources*) const;
558 
559   typedef HeapVector<DescriptionSource> DescriptionSources;
560   // Takes the result of nameFrom from calling |name|, above, and retrieves the
561   // accessible description of the object, which is secondary to |name|, an enum
562   // indicating where the description was derived from, and a list of objects
563   // that were used to derive the description, if any.
564   virtual String Description(ax::mojom::NameFrom,
565                              ax::mojom::DescriptionFrom&,
566                              AXObjectVector* description_objects) const {
567     return String();
568   }
569 
570   // Same as above, but returns a list of all potential sources for the
571   // description, indicating which were used.
572   virtual String Description(ax::mojom::NameFrom,
573                              ax::mojom::DescriptionFrom&,
574                              DescriptionSources*,
575                              AXRelatedObjectVector*) const {
576     return String();
577   }
578 
579   // Takes the result of nameFrom and descriptionFrom from calling |name| and
580   // |description|, above, and retrieves the placeholder of the object, if
581   // present and if it wasn't already exposed by one of the two functions above.
582   virtual String Placeholder(ax::mojom::NameFrom) const { return String(); }
583 
584   // Takes the result of nameFrom and retrieves the HTML Title of the object,
585   // if present and if it wasn't already exposed by |GetName| above.
586   // HTML Title is typically used as a tooltip.
587   virtual String Title(ax::mojom::NameFrom) const { return String(); }
588 
589   // Internal functions used by name and description, above.
590   typedef HeapHashSet<Member<const AXObject>> AXObjectSet;
591   virtual String TextAlternative(bool recursive,
592                                  bool in_aria_labelled_by_traversal,
593                                  AXObjectSet& visited,
594                                  ax::mojom::NameFrom& name_from,
595                                  AXRelatedObjectVector* related_objects,
596                                  NameSources* name_sources) const {
597     return String();
598   }
599   virtual String TextFromDescendants(AXObjectSet& visited,
600                                      bool recursive) const {
601     return String();
602   }
603 
604   // Returns result of Accessible Name Calculation algorithm.
605   // This is a simpler high-level interface to |name| used by Inspector.
606   String ComputedName() const;
607 
608   // Internal function used to determine whether the result of calling |name| on
609   // this object would return text that came from the an HTML label element or
610   // not. This is intended to be faster than calling |name| or
611   // |textAlternative|, and without side effects (it won't call
612   // axObjectCache->getOrCreate).
613   virtual bool NameFromLabelElement() const { return false; }
614 
615   //
616   // Properties of static elements.
617   //
618 
619   virtual const AtomicString& AccessKey() const { return g_null_atom; }
620   RGBA32 BackgroundColor() const;
621   virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; }
622   virtual RGBA32 GetColor() const { return Color::kBlack; }
623   // Used by objects of role ColorWellRole.
624   virtual RGBA32 ColorValue() const { return Color::kTransparent; }
625   virtual bool CanvasHasFallbackContent() const { return false; }
626   virtual String FontFamily() const { return String(); }
627   // Font size is in pixels.
628   virtual float FontSize() const { return 0.0f; }
629   virtual float FontWeight() const { return 0.0f; }
630   // Value should be 1-based. 0 means not supported.
631   virtual int HeadingLevel() const { return 0; }
632   // Value should be 1-based. 0 means not supported.
633   virtual unsigned HierarchicalLevel() const { return 0; }
634   // Return the content of an image or canvas as an image data url in
635   // PNG format. If |maxSize| is not empty and if the image is larger than
636   // those dimensions, the image will be resized proportionally first to fit.
637   virtual String ImageDataUrl(const IntSize& max_size) const {
638     return g_null_atom;
639   }
640   virtual AXObject* InPageLinkTarget() const { return nullptr; }
641   virtual AccessibilityOrientation Orientation() const;
642   virtual ax::mojom::ListStyle GetListStyle() const {
643     return ax::mojom::ListStyle::kNone;
644   }
645   virtual String GetText() const { return String(); }
646   virtual ax::mojom::TextDirection GetTextDirection() const {
647     return ax::mojom::TextDirection::kLtr;
648   }
649   virtual ax::mojom::TextPosition GetTextPosition() const {
650     return ax::mojom::TextPosition::kNone;
651   }
652   virtual int TextLength() const { return 0; }
653 
654   virtual void GetTextStyleAndTextDecorationStyle(
655       int32_t* text_style,
656       ax::mojom::TextDecorationStyle* text_overline_style,
657       ax::mojom::TextDecorationStyle* text_strikethrough_style,
658       ax::mojom::TextDecorationStyle* text_underline_style) const {
659     *text_style = 0;
660     *text_overline_style = ax::mojom::TextDecorationStyle::kNone;
661     *text_strikethrough_style = ax::mojom::TextDecorationStyle::kNone;
662     *text_underline_style = ax::mojom::TextDecorationStyle::kNone;
663   }
664 
665   virtual AXObjectVector RadioButtonsInGroup() const {
666     return AXObjectVector();
667   }
668   virtual KURL Url() const { return KURL(); }
669   virtual AXObject* ChooserPopup() const { return nullptr; }
670 
671   // Load inline text boxes for just this node, even if
672   // settings->inlineTextBoxAccessibilityEnabled() is false.
673   virtual void LoadInlineTextBoxes() {}
674 
675   // Walk the AXObjects on the same line. This is supported on any
676   // object type but primarily intended to be used for inline text boxes.
677   virtual AXObject* NextOnLine() const { return nullptr; }
678   virtual AXObject* PreviousOnLine() const { return nullptr; }
679 
680   // For all node objects. The start and end character offset of each
681   // marker, such as spelling or grammar error.
682   virtual void Markers(Vector<DocumentMarker::MarkerType>&,
683                        Vector<AXRange>&) const;
684   // For an inline text box.
685   // The integer horizontal pixel offset of each character in the string;
686   // negative values for RTL.
687   virtual void TextCharacterOffsets(Vector<int>&) const;
688   // The start and end character offset of each word in the object's text.
689   virtual void GetWordBoundaries(Vector<int>& word_starts,
690                                  Vector<int>& word_ends) const;
691   // Returns the text offset (text offset as in AXPosition, not as in
692   // pixel offset) in the container of an inline text box.
693   virtual unsigned TextOffsetInContainer(unsigned offset) const {
694     return offset;
695   }
696 
697   // Properties of interactive elements.
698   ax::mojom::DefaultActionVerb Action() const;
699   ax::mojom::CheckedState CheckedState() const;
700   virtual ax::mojom::AriaCurrentState GetAriaCurrentState() const {
701     return ax::mojom::AriaCurrentState::kNone;
702   }
703   virtual ax::mojom::InvalidState GetInvalidState() const {
704     return ax::mojom::InvalidState::kNone;
705   }
706   // Only used when invalidState() returns InvalidStateOther.
707   virtual String AriaInvalidValue() const { return String(); }
708   virtual String ValueDescription() const { return String(); }
709   virtual bool ValueForRange(float* out_value) const { return false; }
710   virtual bool MaxValueForRange(float* out_value) const { return false; }
711   virtual bool MinValueForRange(float* out_value) const { return false; }
712   virtual bool StepValueForRange(float* out_value) const { return false; }
713   virtual String StringValue() const { return String(); }
714   virtual AXRestriction Restriction() const;
715 
716   // ARIA attributes.
717   virtual ax::mojom::Role DetermineAccessibilityRole();
718   ax::mojom::Role DetermineAriaRoleAttribute() const;
719   virtual ax::mojom::Role AriaRoleAttribute() const;
720   virtual bool HasAriaAttribute() const { return false; }
721   virtual AXObject* ActiveDescendant() { return nullptr; }
722   virtual String AutoComplete() const { return String(); }
723   virtual void AriaOwnsElements(AXObjectVector& owns) const {}
724   virtual void AriaDescribedbyElements(AXObjectVector&) const {}
725   virtual AXObject* ErrorMessage() const { return nullptr; }
726   virtual ax::mojom::HasPopup HasPopup() const {
727     return ax::mojom::HasPopup::kFalse;
728   }
729   virtual bool IsEditable() const { return false; }
730   bool IsEditableRoot() const;
731   virtual bool ComputeIsEditableRoot() const { return false; }
732   virtual bool IsMultiline() const { return false; }
733   virtual bool IsRichlyEditable() const { return false; }
734   bool AriaCheckedIsPresent() const;
735   bool AriaPressedIsPresent() const;
736   bool HasGlobalARIAAttribute() const;
737   bool SupportsARIAExpanded() const;
738   virtual bool SupportsARIADragging() const { return false; }
739   virtual void Dropeffects(Vector<ax::mojom::Dropeffect>& dropeffects) const {}
740   virtual bool SupportsARIAOwns() const { return false; }
741   bool SupportsRangeValue() const;
742   bool SupportsARIAReadOnly() const;
743 
744   // Returns 0-based index.
745   int IndexInParent() const;
746 
747   // Value should be 1-based. 0 means not supported.
748   virtual int PosInSet() const { return 0; }
749   virtual int SetSize() const { return 0; }
750   bool SupportsARIASetSizeAndPosInSet() const;
751 
752   // ARIA live-region features.
753   bool IsLiveRegionRoot() const;  // Any live region, including polite="off".
754   bool IsActiveLiveRegionRoot() const;  // Live region that is not polite="off".
755   AXObject* LiveRegionRoot() const;  // Container that controls live politeness.
756   virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; }
757   virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; }
758   bool LiveRegionAtomic() const;
759 
760   const AtomicString& ContainerLiveRegionStatus() const;
761   const AtomicString& ContainerLiveRegionRelevant() const;
762   bool ContainerLiveRegionAtomic() const;
763   bool ContainerLiveRegionBusy() const;
764 
765   // Every object's bounding box is returned relative to a
766   // container object (which is guaranteed to be an ancestor) and
767   // optionally a transformation matrix that needs to be applied too.
768   // To compute the absolute bounding box of an element, start with its
769   // boundsInContainer and apply the transform. Then as long as its container is
770   // not null, walk up to its container and offset by the container's offset
771   // from origin, the container's scroll position if any, and apply the
772   // container's transform.  Do this until you reach the root of the tree.
773   // If the object clips its children, for example by having overflow:hidden,
774   // set |clips_children| to true.
775   virtual void GetRelativeBounds(AXObject** out_container,
776                                  FloatRect& out_bounds_in_container,
777                                  SkMatrix44& out_container_transform,
778                                  bool* clips_children = nullptr) const;
779 
780   FloatRect LocalBoundingBoxRectForAccessibility();
781 
782   // Get the bounds in frame-relative coordinates as a LayoutRect.
783   LayoutRect GetBoundsInFrameCoordinates() const;
784 
785   // Explicitly set an object's bounding rect and offset container.
786   void SetElementRect(LayoutRect r, AXObject* container) {
787     explicit_element_rect_ = r;
788     explicit_container_id_ = container->AXObjectID();
789   }
790 
791   // Hit testing.
792   // Called on the root AX object to return the deepest available element.
793   virtual AXObject* AccessibilityHitTest(const IntPoint&) const {
794     return nullptr;
795   }
796   // Called on the AX object after the layout tree determines which is the right
797   // AXLayoutObject.
798   virtual AXObject* ElementAccessibilityHitTest(const IntPoint&) const;
799 
800   // High-level accessibility tree access. Other modules should only use these
801   // functions.
802   AncestorsIterator AncestorsBegin();
803   AncestorsIterator AncestorsEnd();
804   InOrderTraversalIterator GetInOrderTraversalIterator();
805   int ChildCount() const;
806   const AXObjectVector& Children() const;
807   const AXObjectVector& Children();
808   // Returns the first child for this object.
809   // Works for all nodes, and may return nodes that are accessibility ignored.
810   AXObject* FirstChild() const;
811   // Returns the last child for this object.
812   // Works for all nodes, and may return nodes that are accessibility ignored.
813   AXObject* LastChild() const;
814   // Returns the deepest first child for this object.
815   // Works for all nodes, and may return nodes that are accessibility ignored.
816   AXObject* DeepestFirstChild() const;
817   // Returns the deepest last child for this object.
818   // Works for all nodes, and may return nodes that are accessibility ignored.
819   AXObject* DeepestLastChild() const;
820   bool IsAncestorOf(const AXObject&) const;
821   bool IsDescendantOf(const AXObject&) const;
822   // Next sibling for this object, where the sibling may be
823   // an accessibility ignored object.
824   // Works for all nodes that are included in the accessibility tree,
825   // and may return nodes that are accessibility ignored.
826   AXObject* NextSiblingIncludingIgnored() const;
827   // Previous sibling for this object, where the sibling may be
828   // an accessibility ignored object.
829   // Works for all nodes that are included in the accessibility tree,
830   // and may return nodes that are accessibility ignored.
831   AXObject* PreviousSiblingIncludingIgnored() const;
832   // Returns the next object in tree using depth-first pre-order traversal,
833   // optionally staying within a specified AXObject.
834   // Works for all nodes that are included in the accessibility tree,
835   // and may return nodes that are accessibility ignored.
836   AXObject* NextInPreOrderIncludingIgnored(
837       const AXObject* within = nullptr) const;
838   // Returns the previous object in tree using depth-first pre-order traversal,
839   // optionally staying within a specified AXObject.
840   // Works for all nodes that are included in the accessibility tree,
841   // and may return nodes that are accessibility ignored.
842   AXObject* PreviousInPreOrderIncludingIgnored(
843       const AXObject* within = nullptr) const;
844   // Returns the previous object in tree using depth-first post-order traversal,
845   // optionally staying within a specified AXObject.
846   // Works for all nodes that are included in the accessibility tree,
847   // and may return nodes that are accessibility ignored.
848   AXObject* PreviousInPostOrderIncludingIgnored(
849       const AXObject* within = nullptr) const;
850   // Next sibling for this object that's not accessibility ignored.
851   // Flattens accessibility ignored nodes, so the sibling will have the
852   // same unignored parent, but may have a different parent in tree.
853   // Doesn't work with nodes that are accessibility ignored.
854   AXObject* NextSibling() const;
855   // Previous sibling for this object that's not accessibility ignored.
856   // Flattens accessibility ignored nodes, so the sibling will have the
857   // same unignored parent, but may have a different parent in tree.
858   // Doesn't work with nodes that are accessibility ignored.
859   AXObject* PreviousSibling() const;
860   // Next object in tree using depth-first pre-order traversal that's
861   // not accessibility ignored.
862   // Doesn't work with nodes that are accessibility ignored.
863   AXObject* NextInTreeObject() const;
864   // Previous object in tree using depth-first pre-order traversal that's
865   // not accessibility ignored.
866   // Doesn't work with nodes that are accessibility ignored.
867   AXObject* PreviousInTreeObject() const;
868   // Get or create the parent of this object.
869   // Works for all nodes, and may return nodes that are accessibility ignored.
870   AXObject* ParentObject() const;
871   // Get the parent of this object if it has already been created.
872   // Works for all nodes, and may return nodes that are accessibility ignored.
873   AXObject* ParentObjectIfExists() const;
874   virtual AXObject* ComputeParent() const = 0;
875   virtual AXObject* ComputeParentIfExists() const { return nullptr; }
876   AXObject* CachedParentObject() const { return parent_; }
877   // Get or create the first ancestor that's not accessibility ignored.
878   // Works for all nodes.
879   AXObject* ParentObjectUnignored() const;
880   // Get or create the first ancestor that's included in the accessibility tree.
881   // Works for all nodes, and may return nodes that are accessibility ignored.
882   AXObject* ParentObjectIncludedInTree() const;
883   AXObject* ContainerWidget() const;
884   bool IsContainerWidget() const;
885 
886   // Low-level accessibility tree exploration, only for use within the
887   // accessibility module.
888   virtual AXObject* RawFirstChild() const { return nullptr; }
889   virtual AXObject* RawNextSibling() const { return nullptr; }
890   virtual void AddChildren() {}
891   virtual bool CanHaveChildren() const { return true; }
892   bool HasChildren() const { return have_children_; }
893   virtual void UpdateChildrenIfNecessary();
894   virtual bool NeedsToUpdateChildren() const { return false; }
895   virtual void SetNeedsToUpdateChildren() {}
896   virtual void ClearChildren();
897   void DetachFromParent() { parent_ = nullptr; }
898   void AddAccessibleNodeChildren();
899   virtual void SelectedOptions(AXObjectVector&) const {}
900 
901   // Properties of the object's owning document or page.
902   virtual double EstimatedLoadingProgress() const { return 0; }
903   virtual AXObject* RootScroller() const;
904 
905   // DOM and layout tree access.
906   virtual Node* GetNode() const { return nullptr; }
907   Element* GetElement() const;  // Same as GetNode, if it's an Element.
908   virtual LayoutObject* GetLayoutObject() const { return nullptr; }
909   virtual Document* GetDocument() const;
910   virtual LocalFrameView* DocumentFrameView() const;
911   virtual Element* AnchorElement() const { return nullptr; }
912   virtual Element* ActionElement() const { return nullptr; }
913   virtual AtomicString Language() const;
914   bool HasAttribute(const QualifiedName&) const;
915   const AtomicString& GetAttribute(const QualifiedName&) const;
916 
917   // Scrollable containers.
918   bool IsScrollableContainer() const;
919   bool IsUserScrollable() const;  // Only true if actual scrollbars are present.
920   IntPoint GetScrollOffset() const;
921   IntPoint MinimumScrollOffset() const;
922   IntPoint MaximumScrollOffset() const;
923   void SetScrollOffset(const IntPoint&) const;
924 
925   // Tables and grids.
926   bool IsTableLikeRole() const;
927   bool IsTableRowLikeRole() const;
928   bool IsTableCellLikeRole() const;
929   virtual bool IsDataTable() const { return false; }
930 
931   // For a table.
932   virtual unsigned ColumnCount() const;
933   virtual unsigned RowCount() const;
934   virtual void ColumnHeaders(AXObjectVector&) const;
935   virtual void RowHeaders(AXObjectVector&) const;
936   virtual AXObject* CellForColumnAndRow(unsigned column, unsigned row) const;
937 
938   // For a cell.
939   virtual unsigned ColumnIndex() const;
940   virtual unsigned RowIndex() const;
941   virtual unsigned ColumnSpan() const;
942   virtual unsigned RowSpan() const;
943   unsigned AriaColumnIndex() const;
944   unsigned AriaRowIndex() const;
945   int AriaColumnCount() const;
946   int AriaRowCount() const;
947   virtual ax::mojom::SortDirection GetSortDirection() const {
948     return ax::mojom::SortDirection::kNone;
949   }
950 
951   // For a row or column.
952   virtual AXObject* HeaderObject() const { return nullptr; }
953 
954   // If this object itself scrolls, return its ScrollableArea.
955   virtual ScrollableArea* GetScrollableAreaIfScrollable() const {
956     return nullptr;
957   }
958 
959   // Modify or take an action on an object.
960   //
961   // These are the public interfaces, called from outside of Blink.
962   // Each one first tries to fire an Accessibility Object Model event,
963   // if applicable, and if that isn't handled, falls back on the
964   // native implementation via a virtual member function, below.
965   //
966   // For example, |RequestIncrementAction| fires the AOM event and if
967   // that isn't handled it calls |DoNativeIncrement|.
968   //
969   // These all return true if handled.
970   bool RequestDecrementAction();
971   bool RequestClickAction();
972   bool RequestFocusAction();
973   bool RequestIncrementAction();
974   bool RequestScrollToGlobalPointAction(const IntPoint&);
975   bool RequestScrollToMakeVisibleAction();
976   bool RequestScrollToMakeVisibleWithSubFocusAction(
977       const IntRect&,
978       blink::mojom::blink::ScrollAlignment horizontal_scroll_alignment,
979       blink::mojom::blink::ScrollAlignment vertical_scroll_alignment);
980   bool RequestSetSelectedAction(bool);
981   bool RequestSetSequentialFocusNavigationStartingPointAction();
982   bool RequestSetValueAction(const String&);
983   bool RequestShowContextMenuAction();
984 
985   // These are actions, just like the actions above, and they allow us
986   // to keep track of nodes that gain or lose accessibility focus, but
987   // this isn't exposed to the open web so they're explicitly marked as
988   // internal so it's clear that these should not dispatch DOM events.
989   bool InternalClearAccessibilityFocusAction();
990   bool InternalSetAccessibilityFocusAction();
991 
992   // Native implementations of actions that aren't handled by AOM
993   // event listeners. These all return true if handled.
994   virtual bool OnNativeDecrementAction();
995   virtual bool OnNativeClickAction();
996   virtual bool OnNativeFocusAction();
997   virtual bool OnNativeIncrementAction();
998   bool OnNativeScrollToGlobalPointAction(const IntPoint&) const;
999   bool OnNativeScrollToMakeVisibleAction() const;
1000   bool OnNativeScrollToMakeVisibleWithSubFocusAction(
1001       const IntRect&,
1002       blink::mojom::blink::ScrollAlignment horizontal_scroll_alignment,
1003       blink::mojom::blink::ScrollAlignment vertical_scroll_alignment) const;
1004   virtual bool OnNativeSetSelectedAction(bool);
1005   virtual bool OnNativeSetSequentialFocusNavigationStartingPointAction();
1006   virtual bool OnNativeSetValueAction(const String&);
1007   bool OnNativeShowContextMenuAction();
1008 
1009   // Notifications that this object may have changed.
1010   virtual void ChildrenChanged() {}
1011   virtual void HandleActiveDescendantChanged() {}
1012   virtual void HandleAutofillStateChanged(WebAXAutofillState) {}
1013   virtual void HandleAriaExpandedChanged() {}
1014   virtual void SelectionChanged();
1015   virtual void TextChanged() {}
1016 
1017   // Static helper functions.
1018   static bool IsARIAControl(ax::mojom::Role);
1019   static bool IsARIAInput(ax::mojom::Role);
1020   // Is this a widget that requires container widget.
1021   bool IsSubWidget() const;
1022   static ax::mojom::Role AriaRoleToWebCoreRole(const String&);
1023   static const AtomicString& RoleName(ax::mojom::Role);
1024   static const AtomicString& InternalRoleName(ax::mojom::Role);
1025   static void AccessibleNodeListToElementVector(const AccessibleNodeList&,
1026                                                 HeapVector<Member<Element>>&);
1027 
1028   // Given two AX objects, returns the lowest common ancestor and the child
1029   // indices in that ancestor corresponding to the branch under which each
1030   // object is to be found. If the lowest common ancestor is the same as either
1031   // of the objects, the corresponding index is set to -1 to indicate this.
1032   static const AXObject* LowestCommonAncestor(const AXObject& first,
1033                                               const AXObject& second,
1034                                               int* index_in_ancestor1,
1035                                               int* index_in_ancestor2);
1036 
1037   // Blink-internal DOM Node ID. Currently used for PDF exporting.
1038   int GetDOMNodeId() const;
1039 
1040   // Returns a string representation of this object.
1041   String ToString() const;
1042 
1043  protected:
1044   AXID id_;
1045   AXObjectVector children_;
1046   mutable bool have_children_;
1047   ax::mojom::Role role_;
1048   ax::mojom::Role aria_role_;
1049   mutable AXObjectInclusion last_known_is_ignored_value_;
1050   mutable AXObjectInclusion last_known_is_ignored_but_included_in_tree_value_;
1051   LayoutRect explicit_element_rect_;
1052   AXID explicit_container_id_;
1053 
1054   // Used only inside textAlternative():
1055   static String CollapseWhitespace(const String&);
1056   static String RecursiveTextAlternative(const AXObject&,
1057                                          bool in_aria_labelled_by_traversal,
1058                                          AXObjectSet& visited);
1059   static String RecursiveTextAlternative(const AXObject&,
1060                                          bool in_aria_labelled_by_traversal,
1061                                          AXObjectSet& visited,
1062                                          ax::mojom::NameFrom& name_from);
1063   bool IsHiddenForTextAlternativeCalculation() const;
1064   String AriaTextAlternative(bool recursive,
1065                              bool in_aria_labelled_by_traversal,
1066                              AXObjectSet& visited,
1067                              ax::mojom::NameFrom&,
1068                              AXRelatedObjectVector*,
1069                              NameSources*,
1070                              bool* found_text_alternative) const;
1071   String TextFromElements(bool in_aria_labelled_by_traversal,
1072                           AXObjectSet& visited,
1073                           HeapVector<Member<Element>>& elements,
1074                           AXRelatedObjectVector* related_objects) const;
1075   void ElementsFromAttribute(HeapVector<Member<Element>>& elements,
1076                              const QualifiedName&,
1077                              Vector<String>& ids) const;
1078   void AriaLabelledbyElementVector(HeapVector<Member<Element>>& elements,
1079                                    Vector<String>& ids) const;
1080   String TextFromAriaLabelledby(AXObjectSet& visited,
1081                                 AXRelatedObjectVector* related_objects,
1082                                 Vector<String>& ids) const;
1083   String TextFromAriaDescribedby(AXRelatedObjectVector* related_objects,
1084                                  Vector<String>& ids) const;
1085   virtual const AXObject* InheritsPresentationalRoleFrom() const {
1086     return nullptr;
1087   }
1088 
1089   bool NameFromContents(bool recursive) const;
1090   bool NameFromSelectedOption(bool recursive) const;
1091 
1092   ax::mojom::Role ButtonRoleType() const;
1093 
1094   virtual LayoutObject* LayoutObjectForRelativeBounds() const {
1095     return nullptr;
1096   }
1097 
1098   bool CanSetSelectedAttribute() const;
1099   const AXObject* InertRoot() const;
1100 
1101   // Returns true if the event was handled.
1102   bool DispatchEventToAOMEventListeners(Event&);
1103 
1104   // Finds table, table row, and table cell parents and children
1105   // skipping over generic containers.
1106   AXObjectVector TableRowChildren() const;
1107   AXObjectVector TableCellChildren() const;
1108   const AXObject* TableRowParent() const;
1109   const AXObject* TableParent() const;
1110 
1111   mutable Member<AXObject> parent_;
1112 
1113   // The following cached attribute values (the ones starting with m_cached*)
1114   // are only valid if m_lastModificationCount matches
1115   // AXObjectCacheImpl::modificationCount().
1116   mutable int last_modification_count_;
1117   mutable RGBA32 cached_background_color_;
1118   mutable bool cached_is_ignored_ : 1;
1119   mutable bool cached_is_ignored_but_included_in_tree_ : 1;
1120 
1121   mutable bool cached_is_inert_or_aria_hidden_ : 1;
1122   mutable bool cached_is_descendant_of_leaf_node_ : 1;
1123   mutable bool cached_is_descendant_of_disabled_node_ : 1;
1124   mutable bool cached_has_inherited_presentational_role_ : 1;
1125   mutable bool cached_is_editable_root_;
1126   mutable Member<AXObject> cached_live_region_root_;
1127   mutable int cached_aria_column_index_;
1128   mutable int cached_aria_row_index_;
1129   mutable FloatRect cached_local_bounding_box_rect_for_accessibility_;
1130 
1131   Member<AXObjectCacheImpl> ax_object_cache_;
1132 
1133   // Updates the cached attribute values. This may be recursive, so to prevent
1134   // deadlocks,
1135   // functions called here may only search up the tree (ancestors), not down.
1136   void UpdateCachedAttributeValuesIfNeeded() const;
1137 
1138  private:
1139   void UpdateDistributionForFlatTreeTraversal() const;
1140   bool IsARIAControlledByTextboxWithActiveDescendant() const;
1141   bool AncestorExposesActiveDescendant() const;
1142   bool IsCheckable() const;
1143   static bool IsNativeCheckboxInMixedState(const Node*);
1144   static bool IncludesARIAWidgetRole(const String&);
1145   static bool HasInteractiveARIAAttribute(const Element&);
1146   ax::mojom::Role RemapAriaRoleDueToParent(ax::mojom::Role) const;
1147   unsigned ComputeAriaColumnIndex() const;
1148   unsigned ComputeAriaRowIndex() const;
1149   bool HasInternalsAttribute(Element&, const QualifiedName&) const;
1150   const AtomicString& GetInternalsAttribute(Element&,
1151                                             const QualifiedName&) const;
1152   bool IsHiddenViaStyle() const;
1153 
1154   static unsigned number_of_live_ax_objects_;
1155 
1156   DISALLOW_COPY_AND_ASSIGN(AXObject);
1157 };
1158 
1159 MODULES_EXPORT bool operator==(const AXObject& first, const AXObject& second);
1160 MODULES_EXPORT bool operator!=(const AXObject& first, const AXObject& second);
1161 MODULES_EXPORT bool operator<(const AXObject& first, const AXObject& second);
1162 MODULES_EXPORT bool operator<=(const AXObject& first, const AXObject& second);
1163 MODULES_EXPORT bool operator>(const AXObject& first, const AXObject& second);
1164 MODULES_EXPORT bool operator>=(const AXObject& first, const AXObject& second);
1165 MODULES_EXPORT std::ostream& operator<<(std::ostream&, const AXObject&);
1166 
1167 }  // namespace blink
1168 
1169 #endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_ACCESSIBILITY_AX_OBJECT_H_
1170