Commit 8bc5afc5 authored by Alexander Surkov's avatar Alexander Surkov Committed by Chromium LUCI CQ

a11y inspect reorg: expose ChromeIdentifier attribute on mac

Inspect tools provide option to show internal ids of accessible
objects, which is a handy feature for debugging and event recording.
Platform tree formatters rely on internal accessible trees to retrieve
object ids. It should be avoided, because the tree formatters should
operate on external trees to produce same results not depending on how
a tree formatter was initiated (whether by tests or by ax_dump_tree
tool).

WebKit exposes AXIdentifier attribute, which looks like a great match
for this case. However, no comments from Apple so far about what
exactly this attribute is for, so let's move with ChromeIdentifier
attribute for now. Later it can be revisited.

Bug: 1134623
Change-Id: I367158bc8802734d0e9311c9739eb8da13ff0cf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602356
Commit-Queue: Alexander Surkov <asurkov@igalia.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839602}
parent 695b737d
......@@ -71,7 +71,7 @@ void AccessibilityTreeFormatterMac::AddDefaultFilters(
}
if (show_ids()) {
AddPropertyFilter(property_filters, "id");
AddPropertyFilter(property_filters, "ChromeAXNodeId");
}
}
......@@ -160,15 +160,9 @@ void AccessibilityTreeFormatterMac::AddProperties(
base::Value* dict) const {
// Chromium tree special processing
if (IsBrowserAccessibilityCocoa(node)) {
// Position (no size since it's exposed as standard AXSize attribute)
BrowserAccessibilityCocoa* cocoa_node =
static_cast<BrowserAccessibilityCocoa*>(node);
// DOM element id
BrowserAccessibility* owner_node = [cocoa_node owner];
dict->SetKey("id",
base::Value(base::NumberToString16(owner_node->GetId())));
// Position (no size since it's exposed as standard AXSize attribute)
dict->SetPath(kPositionDictAttr, PopulatePosition(cocoa_node));
}
......
......@@ -222,6 +222,7 @@ NSString* const
@"AXTextMarkerNodeDebugDescription";
// Other private attributes.
NSString* const NSAccessibilityIdentifierChromeAttribute = @"ChromeAXNodeId";
NSString* const NSAccessibilitySelectTextWithCriteriaParameterizedAttribute =
@"AXSelectTextWithCriteria";
NSString* const NSAccessibilityIndexForChildUIElementParameterizedAttribute =
......@@ -803,6 +804,7 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
{NSAccessibilityAutocompleteValueAttribute, @"autocompleteValue"},
{NSAccessibilityBlockQuoteLevelAttribute, @"blockQuoteLevel"},
{NSAccessibilityChildrenAttribute, @"children"},
{NSAccessibilityIdentifierChromeAttribute, @"internalId"},
{NSAccessibilityColumnsAttribute, @"columns"},
{NSAccessibilityColumnHeaderUIElementsAttribute, @"columnHeaders"},
{NSAccessibilityColumnIndexRangeAttribute, @"columnIndexRange"},
......@@ -3394,6 +3396,7 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
NSMutableArray* ret = [NSMutableArray
arrayWithObjects:NSAccessibilityBlockQuoteLevelAttribute,
NSAccessibilityChildrenAttribute,
NSAccessibilityIdentifierChromeAttribute,
NSAccessibilityDescriptionAttribute,
NSAccessibilityDOMClassList,
NSAccessibilityDOMIdentifierAttribute,
......@@ -3859,6 +3862,10 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
return _owner->GetId();
}
- (NSString*)internalId {
return [@(_owner->GetId()) stringValue];
}
- (BOOL)accessibilityNotifiesWhenDestroyed {
TRACE_EVENT0("accessibility",
"BrowserAccessibilityCocoa::accessibilityNotifiesWhenDestroyed");
......
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