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

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

Issue 558073002: Hook up guest browser plugins to the accessibility tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cross_process_iframes_plugins_3
Patch Set: Rebase Created 6 years, 3 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" 12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h"
13 #include "content/renderer/browser_plugin/browser_plugin.h"
13 #include "content/renderer/render_frame_impl.h" 14 #include "content/renderer/render_frame_impl.h"
14 #include "content/renderer/render_frame_proxy.h" 15 #include "content/renderer/render_frame_proxy.h"
15 #include "content/renderer/render_view_impl.h" 16 #include "content/renderer/render_view_impl.h"
16 #include "third_party/WebKit/public/platform/WebRect.h" 17 #include "third_party/WebKit/public/platform/WebRect.h"
17 #include "third_party/WebKit/public/platform/WebSize.h" 18 #include "third_party/WebKit/public/platform/WebSize.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 19 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/WebVector.h" 20 #include "third_party/WebKit/public/platform/WebVector.h"
20 #include "third_party/WebKit/public/web/WebAXEnums.h" 21 #include "third_party/WebKit/public/web/WebAXEnums.h"
21 #include "third_party/WebKit/public/web/WebAXObject.h" 22 #include "third_party/WebKit/public/web/WebAXObject.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebDocumentType.h" 24 #include "third_party/WebKit/public/web/WebDocumentType.h"
24 #include "third_party/WebKit/public/web/WebElement.h" 25 #include "third_party/WebKit/public/web/WebElement.h"
25 #include "third_party/WebKit/public/web/WebFormControlElement.h" 26 #include "third_party/WebKit/public/web/WebFormControlElement.h"
26 #include "third_party/WebKit/public/web/WebFrame.h" 27 #include "third_party/WebKit/public/web/WebFrame.h"
27 #include "third_party/WebKit/public/web/WebLocalFrame.h" 28 #include "third_party/WebKit/public/web/WebLocalFrame.h"
28 #include "third_party/WebKit/public/web/WebInputElement.h"
29 #include "third_party/WebKit/public/web/WebNode.h" 29 #include "third_party/WebKit/public/web/WebNode.h"
30 #include "third_party/WebKit/public/web/WebPlugin.h"
31 #include "third_party/WebKit/public/web/WebPluginContainer.h"
30 #include "third_party/WebKit/public/web/WebView.h" 32 #include "third_party/WebKit/public/web/WebView.h"
31 33
32 using base::ASCIIToUTF16; 34 using base::ASCIIToUTF16;
33 using base::UTF16ToUTF8; 35 using base::UTF16ToUTF8;
34 using blink::WebAXObject; 36 using blink::WebAXObject;
35 using blink::WebDocument; 37 using blink::WebDocument;
36 using blink::WebDocumentType; 38 using blink::WebDocumentType;
37 using blink::WebElement; 39 using blink::WebElement;
38 using blink::WebLocalFrame; 40 using blink::WebLocalFrame;
39 using blink::WebNode; 41 using blink::WebNode;
42 using blink::WebPlugin;
43 using blink::WebPluginContainer;
40 using blink::WebVector; 44 using blink::WebVector;
41 using blink::WebView; 45 using blink::WebView;
42 46
43 namespace content { 47 namespace content {
44 48
45 namespace { 49 namespace {
46 50
47 // Returns true if |ancestor| is the first unignored parent of |child|, 51 // Returns true if |ancestor| is the first unignored parent of |child|,
48 // which means that when walking up the parent chain from |child|, 52 // which means that when walking up the parent chain from |child|,
49 // |ancestor| is the *first* ancestor that isn't marked as 53 // |ancestor| is the *first* ancestor that isn't marked as
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 std::vector<int32> ids; 94 std::vector<int32> ids;
91 for(size_t i = 0; i < objects.size(); i++) 95 for(size_t i = 0; i < objects.size(); i++)
92 ids.push_back(objects[i].axID()); 96 ids.push_back(objects[i].axID());
93 if (ids.size() > 0) 97 if (ids.size() > 0)
94 dst->AddIntListAttribute(attr, ids); 98 dst->AddIntListAttribute(attr, ids);
95 } 99 }
96 100
97 } // Anonymous namespace 101 } // Anonymous namespace
98 102
99 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame) 103 BlinkAXTreeSource::BlinkAXTreeSource(RenderFrameImpl* render_frame)
100 : render_frame_(render_frame) { 104 : render_frame_(render_frame),
105 node_to_frame_routing_id_map_(NULL),
106 node_to_browser_plugin_instance_id_map_(NULL) {
101 } 107 }
102 108
103 BlinkAXTreeSource::~BlinkAXTreeSource() { 109 BlinkAXTreeSource::~BlinkAXTreeSource() {
104 } 110 }
105 111
106 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { 112 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const {
107 const blink::WebAXObject& root = GetRoot(); 113 const blink::WebAXObject& root = GetRoot();
108 while (IsValid(node)) { 114 while (IsValid(node)) {
109 if (node.equals(root)) 115 if (node.equals(root))
110 return true; 116 return true;
111 node = GetParent(node); 117 node = GetParent(node);
112 } 118 }
113 return false; 119 return false;
114 } 120 }
115 121
116 void BlinkAXTreeSource::CollectChildFrameIdMapping( 122 void BlinkAXTreeSource::CollectChildFrameIdMapping(
117 std::map<int32, int>* node_to_frame_routing_id_map) { 123 std::map<int32, int>* node_to_frame_routing_id_map,
124 std::map<int32, int>* node_to_browser_plugin_instance_id_map) {
118 node_to_frame_routing_id_map_ = node_to_frame_routing_id_map; 125 node_to_frame_routing_id_map_ = node_to_frame_routing_id_map;
126 node_to_browser_plugin_instance_id_map_ =
127 node_to_browser_plugin_instance_id_map;
119 } 128 }
120 129
121 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { 130 blink::WebAXObject BlinkAXTreeSource::GetRoot() const {
122 return GetMainDocument().accessibilityObject(); 131 return GetMainDocument().accessibilityObject();
123 } 132 }
124 133
125 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { 134 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const {
126 return GetMainDocument().accessibilityObjectFromID(id); 135 return GetMainDocument().accessibilityObjectFromID(id);
127 } 136 }
128 137
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 std::string role = GetEquivalentAriaRoleString(dst->role); 352 std::string role = GetEquivalentAriaRoleString(dst->role);
344 if (!role.empty()) 353 if (!role.empty())
345 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); 354 dst->AddStringAttribute(ui::AX_ATTR_ROLE, role);
346 } 355 }
347 356
348 // Live region attributes 357 // Live region attributes
349 live_atomic = UTF16ToUTF8(element.getAttribute("aria-atomic")); 358 live_atomic = UTF16ToUTF8(element.getAttribute("aria-atomic"));
350 live_busy = UTF16ToUTF8(element.getAttribute("aria-busy")); 359 live_busy = UTF16ToUTF8(element.getAttribute("aria-busy"));
351 live_status = UTF16ToUTF8(element.getAttribute("aria-live")); 360 live_status = UTF16ToUTF8(element.getAttribute("aria-live"));
352 live_relevant = UTF16ToUTF8(element.getAttribute("aria-relevant")); 361 live_relevant = UTF16ToUTF8(element.getAttribute("aria-relevant"));
362
363 // Browser plugin (used in a <webview>).
364 if (node_to_browser_plugin_instance_id_map_) {
365 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element);
366 if (browser_plugin) {
367 (*node_to_browser_plugin_instance_id_map_)[dst->id] =
368 browser_plugin->browser_plugin_instance_id();
369 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
370 }
371 }
353 } 372 }
354 373
355 // Walk up the parent chain to set live region attributes of containers 374 // Walk up the parent chain to set live region attributes of containers
356 std::string container_live_atomic; 375 std::string container_live_atomic;
357 std::string container_live_busy; 376 std::string container_live_busy;
358 std::string container_live_status; 377 std::string container_live_status;
359 std::string container_live_relevant; 378 std::string container_live_relevant;
360 WebAXObject container_accessible = src; 379 WebAXObject container_accessible = src;
361 while (!container_accessible.isDetached()) { 380 while (!container_accessible.isDetached()) {
362 WebNode container_node = container_accessible.node(); 381 WebNode container_node = container_accessible.node();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); 473 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height());
455 474
456 const gfx::Size& max_offset = document.maximumScrollOffset(); 475 const gfx::Size& max_offset = document.maximumScrollOffset();
457 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); 476 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width());
458 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, max_offset.height()); 477 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, max_offset.height());
459 478
460 if (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) { 479 if (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) {
461 WebLocalFrame* frame = document.frame(); 480 WebLocalFrame* frame = document.frame();
462 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); 481 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
463 if (render_frame) { 482 if (render_frame) {
464 node_to_frame_routing_id_map_->insert(std::pair<int32, int>( 483 (*node_to_frame_routing_id_map_)[dst->id] =
465 dst->id, render_frame->GetRoutingID())); 484 render_frame->GetRoutingID();
485 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
466 } else { 486 } else {
467 RenderFrameProxy* render_frame_proxy = 487 RenderFrameProxy* render_frame_proxy =
468 RenderFrameProxy::FromWebFrame(frame); 488 RenderFrameProxy::FromWebFrame(frame);
469 if (render_frame_proxy) { 489 if (render_frame_proxy) {
470 node_to_frame_routing_id_map_->insert(std::pair<int32, int>( 490 (*node_to_frame_routing_id_map_)[dst->id] =
471 dst->id, render_frame_proxy->routing_id())); 491 render_frame_proxy->routing_id();
492 dst->AddBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST, true);
472 } 493 }
473 } 494 }
474 } 495 }
475 } 496 }
476 497
477 if (dst->role == ui::AX_ROLE_TABLE) { 498 if (dst->role == ui::AX_ROLE_TABLE) {
478 int column_count = src.columnCount(); 499 int column_count = src.columnCount();
479 int row_count = src.rowCount(); 500 int row_count = src.rowCount();
480 if (column_count > 0 && row_count > 0) { 501 if (column_count > 0 && row_count > 0) {
481 std::set<int32> unique_cell_id_set; 502 std::set<int32> unique_cell_id_set;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); 594 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst);
574 } 595 }
575 596
576 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 597 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
577 if (render_frame_ && render_frame_->GetWebFrame()) 598 if (render_frame_ && render_frame_->GetWebFrame())
578 return render_frame_->GetWebFrame()->document(); 599 return render_frame_->GetWebFrame()->document();
579 return WebDocument(); 600 return WebDocument();
580 } 601 }
581 602
582 } // namespace content 603 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698