Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: content/renderer/accessibility/blink_ax_tree_source.cc

Issue 1413423003: Move some AX attrs from AXNodeData to AXTreeData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { 125 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const {
126 const blink::WebAXObject& root = GetRoot(); 126 const blink::WebAXObject& root = GetRoot();
127 while (IsValid(node)) { 127 while (IsValid(node)) {
128 if (node.equals(root)) 128 if (node.equals(root))
129 return true; 129 return true;
130 node = GetParent(node); 130 node = GetParent(node);
131 } 131 }
132 return false; 132 return false;
133 } 133 }
134 134
135 AXContentTreeData BlinkAXTreeSource::GetTreeData() const {
136 AXContentTreeData tree_data;
137
138 blink::WebDocument document = BlinkAXTreeSource::GetMainDocument();
139 const blink::WebAXObject& root = GetRoot();
140
141 tree_data.title = document.title().utf8();
142 tree_data.url = document.url().spec();
143 tree_data.mimetype = document.isXHTMLDocument() ? "text/xhtml" : "text/html";
144 tree_data.loaded = root.isLoaded();
145 tree_data.loading_progress = root.estimatedLoadingProgress();
146
147 const WebDocumentType& doctype = document.doctype();
148 if (!doctype.isNull())
149 tree_data.doctype = UTF16ToUTF8(base::StringPiece16(doctype.name()));
150
151 WebAXObject anchor_object, focus_object;
152 int anchor_offset, focus_offset;
153 root.selection(anchor_object, anchor_offset, focus_object, focus_offset);
154 if (!anchor_object.isNull() && !focus_object.isNull() &&
155 anchor_offset >= 0 && focus_offset >= 0) {
156 int32 anchor_id = anchor_object.axID();
157 int32 focus_id = focus_object.axID();
158 tree_data.sel_anchor_object_id = anchor_id;
159 tree_data.sel_anchor_offset = anchor_offset;
160 tree_data.sel_focus_object_id = focus_id;
161 tree_data.sel_focus_offset = focus_offset;
162 }
163
164 // Get the tree ID for this frame and possibly the parent frame.
165 WebLocalFrame* web_frame = document.frame();
166 if (web_frame) {
167 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame);
168 tree_data.routing_id = render_frame->GetRoutingID();
169
170 // Get the tree ID for the parent frame, if it's remote.
171 // (If it's local, it's already part of this same tree.)
172 blink::WebFrame* parent_web_frame = web_frame->parent();
173 if (parent_web_frame && parent_web_frame->isWebRemoteFrame()) {
174 RenderFrameProxy* parent_render_frame_proxy =
175 RenderFrameProxy::FromWebFrame(parent_web_frame);
176 tree_data.parent_routing_id = parent_render_frame_proxy->routing_id();
177 }
178 }
179
180 return tree_data;
181 }
182
135 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { 183 blink::WebAXObject BlinkAXTreeSource::GetRoot() const {
136 if (!root_.isNull()) 184 if (!root_.isNull())
137 return root_; 185 return root_;
138 return GetMainDocument().accessibilityObject(); 186 return GetMainDocument().accessibilityObject();
139 } 187 }
140 188
141 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { 189 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const {
142 return GetMainDocument().accessibilityObjectFromID(id); 190 return GetMainDocument().accessibilityObjectFromID(id);
143 } 191 }
144 192
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 src.maxValueForRange()); 524 src.maxValueForRange());
477 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, 525 dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE,
478 src.minValueForRange()); 526 src.minValueForRange());
479 } 527 }
480 528
481 if (dst->role == ui::AX_ROLE_WEB_AREA) { 529 if (dst->role == ui::AX_ROLE_WEB_AREA) {
482 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); 530 dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document");
483 const WebDocument& document = src.document(); 531 const WebDocument& document = src.document();
484 if (name.empty()) 532 if (name.empty())
485 name = UTF16ToUTF8(base::StringPiece16(document.title())); 533 name = UTF16ToUTF8(base::StringPiece16(document.title()));
486 dst->AddStringAttribute(
487 ui::AX_ATTR_DOC_TITLE,
488 UTF16ToUTF8(base::StringPiece16(document.title())));
489 dst->AddStringAttribute(ui::AX_ATTR_DOC_URL, document.url().spec());
490 dst->AddStringAttribute(
491 ui::AX_ATTR_DOC_MIMETYPE,
492 document.isXHTMLDocument() ? "text/xhtml" : "text/html");
493 dst->AddBoolAttribute(ui::AX_ATTR_DOC_LOADED, src.isLoaded());
494 dst->AddFloatAttribute(ui::AX_ATTR_DOC_LOADING_PROGRESS,
495 src.estimatedLoadingProgress());
496
497 const WebDocumentType& doctype = document.doctype();
498 if (!doctype.isNull()) {
499 dst->AddStringAttribute(
500 ui::AX_ATTR_DOC_DOCTYPE,
501 UTF16ToUTF8(base::StringPiece16(doctype.name())));
502 }
503
504 WebAXObject anchor_object, focus_object;
505 int anchor_offset, focus_offset;
506 src.selection(anchor_object, anchor_offset, focus_object, focus_offset);
507 if (!anchor_object.isNull() && !focus_object.isNull() &&
508 anchor_offset >= 0 && focus_offset >= 0) {
509 int32 anchor_id = anchor_object.axID();
510 int32 focus_id = focus_object.axID();
511 dst->AddIntAttribute(ui::AX_ATTR_ANCHOR_OBJECT_ID, anchor_id);
512 dst->AddIntAttribute(ui::AX_ATTR_ANCHOR_OFFSET, anchor_offset);
513 dst->AddIntAttribute(ui::AX_ATTR_FOCUS_OBJECT_ID, focus_id);
514 dst->AddIntAttribute(ui::AX_ATTR_FOCUS_OFFSET, focus_offset);
515 }
516
517 // Get the tree ID for this frame and possibly the parent frame.
518 WebLocalFrame* web_frame = document.frame();
519 if (web_frame) {
520 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame);
521 dst->AddContentIntAttribute(
522 AX_CONTENT_ATTR_ROUTING_ID,
523 render_frame->GetRoutingID());
524
525 // Get the tree ID for the parent frame, if it's remote.
526 // (If it's local, it's already part of this same tree.)
527 blink::WebFrame* parent_web_frame = web_frame->parent();
528 if (parent_web_frame && parent_web_frame->isWebRemoteFrame()) {
529 RenderFrameProxy* parent_render_frame_proxy =
530 RenderFrameProxy::FromWebFrame(parent_web_frame);
531 dst->AddContentIntAttribute(
532 AX_CONTENT_ATTR_PARENT_ROUTING_ID,
533 parent_render_frame_proxy->routing_id());
534 }
535 }
536 } 534 }
537 535
538 if (dst->role == ui::AX_ROLE_TABLE) { 536 if (dst->role == ui::AX_ROLE_TABLE) {
539 int column_count = src.columnCount(); 537 int column_count = src.columnCount();
540 int row_count = src.rowCount(); 538 int row_count = src.rowCount();
541 if (column_count > 0 && row_count > 0) { 539 if (column_count > 0 && row_count > 0) {
542 std::set<int32> unique_cell_id_set; 540 std::set<int32> unique_cell_id_set;
543 std::vector<int32> cell_ids; 541 std::vector<int32> cell_ids;
544 std::vector<int32> unique_cell_ids; 542 std::vector<int32> unique_cell_ids;
545 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); 543 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 653 }
656 } 654 }
657 655
658 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 656 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
659 if (render_frame_ && render_frame_->GetWebFrame()) 657 if (render_frame_ && render_frame_->GetWebFrame())
660 return render_frame_->GetWebFrame()->document(); 658 return render_frame_->GetWebFrame()->document();
661 return WebDocument(); 659 return WebDocument();
662 } 660 }
663 661
664 } // namespace content 662 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/blink_ax_tree_source.h ('k') | content/renderer/accessibility/renderer_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698