Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/blink_ax_tree_source.h" | 5 #include "content/renderer/accessibility/blink_ax_tree_source.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, | 101 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, |
| 102 WebVector<WebAXObject> objects, | 102 WebVector<WebAXObject> objects, |
| 103 AXContentNodeData* dst) { | 103 AXContentNodeData* dst) { |
| 104 std::vector<int32> ids; | 104 std::vector<int32> ids; |
| 105 for(size_t i = 0; i < objects.size(); i++) | 105 for(size_t i = 0; i < objects.size(); i++) |
| 106 ids.push_back(objects[i].axID()); | 106 ids.push_back(objects[i].axID()); |
| 107 if (ids.size() > 0) | 107 if (ids.size() > 0) |
| 108 dst->AddIntListAttribute(attr, ids); | 108 dst->AddIntListAttribute(attr, ids); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // Anonymous namespace | 111 std::string ToUTF8(const blink::WebString& str) { |
| 112 return UTF16ToUTF8(base::StringPiece16(str)); | |
| 113 } | |
| 114 | |
| 115 } // namespace | |
| 112 | 116 |
| 113 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) | 117 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) |
| 114 : render_frame_(render_frame), | 118 : render_frame_(render_frame), |
| 115 accessibility_focus_id_(-1) { | 119 accessibility_focus_id_(-1) { |
| 116 } | 120 } |
| 117 | 121 |
| 118 BlinkAXTreeSource::~BlinkAXTreeSource() { | 122 BlinkAXTreeSource::~BlinkAXTreeSource() { |
| 119 } | 123 } |
| 120 | 124 |
| 121 void BlinkAXTreeSource::SetRoot(blink::WebAXObject root) { | 125 void BlinkAXTreeSource::SetRoot(blink::WebAXObject root) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 139 const blink::WebAXObject& root = GetRoot(); | 143 const blink::WebAXObject& root = GetRoot(); |
| 140 | 144 |
| 141 tree_data.title = document.title().utf8(); | 145 tree_data.title = document.title().utf8(); |
| 142 tree_data.url = document.url().spec(); | 146 tree_data.url = document.url().spec(); |
| 143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; | 147 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; |
| 144 tree_data.loaded = root.isLoaded(); | 148 tree_data.loaded = root.isLoaded(); |
| 145 tree_data.loading_progress = root.estimatedLoadingProgress(); | 149 tree_data.loading_progress = root.estimatedLoadingProgress(); |
| 146 | 150 |
| 147 const WebDocumentType& doctype = document.doctype(); | 151 const WebDocumentType& doctype = document.doctype(); |
| 148 if (!doctype.isNull()) | 152 if (!doctype.isNull()) |
| 149 tree_data.doctype = UTF16ToUTF8(base::StringPiece16(doctype.name())); | 153 tree_data.doctype = ToUTF8(doctype.name()); |
| 150 | 154 |
| 151 WebAXObject anchor_object, focus_object; | 155 WebAXObject anchor_object, focus_object; |
| 152 int anchor_offset, focus_offset; | 156 int anchor_offset, focus_offset; |
| 153 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); | 157 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); |
| 154 if (!anchor_object.isNull() && !focus_object.isNull() && | 158 if (!anchor_object.isNull() && !focus_object.isNull() && |
| 155 anchor_offset >= 0 && focus_offset >= 0) { | 159 anchor_offset >= 0 && focus_offset >= 0) { |
| 156 int32 anchor_id = anchor_object.axID(); | 160 int32 anchor_id = anchor_object.axID(); |
| 157 int32 focus_id = focus_object.axID(); | 161 int32 focus_id = focus_object.axID(); |
| 158 tree_data.sel_anchor_object_id = anchor_id; | 162 tree_data.sel_anchor_object_id = anchor_id; |
| 159 tree_data.sel_anchor_offset = anchor_offset; | 163 tree_data.sel_anchor_offset = anchor_offset; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 blink::WebAXObject BlinkAXTreeSource::GetNull() const { | 260 blink::WebAXObject BlinkAXTreeSource::GetNull() const { |
| 257 return blink::WebAXObject(); | 261 return blink::WebAXObject(); |
| 258 } | 262 } |
| 259 | 263 |
| 260 void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, | 264 void BlinkAXTreeSource::SerializeNode(blink::WebAXObject src, |
| 261 AXContentNodeData* dst) const { | 265 AXContentNodeData* dst) const { |
| 262 dst->role = AXRoleFromBlink(src.role()); | 266 dst->role = AXRoleFromBlink(src.role()); |
| 263 dst->state = AXStateFromBlink(src); | 267 dst->state = AXStateFromBlink(src); |
| 264 dst->location = src.boundingBoxRect(); | 268 dst->location = src.boundingBoxRect(); |
| 265 dst->id = src.axID(); | 269 dst->id = src.axID(); |
| 266 std::string name = UTF16ToUTF8(base::StringPiece16(src.deprecatedTitle())); | 270 |
| 271 blink::WebAXNameFrom nameFrom; | |
| 272 blink::WebVector<blink::WebAXObject> nameObjects; | |
| 273 blink::WebString web_name = src.name(nameFrom, nameObjects); | |
| 274 if (!web_name.isEmpty()) { | |
| 275 dst->AddStringAttribute(ui::AX_ATTR_NAME, ToUTF8(web_name)); | |
| 276 dst->AddIntAttribute(ui::AX_ATTR_NAME_FROM, AXNameFromFromBlink(nameFrom)); | |
| 277 AddIntListAttributeFromWebObjects( | |
| 278 ui::AX_ATTR_LABELLEDBY_IDS, nameObjects, dst); | |
| 279 } | |
| 280 | |
| 281 blink::WebAXDescriptionFrom descriptionFrom; | |
| 282 blink::WebVector<blink::WebAXObject> descriptionObjects; | |
| 283 blink::WebString web_description = src.description( | |
|
aboxhall
2015/11/13 23:13:49
more spaces??
dmazzoni
2015/11/16 18:52:04
Same - the code looks fine to me. Is codereview.ch
aboxhall
2015/11/16 22:03:27
Super weird. Yeah, it looks fine now.
| |
| 284 nameFrom, descriptionFrom, descriptionObjects); | |
| 285 if (!web_description.isEmpty()) { | |
| 286 dst->AddStringAttribute(ui::AX_ATTR_DESCRIPTION, ToUTF8(web_description)); | |
| 287 dst->AddIntAttribute(ui::AX_ATTR_DESCRIPTION_FROM, | |
| 288 AXDescriptionFromFromBlink(descriptionFrom)); | |
| 289 AddIntListAttributeFromWebObjects( | |
| 290 ui::AX_ATTR_DESCRIBEDBY_IDS, descriptionObjects, dst); | |
| 291 } | |
| 292 | |
| 293 blink::WebString web_placeholder = src.placeholder(nameFrom, descriptionFrom); | |
| 294 if (!web_placeholder.isEmpty()) | |
| 295 dst->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, ToUTF8(web_placeholder)); | |
| 267 | 296 |
| 268 std::string value; | 297 std::string value; |
| 269 if (src.valueDescription().length()) { | 298 if (src.valueDescription().length()) { |
| 270 dst->AddStringAttribute(ui::AX_ATTR_VALUE, | 299 dst->AddStringAttribute(ui::AX_ATTR_VALUE, ToUTF8(src.valueDescription())); |
| 271 UTF16ToUTF8(base::StringPiece16( | |
| 272 src.valueDescription()))); | |
| 273 } else { | 300 } else { |
| 274 dst->AddStringAttribute( | 301 dst->AddStringAttribute(ui::AX_ATTR_VALUE, ToUTF8(src.stringValue())); |
| 275 ui::AX_ATTR_VALUE, | |
| 276 UTF16ToUTF8(base::StringPiece16(src.stringValue()))); | |
| 277 } | 302 } |
| 278 | 303 |
| 279 if (dst->role == ui::AX_ROLE_COLOR_WELL) | 304 if (dst->role == ui::AX_ROLE_COLOR_WELL) |
| 280 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); | 305 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); |
| 281 | 306 |
| 282 | 307 |
| 283 // Text attributes. | 308 // Text attributes. |
| 284 if (src.backgroundColor()) | 309 if (src.backgroundColor()) |
| 285 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); | 310 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); |
| 286 | 311 |
| 287 if (src.color()) | 312 if (src.color()) |
| 288 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); | 313 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); |
| 289 | 314 |
| 290 // Font size is in pixels. | 315 // Font size is in pixels. |
| 291 if (src.fontSize()) | 316 if (src.fontSize()) |
| 292 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); | 317 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); |
| 293 | 318 |
| 294 if (src.invalidState()) { | 319 if (src.invalidState()) { |
| 295 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, | 320 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, |
| 296 AXInvalidStateFromBlink(src.invalidState())); | 321 AXInvalidStateFromBlink(src.invalidState())); |
| 297 } | 322 } |
| 298 if (src.invalidState() == blink::WebAXInvalidStateOther) { | 323 if (src.invalidState() == blink::WebAXInvalidStateOther) { |
| 299 dst->AddStringAttribute( | 324 dst->AddStringAttribute( |
| 300 ui::AX_ATTR_ARIA_INVALID_VALUE, | 325 ui::AX_ATTR_ARIA_INVALID_VALUE, ToUTF8(src.ariaInvalidValue())); |
| 301 UTF16ToUTF8(base::StringPiece16(src.ariaInvalidValue()))); | |
| 302 } | 326 } |
| 303 | 327 |
| 304 if (src.textDirection()) { | 328 if (src.textDirection()) { |
| 305 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 329 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 306 AXTextDirectionFromBlink(src.textDirection())); | 330 AXTextDirectionFromBlink(src.textDirection())); |
| 307 } | 331 } |
| 308 | 332 |
| 309 if (src.textStyle()) { | 333 if (src.textStyle()) { |
| 310 dst->AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, | 334 dst->AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, |
| 311 AXTextStyleFromBlink(src.textStyle())); | 335 AXTextStyleFromBlink(src.textStyle())); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 330 word_ends.reserve(src_word_starts.size()); | 354 word_ends.reserve(src_word_starts.size()); |
| 331 for (size_t i = 0; i < src_word_starts.size(); ++i) { | 355 for (size_t i = 0; i < src_word_starts.size(); ++i) { |
| 332 word_starts.push_back(src_word_starts[i]); | 356 word_starts.push_back(src_word_starts[i]); |
| 333 word_ends.push_back(src_word_ends[i]); | 357 word_ends.push_back(src_word_ends[i]); |
| 334 } | 358 } |
| 335 dst->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, word_starts); | 359 dst->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, word_starts); |
| 336 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); | 360 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); |
| 337 } | 361 } |
| 338 | 362 |
| 339 if (src.accessKey().length()) { | 363 if (src.accessKey().length()) { |
| 340 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, | 364 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, ToUTF8(src.accessKey())); |
| 341 UTF16ToUTF8(base::StringPiece16(src.accessKey()))); | |
| 342 } | 365 } |
| 343 | 366 |
| 344 if (src.actionVerb().length()) | 367 if (src.actionVerb().length()) |
| 345 dst->AddStringAttribute( | 368 dst->AddStringAttribute(ui::AX_ATTR_ACTION, ToUTF8(src.actionVerb())); |
| 346 ui::AX_ATTR_ACTION, | |
| 347 UTF16ToUTF8(base::StringPiece16(src.actionVerb()))); | |
| 348 if (src.ariaAutoComplete().length()) | 369 if (src.ariaAutoComplete().length()) |
| 349 dst->AddStringAttribute( | 370 dst->AddStringAttribute( |
| 350 ui::AX_ATTR_AUTO_COMPLETE, | 371 ui::AX_ATTR_AUTO_COMPLETE, ToUTF8(src.ariaAutoComplete())); |
| 351 UTF16ToUTF8(base::StringPiece16(src.ariaAutoComplete()))); | |
| 352 if (src.isAriaReadOnly()) | 372 if (src.isAriaReadOnly()) |
| 353 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); | 373 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); |
| 354 if (src.isButtonStateMixed()) | 374 if (src.isButtonStateMixed()) |
| 355 dst->AddBoolAttribute(ui::AX_ATTR_BUTTON_MIXED, true); | 375 dst->AddBoolAttribute(ui::AX_ATTR_BUTTON_MIXED, true); |
| 356 if (src.canSetValueAttribute()) | 376 if (src.canSetValueAttribute()) |
| 357 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); | 377 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); |
| 358 if (src.deprecatedAccessibilityDescription().length()) { | |
| 359 dst->AddStringAttribute( | |
| 360 ui::AX_ATTR_DESCRIPTION, | |
| 361 UTF16ToUTF8(base::StringPiece16( | |
| 362 src.deprecatedAccessibilityDescription()))); | |
| 363 } | |
| 364 if (src.hasComputedStyle()) { | 378 if (src.hasComputedStyle()) { |
| 365 dst->AddStringAttribute( | 379 dst->AddStringAttribute( |
| 366 ui::AX_ATTR_DISPLAY, | 380 ui::AX_ATTR_DISPLAY, ToUTF8(src.computedStyleDisplay())); |
| 367 UTF16ToUTF8(base::StringPiece16(src.computedStyleDisplay()))); | |
| 368 } | |
| 369 if (src.deprecatedHelpText().length()) | |
| 370 dst->AddStringAttribute( | |
| 371 ui::AX_ATTR_HELP, | |
| 372 UTF16ToUTF8(base::StringPiece16((src.deprecatedHelpText())))); | |
| 373 if (src.deprecatedPlaceholder().length()) { | |
| 374 dst->AddStringAttribute( | |
| 375 ui::AX_ATTR_PLACEHOLDER, | |
| 376 UTF16ToUTF8(base::StringPiece16(src.deprecatedPlaceholder()))); | |
| 377 } | 381 } |
| 378 if (src.keyboardShortcut().length()) { | 382 if (src.keyboardShortcut().length()) { |
| 379 dst->AddStringAttribute( | 383 dst->AddStringAttribute( |
| 380 ui::AX_ATTR_SHORTCUT, | 384 ui::AX_ATTR_SHORTCUT, |
| 381 UTF16ToUTF8(base::StringPiece16(src.keyboardShortcut()))); | 385 UTF16ToUTF8(base::StringPiece16(src.keyboardShortcut()))); |
| 382 } | 386 } |
| 383 if (!src.deprecatedTitleUIElement().isDetached()) { | |
| 384 dst->AddIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, | |
| 385 src.deprecatedTitleUIElement().axID()); | |
| 386 } | |
| 387 if (!src.ariaActiveDescendant().isDetached()) { | 387 if (!src.ariaActiveDescendant().isDetached()) { |
| 388 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, | 388 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, |
| 389 src.ariaActiveDescendant().axID()); | 389 src.ariaActiveDescendant().axID()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 if (!src.url().isEmpty()) | 392 if (!src.url().isEmpty()) |
| 393 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().spec()); | 393 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().spec()); |
| 394 | 394 |
| 395 if (dst->role == ui::AX_ROLE_HEADING) | 395 if (dst->role == ui::AX_ROLE_HEADING) |
| 396 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); | 396 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 426 // TODO(ctguil): The tagName in WebKit is lower cased but | 426 // TODO(ctguil): The tagName in WebKit is lower cased but |
| 427 // HTMLElement::nodeName calls localNameUpper. Consider adding | 427 // HTMLElement::nodeName calls localNameUpper. Consider adding |
| 428 // a WebElement method that returns the original lower cased tagName. | 428 // a WebElement method that returns the original lower cased tagName. |
| 429 dst->AddStringAttribute( | 429 dst->AddStringAttribute( |
| 430 ui::AX_ATTR_HTML_TAG, | 430 ui::AX_ATTR_HTML_TAG, |
| 431 base::ToLowerASCII(UTF16ToUTF8( | 431 base::ToLowerASCII(UTF16ToUTF8( |
| 432 base::StringPiece16(element.tagName())))); | 432 base::StringPiece16(element.tagName())))); |
| 433 for (unsigned i = 0; i < element.attributeCount(); ++i) { | 433 for (unsigned i = 0; i < element.attributeCount(); ++i) { |
| 434 std::string name = base::ToLowerASCII(UTF16ToUTF8( | 434 std::string name = base::ToLowerASCII(UTF16ToUTF8( |
| 435 base::StringPiece16(element.attributeLocalName(i)))); | 435 base::StringPiece16(element.attributeLocalName(i)))); |
| 436 std::string value = | 436 std::string value = ToUTF8(element.attributeValue(i)); |
| 437 UTF16ToUTF8(base::StringPiece16(element.attributeValue(i))); | |
| 438 dst->html_attributes.push_back(std::make_pair(name, value)); | 437 dst->html_attributes.push_back(std::make_pair(name, value)); |
| 439 } | 438 } |
| 440 | 439 |
| 441 if (src.isEditable()) { | 440 if (src.isEditable()) { |
| 442 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart()); | 441 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart()); |
| 443 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd()); | 442 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd()); |
| 444 | 443 |
| 445 WebVector<int> src_line_breaks; | 444 WebVector<int> src_line_breaks; |
| 446 src.lineBreaks(src_line_breaks); | 445 src.lineBreaks(src_line_breaks); |
| 447 if (src_line_breaks.size() > 0) { | 446 if (src_line_breaks.size() > 0) { |
| 448 std::vector<int32> line_breaks; | 447 std::vector<int32> line_breaks; |
| 449 line_breaks.reserve(src_line_breaks.size()); | 448 line_breaks.reserve(src_line_breaks.size()); |
| 450 for (size_t i = 0; i < src_line_breaks.size(); ++i) | 449 for (size_t i = 0; i < src_line_breaks.size(); ++i) |
| 451 line_breaks.push_back(src_line_breaks[i]); | 450 line_breaks.push_back(src_line_breaks[i]); |
| 452 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); | 451 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); |
| 453 } | 452 } |
| 454 } | 453 } |
| 455 | 454 |
| 456 // ARIA role. | 455 // ARIA role. |
| 457 if (element.hasAttribute("role")) { | 456 if (element.hasAttribute("role")) { |
| 458 dst->AddStringAttribute( | 457 dst->AddStringAttribute( |
| 459 ui::AX_ATTR_ROLE, | 458 ui::AX_ATTR_ROLE, ToUTF8(element.getAttribute("role"))); |
| 460 UTF16ToUTF8(base::StringPiece16(element.getAttribute("role")))); | |
| 461 } else { | 459 } else { |
| 462 std::string role = GetEquivalentAriaRoleString(dst->role); | 460 std::string role = GetEquivalentAriaRoleString(dst->role); |
| 463 if (!role.empty()) | 461 if (!role.empty()) |
| 464 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); | 462 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); |
| 465 else if (dst->role == ui::AX_ROLE_TIME) | 463 else if (dst->role == ui::AX_ROLE_TIME) |
| 466 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time"); | 464 dst->AddStringAttribute(ui::AX_ATTR_ROLE, "time"); |
| 467 } | 465 } |
| 468 | 466 |
| 469 // Browser plugin (used in a <webview>). | 467 // Browser plugin (used in a <webview>). |
| 470 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); | 468 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 489 } | 487 } |
| 490 } | 488 } |
| 491 | 489 |
| 492 if (src.isInLiveRegion()) { | 490 if (src.isInLiveRegion()) { |
| 493 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC, src.liveRegionAtomic()); | 491 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC, src.liveRegionAtomic()); |
| 494 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_BUSY, src.liveRegionBusy()); | 492 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_BUSY, src.liveRegionBusy()); |
| 495 if (src.liveRegionBusy()) | 493 if (src.liveRegionBusy()) |
| 496 dst->state |= (1 << ui::AX_STATE_BUSY); | 494 dst->state |= (1 << ui::AX_STATE_BUSY); |
| 497 if (!src.liveRegionStatus().isEmpty()) { | 495 if (!src.liveRegionStatus().isEmpty()) { |
| 498 dst->AddStringAttribute( | 496 dst->AddStringAttribute( |
| 499 ui::AX_ATTR_LIVE_STATUS, | 497 ui::AX_ATTR_LIVE_STATUS, ToUTF8(src.liveRegionStatus())); |
| 500 UTF16ToUTF8(base::StringPiece16(src.liveRegionStatus()))); | |
| 501 } | 498 } |
| 502 dst->AddStringAttribute( | 499 dst->AddStringAttribute( |
| 503 ui::AX_ATTR_LIVE_RELEVANT, | 500 ui::AX_ATTR_LIVE_RELEVANT, ToUTF8(src.liveRegionRelevant())); |
| 504 UTF16ToUTF8(base::StringPiece16(src.liveRegionRelevant()))); | |
| 505 dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, | 501 dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, |
| 506 src.containerLiveRegionAtomic()); | 502 src.containerLiveRegionAtomic()); |
| 507 dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_BUSY, | 503 dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_BUSY, |
| 508 src.containerLiveRegionBusy()); | 504 src.containerLiveRegionBusy()); |
| 509 dst->AddStringAttribute( | 505 dst->AddStringAttribute( |
| 510 ui::AX_ATTR_CONTAINER_LIVE_STATUS, | 506 ui::AX_ATTR_CONTAINER_LIVE_STATUS, |
| 511 UTF16ToUTF8(base::StringPiece16(src.containerLiveRegionStatus()))); | 507 ToUTF8(src.containerLiveRegionStatus())); |
| 512 dst->AddStringAttribute( | 508 dst->AddStringAttribute( |
| 513 ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, | 509 ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, |
| 514 UTF16ToUTF8(base::StringPiece16(src.containerLiveRegionRelevant()))); | 510 ToUTF8(src.containerLiveRegionRelevant())); |
| 515 } | 511 } |
| 516 | 512 |
| 517 if (dst->role == ui::AX_ROLE_PROGRESS_INDICATOR || | 513 if (dst->role == ui::AX_ROLE_PROGRESS_INDICATOR || |
| 518 dst->role == ui::AX_ROLE_METER || | 514 dst->role == ui::AX_ROLE_METER || |
| 519 dst->role == ui::AX_ROLE_SCROLL_BAR || | 515 dst->role == ui::AX_ROLE_SCROLL_BAR || |
| 520 dst->role == ui::AX_ROLE_SLIDER || | 516 dst->role == ui::AX_ROLE_SLIDER || |
| 521 dst->role == ui::AX_ROLE_SPIN_BUTTON) { | 517 dst->role == ui::AX_ROLE_SPIN_BUTTON) { |
| 522 dst->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, src.valueForRange()); | 518 dst->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, src.valueForRange()); |
| 523 dst->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, | 519 dst->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, |
| 524 src.maxValueForRange()); | 520 src.maxValueForRange()); |
| 525 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, | 521 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, |
| 526 src.minValueForRange()); | 522 src.minValueForRange()); |
| 527 } | 523 } |
| 528 | 524 |
| 529 if (dst->role == ui::AX_ROLE_WEB_AREA) { | 525 if (dst->role == ui::AX_ROLE_WEB_AREA) |
| 530 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); | 526 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); |
| 531 const WebDocument& document = src.document(); | |
| 532 if (name.empty()) | |
| 533 name = UTF16ToUTF8(base::StringPiece16(document.title())); | |
| 534 } | |
| 535 | 527 |
| 536 if (dst->role == ui::AX_ROLE_TABLE) { | 528 if (dst->role == ui::AX_ROLE_TABLE) { |
| 537 int column_count = src.columnCount(); | 529 int column_count = src.columnCount(); |
| 538 int row_count = src.rowCount(); | 530 int row_count = src.rowCount(); |
| 539 if (column_count > 0 && row_count > 0) { | 531 if (column_count > 0 && row_count > 0) { |
| 540 std::set<int32> unique_cell_id_set; | 532 std::set<int32> unique_cell_id_set; |
| 541 std::vector<int32> cell_ids; | 533 std::vector<int32> cell_ids; |
| 542 std::vector<int32> unique_cell_ids; | 534 std::vector<int32> unique_cell_ids; |
| 543 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); | 535 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); |
| 544 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); | 536 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, src.cellRowIndex()); | 579 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, src.cellRowIndex()); |
| 588 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, src.cellRowSpan()); | 580 dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, src.cellRowSpan()); |
| 589 } | 581 } |
| 590 | 582 |
| 591 if ((dst->role == ui::AX_ROLE_ROW_HEADER || | 583 if ((dst->role == ui::AX_ROLE_ROW_HEADER || |
| 592 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { | 584 dst->role == ui::AX_ROLE_COLUMN_HEADER) && src.sortDirection()) { |
| 593 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, | 585 dst->AddIntAttribute(ui::AX_ATTR_SORT_DIRECTION, |
| 594 AXSortDirectionFromBlink(src.sortDirection())); | 586 AXSortDirectionFromBlink(src.sortDirection())); |
| 595 } | 587 } |
| 596 | 588 |
| 597 dst->AddStringAttribute(ui::AX_ATTR_NAME, name); | |
| 598 | |
| 599 // Add the ids of *indirect* children - those who are children of this node, | 589 // Add the ids of *indirect* children - those who are children of this node, |
| 600 // but whose parent is *not* this node. One example is a table | 590 // but whose parent is *not* this node. One example is a table |
| 601 // cell, which is a child of both a row and a column. Because the cell's | 591 // cell, which is a child of both a row and a column. Because the cell's |
| 602 // parent is the row, the row adds it as a child, and the column adds it | 592 // parent is the row, the row adds it as a child, and the column adds it |
| 603 // as an indirect child. | 593 // as an indirect child. |
| 604 int child_count = src.childCount(); | 594 int child_count = src.childCount(); |
| 605 for (int i = 0; i < child_count; ++i) { | 595 for (int i = 0; i < child_count; ++i) { |
| 606 WebAXObject child = src.childAt(i); | 596 WebAXObject child = src.childAt(i); |
| 607 std::vector<int32> indirect_child_ids; | 597 std::vector<int32> indirect_child_ids; |
| 608 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child)) | 598 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child)) |
| 609 indirect_child_ids.push_back(child.axID()); | 599 indirect_child_ids.push_back(child.axID()); |
| 610 if (indirect_child_ids.size() > 0) { | 600 if (indirect_child_ids.size() > 0) { |
| 611 dst->AddIntListAttribute( | 601 dst->AddIntListAttribute( |
| 612 ui::AX_ATTR_INDIRECT_CHILD_IDS, indirect_child_ids); | 602 ui::AX_ATTR_INDIRECT_CHILD_IDS, indirect_child_ids); |
| 613 } | 603 } |
| 614 } | 604 } |
| 615 | 605 |
| 616 WebVector<WebAXObject> controls; | 606 WebVector<WebAXObject> controls; |
| 617 if (src.ariaControls(controls)) | 607 if (src.ariaControls(controls)) |
| 618 AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst); | 608 AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, controls, dst); |
| 619 | 609 |
| 620 WebVector<WebAXObject> describedby; | |
| 621 if (src.deprecatedAriaDescribedby(describedby)) { | |
| 622 AddIntListAttributeFromWebObjects( | |
| 623 ui::AX_ATTR_DESCRIBEDBY_IDS, describedby, dst); | |
| 624 } | |
| 625 | |
| 626 WebVector<WebAXObject> flowTo; | 610 WebVector<WebAXObject> flowTo; |
| 627 if (src.ariaFlowTo(flowTo)) | 611 if (src.ariaFlowTo(flowTo)) |
| 628 AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst); | 612 AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, flowTo, dst); |
| 629 | 613 |
| 630 WebVector<WebAXObject> labelledby; | |
| 631 if (src.deprecatedAriaLabelledby(labelledby)) { | |
| 632 AddIntListAttributeFromWebObjects( | |
| 633 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); | |
| 634 } | |
| 635 | |
| 636 WebVector<WebAXObject> owns; | |
| 637 if (src.ariaOwns(owns)) | |
| 638 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | |
| 639 | |
| 640 | |
| 641 if (src.isScrollableContainer()) { | 614 if (src.isScrollableContainer()) { |
| 642 const gfx::Point& scrollOffset = src.scrollOffset(); | 615 const gfx::Point& scrollOffset = src.scrollOffset(); |
| 643 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scrollOffset.x()); | 616 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scrollOffset.x()); |
| 644 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scrollOffset.y()); | 617 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scrollOffset.y()); |
| 645 | 618 |
| 646 const gfx::Point& minScrollOffset = src.minimumScrollOffset(); | 619 const gfx::Point& minScrollOffset = src.minimumScrollOffset(); |
| 647 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, minScrollOffset.x()); | 620 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, minScrollOffset.x()); |
| 648 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, minScrollOffset.y()); | 621 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, minScrollOffset.y()); |
| 649 | 622 |
| 650 const gfx::Point& maxScrollOffset = src.maximumScrollOffset(); | 623 const gfx::Point& maxScrollOffset = src.maximumScrollOffset(); |
| 651 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, maxScrollOffset.x()); | 624 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, maxScrollOffset.x()); |
| 652 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, maxScrollOffset.y()); | 625 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, maxScrollOffset.y()); |
| 653 } | 626 } |
| 654 } | 627 } |
| 655 | 628 |
| 656 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 629 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 657 if (render_frame_ && render_frame_->GetWebFrame()) | 630 if (render_frame_ && render_frame_->GetWebFrame()) |
| 658 return render_frame_->GetWebFrame()->document(); | 631 return render_frame_->GetWebFrame()->document(); |
| 659 return WebDocument(); | 632 return WebDocument(); |
| 660 } | 633 } |
| 661 | 634 |
| 662 } // namespace content | 635 } // namespace content |
| OLD | NEW |