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> |
| 8 |
7 #include <set> | 9 #include <set> |
8 | 10 |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
13 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 15 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
14 #include "content/renderer/accessibility/renderer_accessibility.h" | 16 #include "content/renderer/accessibility/renderer_accessibility.h" |
15 #include "content/renderer/browser_plugin/browser_plugin.h" | 17 #include "content/renderer/browser_plugin/browser_plugin.h" |
16 #include "content/renderer/render_frame_impl.h" | 18 #include "content/renderer/render_frame_impl.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 default: | 94 default: |
93 break; | 95 break; |
94 } | 96 } |
95 | 97 |
96 return std::string(); | 98 return std::string(); |
97 } | 99 } |
98 | 100 |
99 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, | 101 void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, |
100 WebVector<WebAXObject> objects, | 102 WebVector<WebAXObject> objects, |
101 AXContentNodeData* dst) { | 103 AXContentNodeData* dst) { |
102 std::vector<int32> ids; | 104 std::vector<int32_t> ids; |
103 for(size_t i = 0; i < objects.size(); i++) | 105 for(size_t i = 0; i < objects.size(); i++) |
104 ids.push_back(objects[i].axID()); | 106 ids.push_back(objects[i].axID()); |
105 if (ids.size() > 0) | 107 if (ids.size() > 0) |
106 dst->AddIntListAttribute(attr, ids); | 108 dst->AddIntListAttribute(attr, ids); |
107 } | 109 } |
108 | 110 |
109 } // namespace | 111 } // namespace |
110 | 112 |
111 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) | 113 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) |
112 : render_frame_(render_frame), | 114 : render_frame_(render_frame), |
(...skipping 28 matching lines...) Expand all Loading... |
141 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; | 143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html"; |
142 tree_data.loaded = root.isLoaded(); | 144 tree_data.loaded = root.isLoaded(); |
143 tree_data.loading_progress = root.estimatedLoadingProgress(); | 145 tree_data.loading_progress = root.estimatedLoadingProgress(); |
144 tree_data.doctype = "html"; | 146 tree_data.doctype = "html"; |
145 | 147 |
146 WebAXObject anchor_object, focus_object; | 148 WebAXObject anchor_object, focus_object; |
147 int anchor_offset, focus_offset; | 149 int anchor_offset, focus_offset; |
148 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); | 150 root.selection(anchor_object, anchor_offset, focus_object, focus_offset); |
149 if (!anchor_object.isNull() && !focus_object.isNull() && | 151 if (!anchor_object.isNull() && !focus_object.isNull() && |
150 anchor_offset >= 0 && focus_offset >= 0) { | 152 anchor_offset >= 0 && focus_offset >= 0) { |
151 int32 anchor_id = anchor_object.axID(); | 153 int32_t anchor_id = anchor_object.axID(); |
152 int32 focus_id = focus_object.axID(); | 154 int32_t focus_id = focus_object.axID(); |
153 tree_data.sel_anchor_object_id = anchor_id; | 155 tree_data.sel_anchor_object_id = anchor_id; |
154 tree_data.sel_anchor_offset = anchor_offset; | 156 tree_data.sel_anchor_offset = anchor_offset; |
155 tree_data.sel_focus_object_id = focus_id; | 157 tree_data.sel_focus_object_id = focus_id; |
156 tree_data.sel_focus_offset = focus_offset; | 158 tree_data.sel_focus_offset = focus_offset; |
157 } | 159 } |
158 | 160 |
159 // Get the tree ID for this frame and possibly the parent frame. | 161 // Get the tree ID for this frame and possibly the parent frame. |
160 WebLocalFrame* web_frame = document.frame(); | 162 WebLocalFrame* web_frame = document.frame(); |
161 if (web_frame) { | 163 if (web_frame) { |
162 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame); | 164 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame); |
(...skipping 11 matching lines...) Expand all Loading... |
174 | 176 |
175 return tree_data; | 177 return tree_data; |
176 } | 178 } |
177 | 179 |
178 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { | 180 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { |
179 if (!root_.isNull()) | 181 if (!root_.isNull()) |
180 return root_; | 182 return root_; |
181 return GetMainDocument().accessibilityObject(); | 183 return GetMainDocument().accessibilityObject(); |
182 } | 184 } |
183 | 185 |
184 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { | 186 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32_t id) const { |
185 return GetMainDocument().accessibilityObjectFromID(id); | 187 return GetMainDocument().accessibilityObjectFromID(id); |
186 } | 188 } |
187 | 189 |
188 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { | 190 int32_t BlinkAXTreeSource::GetId(blink::WebAXObject node) const { |
189 return node.axID(); | 191 return node.axID(); |
190 } | 192 } |
191 | 193 |
192 void BlinkAXTreeSource::GetChildren( | 194 void BlinkAXTreeSource::GetChildren( |
193 blink::WebAXObject parent, | 195 blink::WebAXObject parent, |
194 std::vector<blink::WebAXObject>* out_children) const { | 196 std::vector<blink::WebAXObject>* out_children) const { |
195 if (parent.role() == blink::WebAXRoleStaticText) { | 197 if (parent.role() == blink::WebAXRoleStaticText) { |
196 blink::WebAXObject ancestor = parent; | 198 blink::WebAXObject ancestor = parent; |
197 while (!ancestor.isDetached()) { | 199 while (!ancestor.isDetached()) { |
198 if (ancestor.axID() == accessibility_focus_id_) { | 200 if (ancestor.axID() == accessibility_focus_id_) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 325 |
324 if (src.textStyle()) { | 326 if (src.textStyle()) { |
325 dst->AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, | 327 dst->AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, |
326 AXTextStyleFromBlink(src.textStyle())); | 328 AXTextStyleFromBlink(src.textStyle())); |
327 } | 329 } |
328 | 330 |
329 | 331 |
330 if (dst->role == ui::AX_ROLE_INLINE_TEXT_BOX) { | 332 if (dst->role == ui::AX_ROLE_INLINE_TEXT_BOX) { |
331 WebVector<int> src_character_offsets; | 333 WebVector<int> src_character_offsets; |
332 src.characterOffsets(src_character_offsets); | 334 src.characterOffsets(src_character_offsets); |
333 std::vector<int32> character_offsets; | 335 std::vector<int32_t> character_offsets; |
334 character_offsets.reserve(src_character_offsets.size()); | 336 character_offsets.reserve(src_character_offsets.size()); |
335 for (size_t i = 0; i < src_character_offsets.size(); ++i) | 337 for (size_t i = 0; i < src_character_offsets.size(); ++i) |
336 character_offsets.push_back(src_character_offsets[i]); | 338 character_offsets.push_back(src_character_offsets[i]); |
337 dst->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); | 339 dst->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); |
338 | 340 |
339 WebVector<int> src_word_starts; | 341 WebVector<int> src_word_starts; |
340 WebVector<int> src_word_ends; | 342 WebVector<int> src_word_ends; |
341 src.wordBoundaries(src_word_starts, src_word_ends); | 343 src.wordBoundaries(src_word_starts, src_word_ends); |
342 std::vector<int32> word_starts; | 344 std::vector<int32_t> word_starts; |
343 std::vector<int32> word_ends; | 345 std::vector<int32_t> word_ends; |
344 word_starts.reserve(src_word_starts.size()); | 346 word_starts.reserve(src_word_starts.size()); |
345 word_ends.reserve(src_word_starts.size()); | 347 word_ends.reserve(src_word_starts.size()); |
346 for (size_t i = 0; i < src_word_starts.size(); ++i) { | 348 for (size_t i = 0; i < src_word_starts.size(); ++i) { |
347 word_starts.push_back(src_word_starts[i]); | 349 word_starts.push_back(src_word_starts[i]); |
348 word_ends.push_back(src_word_ends[i]); | 350 word_ends.push_back(src_word_ends[i]); |
349 } | 351 } |
350 dst->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, word_starts); | 352 dst->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, word_starts); |
351 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); | 353 dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); |
352 } | 354 } |
353 | 355 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 dst->html_attributes.push_back(std::make_pair(name, value)); | 431 dst->html_attributes.push_back(std::make_pair(name, value)); |
430 } | 432 } |
431 | 433 |
432 if (src.isEditable()) { | 434 if (src.isEditable()) { |
433 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart()); | 435 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.selectionStart()); |
434 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd()); | 436 dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.selectionEnd()); |
435 | 437 |
436 WebVector<int> src_line_breaks; | 438 WebVector<int> src_line_breaks; |
437 src.lineBreaks(src_line_breaks); | 439 src.lineBreaks(src_line_breaks); |
438 if (src_line_breaks.size() > 0) { | 440 if (src_line_breaks.size() > 0) { |
439 std::vector<int32> line_breaks; | 441 std::vector<int32_t> line_breaks; |
440 line_breaks.reserve(src_line_breaks.size()); | 442 line_breaks.reserve(src_line_breaks.size()); |
441 for (size_t i = 0; i < src_line_breaks.size(); ++i) | 443 for (size_t i = 0; i < src_line_breaks.size(); ++i) |
442 line_breaks.push_back(src_line_breaks[i]); | 444 line_breaks.push_back(src_line_breaks[i]); |
443 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); | 445 dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); |
444 } | 446 } |
445 } | 447 } |
446 | 448 |
447 // ARIA role. | 449 // ARIA role. |
448 if (element.hasAttribute("role")) { | 450 if (element.hasAttribute("role")) { |
449 dst->AddStringAttribute( | 451 dst->AddStringAttribute( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 src.minValueForRange()); | 519 src.minValueForRange()); |
518 } | 520 } |
519 | 521 |
520 if (dst->role == ui::AX_ROLE_WEB_AREA) | 522 if (dst->role == ui::AX_ROLE_WEB_AREA) |
521 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); | 523 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); |
522 | 524 |
523 if (dst->role == ui::AX_ROLE_TABLE) { | 525 if (dst->role == ui::AX_ROLE_TABLE) { |
524 int column_count = src.columnCount(); | 526 int column_count = src.columnCount(); |
525 int row_count = src.rowCount(); | 527 int row_count = src.rowCount(); |
526 if (column_count > 0 && row_count > 0) { | 528 if (column_count > 0 && row_count > 0) { |
527 std::set<int32> unique_cell_id_set; | 529 std::set<int32_t> unique_cell_id_set; |
528 std::vector<int32> cell_ids; | 530 std::vector<int32_t> cell_ids; |
529 std::vector<int32> unique_cell_ids; | 531 std::vector<int32_t> unique_cell_ids; |
530 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); | 532 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); |
531 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); | 533 dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); |
532 WebAXObject header = src.headerContainerObject(); | 534 WebAXObject header = src.headerContainerObject(); |
533 if (!header.isDetached()) | 535 if (!header.isDetached()) |
534 dst->AddIntAttribute(ui::AX_ATTR_TABLE_HEADER_ID, header.axID()); | 536 dst->AddIntAttribute(ui::AX_ATTR_TABLE_HEADER_ID, header.axID()); |
535 for (int i = 0; i < column_count * row_count; ++i) { | 537 for (int i = 0; i < column_count * row_count; ++i) { |
536 WebAXObject cell = src.cellForColumnAndRow( | 538 WebAXObject cell = src.cellForColumnAndRow( |
537 i % column_count, i / column_count); | 539 i % column_count, i / column_count); |
538 int cell_id = -1; | 540 int cell_id = -1; |
539 if (!cell.isDetached()) { | 541 if (!cell.isDetached()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 584 } |
583 | 585 |
584 // Add the ids of *indirect* children - those who are children of this node, | 586 // Add the ids of *indirect* children - those who are children of this node, |
585 // but whose parent is *not* this node. One example is a table | 587 // but whose parent is *not* this node. One example is a table |
586 // cell, which is a child of both a row and a column. Because the cell's | 588 // cell, which is a child of both a row and a column. Because the cell's |
587 // parent is the row, the row adds it as a child, and the column adds it | 589 // parent is the row, the row adds it as a child, and the column adds it |
588 // as an indirect child. | 590 // as an indirect child. |
589 int child_count = src.childCount(); | 591 int child_count = src.childCount(); |
590 for (int i = 0; i < child_count; ++i) { | 592 for (int i = 0; i < child_count; ++i) { |
591 WebAXObject child = src.childAt(i); | 593 WebAXObject child = src.childAt(i); |
592 std::vector<int32> indirect_child_ids; | 594 std::vector<int32_t> indirect_child_ids; |
593 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child)) | 595 if (!is_iframe && !child.isDetached() && !IsParentUnignoredOf(src, child)) |
594 indirect_child_ids.push_back(child.axID()); | 596 indirect_child_ids.push_back(child.axID()); |
595 if (indirect_child_ids.size() > 0) { | 597 if (indirect_child_ids.size() > 0) { |
596 dst->AddIntListAttribute( | 598 dst->AddIntListAttribute( |
597 ui::AX_ATTR_INDIRECT_CHILD_IDS, indirect_child_ids); | 599 ui::AX_ATTR_INDIRECT_CHILD_IDS, indirect_child_ids); |
598 } | 600 } |
599 } | 601 } |
600 | 602 |
601 WebVector<WebAXObject> controls; | 603 WebVector<WebAXObject> controls; |
602 if (src.ariaControls(controls)) | 604 if (src.ariaControls(controls)) |
(...skipping 18 matching lines...) Expand all Loading... |
621 } | 623 } |
622 } | 624 } |
623 | 625 |
624 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 626 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
625 if (render_frame_ && render_frame_->GetWebFrame()) | 627 if (render_frame_ && render_frame_->GetWebFrame()) |
626 return render_frame_->GetWebFrame()->document(); | 628 return render_frame_->GetWebFrame()->document(); |
627 return WebDocument(); | 629 return WebDocument(); |
628 } | 630 } |
629 | 631 |
630 } // namespace content | 632 } // namespace content |
OLD | NEW |