Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: content/renderer/accessibility/accessibility_node_serializer.cc

Issue 98183011: Expose semantics of landmark and related roles for assitive technologies (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/accessibility/accessibility_node_serializer.h" 5 #include "content/renderer/accessibility/accessibility_node_serializer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 if (o.isVertical()) 118 if (o.isVertical())
119 state |= (1 << blink::WebAXStateVertical); 119 state |= (1 << blink::WebAXStateVertical);
120 120
121 if (o.isVisited()) 121 if (o.isVisited())
122 state |= (1 << blink::WebAXStateVisited); 122 state |= (1 << blink::WebAXStateVisited);
123 123
124 return state; 124 return state;
125 } 125 }
126 126
127 std::string ConvertRole(const blink::WebAXRole role) {
dmazzoni 2014/01/05 05:27:38 Let's call this GetEquivalentAriaRoleString.
128 switch (role) {
129 case blink::WebAXRoleArticle:
130 return "article";
131 case blink::WebAXRoleComplementary:
132 return "complementary";
133 case blink::WebAXRoleContentInfo:
134 case blink::WebAXRoleFooter:
135 return "contentinfo";
136 case blink::WebAXRoleBanner:
137 return "banner";
138 case blink::WebAXRoleMain:
139 return "main";
140 case blink::WebAXRoleNavigation:
141 return "navigation";
142 case blink::WebAXRoleRegion:
143 return "region";
144 default:
145 break;
146 }
147
148 return std::string();
149 }
150
127 } // Anonymous namespace 151 } // Anonymous namespace
128 152
129 void SerializeAccessibilityNode( 153 void SerializeAccessibilityNode(
130 const WebAXObject& src, 154 const WebAXObject& src,
131 AccessibilityNodeData* dst) { 155 AccessibilityNodeData* dst) {
132 dst->role = src.role(); 156 dst->role = src.role();
133 dst->state = ConvertState(src); 157 dst->state = ConvertState(src);
134 dst->location = src.boundingBoxRect(); 158 dst->location = src.boundingBoxRect();
135 dst->id = src.axID(); 159 dst->id = src.axID();
136 std::string name = base::UTF16ToUTF8(src.title()); 160 std::string name = base::UTF16ToUTF8(src.title());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 for (size_t i = 0; i < src_line_breaks.size(); ++i) 295 for (size_t i = 0; i < src_line_breaks.size(); ++i)
272 line_breaks.push_back(src_line_breaks[i]); 296 line_breaks.push_back(src_line_breaks[i]);
273 dst->AddIntListAttribute(dst->ATTR_LINE_BREAKS, line_breaks); 297 dst->AddIntListAttribute(dst->ATTR_LINE_BREAKS, line_breaks);
274 } 298 }
275 } 299 }
276 300
277 // ARIA role. 301 // ARIA role.
278 if (element.hasAttribute("role")) { 302 if (element.hasAttribute("role")) {
279 dst->AddStringAttribute(dst->ATTR_ROLE, 303 dst->AddStringAttribute(dst->ATTR_ROLE,
280 base::UTF16ToUTF8(element.getAttribute("role"))); 304 base::UTF16ToUTF8(element.getAttribute("role")));
305 } else {
306 std::string role = ConvertRole(src.role());
307 if (!role.empty()) {
dmazzoni 2014/01/05 05:27:38 Nit: the Chromium style is to not use { } braces w
308 dst->AddStringAttribute(dst->ATTR_ROLE, role);
309 }
281 } 310 }
282 311
283 // Live region attributes 312 // Live region attributes
284 live_atomic = base::UTF16ToUTF8(element.getAttribute("aria-atomic")); 313 live_atomic = base::UTF16ToUTF8(element.getAttribute("aria-atomic"));
285 live_busy = base::UTF16ToUTF8(element.getAttribute("aria-busy")); 314 live_busy = base::UTF16ToUTF8(element.getAttribute("aria-busy"));
286 live_status = base::UTF16ToUTF8(element.getAttribute("aria-live")); 315 live_status = base::UTF16ToUTF8(element.getAttribute("aria-live"));
287 live_relevant = base::UTF16ToUTF8(element.getAttribute("aria-relevant")); 316 live_relevant = base::UTF16ToUTF8(element.getAttribute("aria-relevant"));
288 } 317 }
289 318
290 // Walk up the parent chain to set live region attributes of containers 319 // Walk up the parent chain to set live region attributes of containers
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 WebNode node = parent.node(); 513 WebNode node = parent.node();
485 if (!node.isNull() && node.isElementNode()) { 514 if (!node.isNull() && node.isElementNode()) {
486 WebElement element = node.to<WebElement>(); 515 WebElement element = node.to<WebElement>();
487 is_iframe = (element.tagName() == base::ASCIIToUTF16("IFRAME")); 516 is_iframe = (element.tagName() == base::ASCIIToUTF16("IFRAME"));
488 } 517 }
489 518
490 return (is_iframe || IsParentUnignoredOf(parent, child)); 519 return (is_iframe || IsParentUnignoredOf(parent, child));
491 } 520 }
492 521
493 } // namespace content 522 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698