Commit 2d8012e3 authored by Aaron Leventhal's avatar Aaron Leventhal Committed by Commit Bot

More default text attribute value removal

According to the IA2 spec here:
https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
"If an attribute is not specified and if the table shows that there is a default value, the default value should be assumed."

This makes the a11y tree less noisy, smaller and easier to debug, and is similar to how Firefox works.

Bug: 844147
Change-Id: I3f7827d10d9659e5e758827a806da0b7f6598e41
Reviewed-on: https://chromium-review.googlesource.com/1066112Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560318}
parent ea417ed7
......@@ -1933,7 +1933,8 @@ std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
unsigned int red = SkColorGetR(color);
unsigned int green = SkColorGetG(color);
unsigned int blue = SkColorGetB(color);
if (alpha) {
// Don't expose default value of pure white.
if (alpha && (red != 255 || green != 255 || blue != 255)) {
base::string16 color_value = L"rgb(" + base::UintToString16(red) + L',' +
base::UintToString16(green) + L',' +
base::UintToString16(blue) + L')';
......@@ -1946,11 +1947,14 @@ std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
unsigned int red = SkColorGetR(color);
unsigned int green = SkColorGetG(color);
unsigned int blue = SkColorGetB(color);
base::string16 color_value = L"rgb(" + base::UintToString16(red) + L',' +
base::UintToString16(green) + L',' +
base::UintToString16(blue) + L')';
SanitizeStringAttributeForIA2(color_value, &color_value);
attributes.push_back(L"color:" + color_value);
// Don't expose default value of black.
if (red || green || blue) {
base::string16 color_value = L"rgb(" + base::UintToString16(red) + L',' +
base::UintToString16(green) + L',' +
base::UintToString16(blue) + L')';
SanitizeStringAttributeForIA2(color_value, &color_value);
attributes.push_back(L"color:" + color_value);
}
}
base::string16 font_family(owner()->GetInheritedString16Attribute(
......@@ -2043,8 +2047,8 @@ std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
base::string16 language(owner()->GetInheritedString16Attribute(
ax::mojom::StringAttribute::kLanguage));
// Default value should be L"en-US".
if (!language.empty()) {
// Don't expose default value should of L"en-US".
if (!language.empty() && language != L"en-US") {
SanitizeStringAttributeForIA2(language, &language);
attributes.push_back(L"language:" + language);
}
......
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE offset:0 background-color:rgb(0\,0\,255) color:rgb(255\,0\,0) offset:1 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) ia2_hypertext='<obj0><obj1>'
ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE offset:0 background-color:rgb(0\,0\,255) color:rgb(255\,0\,0) offset:1 ia2_hypertext='<obj0><obj1>'
++IA2_ROLE_PARAGRAPH offset:0 background-color:rgb(0\,0\,255) color:rgb(255\,0\,0) ia2_hypertext='Red on blue.'
++++ROLE_SYSTEM_STATICTEXT name='Red on blue.' offset:0 background-color:rgb(0\,0\,255) color:rgb(255\,0\,0) ia2_hypertext='Red on blue.'
++IA2_ROLE_SECTION FOCUSABLE IA2_STATE_MULTI_LINE offset:0 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) offset:9 background-color:rgb(0\,0\,255) color:rgb(0\,0\,0) offset:25 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) offset:26 background-color:rgb(255\,255\,255) color:rgb(0\,255\,0) ia2_hypertext='Default. Blue background. Green text.'
++++ROLE_SYSTEM_STATICTEXT name='Default.' offset:0 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) ia2_hypertext='Default.'
++++ROLE_SYSTEM_STATICTEXT name=' ' offset:0 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) ia2_hypertext=' '
++++ROLE_SYSTEM_STATICTEXT name='Blue background.' offset:0 background-color:rgb(0\,0\,255) color:rgb(0\,0\,0) ia2_hypertext='Blue background.'
++++ROLE_SYSTEM_STATICTEXT name=' ' offset:0 background-color:rgb(255\,255\,255) color:rgb(0\,0\,0) ia2_hypertext=' '
++++ROLE_SYSTEM_STATICTEXT name='Green text.' offset:0 background-color:rgb(255\,255\,255) color:rgb(0\,255\,0) ia2_hypertext='Green text.'
\ No newline at end of file
++IA2_ROLE_SECTION FOCUSABLE IA2_STATE_MULTI_LINE offset:0 offset:9 background-color:rgb(0\,0\,255) offset:25 offset:26 color:rgb(0\,255\,0) ia2_hypertext='Default. Blue background. Green text.'
++++ROLE_SYSTEM_STATICTEXT name='Default.' offset:0 ia2_hypertext='Default.'
++++ROLE_SYSTEM_STATICTEXT name=' ' offset:0 ia2_hypertext=' '
++++ROLE_SYSTEM_STATICTEXT name='Blue background.' offset:0 background-color:rgb(0\,0\,255) ia2_hypertext='Blue background.'
++++ROLE_SYSTEM_STATICTEXT name=' ' offset:0 ia2_hypertext=' '
++++ROLE_SYSTEM_STATICTEXT name='Green text.' offset:0 color:rgb(0\,255\,0) ia2_hypertext='Green text.'
\ No newline at end of file
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