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

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

Issue 558943002: Revert of Cross-process iframe accessibility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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/render_frame_impl.h" 13 #include "content/renderer/render_frame_impl.h"
14 #include "content/renderer/render_frame_proxy.h"
15 #include "content/renderer/render_view_impl.h" 14 #include "content/renderer/render_view_impl.h"
16 #include "third_party/WebKit/public/platform/WebRect.h" 15 #include "third_party/WebKit/public/platform/WebRect.h"
17 #include "third_party/WebKit/public/platform/WebSize.h" 16 #include "third_party/WebKit/public/platform/WebSize.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 17 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/WebVector.h" 18 #include "third_party/WebKit/public/platform/WebVector.h"
20 #include "third_party/WebKit/public/web/WebAXEnums.h" 19 #include "third_party/WebKit/public/web/WebAXEnums.h"
21 #include "third_party/WebKit/public/web/WebAXObject.h" 20 #include "third_party/WebKit/public/web/WebAXObject.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 21 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebDocumentType.h" 22 #include "third_party/WebKit/public/web/WebDocumentType.h"
24 #include "third_party/WebKit/public/web/WebElement.h" 23 #include "third_party/WebKit/public/web/WebElement.h"
25 #include "third_party/WebKit/public/web/WebFormControlElement.h" 24 #include "third_party/WebKit/public/web/WebFormControlElement.h"
26 #include "third_party/WebKit/public/web/WebFrame.h"
27 #include "third_party/WebKit/public/web/WebLocalFrame.h"
28 #include "third_party/WebKit/public/web/WebInputElement.h" 25 #include "third_party/WebKit/public/web/WebInputElement.h"
29 #include "third_party/WebKit/public/web/WebNode.h" 26 #include "third_party/WebKit/public/web/WebNode.h"
30 #include "third_party/WebKit/public/web/WebView.h" 27 #include "third_party/WebKit/public/web/WebView.h"
31 28
32 using base::ASCIIToUTF16; 29 using base::ASCIIToUTF16;
33 using base::UTF16ToUTF8; 30 using base::UTF16ToUTF8;
34 using blink::WebAXObject; 31 using blink::WebAXObject;
35 using blink::WebDocument; 32 using blink::WebDocument;
36 using blink::WebDocumentType; 33 using blink::WebDocumentType;
37 using blink::WebElement; 34 using blink::WebElement;
38 using blink::WebLocalFrame; 35 using blink::WebFrame;
39 using blink::WebNode; 36 using blink::WebNode;
40 using blink::WebVector; 37 using blink::WebVector;
41 using blink::WebView; 38 using blink::WebView;
42 39
43 namespace content { 40 namespace content {
44 41
45 namespace { 42 namespace {
46 43
47 // Returns true if |ancestor| is the first unignored parent of |child|, 44 // Returns true if |ancestor| is the first unignored parent of |child|,
48 // which means that when walking up the parent chain from |child|, 45 // which means that when walking up the parent chain from |child|,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { 103 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const {
107 const blink::WebAXObject& root = GetRoot(); 104 const blink::WebAXObject& root = GetRoot();
108 while (IsValid(node)) { 105 while (IsValid(node)) {
109 if (node.equals(root)) 106 if (node.equals(root))
110 return true; 107 return true;
111 node = GetParent(node); 108 node = GetParent(node);
112 } 109 }
113 return false; 110 return false;
114 } 111 }
115 112
116 void BlinkAXTreeSource::CollectChildFrameIdMapping(
117 std::map<int32, int>* node_to_frame_routing_id_map) {
118 node_to_frame_routing_id_map_ = node_to_frame_routing_id_map;
119 }
120
121 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { 113 blink::WebAXObject BlinkAXTreeSource::GetRoot() const {
122 return GetMainDocument().accessibilityObject(); 114 return GetMainDocument().accessibilityObject();
123 } 115 }
124 116
125 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { 117 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const {
126 return GetMainDocument().accessibilityObjectFromID(id); 118 return GetMainDocument().accessibilityObjectFromID(id);
127 } 119 }
128 120
129 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { 121 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const {
130 return node.axID(); 122 return node.axID();
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width()); 441 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width());
450 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height()); 442 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height());
451 443
452 const gfx::Size& min_offset = document.minimumScrollOffset(); 444 const gfx::Size& min_offset = document.minimumScrollOffset();
453 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width()); 445 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width());
454 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); 446 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height());
455 447
456 const gfx::Size& max_offset = document.maximumScrollOffset(); 448 const gfx::Size& max_offset = document.maximumScrollOffset();
457 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); 449 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width());
458 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, max_offset.height()); 450 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, max_offset.height());
459
460 if (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) {
461 WebLocalFrame* frame = document.frame();
462 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame);
463 if (render_frame) {
464 node_to_frame_routing_id_map_->insert(std::pair<int32, int>(
465 dst->id, render_frame->GetRoutingID()));
466 } else {
467 RenderFrameProxy* render_frame_proxy =
468 RenderFrameProxy::FromWebFrame(frame);
469 if (render_frame_proxy) {
470 node_to_frame_routing_id_map_->insert(std::pair<int32, int>(
471 dst->id, render_frame_proxy->routing_id()));
472 }
473 }
474 }
475 } 451 }
476 452
477 if (dst->role == ui::AX_ROLE_TABLE) { 453 if (dst->role == ui::AX_ROLE_TABLE) {
478 int column_count = src.columnCount(); 454 int column_count = src.columnCount();
479 int row_count = src.rowCount(); 455 int row_count = src.rowCount();
480 if (column_count > 0 && row_count > 0) { 456 if (column_count > 0 && row_count > 0) {
481 std::set<int32> unique_cell_id_set; 457 std::set<int32> unique_cell_id_set;
482 std::vector<int32> cell_ids; 458 std::vector<int32> cell_ids;
483 std::vector<int32> unique_cell_ids; 459 std::vector<int32> unique_cell_ids;
484 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); 460 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 AddIntListAttributeFromWebObjects( 543 AddIntListAttributeFromWebObjects(
568 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); 544 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst);
569 } 545 }
570 546
571 WebVector<WebAXObject> owns; 547 WebVector<WebAXObject> owns;
572 if (src.ariaOwns(owns)) 548 if (src.ariaOwns(owns))
573 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); 549 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst);
574 } 550 }
575 551
576 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { 552 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const {
577 if (render_frame_ && render_frame_->GetWebFrame()) 553 WebView* view = render_frame_->render_view()->GetWebView();
578 return render_frame_->GetWebFrame()->document(); 554 WebFrame* main_frame = view ? view->mainFrame() : NULL;
555
556 if (main_frame)
557 return main_frame->document();
579 return WebDocument(); 558 return WebDocument();
580 } 559 }
581 560
582 } // namespace content 561 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/blink_ax_tree_source.h ('k') | content/renderer/accessibility/renderer_accessibility.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698