| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 return false; | 132 return false; |
| 133 } | 133 } |
| 134 | 134 |
| 135 AXContentTreeData BlinkAXTreeSource::GetTreeData() const { | 135 AXContentTreeData BlinkAXTreeSource::GetTreeData() const { |
| 136 AXContentTreeData tree_data; | 136 AXContentTreeData tree_data; |
| 137 | 137 |
| 138 blink::WebDocument document = BlinkAXTreeSource::GetMainDocument(); | 138 blink::WebDocument document = BlinkAXTreeSource::GetMainDocument(); |
| 139 const blink::WebAXObject& root = GetRoot(); | 139 const blink::WebAXObject& root = GetRoot(); |
| 140 | 140 |
| 141 tree_data.doctype = "html"; |
| 142 tree_data.loaded = root.isLoaded(); |
| 143 tree_data.loading_progress = root.estimatedLoadingProgress(); |
| 144 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; |
| 141 tree_data.title = document.title().utf8(); | 145 tree_data.title = document.title().utf8(); |
| 142 tree_data.url = document.url().string().utf8(); | 146 tree_data.url = document.url().string().utf8(); |
| 143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; | |
| 144 tree_data.loaded = root.isLoaded(); | |
| 145 tree_data.loading_progress = root.estimatedLoadingProgress(); | |
| 146 tree_data.doctype = "html"; | |
| 147 | 147 |
| 148 WebAXObject focus = document.focusedAccessibilityObject(); | 148 WebAXObject focus = document.focusedAccessibilityObject(); |
| 149 if (!focus.isNull()) | 149 if (!focus.isNull()) |
| 150 tree_data.focus_id = focus.axID(); | 150 tree_data.focus_id = focus.axID(); |
| 151 | 151 |
| 152 WebAXObject anchor_object, focus_object; | 152 WebAXObject anchor_object, focus_object; |
| 153 int anchor_offset, focus_offset; | 153 int anchor_offset, focus_offset; |
| 154 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); | 154 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); |
| 155 if (!anchor_object.isNull() && !focus_object.isNull() && | 155 if (!anchor_object.isNull() && !focus_object.isNull() && |
| 156 anchor_offset >= 0 && focus_offset >= 0) { | 156 anchor_offset >= 0 && focus_offset >= 0) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); | 302 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); |
| 303 | 303 |
| 304 | 304 |
| 305 // Text attributes. | 305 // Text attributes. |
| 306 if (src.backgroundColor()) | 306 if (src.backgroundColor()) |
| 307 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); | 307 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); |
| 308 | 308 |
| 309 if (src.color()) | 309 if (src.color()) |
| 310 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); | 310 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); |
| 311 | 311 |
| 312 if (src.fontFamily().length()) { |
| 313 WebAXObject parent = src.parentObject(); |
| 314 if (parent.isNull() || parent.fontFamily() != src.fontFamily()) |
| 315 dst->AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, src.fontFamily().utf8()); |
| 316 } |
| 317 |
| 312 // Font size is in pixels. | 318 // Font size is in pixels. |
| 313 if (src.fontSize()) | 319 if (src.fontSize()) |
| 314 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); | 320 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); |
| 315 | 321 |
| 316 if (src.invalidState()) { | 322 if (src.invalidState()) { |
| 317 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, | 323 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, |
| 318 AXInvalidStateFromBlink(src.invalidState())); | 324 AXInvalidStateFromBlink(src.invalidState())); |
| 319 } | 325 } |
| 320 if (src.invalidState() == blink::WebAXInvalidStateOther) { | 326 if (src.invalidState() == blink::WebAXInvalidStateOther && |
| 327 src.ariaInvalidValue().length()) { |
| 321 dst->AddStringAttribute( | 328 dst->AddStringAttribute( |
| 322 ui::AX_ATTR_ARIA_INVALID_VALUE, src.ariaInvalidValue().utf8()); | 329 ui::AX_ATTR_ARIA_INVALID_VALUE, src.ariaInvalidValue().utf8()); |
| 323 } | 330 } |
| 324 | 331 |
| 325 if (src.textDirection()) { | 332 if (src.textDirection()) { |
| 326 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 333 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 327 AXTextDirectionFromBlink(src.textDirection())); | 334 AXTextDirectionFromBlink(src.textDirection())); |
| 328 } | 335 } |
| 329 | 336 |
| 330 if (src.textStyle()) { | 337 if (src.textStyle()) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 357 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); | 364 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); |
| 358 } | 365 } |
| 359 | 366 |
| 360 if (src.accessKey().length()) { | 367 if (src.accessKey().length()) { |
| 361 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, src.accessKey().utf8()); | 368 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, src.accessKey().utf8()); |
| 362 } | 369 } |
| 363 | 370 |
| 364 if (src.actionVerb().length()) { | 371 if (src.actionVerb().length()) { |
| 365 dst->AddStringAttribute(ui::AX_ATTR_ACTION, src.actionVerb().utf8()); | 372 dst->AddStringAttribute(ui::AX_ATTR_ACTION, src.actionVerb().utf8()); |
| 366 } | 373 } |
| 367 if (src.ariaAutoComplete().length()) | 374 |
| 375 if (src.ariaAutoComplete().length()) { |
| 368 dst->AddStringAttribute( | 376 dst->AddStringAttribute( |
| 369 ui::AX_ATTR_AUTO_COMPLETE, | 377 ui::AX_ATTR_AUTO_COMPLETE, |
| 370 src.ariaAutoComplete().utf8()); | 378 src.ariaAutoComplete().utf8()); |
| 379 } |
| 380 |
| 371 if (src.isAriaReadOnly()) | 381 if (src.isAriaReadOnly()) |
| 372 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); | 382 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); |
| 383 |
| 373 if (src.isButtonStateMixed()) | 384 if (src.isButtonStateMixed()) |
| 374 dst->AddBoolAttribute(ui::AX_ATTR_STATE_MIXED, true); | 385 dst->AddBoolAttribute(ui::AX_ATTR_STATE_MIXED, true); |
| 386 |
| 375 if (src.canSetValueAttribute()) | 387 if (src.canSetValueAttribute()) |
| 376 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); | 388 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); |
| 389 |
| 377 if (src.hasComputedStyle()) { | 390 if (src.hasComputedStyle()) { |
| 378 dst->AddStringAttribute( | 391 dst->AddStringAttribute( |
| 379 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); | 392 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); |
| 380 } | 393 } |
| 394 |
| 395 if (src.language().length()) { |
| 396 WebAXObject parent = src.parentObject(); |
| 397 if (parent.isNull() || parent.language() != src.language()) |
| 398 dst->AddStringAttribute(ui::AX_ATTR_LANGUAGE, src.language().utf8()); |
| 399 } |
| 400 |
| 381 if (src.keyboardShortcut().length()) { | 401 if (src.keyboardShortcut().length()) { |
| 382 dst->AddStringAttribute( | 402 dst->AddStringAttribute( |
| 383 ui::AX_ATTR_SHORTCUT, | 403 ui::AX_ATTR_SHORTCUT, |
| 384 src.keyboardShortcut().utf8()); | 404 src.keyboardShortcut().utf8()); |
| 385 } | 405 } |
| 406 |
| 386 if (!src.ariaActiveDescendant().isDetached()) { | 407 if (!src.ariaActiveDescendant().isDetached()) { |
| 387 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, | 408 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, |
| 388 src.ariaActiveDescendant().axID()); | 409 src.ariaActiveDescendant().axID()); |
| 389 } | 410 } |
| 390 | 411 |
| 391 if (!src.url().isEmpty()) | 412 if (!src.url().isEmpty()) |
| 392 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().string().utf8()); | 413 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().string().utf8()); |
| 393 | 414 |
| 394 if (dst->role == ui::AX_ROLE_HEADING) | 415 if (dst->role == ui::AX_ROLE_HEADING) |
| 395 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); | 416 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 } | 642 } |
| 622 } | 643 } |
| 623 | 644 |
| 624 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 645 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 625 if (render_frame_ && render_frame_->GetWebFrame()) | 646 if (render_frame_ && render_frame_->GetWebFrame()) |
| 626 return render_frame_->GetWebFrame()->document(); | 647 return render_frame_->GetWebFrame()->document(); |
| 627 return WebDocument(); | 648 return WebDocument(); |
| 628 } | 649 } |
| 629 | 650 |
| 630 } // namespace content | 651 } // namespace content |
| OLD | NEW |