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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.title = document.title().utf8(); | 141 tree_data.title = document.title().utf8(); |
142 tree_data.url = document.url().string().utf8(); | 142 tree_data.url = document.url().string().utf8(); |
143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; | 143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; |
144 tree_data.loaded = root.isLoaded(); | 144 tree_data.loaded = root.isLoaded(); |
145 tree_data.loading_progress = root.estimatedLoadingProgress(); | 145 tree_data.loading_progress = root.estimatedLoadingProgress(); |
146 tree_data.doctype = "html"; | 146 tree_data.doctype = "html"; |
147 | 147 |
| 148 WebAXObject focus = document.focusedAccessibilityObject(); |
| 149 if (!focus.isNull()) |
| 150 tree_data.focus_id = focus.axID(); |
| 151 |
148 WebAXObject anchor_object, focus_object; | 152 WebAXObject anchor_object, focus_object; |
149 int anchor_offset, focus_offset; | 153 int anchor_offset, focus_offset; |
150 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); | 154 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); |
151 if (!anchor_object.isNull() && !focus_object.isNull() && | 155 if (!anchor_object.isNull() && !focus_object.isNull() && |
152 anchor_offset >= 0 && focus_offset >= 0) { | 156 anchor_offset >= 0 && focus_offset >= 0) { |
153 int32_t anchor_id = anchor_object.axID(); | 157 int32_t anchor_id = anchor_object.axID(); |
154 int32_t focus_id = focus_object.axID(); | 158 int32_t focus_id = focus_object.axID(); |
155 tree_data.sel_anchor_object_id = anchor_id; | 159 tree_data.sel_anchor_object_id = anchor_id; |
156 tree_data.sel_anchor_offset = anchor_offset; | 160 tree_data.sel_anchor_offset = anchor_offset; |
157 tree_data.sel_focus_object_id = focus_id; | 161 tree_data.sel_focus_object_id = focus_id; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, | 399 dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, |
396 src.hierarchicalLevel()); | 400 src.hierarchicalLevel()); |
397 } | 401 } |
398 | 402 |
399 if (src.setSize()) | 403 if (src.setSize()) |
400 dst->AddIntAttribute(ui::AX_ATTR_SET_SIZE, src.setSize()); | 404 dst->AddIntAttribute(ui::AX_ATTR_SET_SIZE, src.setSize()); |
401 | 405 |
402 if (src.posInSet()) | 406 if (src.posInSet()) |
403 dst->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, src.posInSet()); | 407 dst->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, src.posInSet()); |
404 | 408 |
405 // Treat the active list box item as focused. | |
406 if (dst->role == ui::AX_ROLE_LIST_BOX_OPTION && | |
407 src.isSelectedOptionActive()) { | |
408 dst->state |= (1 << ui::AX_STATE_FOCUSED); | |
409 } | |
410 | |
411 if (src.canvasHasFallbackContent()) | 409 if (src.canvasHasFallbackContent()) |
412 dst->AddBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK, true); | 410 dst->AddBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK, true); |
413 | 411 |
414 WebNode node = src.node(); | 412 WebNode node = src.node(); |
415 bool is_iframe = false; | 413 bool is_iframe = false; |
416 | 414 |
417 if (!node.isNull() && node.isElementNode()) { | 415 if (!node.isNull() && node.isElementNode()) { |
418 WebElement element = node.to<WebElement>(); | 416 WebElement element = node.to<WebElement>(); |
419 is_iframe = element.hasHTMLTagName("iframe"); | 417 is_iframe = element.hasHTMLTagName("iframe"); |
420 | 418 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 621 } |
624 } | 622 } |
625 | 623 |
626 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 624 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
627 if (render_frame_ && render_frame_->GetWebFrame()) | 625 if (render_frame_ && render_frame_->GetWebFrame()) |
628 return render_frame_->GetWebFrame()->document(); | 626 return render_frame_->GetWebFrame()->document(); |
629 return WebDocument(); | 627 return WebDocument(); |
630 } | 628 } |
631 | 629 |
632 } // namespace content | 630 } // namespace content |
OLD | NEW |