Commit 487bd8ec authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

Ensure className exposed in Blink, UIA

StringAttribute::kClassName was unused. The only way the class name was
exposed was via the HTML attributes.

Expose via kClassName and remove from HTML attributes list.

Bug: None
Change-Id: I9667bd57460271a7310f26f8fee19fe41c234f05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2105953
Auto-Submit: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751370}
parent 517d386e
...@@ -1079,6 +1079,10 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, ...@@ -1079,6 +1079,10 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src,
WebElement element = node.To<WebElement>(); WebElement element = node.To<WebElement>();
is_iframe = element.HasHTMLTagName("iframe"); is_iframe = element.HasHTMLTagName("iframe");
if (element.HasAttribute("class")) {
TruncateAndAddStringAttribute(dst, ax::mojom::StringAttribute::kClassName,
element.GetAttribute("class").Utf8());
}
if (accessibility_mode_.has_mode(ui::AXMode::kHTML)) { if (accessibility_mode_.has_mode(ui::AXMode::kHTML)) {
// TODO(ctguil): The tagName in WebKit is lower cased but // TODO(ctguil): The tagName in WebKit is lower cased but
// HTMLElement::nodeName calls localNameUpper. Consider adding // HTMLElement::nodeName calls localNameUpper. Consider adding
...@@ -1089,8 +1093,10 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, ...@@ -1089,8 +1093,10 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src,
for (unsigned i = 0; i < element.AttributeCount(); ++i) { for (unsigned i = 0; i < element.AttributeCount(); ++i) {
std::string name = std::string name =
base::ToLowerASCII(element.AttributeLocalName(i).Utf8()); base::ToLowerASCII(element.AttributeLocalName(i).Utf8());
std::string value = element.AttributeValue(i).Utf8(); if (name != "class") { // class already in kClassName.
dst->html_attributes.push_back(std::make_pair(name, value)); std::string value = element.AttributeValue(i).Utf8();
dst->html_attributes.push_back(std::make_pair(name, value));
}
} }
// TODO(nektar): Turn off kHTMLAccessibilityMode for automation and Mac // TODO(nektar): Turn off kHTMLAccessibilityMode for automation and Mac
......
rootWebArea htmlTag='#document'
++genericContainer ignored htmlTag='body'
++++heading className='headerClass' htmlTag='h1' name='Image'
++++++staticText name='Image'
++++++++inlineTextBox name='Image'
++++image className='imageClass' htmlTag='img' name='ImageAlt'
\ No newline at end of file
Document Document
++Text Name='Image' ++Text Name='Image' ClassName='headerClass'
++++Text Name='Image' IsControlElement=false ++++Text Name='Image' IsControlElement=false
++Image Name='ImageAlt' ++Image Name='ImageAlt' ClassName='imageClass'
<-- End-of-file --> <-- End-of-file -->
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
@WIN-ALLOW:id:* @WIN-ALLOW:id:*
@WIN-ALLOW:src:* @WIN-ALLOW:src:*
@WIN-ALLOW:tag:* @WIN-ALLOW:tag:*
@UIA-WIN-ALLOW:ClassName*
@AURALINUX-ALLOW:class:* @AURALINUX-ALLOW:class:*
@AURALINUX-ALLOW:id:* @AURALINUX-ALLOW:id:*
@AURALINUX-ALLOW:src:* @AURALINUX-ALLOW:src:*
@AURALINUX-ALLOW:tag:* @AURALINUX-ALLOW:tag:*
@BLINK-ALLOW:htmlTag* @BLINK-ALLOW:htmlTag*
@BLINK-ALLOW:className*
--> -->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
......
...@@ -1126,8 +1126,7 @@ void AXPlatformNodeBase::ComputeAttributes(PlatformAttributeList* attributes) { ...@@ -1126,8 +1126,7 @@ void AXPlatformNodeBase::ComputeAttributes(PlatformAttributeList* attributes) {
// Expose class attribute. // Expose class attribute.
std::string class_attr; std::string class_attr;
if (GetData().GetHtmlAttribute("class", &class_attr) || if (GetData().GetStringAttribute(ax::mojom::StringAttribute::kClassName,
GetData().GetStringAttribute(ax::mojom::StringAttribute::kClassName,
&class_attr)) { &class_attr)) {
AddAttributeToList("class", class_attr, attributes); AddAttributeToList("class", class_attr, attributes);
} }
......
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