diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index 8c599b11fb4cf..673f07531759f 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc @@ -176,10 +176,6 @@ bool BrowserAccessibility::IsDescendantOf( return node()->IsDescendantOfCrossingTreeBoundary(ancestor->node()); } -bool BrowserAccessibility::IsIgnored() const { - return node()->IsIgnored(); -} - bool BrowserAccessibility::IsIgnoredForTextNavigation() const { return node()->IsIgnoredForTextNavigation(); } @@ -722,13 +718,6 @@ bool BrowserAccessibility::HasExplicitlyEmptyName() const { return GetNameFrom() == ax::mojom::NameFrom::kAttributeExplicitlyEmpty; } -BrowserAccessibility::AXPosition BrowserAccessibility::CreatePositionAt( - int offset, - ax::mojom::TextAffinity affinity) const { - return ui::AXNodePosition::CreatePosition( - *node(), /* child_index_or_text_offset */ offset); -} - // |offset| could either be a text character or a child index in case of // non-text objects. // Currently, to be safe, we convert to text leaf equivalents and we don't use @@ -744,29 +733,12 @@ std::u16string BrowserAccessibility::GetNameAsString16() const { return node()->GetNameUTF16(); } -const std::string& BrowserAccessibility::GetDescription() const { - return GetStringAttribute(ax::mojom::StringAttribute::kDescription); -} - std::u16string BrowserAccessibility::GetHypertext() const { // Overloaded by platforms which require a hypertext accessibility text // implementation. return std::u16string(); } -const std::map& -BrowserAccessibility::GetHypertextOffsetToHyperlinkChildIndex() const { - return node()->GetHypertextOffsetToHyperlinkChildIndex(); -} - -std::u16string BrowserAccessibility::GetTextContentUTF16() const { - return node()->GetTextContentUTF16(); -} - -std::u16string BrowserAccessibility::GetValueForControl() const { - return base::UTF8ToUTF16(node()->GetValueForControl()); -} - gfx::Rect BrowserAccessibility::RelativeToAbsoluteBounds( gfx::RectF bounds, const ui::AXCoordinateSystem coordinate_system, @@ -844,14 +816,6 @@ bool BrowserAccessibility::IsOffscreen() const { return offscreen_result == ui::AXOffscreenResult::kOffscreen; } -bool BrowserAccessibility::IsMinimized() const { - return false; -} - -bool BrowserAccessibility::IsText() const { - return node()->IsText(); -} - bool BrowserAccessibility::IsWebContent() const { return true; } @@ -928,10 +892,6 @@ std::set BrowserAccessibility::GetReverseRelations( manager_->ax_tree()->GetReverseRelations(attr, GetData().id)); } -std::u16string BrowserAccessibility::GetAuthorUniqueId() const { - return node()->GetHtmlAttribute("id"); -} - const ui::AXUniqueId& BrowserAccessibility::GetUniqueId() const { // This is not the same as GetData().id which comes from Blink, because // those ids are only unique within the Blink process. We need one that is @@ -969,39 +929,10 @@ BrowserAccessibility::GetUIADirectChildrenInRange( return {}; } -gfx::NativeViewAccessible BrowserAccessibility::GetNativeViewAccessible() { - // TODO(703369) On Windows, where we have started to migrate to an - // AXPlatformNode implementation, the BrowserAccessibilityWin subclass has - // overridden this method. On all other platforms, this method should not be - // called yet. In the future, when all subclasses have moved over to be - // implemented by AXPlatformNode, we may make this method completely virtual. - NOTREACHED(); - return nullptr; -} - // // AXPlatformNodeDelegate. // -const ui::AXNodeData& BrowserAccessibility::GetData() const { - return node()->data(); -} - -BrowserAccessibility::AXPosition BrowserAccessibility::CreateTextPositionAt( - int offset, - ax::mojom::TextAffinity affinity) const { - DCHECK(node()->IsDataValid()); - DCHECK(manager_->GetNode(GetId())) - << "No node for id: " << GetId() << " " << node()->id() << " " - << node()->data().id; - return ui::AXNodePosition::CreateTextPosition(*node(), offset, affinity); -} - -gfx::NativeViewAccessible BrowserAccessibility::GetNSWindow() { - NOTREACHED(); - return nullptr; -} - gfx::NativeViewAccessible BrowserAccessibility::GetParent() const { BrowserAccessibility* parent = PlatformGetParent(); if (parent) @@ -1025,10 +956,6 @@ gfx::NativeViewAccessible BrowserAccessibility::ChildAtIndex(size_t index) { return child->GetNativeViewAccessible(); } -bool BrowserAccessibility::HasModalDialog() const { - return false; -} - gfx::NativeViewAccessible BrowserAccessibility::GetFirstChild() { BrowserAccessibility* child = PlatformGetFirstChild(); if (!child) @@ -1057,10 +984,6 @@ gfx::NativeViewAccessible BrowserAccessibility::GetPreviousSibling() { return sibling->GetNativeViewAccessible(); } -bool BrowserAccessibility::IsChildOfLeaf() const { - return node()->IsChildOfLeaf(); -} - bool BrowserAccessibility::IsEmptyLeaf() const { return node()->IsEmptyLeaf(); } @@ -1097,10 +1020,6 @@ bool BrowserAccessibility::IsToplevelBrowserWindow() { return false; } -bool BrowserAccessibility::IsDescendantOfAtomicTextField() const { - return node()->IsDescendantOfAtomicTextField(); -} - bool BrowserAccessibility::IsPlatformDocument() const { return ui::IsPlatformDocument(GetRole()); } @@ -1967,10 +1886,6 @@ ui::TextAttributeList BrowserAccessibility::ComputeTextAttributes() const { return ui::TextAttributeList(); } -std::string BrowserAccessibility::GetInheritedFontFamilyName() const { - return GetInheritedStringAttribute(ax::mojom::StringAttribute::kFontFamily); -} - ui::TextAttributeMap BrowserAccessibility::GetSpellingAndGrammarAttributes() const { // TODO(crbug.com/1049261): This is one of the few methods that won't be moved diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index 79974df2c0603..cea96ee5ba8b6 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h @@ -375,32 +375,16 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { std::u16string GetNameAsString16() const; // `AXPlatformNodeDelegate` implementation. - std::u16string GetAuthorUniqueId() const override; - const ui::AXNodeData& GetData() const override; - AXPosition CreatePositionAt( - int offset, - ax::mojom::TextAffinity affinity = - ax::mojom::TextAffinity::kDownstream) const override; - AXPosition CreateTextPositionAt( - int offset, - ax::mojom::TextAffinity affinity = - ax::mojom::TextAffinity::kDownstream) const override; - gfx::NativeViewAccessible GetNSWindow() override; - gfx::NativeViewAccessible GetNativeViewAccessible() override; gfx::NativeViewAccessible GetParent() const override; size_t GetChildCount() const override; gfx::NativeViewAccessible ChildAtIndex(size_t index) override; - bool HasModalDialog() const override; gfx::NativeViewAccessible GetFirstChild() override; gfx::NativeViewAccessible GetLastChild() override; gfx::NativeViewAccessible GetNextSibling() override; gfx::NativeViewAccessible GetPreviousSibling() override; - bool IsChildOfLeaf() const override; - bool IsDescendantOfAtomicTextField() const override; bool IsPlatformDocument() const override; bool IsLeaf() const override; bool IsFocused() const override; - bool IsIgnored() const override; bool IsToplevelBrowserWindow() override; gfx::NativeViewAccessible GetLowestPlatformAncestor() const override; gfx::NativeViewAccessible GetTextFieldAncestor() const override; @@ -410,13 +394,8 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { std::unique_ptr ChildrenBegin() override; std::unique_ptr ChildrenEnd() override; - const std::string& GetDescription() const override; std::u16string GetHypertext() const override; - const std::map& GetHypertextOffsetToHyperlinkChildIndex() - const override; bool SetHypertextSelection(int start_offset, int end_offset) override; - std::u16string GetTextContentUTF16() const override; - std::u16string GetValueForControl() const override; gfx::Rect GetBoundsRect( const ui::AXCoordinateSystem coordinate_system, const ui::AXClippingBehavior clipping_behavior, @@ -459,11 +438,8 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { std::u16string GetStyleNameAttributeAsLocalizedString() const override; ui::TextAttributeMap ComputeTextAttributeMap( const ui::TextAttributeList& default_attributes) const override; - std::string GetInheritedFontFamilyName() const override; bool ShouldIgnoreHoveredStateForTesting() override; bool IsOffscreen() const override; - bool IsMinimized() const override; - bool IsText() const override; bool IsWebContent() const override; bool HasVisibleCaretOrSelection() const override; ui::AXPlatformNode* GetTargetNodeForRelation( diff --git a/ui/accessibility/platform/ax_platform_node_delegate.cc b/ui/accessibility/platform/ax_platform_node_delegate.cc index 554f8cc758882..23b26e0a67eb1 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate.cc +++ b/ui/accessibility/platform/ax_platform_node_delegate.cc @@ -6,7 +6,9 @@ #include "base/containers/fixed_flat_set.h" #include "base/notreached.h" +#include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/ax_selection.h" +#include "ui/accessibility/platform/ax_platform_node.h" #include "ui/accessibility/platform/ax_platform_tree_manager.h" namespace ui { @@ -33,6 +35,448 @@ AXTreeManager* AXPlatformNodeDelegate::GetTreeManager() const { return AXTreeManager::FromID(GetTreeData().tree_id); } +const AXNodeData& AXPlatformNodeDelegate::GetData() const { + if (node_) + return node_->data(); + + static base::NoDestructor empty_data; + return *empty_data; +} + +std::u16string AXPlatformNodeDelegate::GetTextContentUTF16() const { + if (node_) + return node_->GetTextContentUTF16(); + + // Unlike in web content the "kValue" attribute always takes precedence, + // because we assume that users of the base impl, such as Views controls, + // are carefully crafted by hand, in contrast to HTML pages, where any content + // that might be present in the shadow DOM (AKA in the internal accessibility + // tree) is actually used by the renderer when assigning the "kValue" + // attribute, including any redundant white space. + std::u16string value = + GetString16Attribute(ax::mojom::StringAttribute::kValue); + if (!value.empty()) + return value; + + // TODO(https://crbug.com/1030703): The check for `IsInvisibleOrIgnored()` + // should not be needed. `ChildAtIndex()` and `GetChildCount()` are already + // supposed to skip over nodes that are invisible or ignored, but + // `ViewAXPlatformNodeDelegate` does not currently implement this behavior. + if (IsLeaf() && !IsInvisibleOrIgnored()) + return GetString16Attribute(ax::mojom::StringAttribute::kName); + + std::u16string text_content; + for (size_t i = 0; i < GetChildCount(); ++i) { + // TODO(nektar): Add const to all tree traversal methods and remove + // const_cast. + const AXPlatformNode* child = AXPlatformNode::FromNativeViewAccessible( + const_cast(this)->ChildAtIndex(i)); + if (!child || !child->GetDelegate()) + continue; + text_content += child->GetDelegate()->GetTextContentUTF16(); + } + return text_content; +} + +std::u16string AXPlatformNodeDelegate::GetValueForControl() const { + if (node_) + return base::UTF8ToUTF16(node()->GetValueForControl()); + + if (!IsControl(GetRole()) && !GetData().IsRangeValueSupported()) + return std::u16string(); + + std::u16string value = + GetString16Attribute(ax::mojom::StringAttribute::kValue); + float numeric_value; + if (GetData().IsRangeValueSupported() && value.empty() && + GetData().GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + &numeric_value)) { + value = base::NumberToString16(numeric_value); + } + return value; +} + +AXNodePosition::AXPositionInstance AXPlatformNodeDelegate::CreatePositionAt( + int offset, + ax::mojom::TextAffinity affinity) const { + if (node_) + return AXNodePosition::CreatePosition(*node_, offset, affinity); + return AXNodePosition::CreateNullPosition(); +} + +AXNodePosition::AXPositionInstance AXPlatformNodeDelegate::CreateTextPositionAt( + int offset, + ax::mojom::TextAffinity affinity) const { + if (node_) { + DCHECK(node_->tree()) + << "All nodes should be owned by an accessibility tree.\n" + << *node_; + DCHECK(node_->IsDataValid()); + return AXNodePosition::CreateTextPosition(*node_, offset, affinity); + } + return AXNodePosition::CreateNullPosition(); +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetNSWindow() { + NOTREACHED() << "Only available on macOS."; + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetNativeViewAccessible() { + // TODO(crbug.com/703369) On Windows, where we have started to migrate to an + // AXPlatformNode implementation, the BrowserAccessibilityWin subclass has + // overridden this method. On all other platforms, this method should not be + // called yet. In the future, when all subclasses have moved over to be + // implemented by AXPlatformNode, we may make this method completely virtual. + NOTREACHED() << "https://crbug.com/703369"; + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetParent() const { + return nullptr; +} + +absl::optional AXPlatformNodeDelegate::GetIndexInParent() { + if (node_) + return node_->GetUnignoredIndexInParent(); + + AXPlatformNodeDelegate* parent = GetParentDelegate(); + if (!parent) + return absl::nullopt; + + for (size_t i = 0; i < parent->GetChildCount(); i++) { + AXPlatformNode* child_node = + AXPlatformNode::FromNativeViewAccessible(parent->ChildAtIndex(i)); + if (child_node && child_node->GetDelegate() == this) + return i; + } + return absl::nullopt; +} + +size_t AXPlatformNodeDelegate::GetChildCount() const { + return 0u; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::ChildAtIndex(size_t index) { + return nullptr; +} + +bool AXPlatformNodeDelegate::HasModalDialog() const { + return false; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetFirstChild() { + if (GetChildCount() > 0) + return ChildAtIndex(0); + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetLastChild() { + size_t child_count = GetChildCount(); + if (child_count > 0) + return ChildAtIndex(child_count - 1); + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetNextSibling() { + AXPlatformNodeDelegate* parent = GetParentDelegate(); + if (!parent) + return nullptr; + auto index = GetIndexInParent(); + if (index.has_value()) { + size_t next_index = index.value() + 1; + if (next_index < parent->GetChildCount()) + return parent->ChildAtIndex(next_index); + } + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetPreviousSibling() { + AXPlatformNodeDelegate* parent = GetParentDelegate(); + if (!parent) + return nullptr; + auto index = GetIndexInParent(); + if (index.has_value()) { + size_t next_index = index.value() - 1; + if (next_index < parent->GetChildCount()) + return parent->ChildAtIndex(next_index); + } + return nullptr; +} + +bool AXPlatformNodeDelegate::IsChildOfLeaf() const { + if (node_) + return node_->IsChildOfLeaf(); + + // TODO(nektar): Make all tree traversal methods const and remove const_cast. + const AXPlatformNodeDelegate* parent = + const_cast(this)->GetParentDelegate(); + if (!parent) + return false; + if (parent->IsLeaf()) + return true; + return parent->IsChildOfLeaf(); +} + +bool AXPlatformNodeDelegate::IsDescendantOfAtomicTextField() const { + if (node_) + return node_->IsDescendantOfAtomicTextField(); + + // TODO(nektar): Add const to all tree traversal methods and remove + // const_cast. + for (AXPlatformNodeDelegate* ancestor_delegate = + const_cast(this); + ancestor_delegate; + ancestor_delegate = static_cast( + ancestor_delegate->GetParentDelegate())) { + if (ancestor_delegate->GetData().IsAtomicTextField()) + return true; + } + return false; +} + +bool AXPlatformNodeDelegate::IsPlatformDocument() const { + return ui::IsPlatformDocument(GetRole()); +} + +bool AXPlatformNodeDelegate::IsFocused() const { + // TODO(accessibility): Move `GetFocus` into `AXTreeManager` so we can use + // `BrowserAccessibility` implementation here and remove it from there. + return false; +} + +bool AXPlatformNodeDelegate::IsIgnored() const { + if (node_) + return node_->IsIgnored(); + + // To avoid the situation where a screen reader user will not be able to + // access a focused node because it has accidentally been marked as ignored, + // we unignore any nodes that are focused. However, we don't need to check + // this here because subclasses should make sure that the ignored state is + // removed from all nodes that are currently focused. This condition will be + // enforced once we switch to using an AXTree of AXNodes in Views. + return GetRole() == ax::mojom::Role::kNone || + HasState(ax::mojom::State::kIgnored); +} + +bool AXPlatformNodeDelegate::IsToplevelBrowserWindow() { + return false; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetLowestPlatformAncestor() + const { + AXPlatformNodeDelegate* current_delegate = + const_cast(this); + AXPlatformNodeDelegate* lowest_unignored_delegate = current_delegate; + if (lowest_unignored_delegate->IsIgnored()) { + lowest_unignored_delegate = static_cast( + lowest_unignored_delegate->GetParentDelegate()); + } + DCHECK(!lowest_unignored_delegate || !lowest_unignored_delegate->IsIgnored()) + << "`AXPlatformNodeDelegate::GetParentDelegate()` should return " + "either an unignored object or nullptr."; + + // `highest_leaf_delegate` could be nullptr. + AXPlatformNodeDelegate* highest_leaf_delegate = lowest_unignored_delegate; + // For the purposes of this method, a leaf node does not include leaves in the + // internal accessibility tree, only in the platform exposed tree. + for (AXPlatformNodeDelegate* ancestor_delegate = lowest_unignored_delegate; + ancestor_delegate; + ancestor_delegate = static_cast( + ancestor_delegate->GetParentDelegate())) { + if (ancestor_delegate->IsLeaf()) + highest_leaf_delegate = ancestor_delegate; + } + if (highest_leaf_delegate) + return highest_leaf_delegate->GetNativeViewAccessible(); + + if (lowest_unignored_delegate) + return lowest_unignored_delegate->GetNativeViewAccessible(); + return current_delegate->GetNativeViewAccessible(); +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetTextFieldAncestor() const { + // TODO(nektar): Add const to all tree traversal methods and remove + // const_cast. + for (AXPlatformNodeDelegate* ancestor_delegate = + const_cast(this); + ancestor_delegate; + ancestor_delegate = static_cast( + ancestor_delegate->GetParentDelegate())) { + if (ancestor_delegate->GetData().IsTextField()) + return ancestor_delegate->GetNativeViewAccessible(); + } + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetSelectionContainer() + const { + // TODO(nektar): Add const to all tree traversal methods and remove + // const_cast. + for (AXPlatformNodeDelegate* ancestor_delegate = + const_cast(this); + ancestor_delegate; + ancestor_delegate = static_cast( + ancestor_delegate->GetParentDelegate())) { + if (IsContainerWithSelectableChildren(ancestor_delegate->GetRole())) + return ancestor_delegate->GetNativeViewAccessible(); + } + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetTableAncestor() const { + // TODO(nektar): Add const to all tree traversal methods and remove + // const_cast. + for (AXPlatformNodeDelegate* ancestor_delegate = + const_cast(this); + ancestor_delegate; + ancestor_delegate = static_cast( + ancestor_delegate->GetParentDelegate())) { + if (IsTableLike(ancestor_delegate->GetRole())) + return ancestor_delegate->GetNativeViewAccessible(); + } + return nullptr; +} + +const std::string& AXPlatformNodeDelegate::GetName() const { + if (node_) + return node()->GetNameUTF8(); + return GetStringAttribute(ax::mojom::StringAttribute::kName); +} + +const std::string& AXPlatformNodeDelegate::GetDescription() const { + return GetStringAttribute(ax::mojom::StringAttribute::kDescription); +} + +std::u16string AXPlatformNodeDelegate::GetHypertext() const { + // Overloaded by platforms which require a hypertext accessibility text + // implementation. + return std::u16string(); +} + +const std::map& +AXPlatformNodeDelegate::GetHypertextOffsetToHyperlinkChildIndex() const { + if (node_) + return node_->GetHypertextOffsetToHyperlinkChildIndex(); + + // TODO(nektar): Remove this dummy method once hypertext computation and + // selection handling has moved entirely to AXNode / AXPosition. + static base::NoDestructor> dummy_map; + return *dummy_map; +} + +bool AXPlatformNodeDelegate::SetHypertextSelection(int start_offset, + int end_offset) { + AXActionData action_data; + action_data.action = ax::mojom::Action::kSetSelection; + action_data.anchor_node_id = action_data.focus_node_id = GetData().id; + action_data.anchor_offset = start_offset; + action_data.focus_offset = end_offset; + return AccessibilityPerformAction(action_data); +} + +TextAttributeMap AXPlatformNodeDelegate::ComputeTextAttributeMap( + const TextAttributeList& default_attributes) const { + ui::TextAttributeMap attributes_map; + attributes_map[0] = default_attributes; + return attributes_map; +} + +std::string AXPlatformNodeDelegate::GetInheritedFontFamilyName() const { + return GetInheritedStringAttribute(ax::mojom::StringAttribute::kFontFamily); +} + +gfx::Rect AXPlatformNodeDelegate::GetBoundsRect( + const AXCoordinateSystem coordinate_system, + const AXClippingBehavior clipping_behavior, + AXOffscreenResult* offscreen_result) const { + return gfx::Rect(); +} + +gfx::Rect AXPlatformNodeDelegate::GetHypertextRangeBoundsRect( + const int start_offset, + const int end_offset, + const AXCoordinateSystem coordinate_system, + const AXClippingBehavior clipping_behavior, + AXOffscreenResult* offscreen_result) const { + return gfx::Rect(); +} + +gfx::Rect AXPlatformNodeDelegate::GetInnerTextRangeBoundsRect( + const int start_offset, + const int end_offset, + const AXCoordinateSystem coordinate_system, + const AXClippingBehavior clipping_behavior, + AXOffscreenResult* offscreen_result) const { + return gfx::Rect(); +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::HitTestSync( + int screen_physical_pixel_x, + int screen_physical_pixel_y) const { + return nullptr; +} + +gfx::NativeViewAccessible AXPlatformNodeDelegate::GetFocus() const { + return nullptr; +} + +bool AXPlatformNodeDelegate::IsOffscreen() const { + return false; +} + +bool AXPlatformNodeDelegate::IsMinimized() const { + return false; +} + +bool AXPlatformNodeDelegate::IsText() const { + if (node_) + return node_->IsText(); + return ui::IsText(GetRole()); +} + +bool AXPlatformNodeDelegate::IsWebContent() const { + return false; +} + +bool AXPlatformNodeDelegate::HasVisibleCaretOrSelection() const { + return IsDescendantOfAtomicTextField(); +} + +std::set AXPlatformNodeDelegate::GetReverseRelations( + ax::mojom::IntAttribute attr) { + // TODO(accessibility) Implement these if views ever use relations more + // widely. The use so far has been for the Omnibox to the suggestion + // popup. If this is ever implemented, then the "popup for" to "controlled + // by" mapping in AXPlatformRelationWin can be removed, as it would be + // redundant with setting the controls relationship. + return std::set(); +} + +std::set AXPlatformNodeDelegate::GetReverseRelations( + ax::mojom::IntListAttribute attr) { + return std::set(); +} + +std::u16string AXPlatformNodeDelegate::GetAuthorUniqueId() const { + if (node_) + return node_->GetHtmlAttribute("id"); + return std::u16string(); +} + +const AXUniqueId& AXPlatformNodeDelegate::GetUniqueId() const { + static base::NoDestructor dummy_unique_id; + return *dummy_unique_id; +} + +AXPlatformNodeDelegate* AXPlatformNodeDelegate::GetParentDelegate() const { + AXPlatformNode* parent_node = + ui::AXPlatformNode::FromNativeViewAccessible(GetParent()); + if (parent_node) + return parent_node->GetDelegate(); + return nullptr; +} + const AXTreeData& AXPlatformNodeDelegate::GetTreeData() const { if (node_) { DCHECK(node_->tree()) @@ -398,12 +842,6 @@ bool AXPlatformNodeDelegate::IsInvisibleOrIgnored() const { return IsIgnored() || GetData().IsInvisible(); } -const std::string& AXPlatformNodeDelegate::GetName() const { - if (node_) - return node()->GetNameUTF8(); - return GetStringAttribute(ax::mojom::StringAttribute::kName); -} - bool AXPlatformNodeDelegate::IsTable() const { if (node_) return node_->IsTable(); diff --git a/ui/accessibility/platform/ax_platform_node_delegate.h b/ui/accessibility/platform/ax_platform_node_delegate.h index b1837dd4da770..52cce0abd2459 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate.h +++ b/ui/accessibility/platform/ax_platform_node_delegate.h @@ -100,7 +100,7 @@ class COMPONENT_EXPORT(AX_PLATFORM) AXPlatformNodeDelegate { // because any attributes that could automatically be computed in the browser // process would also be returned. The browser process would try to correct // missing or erroneous information too. - virtual const AXNodeData& GetData() const = 0; + virtual const AXNodeData& GetData() const; // Get some extra data about the accessibility tree that contains this node. virtual const AXTreeData& GetTreeData() const; @@ -181,14 +181,14 @@ class COMPONENT_EXPORT(AX_PLATFORM) AXPlatformNodeDelegate { // Only text displayed on screen is included. Text from ARIA and HTML // attributes that is either not displayed on screen, or outside this node, // e.g. aria-label and HTML title, is not returned. - virtual std::u16string GetTextContentUTF16() const = 0; + virtual std::u16string GetTextContentUTF16() const; // Returns the value of a control such as a text field, a slider, a ,