Commit c3aed755 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Switched to using a single definition for the document object

What is considered a document object had two different definitions in accessibility.
This patch switches to using one source of truth in ax_role_properties which has a slightly more expanded definition.
The only affected code path is in the use of ISimpleDocument, a deprecated accessibility interface.

An upcoming patch should remove the kDocument role from ui::IsDocument and
rename that method to IsWebRoot.

AX-Relnotes: n/a.

R=dmazzoni@chromium.org, aleventhal@chromium.org

Change-Id: Ifae5f3d879c5ef2cbe708d3d64e9fde41c56858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532667
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Auto-Submit: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826907}
parent 13255881
...@@ -195,8 +195,7 @@ bool BrowserAccessibility::IsDescendantOf( ...@@ -195,8 +195,7 @@ bool BrowserAccessibility::IsDescendantOf(
} }
bool BrowserAccessibility::IsDocument() const { bool BrowserAccessibility::IsDocument() const {
return GetRole() == ax::mojom::Role::kRootWebArea || return ui::IsDocument(GetRole());
GetRole() == ax::mojom::Role::kWebArea;
} }
bool BrowserAccessibility::IsIgnored() const { bool BrowserAccessibility::IsIgnored() const {
......
...@@ -1366,25 +1366,24 @@ STDMETHODIMP BrowserAccessibilityComWin::InternalQueryInterface( ...@@ -1366,25 +1366,24 @@ STDMETHODIMP BrowserAccessibilityComWin::InternalQueryInterface(
BrowserAccessibilityComWin* accessibility = BrowserAccessibilityComWin* accessibility =
reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr); reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr);
if (!accessibility->owner()) { if (!accessibility || !accessibility->owner()) {
*object = nullptr; *object = nullptr;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
ax::mojom::Role role = accessibility->owner()->GetRole();
if (iid == IID_IAccessibleImage) { if (iid == IID_IAccessibleImage) {
const ax::mojom::Role role = accessibility->owner()->GetRole();
if (!ui::IsImage(role)) { if (!ui::IsImage(role)) {
*object = nullptr; *object = nullptr;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
} else if (iid == IID_ISimpleDOMDocument) { } else if (iid == IID_ISimpleDOMDocument) {
if (!ui::IsDocument(role)) { if (!accessibility->IsDocument()) {
*object = nullptr; *object = nullptr;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
} else if (iid == IID_IAccessibleHyperlink) { } else if (iid == IID_IAccessibleHyperlink) {
if (!accessibility || !accessibility->IsHyperlink()) { if (!accessibility->IsHyperlink()) {
*object = nullptr; *object = nullptr;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
......
...@@ -363,9 +363,9 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode { ...@@ -363,9 +363,9 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
// //
AXPlatformNodeDelegate* delegate_ = nullptr; AXPlatformNodeDelegate* delegate_ = nullptr;
protected:
bool IsDocument() const; bool IsDocument() const;
protected:
bool IsSelectionItemSupported() const; bool IsSelectionItemSupported() const;
// Get the role description from the node data or from the image annotation // Get the role description from the node data or from the image annotation
......
...@@ -300,7 +300,7 @@ ITextRangeProvider* AXPlatformNodeTextProviderWin::GetRangeFromChild( ...@@ -300,7 +300,7 @@ ITextRangeProvider* AXPlatformNodeTextProviderWin::GetRangeFromChild(
descendant->GetDelegate()->CreateTextPositionAt(0)->AsLeafTextPosition(); descendant->GetDelegate()->CreateTextPositionAt(0)->AsLeafTextPosition();
AXNodePosition::AXPositionInstance end; AXNodePosition::AXPositionInstance end;
if (ui::IsDocument(descendant->GetData().role)) { if (descendant->IsDocument()) {
// Fast path for getting the range of the web root. // Fast path for getting the range of the web root.
end = start->CreatePositionAtEndOfDocument(); end = start->CreatePositionAtEndOfDocument();
} else if (descendant->GetChildCount() == 0) { } else if (descendant->GetChildCount() == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment