Commit ccc8a0a4 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Chromium LUCI CQ

Made AXNode::IsDescendantOf work the same across BrowserAccessibility,...

Made AXNode::IsDescendantOf work the same across BrowserAccessibility, AXPlatformNodeBase and AXNode

An inconsistency in the behavior of this method that
I found while merging BrowserAccessibilityPosition and AXNodePosition.

AX-Relnotes: n/a.

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

Change-Id: I34ce5d10bc67a7b78438e94a4a9c4b6c21fd5bc9
Bug: 1049261
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644620Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Auto-Submit: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846221}
parent e7d00d9b
...@@ -4,10 +4,11 @@ ...@@ -4,10 +4,11 @@
#include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_node.h"
#include <string.h>
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
...@@ -417,6 +418,9 @@ void AXNode::Destroy() { ...@@ -417,6 +418,9 @@ void AXNode::Destroy() {
} }
bool AXNode::IsDescendantOf(const AXNode* ancestor) const { bool AXNode::IsDescendantOf(const AXNode* ancestor) const {
if (!ancestor)
return false;
if (this == ancestor) if (this == ancestor)
return true; return true;
if (parent()) if (parent())
...@@ -1346,13 +1350,12 @@ bool AXNode::IsInListMarker() const { ...@@ -1346,13 +1350,12 @@ bool AXNode::IsInListMarker() const {
if (data().role == ax::mojom::Role::kListMarker) if (data().role == ax::mojom::Role::kListMarker)
return true; return true;
// List marker node's children can only be text elements. // The children of a list marker node can only be text nodes.
if (!IsText()) if (!IsText())
return false; return false;
// There is no need to iterate over all the ancestors of the current anchor // There is no need to iterate over all the ancestors of the current node
// since a list marker node only has children on 2 levels. // since a list marker has descendants that are only 2 levels deep, i.e.:
// i.e.:
// AXLayoutObject role=kListMarker // AXLayoutObject role=kListMarker
// ++StaticText // ++StaticText
// ++++InlineTextBox // ++++InlineTextBox
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <vector> #include <vector>
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_export.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
......
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