Commit 07dfb81c authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Support aria-description

Part of proposal at https://github.com/aleventhal/aria-annotations

Bug: 1006767
Change-Id: I5b66cd6a93ea799ec1d61a0592733812f7bdf8a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911081
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715294}
parent 3a2f267b
...@@ -520,6 +520,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, ...@@ -520,6 +520,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
RunEventTest(FILE_PATH_LITERAL("description-change-indirect.html")); RunEventTest(FILE_PATH_LITERAL("description-change-indirect.html"));
} }
IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
AccessibilityEventsDescriptionChangeNoRelation) {
RunEventTest(FILE_PATH_LITERAL("description-change-no-relation.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest, IN_PROC_BROWSER_TEST_P(DumpAccessibilityEventsTest,
AccessibilityEventsDisabledStateChanged) { AccessibilityEventsDisabledStateChanged) {
RunEventTest(FILE_PATH_LITERAL("disabled-state-changed.html")); RunEventTest(FILE_PATH_LITERAL("disabled-state-changed.html"));
......
...@@ -542,6 +542,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, ...@@ -542,6 +542,11 @@ IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
RunAriaTest(FILE_PATH_LITERAL("aria-describedby-updates.html")); RunAriaTest(FILE_PATH_LITERAL("aria-describedby-updates.html"));
} }
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest,
AccessibilityAriaDescription) {
RunAriaTest(FILE_PATH_LITERAL("aria-description.html"));
}
IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityAriaDetails) { IN_PROC_BROWSER_TEST_P(DumpAccessibilityTreeTest, AccessibilityAriaDetails) {
RunAriaTest(FILE_PATH_LITERAL("aria-details.html")); RunAriaTest(FILE_PATH_LITERAL("aria-details.html"));
} }
......
rootWebArea
++genericContainer ignored
++++genericContainer description='Text description' name='description' descriptionFrom=attribute
++++genericContainer description='Description from describedby' name='both' descriptionFrom=relatedElement
++++tooltip name='Description from describedby'
++++++staticText name='Description from describedby'
++++++++inlineTextBox name='Description from describedby'
<!DOCTYPE html>
<html>
<body>
<div aria-label="description" aria-description="Text description" ></div>
<div aria-label="both" aria-description="describedby overrides description" aria-describedby="desc1" ></div>
<div role="tooltip" id="desc1">Description from describedby</div>
</body>
</html>
DESCRIPTION-CHANGED:2 role=ROLE_SECTION name='(null)' ENABLED,SENSITIVE,SHOWING,VISIBLE
FullDescription changed on role=group
Text_TextChanged on role=document
<!--
@UIA-WIN-DENY:Text_TextChanged*
-->
<!DOCTYPE html>
<html>
<body>
<div id="a" aria-description="1"></div>
<script>
function go() {
document.getElementById('a').setAttribute('aria-description', '2');
}
</script>
</body>
</html>
...@@ -2470,6 +2470,7 @@ enum WebFeature { ...@@ -2470,6 +2470,7 @@ enum WebFeature {
kFetchBodyStreamInServiceWorker = 3086, kFetchBodyStreamInServiceWorker = 3086,
kFetchBodyStreamOutsideServiceWorker = 3087, kFetchBodyStreamOutsideServiceWorker = 3087,
kGetComputedStyleOutsideFlatTree = 3088, kGetComputedStyleOutsideFlatTree = 3088,
kARIADescriptionAttribute = 3089,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -27,6 +27,8 @@ QualifiedName GetCorrespondingARIAAttribute(AOMStringProperty property) { ...@@ -27,6 +27,8 @@ QualifiedName GetCorrespondingARIAAttribute(AOMStringProperty property) {
return html_names::kAriaCheckedAttr; return html_names::kAriaCheckedAttr;
case AOMStringProperty::kCurrent: case AOMStringProperty::kCurrent:
return html_names::kAriaCurrentAttr; return html_names::kAriaCurrentAttr;
case AOMStringProperty::kDescription:
return html_names::kAriaDescriptionAttr;
case AOMStringProperty::kHasPopUp: case AOMStringProperty::kHasPopUp:
return html_names::kAriaHaspopupAttr; return html_names::kAriaHaspopupAttr;
case AOMStringProperty::kInvalid: case AOMStringProperty::kInvalid:
...@@ -644,6 +646,15 @@ void AccessibleNode::setDescribedBy(AccessibleNodeList* described_by) { ...@@ -644,6 +646,15 @@ void AccessibleNode::setDescribedBy(AccessibleNodeList* described_by) {
NotifyAttributeChanged(html_names::kAriaDescribedbyAttr); NotifyAttributeChanged(html_names::kAriaDescribedbyAttr);
} }
AtomicString AccessibleNode::description() const {
return GetProperty(AOMStringProperty::kDescription);
}
void AccessibleNode::setDescription(const AtomicString& description) {
SetStringProperty(AOMStringProperty::kDescription, description);
NotifyAttributeChanged(html_names::kAriaDescriptionAttr);
}
AccessibleNode* AccessibleNode::details() const { AccessibleNode* AccessibleNode::details() const {
return GetProperty(element_, AOMRelationProperty::kDetails); return GetProperty(element_, AOMRelationProperty::kDetails);
} }
...@@ -1042,6 +1053,7 @@ bool AccessibleNode::IsStringTokenProperty(AOMStringProperty property) { ...@@ -1042,6 +1053,7 @@ bool AccessibleNode::IsStringTokenProperty(AOMStringProperty property) {
case AOMStringProperty::kRelevant: case AOMStringProperty::kRelevant:
case AOMStringProperty::kSort: case AOMStringProperty::kSort:
return true; return true;
case AOMStringProperty::kDescription:
case AOMStringProperty::kKeyShortcuts: case AOMStringProperty::kKeyShortcuts:
case AOMStringProperty::kLabel: case AOMStringProperty::kLabel:
case AOMStringProperty::kPlaceholder: case AOMStringProperty::kPlaceholder:
......
...@@ -27,6 +27,7 @@ enum class AOMStringProperty { ...@@ -27,6 +27,7 @@ enum class AOMStringProperty {
kAutocomplete, kAutocomplete,
kChecked, kChecked,
kCurrent, kCurrent,
kDescription,
kHasPopUp, kHasPopUp,
kInvalid, kInvalid,
kKeyShortcuts, kKeyShortcuts,
...@@ -230,6 +231,9 @@ class CORE_EXPORT AccessibleNode : public EventTargetWithInlineData { ...@@ -230,6 +231,9 @@ class CORE_EXPORT AccessibleNode : public EventTargetWithInlineData {
AccessibleNodeList* describedBy(); AccessibleNodeList* describedBy();
void setDescribedBy(AccessibleNodeList*); void setDescribedBy(AccessibleNodeList*);
AtomicString description() const;
void setDescription(const AtomicString&);
AccessibleNode* details() const; AccessibleNode* details() const;
void setDetails(AccessibleNode*); void setDetails(AccessibleNode*);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
type: "token" type: "token"
}, },
{name: "aria-describedby", type: "IDREF_list"}, {name: "aria-describedby", type: "IDREF_list"},
{name: "aria-description", type: "string"},
{name: "aria-details", type: "IDREF"}, {name: "aria-details", type: "IDREF"},
{name: "aria-disabled", default: "false", type: "boolean"}, {name: "aria-disabled", default: "false", type: "boolean"},
{ {
......
...@@ -582,6 +582,8 @@ AttributeTriggers* HTMLElement::TriggersForAttributeName( ...@@ -582,6 +582,8 @@ AttributeTriggers* HTMLElement::TriggersForAttributeName(
kNoEvent, nullptr}, kNoEvent, nullptr},
{html_names::kAriaDescribedbyAttr, WebFeature::kARIADescribedByAttribute, {html_names::kAriaDescribedbyAttr, WebFeature::kARIADescribedByAttribute,
kNoEvent, nullptr}, kNoEvent, nullptr},
{html_names::kAriaDescriptionAttr, WebFeature::kARIADescriptionAttribute,
kNoEvent, nullptr},
{html_names::kAriaDetailsAttr, WebFeature::kARIADetailsAttribute, {html_names::kAriaDetailsAttr, WebFeature::kARIADetailsAttribute,
kNoEvent, nullptr}, kNoEvent, nullptr},
{html_names::kAriaDisabledAttr, WebFeature::kARIADisabledAttribute, {html_names::kAriaDisabledAttr, WebFeature::kARIADisabledAttribute,
......
...@@ -3623,6 +3623,24 @@ String AXNodeObject::Description(ax::mojom::NameFrom name_from, ...@@ -3623,6 +3623,24 @@ String AXNodeObject::Description(ax::mojom::NameFrom name_from,
} }
} }
// aria-description overrides any HTML-based accessible description,
// but not aria-describedby.
if (RuntimeEnabledFeatures::AccessibilityExposeARIAAnnotationsEnabled(
GetDocument())) {
const AtomicString& aria_desc =
GetAOMPropertyOrARIAAttribute(AOMStringProperty::kDescription);
if (!aria_desc.IsNull()) {
description_from = ax::mojom::DescriptionFrom::kAttribute;
description = aria_desc;
if (description_sources) {
found_description = true;
description_sources->back().text = description;
} else {
return description;
}
}
}
const HTMLInputElement* input_element = ToHTMLInputElementOrNull(GetNode()); const HTMLInputElement* input_element = ToHTMLInputElementOrNull(GetNode());
// value, 5.2.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.html // value, 5.2.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.html
......
...@@ -1400,7 +1400,8 @@ void AXObjectCacheImpl::HandleAttributeChangedWithCleanLayout( ...@@ -1400,7 +1400,8 @@ void AXObjectCacheImpl::HandleAttributeChangedWithCleanLayout(
attr_name == html_names::kAriaLabeledbyAttr || attr_name == html_names::kAriaLabeledbyAttr ||
attr_name == html_names::kAriaLabelledbyAttr) { attr_name == html_names::kAriaLabelledbyAttr) {
TextChangedWithCleanLayout(element); TextChangedWithCleanLayout(element);
} else if (attr_name == html_names::kAriaDescribedbyAttr) { } else if (attr_name == html_names::kAriaDescriptionAttr ||
attr_name == html_names::kAriaDescribedbyAttr) {
// TODO do we need a DescriptionChanged() ? // TODO do we need a DescriptionChanged() ?
TextChangedWithCleanLayout(element); TextChangedWithCleanLayout(element);
} else if (attr_name == html_names::kAriaCheckedAttr || } else if (attr_name == html_names::kAriaCheckedAttr ||
......
...@@ -25457,6 +25457,7 @@ Called by update_net_error_codes.py.--> ...@@ -25457,6 +25457,7 @@ Called by update_net_error_codes.py.-->
<int value="3086" label="FetchBodyStreamInServiceWorker"/> <int value="3086" label="FetchBodyStreamInServiceWorker"/>
<int value="3087" label="FetchBodyStreamOutsideServiceWorker"/> <int value="3087" label="FetchBodyStreamOutsideServiceWorker"/>
<int value="3088" label="GetComputedStyleOutsideFlatTree"/> <int value="3088" label="GetComputedStyleOutsideFlatTree"/>
<int value="3089" label="ARIADescriptionAttribute"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
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