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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h

Issue 2907133002: Move WebAXObject.cpp to core/ (WIP) (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h
diff --git a/third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h b/third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h
index 9eb55268e5b5b0fe5989d5507fc5e6397ddcbb19..ba1f0f3fa5dc9a3861dba28f4e6ae41984323265 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h
+++ b/third_party/WebKit/Source/modules/accessibility/AXObjectImpl.h
@@ -121,9 +121,9 @@ class AXSparseAttributeClient {
public:
virtual void AddBoolAttribute(AXBoolAttribute, bool) = 0;
virtual void AddStringAttribute(AXStringAttribute, const String&) = 0;
- virtual void AddObjectAttribute(AXObjectAttribute, AXObjectImpl&) = 0;
+ virtual void AddObjectAttribute(AXObjectAttribute, AXObject&) = 0;
virtual void AddObjectVectorAttribute(AXObjectVectorAttribute,
- HeapVector<Member<AXObjectImpl>>&) = 0;
+ HeapVector<Member<AXObject>>&) = 0;
};
// The potential native HTML-based text (name, description or placeholder)
@@ -250,73 +250,7 @@ class MODULES_EXPORT AXObjectImpl
WTF_MAKE_NONCOPYABLE(AXObjectImpl);
public:
- typedef HeapVector<Member<AXObjectImpl>> AXObjectVector;
-
- struct AXRange {
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
- // The deepest descendant in which the range starts.
- // (nullptr means the current object.)
- Persistent<AXObjectImpl> anchor_object;
- // The number of characters and child objects in the anchor object
- // before the range starts.
- int anchor_offset;
- // When the same character offset could correspond to two possible
- // cursor positions, upstream means it's on the previous line rather
- // than the next line.
- TextAffinity anchor_affinity;
-
- // The deepest descendant in which the range ends.
- // (nullptr means the current object.)
- Persistent<AXObjectImpl> focus_object;
- // The number of characters and child objects in the focus object
- // before the range ends.
- int focus_offset;
- // When the same character offset could correspond to two possible
- // cursor positions, upstream means it's on the previous line rather
- // than the next line.
- TextAffinity focus_affinity;
-
- AXRange()
- : anchor_object(nullptr),
- anchor_offset(-1),
- anchor_affinity(TextAffinity::kUpstream),
- focus_object(nullptr),
- focus_offset(-1),
- focus_affinity(TextAffinity::kDownstream) {}
-
- AXRange(int start_offset, int end_offset)
- : anchor_object(nullptr),
- anchor_offset(start_offset),
- anchor_affinity(TextAffinity::kUpstream),
- focus_object(nullptr),
- focus_offset(end_offset),
- focus_affinity(TextAffinity::kDownstream) {}
-
- AXRange(AXObjectImpl* anchor_object,
- int anchor_offset,
- TextAffinity anchor_affinity,
- AXObjectImpl* focus_object,
- int focus_offset,
- TextAffinity focus_affinity)
- : anchor_object(anchor_object),
- anchor_offset(anchor_offset),
- anchor_affinity(anchor_affinity),
- focus_object(focus_object),
- focus_offset(focus_offset),
- focus_affinity(focus_affinity) {}
-
- bool IsValid() const {
- return ((anchor_object && focus_object) ||
- (!anchor_object && !focus_object)) &&
- anchor_offset >= 0 && focus_offset >= 0;
- }
-
- // Determines if the range only refers to text offsets under the current
- // object.
- bool IsSimple() const {
- return anchor_object == focus_object || !anchor_object || !focus_object;
- }
- };
+ typedef HeapVector<Member<AXObjectImpl>> AXObjectImplVector;
protected:
AXObjectImpl(AXObjectCacheImpl&);
@@ -373,7 +307,7 @@ class MODULES_EXPORT AXObjectImpl
virtual bool IsAXSVGRoot() const { return false; }
// Check object role or purpose.
- virtual AccessibilityRole RoleValue() const { return role_; }
+ virtual AccessibilityRole RoleValue() const override { return role_; }
bool IsARIATextControl() const;
virtual bool IsARIATreeGridRow() const { return false; }
virtual bool IsAXTable() const { return false; }
@@ -466,7 +400,7 @@ class MODULES_EXPORT AXObjectImpl
virtual bool CanSetSelectedAttribute() const { return false; }
// Whether objects are ignored, i.e. not included in the tree.
- bool AccessibilityIsIgnored();
+ bool AccessibilityIsIgnored() override;
typedef HeapVector<IgnoredReason> IgnoredReasons;
virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const {
return true;
@@ -493,24 +427,18 @@ class MODULES_EXPORT AXObjectImpl
// Accessible name calculation
//
- // Retrieves the accessible name of the object, an enum indicating where the
- // name was derived from, and a list of objects that were used to derive the
- // name, if any.
- virtual String GetName(AXNameFrom&, AXObjectVector* name_objects) const;
+ virtual String GetName(AXNameFrom&,
+ AXObjectVector* name_objects) const override;
typedef HeapVector<NameSource> NameSources;
// Retrieves the accessible name of the object and a list of all potential
// sources for the name, indicating which were used.
virtual String GetName(NameSources*) const;
- typedef HeapVector<DescriptionSource> DescriptionSources;
- // Takes the result of nameFrom from calling |name|, above, and retrieves the
- // accessible description of the object, which is secondary to |name|, an enum
- // indicating where the description was derived from, and a list of objects
- // that were used to derive the description, if any.
- virtual String Description(AXNameFrom,
- AXDescriptionFrom&,
- AXObjectVector* description_objects) const {
+ virtual String Description(
+ AXNameFrom,
+ AXDescriptionFrom&,
+ AXObjectVector* description_objects) const override {
return String();
}
@@ -523,10 +451,7 @@ class MODULES_EXPORT AXObjectImpl
return String();
}
- // Takes the result of nameFrom and descriptionFrom from calling |name| and
- // |description|, above, and retrieves the placeholder of the object, if
- // present and if it wasn't already exposed by one of the two functions above.
- virtual String Placeholder(AXNameFrom) const { return String(); }
+ virtual String Placeholder(AXNameFrom) const override { return String(); }
// Internal functions used by name and description, above.
typedef HeapHashSet<Member<const AXObjectImpl>> AXObjectSet;
@@ -558,58 +483,44 @@ class MODULES_EXPORT AXObjectImpl
// Properties of static elements.
//
- virtual const AtomicString& AccessKey() const { return g_null_atom; }
+ virtual const AtomicString& AccessKey() const override { return g_null_atom; }
RGBA32 BackgroundColor() const;
virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; }
virtual RGBA32 GetColor() const { return Color::kBlack; }
// Used by objects of role ColorWellRole.
virtual RGBA32 ColorValue() const { return Color::kTransparent; }
- virtual bool CanvasHasFallbackContent() const { return false; }
- virtual String FontFamily() const { return g_null_atom; }
- // Font size is in pixels.
- virtual float FontSize() const { return 0.0f; }
+ virtual bool CanvasHasFallbackContent() const override { return false; }
+ virtual String FontFamily() const override { return g_null_atom; }
+ virtual float FontSize() const override { return 0.0f; }
// Value should be 1-based. 0 means not supported.
- virtual int HeadingLevel() const { return 0; }
+ virtual int HeadingLevel() const override { return 0; }
// Value should be 1-based. 0 means not supported.
- virtual unsigned HierarchicalLevel() const { return 0; }
- // Return the content of an image or canvas as an image data url in
- // PNG format. If |maxSize| is not empty and if the image is larger than
- // those dimensions, the image will be resized proportionally first to fit.
- virtual String ImageDataUrl(const IntSize& max_size) const {
+ virtual unsigned HierarchicalLevel() const override { return 0; }
+ virtual String ImageDataUrl(const IntSize& max_size) const override {
return g_null_atom;
}
- virtual AXObjectImpl* InPageLinkTarget() const { return nullptr; }
- virtual AccessibilityOrientation Orientation() const;
+ virtual AXObject* InPageLinkTarget() const override { return nullptr; }
+ virtual AccessibilityOrientation Orientation() const override;
virtual String GetText() const { return String(); }
- virtual AccessibilityTextDirection GetTextDirection() const {
+ virtual AccessibilityTextDirection GetTextDirection() const override {
return kAccessibilityTextDirectionLTR;
}
virtual int TextLength() const { return 0; }
- virtual TextStyle GetTextStyle() const { return kTextStyleNone; }
- virtual AXObjectVector RadioButtonsInGroup() const {
+ virtual TextStyle GetTextStyle() const override { return kTextStyleNone; }
+ virtual AXObjectVector RadioButtonsInGroup() const override {
return AXObjectVector();
}
- virtual KURL Url() const { return KURL(); }
+ virtual KURL Url() const override { return KURL(); }
- // Load inline text boxes for just this node, even if
- // settings->inlineTextBoxAccessibilityEnabled() is false.
- virtual void LoadInlineTextBoxes() {}
+ virtual void LoadInlineTextBoxes() override {}
- // Walk the AXObjects on the same line. This is supported on any
- // object type but primarily intended to be used for inline text boxes.
- virtual AXObjectImpl* NextOnLine() const { return nullptr; }
- virtual AXObjectImpl* PreviousOnLine() const { return nullptr; }
+ virtual AXObject* NextOnLine() const override { return nullptr; }
+ virtual AXObject* PreviousOnLine() const override { return nullptr; }
- // For all node objects. The start and end character offset of each
- // marker, such as spelling or grammar error.
virtual void Markers(Vector<DocumentMarker::MarkerType>&,
- Vector<AXRange>&) const {}
- // For an inline text box.
- // The integer horizontal pixel offset of each character in the string;
- // negative values for RTL.
- virtual void TextCharacterOffsets(Vector<int>&) const {}
- // The start and end character offset of each word in the object's text.
- virtual void GetWordBoundaries(Vector<AXRange>&) const {}
+ Vector<AXRange>&) const override {}
+ virtual void TextCharacterOffsets(Vector<int>&) const override {}
+ virtual void GetWordBoundaries(Vector<AXRange>&) const override {}
// Properties of interactive elements.
AXDefaultActionVerb Action() const;
@@ -617,23 +528,23 @@ class MODULES_EXPORT AXObjectImpl
virtual AriaCurrentState GetAriaCurrentState() const {
return kAriaCurrentStateUndefined;
}
- virtual InvalidState GetInvalidState() const {
+ virtual InvalidState GetInvalidState() const override {
return kInvalidStateUndefined;
}
// Only used when invalidState() returns InvalidStateOther.
- virtual String AriaInvalidValue() const { return String(); }
- virtual String ValueDescription() const { return String(); }
- virtual float ValueForRange() const { return 0.0f; }
- virtual float MaxValueForRange() const { return 0.0f; }
- virtual float MinValueForRange() const { return 0.0f; }
- virtual String StringValue() const { return String(); }
+ virtual String AriaInvalidValue() const override { return String(); }
+ virtual String ValueDescription() const override { return String(); }
+ virtual float ValueForRange() const override { return 0.0f; }
+ virtual float MaxValueForRange() const override { return 0.0f; }
+ virtual float MinValueForRange() const override { return 0.0f; }
+ virtual String StringValue() const override { return String(); }
// ARIA attributes.
virtual AXObjectImpl* ActiveDescendant() { return nullptr; }
virtual String AriaAutoComplete() const { return String(); }
- virtual void AriaOwnsElements(AXObjectVector& owns) const {}
- virtual void AriaDescribedbyElements(AXObjectVector&) const {}
- virtual void AriaLabelledbyElements(AXObjectVector&) const {}
+ virtual void AriaOwnsElements(AXObjectImplVector& owns) const {}
+ virtual void AriaDescribedbyElements(AXObjectImplVector&) const {}
+ virtual void AriaLabelledbyElements(AXObjectImplVector&) const {}
virtual bool AriaHasPopup() const { return false; }
virtual bool IsEditable() const { return false; }
bool IsMultiline() const;
@@ -650,7 +561,7 @@ class MODULES_EXPORT AXObjectImpl
virtual bool SupportsARIADropping() const { return false; }
virtual bool SupportsARIAFlowTo() const { return false; }
virtual bool SupportsARIAOwns() const { return false; }
- bool SupportsRangeValue() const;
+ bool SupportsRangeValue() const override;
virtual SortDirection GetSortDirection() const {
return kSortDirectionUndefined;
}
@@ -665,31 +576,23 @@ class MODULES_EXPORT AXObjectImpl
// ARIA live-region features.
bool IsLiveRegion() const;
- AXObjectImpl* LiveRegionRoot() const;
+ AXObject* LiveRegionRoot() const override;
virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; }
virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; }
virtual bool LiveRegionAtomic() const { return false; }
virtual bool LiveRegionBusy() const { return false; }
- const AtomicString& ContainerLiveRegionStatus() const;
- const AtomicString& ContainerLiveRegionRelevant() const;
- bool ContainerLiveRegionAtomic() const;
- bool ContainerLiveRegionBusy() const;
-
- // Every object's bounding box is returned relative to a
- // container object (which is guaranteed to be an ancestor) and
- // optionally a transformation matrix that needs to be applied too.
- // To compute the absolute bounding box of an element, start with its
- // boundsInContainer and apply the transform. Then as long as its container is
- // not null, walk up to its container and offset by the container's offset
- // from origin, the container's scroll position if any, and apply the
- // container's transform. Do this until you reach the root of the tree.
- virtual void GetRelativeBounds(AXObjectImpl** out_container,
- FloatRect& out_bounds_in_container,
- SkMatrix44& out_container_transform) const;
-
- // Get the bounds in frame-relative coordinates as a LayoutRect.
- LayoutRect GetBoundsInFrameCoordinates() const;
+ const AtomicString& ContainerLiveRegionStatus() const override;
+ const AtomicString& ContainerLiveRegionRelevant() const override;
+ bool ContainerLiveRegionAtomic() const override;
+ bool ContainerLiveRegionBusy() const override;
+
+ virtual void GetRelativeBounds(
+ AXObject** out_container,
+ FloatRect& out_bounds_in_container,
+ SkMatrix44& out_container_transform) const override;
+
+ LayoutRect GetBoundsInFrameCoordinates() const override;
// Explicitly set an object's bounding rect and offset container.
void SetElementRect(LayoutRect r, AXObjectImpl* container) {
@@ -698,8 +601,7 @@ class MODULES_EXPORT AXObjectImpl
}
// Hit testing.
- // Called on the root AX object to return the deepest available element.
- virtual AXObjectImpl* AccessibilityHitTest(const IntPoint&) const {
+ virtual AXObject* AccessibilityHitTest(const IntPoint&) const override {
return 0;
}
// Called on the AX object after the layout tree determines which is the right
@@ -708,7 +610,7 @@ class MODULES_EXPORT AXObjectImpl
// High-level accessibility tree access. Other modules should only use these
// functions.
- const AXObjectVector& Children();
+ const AXObjectImplVector& Children();
AXObjectImpl* ParentObject() const;
AXObjectImpl* ParentObjectIfExists() const;
virtual AXObjectImpl* ComputeParent() const = 0;
@@ -733,58 +635,45 @@ class MODULES_EXPORT AXObjectImpl
virtual AXObjectImpl* ScrollBar(AccessibilityOrientation) { return 0; }
// Properties of the object's owning document or page.
- virtual double EstimatedLoadingProgress() const { return 0; }
+ virtual double EstimatedLoadingProgress() const override { return 0; }
// DOM and layout tree access.
- virtual Node* GetNode() const { return nullptr; }
+ virtual Node* GetNode() const override { return nullptr; }
virtual Element* GetElement() const; // Same as GetNode, if it's an Element.
virtual LayoutObject* GetLayoutObject() const { return nullptr; }
- virtual Document* GetDocument() const;
- virtual LocalFrameView* DocumentFrameView() const;
+ virtual Document* GetDocument() const override;
+ virtual LocalFrameView* DocumentFrameView() const override;
virtual Element* AnchorElement() const { return nullptr; }
virtual Element* ActionElement() const { return nullptr; }
- String Language() const;
+ String Language() const override;
bool HasAttribute(const QualifiedName&) const;
const AtomicString& GetAttribute(const QualifiedName&) const;
- // Methods that retrieve or manipulate the current selection.
-
- // Get the current selection from anywhere in the accessibility tree.
- virtual AXRange Selection() const { return AXRange(); }
- // Gets only the start and end offsets of the selection computed using the
- // current object as the starting point. Returns a null selection if there is
- // no selection in the subtree rooted at this object.
- virtual AXRange SelectionUnderObject() const { return AXRange(); }
- virtual void SetSelection(const AXRange&) {}
+ virtual AXRange Selection() const override { return AXRange(); }
+ virtual AXRange SelectionUnderObject() const override { return AXRange(); }
+ virtual void SetSelection(const AXRange&) override {}
- // Scrollable containers.
- bool IsScrollableContainer() const;
- IntPoint GetScrollOffset() const;
- IntPoint MinimumScrollOffset() const;
- IntPoint MaximumScrollOffset() const;
- void SetScrollOffset(const IntPoint&) const;
+ bool IsScrollableContainer() const override;
+ IntPoint GetScrollOffset() const override;
+ IntPoint MinimumScrollOffset() const override;
+ IntPoint MaximumScrollOffset() const override;
+ void SetScrollOffset(const IntPoint&) const override;
// If this object itself scrolls, return its ScrollableArea.
virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; }
// Modify or take an action on an object.
- virtual void Increment() {}
- virtual void Decrement() {}
- bool PerformDefaultAction() { return Press(); }
- virtual bool Press();
- // Make this object visible by scrolling as many nested scrollable views as
- // needed.
- void ScrollToMakeVisible() const;
- // Same, but if the whole object can't be made visible, try for this subrect,
- // in local coordinates.
- void ScrollToMakeVisibleWithSubFocus(const IntRect&) const;
- // Scroll this object to a given point in global coordinates of the top-level
- // window.
- void ScrollToGlobalPoint(const IntPoint&) const;
- virtual void SetFocused(bool) {}
+ virtual void Increment() override {}
+ virtual void Decrement() override {}
+ bool PerformDefaultAction() override { return Press(); }
+ virtual bool Press() override;
+ void ScrollToMakeVisible() const override;
+ void ScrollToMakeVisibleWithSubFocus(const IntRect&) const override;
+ void ScrollToGlobalPoint(const IntPoint&) const override;
+ virtual void SetFocused(bool) override {}
virtual void SetSelected(bool) {}
- virtual void SetSequentialFocusNavigationStartingPoint();
- virtual void SetValue(const String&) {}
+ virtual void SetSequentialFocusNavigationStartingPoint() override;
+ virtual void SetValue(const String&) override {}
virtual void SetValue(float) {}
// Notifications that this object may have changed.
@@ -797,12 +686,34 @@ class MODULES_EXPORT AXObjectImpl
virtual void UpdateAccessibilityRole() {}
// Text metrics. Most of these should be deprecated, needs major cleanup.
- virtual VisiblePosition VisiblePositionForIndex(int) const {
+ virtual VisiblePosition VisiblePositionForIndex(int) const override {
return VisiblePosition();
}
- int LineForPosition(const VisiblePosition&) const;
+ int LineForPosition(const VisiblePosition&) const override;
virtual int Index(const VisiblePosition&) const { return -1; }
- virtual void LineBreaks(Vector<int>&) const {}
+ virtual void LineBreaks(Vector<int>&) const override {}
+
+ virtual int AriaColumnCount() const;
+ virtual unsigned AriaColumnIndex() const;
+ virtual int AriaRowCount() const;
+ virtual unsigned AriaRowIndex() const;
+ virtual unsigned ColumnCount() const;
+ virtual unsigned RowCount() const;
+ virtual WebAXObject CellForColumnAndRow(unsigned column, unsigned row) const;
+ virtual WebAXObject HeaderContainerObject() const;
+ virtual WebAXObject RowAtIndex(unsigned row_index) const;
+ virtual WebAXObject ColumnAtIndex(unsigned column_index) const;
+ virtual void RowHeaders(WebVector<WebAXObject>&) const;
+ virtual void ColumnHeaders(WebVector<WebAXObject>&) const;
+ virtual unsigned RowIndex() const;
+ virtual WebAXObject RowHeader() const;
+ virtual unsigned ColumnIndex() const;
+ virtual WebAXObject ColumnHeader() const;
+ virtual unsigned CellColumnIndex() const;
+ virtual unsigned CellColumnSpan() const;
+ virtual unsigned CellRowIndex() const;
+ virtual unsigned CellRowSpan() const;
+ virtual WebAXSortDirection SortDirection() const;
// Static helper functions.
static bool IsARIAControl(AccessibilityRole);
@@ -813,7 +724,7 @@ class MODULES_EXPORT AXObjectImpl
protected:
AXID id_;
- AXObjectVector children_;
+ AXObjectImplVector children_;
mutable bool have_children_;
AccessibilityRole role_;
AXObjectInclusion last_known_is_ignored_value_;

Powered by Google App Engine
This is Rietveld 408576698