| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); | 305 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); |
| 306 | 306 |
| 307 | 307 |
| 308 // Text attributes. | 308 // Text attributes. |
| 309 if (src.backgroundColor()) | 309 if (src.backgroundColor()) |
| 310 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); | 310 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); |
| 311 | 311 |
| 312 if (src.color()) | 312 if (src.color()) |
| 313 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); | 313 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); |
| 314 | 314 |
| 315 if (src.fontFamily().length()) { |
| 316 WebAXObject parent = src.parentObject(); |
| 317 if (parent.isNull() || parent.fontFamily() != src.fontFamily()) |
| 318 dst->AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, src.fontFamily().utf8()); |
| 319 } |
| 320 |
| 315 // Font size is in pixels. | 321 // Font size is in pixels. |
| 316 if (src.fontSize()) | 322 if (src.fontSize()) |
| 317 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); | 323 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); |
| 318 | 324 |
| 319 if (src.invalidState()) { | 325 if (src.invalidState()) { |
| 320 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, | 326 dst->AddIntAttribute(ui::AX_ATTR_INVALID_STATE, |
| 321 AXInvalidStateFromBlink(src.invalidState())); | 327 AXInvalidStateFromBlink(src.invalidState())); |
| 322 } | 328 } |
| 323 if (src.invalidState() == blink::WebAXInvalidStateOther) { | 329 if (src.invalidState() == blink::WebAXInvalidStateOther && |
| 330 src.ariaInvalidValue().length()) { |
| 324 dst->AddStringAttribute( | 331 dst->AddStringAttribute( |
| 325 ui::AX_ATTR_ARIA_INVALID_VALUE, src.ariaInvalidValue().utf8()); | 332 ui::AX_ATTR_ARIA_INVALID_VALUE, src.ariaInvalidValue().utf8()); |
| 326 } | 333 } |
| 327 | 334 |
| 328 if (src.textDirection()) { | 335 if (src.textDirection()) { |
| 329 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 336 dst->AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
| 330 AXTextDirectionFromBlink(src.textDirection())); | 337 AXTextDirectionFromBlink(src.textDirection())); |
| 331 } | 338 } |
| 332 | 339 |
| 333 if (src.textStyle()) { | 340 if (src.textStyle()) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 360 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); | 367 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); |
| 361 } | 368 } |
| 362 | 369 |
| 363 if (src.accessKey().length()) { | 370 if (src.accessKey().length()) { |
| 364 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, src.accessKey().utf8()); | 371 dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, src.accessKey().utf8()); |
| 365 } | 372 } |
| 366 | 373 |
| 367 if (src.actionVerb().length()) { | 374 if (src.actionVerb().length()) { |
| 368 dst->AddStringAttribute(ui::AX_ATTR_ACTION, src.actionVerb().utf8()); | 375 dst->AddStringAttribute(ui::AX_ATTR_ACTION, src.actionVerb().utf8()); |
| 369 } | 376 } |
| 370 if (src.ariaAutoComplete().length()) | 377 |
| 378 if (src.ariaAutoComplete().length()) { |
| 371 dst->AddStringAttribute( | 379 dst->AddStringAttribute( |
| 372 ui::AX_ATTR_AUTO_COMPLETE, | 380 ui::AX_ATTR_AUTO_COMPLETE, |
| 373 src.ariaAutoComplete().utf8()); | 381 src.ariaAutoComplete().utf8()); |
| 382 } |
| 383 |
| 374 if (src.isAriaReadOnly()) | 384 if (src.isAriaReadOnly()) |
| 375 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); | 385 dst->AddBoolAttribute(ui::AX_ATTR_ARIA_READONLY, true); |
| 386 |
| 376 if (src.isButtonStateMixed()) | 387 if (src.isButtonStateMixed()) |
| 377 dst->AddBoolAttribute(ui::AX_ATTR_STATE_MIXED, true); | 388 dst->AddBoolAttribute(ui::AX_ATTR_STATE_MIXED, true); |
| 389 |
| 378 if (src.canSetValueAttribute()) | 390 if (src.canSetValueAttribute()) |
| 379 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); | 391 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); |
| 392 |
| 380 if (src.hasComputedStyle()) { | 393 if (src.hasComputedStyle()) { |
| 381 dst->AddStringAttribute( | 394 dst->AddStringAttribute( |
| 382 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); | 395 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); |
| 383 } | 396 } |
| 397 |
| 398 if (src.language().length()) { |
| 399 WebAXObject parent = src.parentObject(); |
| 400 if (parent.isNull() || parent.language() != src.language()) |
| 401 dst->AddStringAttribute(ui::AX_ATTR_LANGUAGE, src.language().utf8()); |
| 402 } |
| 403 |
| 384 if (src.keyboardShortcut().length()) { | 404 if (src.keyboardShortcut().length()) { |
| 385 dst->AddStringAttribute( | 405 dst->AddStringAttribute( |
| 386 ui::AX_ATTR_SHORTCUT, | 406 ui::AX_ATTR_SHORTCUT, |
| 387 src.keyboardShortcut().utf8()); | 407 src.keyboardShortcut().utf8()); |
| 388 } | 408 } |
| 409 |
| 389 if (!src.ariaActiveDescendant().isDetached()) { | 410 if (!src.ariaActiveDescendant().isDetached()) { |
| 390 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, | 411 dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, |
| 391 src.ariaActiveDescendant().axID()); | 412 src.ariaActiveDescendant().axID()); |
| 392 } | 413 } |
| 393 | 414 |
| 394 if (!src.url().isEmpty()) | 415 if (!src.url().isEmpty()) |
| 395 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().string().utf8()); | 416 dst->AddStringAttribute(ui::AX_ATTR_URL, src.url().string().utf8()); |
| 396 | 417 |
| 397 if (dst->role == ui::AX_ROLE_HEADING) | 418 if (dst->role == ui::AX_ROLE_HEADING) |
| 398 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); | 419 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.headingLevel()); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 650 } |
| 630 } | 651 } |
| 631 | 652 |
| 632 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 653 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 633 if (render_frame_ && render_frame_->GetWebFrame()) | 654 if (render_frame_ && render_frame_->GetWebFrame()) |
| 634 return render_frame_->GetWebFrame()->document(); | 655 return render_frame_->GetWebFrame()->document(); |
| 635 return WebDocument(); | 656 return WebDocument(); |
| 636 } | 657 } |
| 637 | 658 |
| 638 } // namespace content | 659 } // namespace content |
| OLD | NEW |