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 <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" |
14 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
15 #include "third_party/WebKit/public/platform/WebRect.h" | 16 #include "third_party/WebKit/public/platform/WebRect.h" |
16 #include "third_party/WebKit/public/platform/WebSize.h" | 17 #include "third_party/WebKit/public/platform/WebSize.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/platform/WebVector.h" | 19 #include "third_party/WebKit/public/platform/WebVector.h" |
19 #include "third_party/WebKit/public/web/WebAXEnums.h" | 20 #include "third_party/WebKit/public/web/WebAXEnums.h" |
20 #include "third_party/WebKit/public/web/WebAXObject.h" | 21 #include "third_party/WebKit/public/web/WebAXObject.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebDocumentType.h" | 23 #include "third_party/WebKit/public/web/WebDocumentType.h" |
23 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
24 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 25 #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" |
25 #include "third_party/WebKit/public/web/WebInputElement.h" | 28 #include "third_party/WebKit/public/web/WebInputElement.h" |
26 #include "third_party/WebKit/public/web/WebNode.h" | 29 #include "third_party/WebKit/public/web/WebNode.h" |
27 #include "third_party/WebKit/public/web/WebView.h" | 30 #include "third_party/WebKit/public/web/WebView.h" |
28 | 31 |
29 using base::ASCIIToUTF16; | 32 using base::ASCIIToUTF16; |
30 using base::UTF16ToUTF8; | 33 using base::UTF16ToUTF8; |
31 using blink::WebAXObject; | 34 using blink::WebAXObject; |
32 using blink::WebDocument; | 35 using blink::WebDocument; |
33 using blink::WebDocumentType; | 36 using blink::WebDocumentType; |
34 using blink::WebElement; | 37 using blink::WebElement; |
35 using blink::WebFrame; | 38 using blink::WebLocalFrame; |
36 using blink::WebNode; | 39 using blink::WebNode; |
37 using blink::WebVector; | 40 using blink::WebVector; |
38 using blink::WebView; | 41 using blink::WebView; |
39 | 42 |
40 namespace content { | 43 namespace content { |
41 | 44 |
42 namespace { | 45 namespace { |
43 | 46 |
44 // Returns true if |ancestor| is the first unignored parent of |child|, | 47 // Returns true if |ancestor| is the first unignored parent of |child|, |
45 // which means that when walking up the parent chain from |child|, | 48 // which means that when walking up the parent chain from |child|, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { | 106 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { |
104 const blink::WebAXObject& root = GetRoot(); | 107 const blink::WebAXObject& root = GetRoot(); |
105 while (IsValid(node)) { | 108 while (IsValid(node)) { |
106 if (node.equals(root)) | 109 if (node.equals(root)) |
107 return true; | 110 return true; |
108 node = GetParent(node); | 111 node = GetParent(node); |
109 } | 112 } |
110 return false; | 113 return false; |
111 } | 114 } |
112 | 115 |
| 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 |
113 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { | 121 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { |
114 return GetMainDocument().accessibilityObject(); | 122 return GetMainDocument().accessibilityObject(); |
115 } | 123 } |
116 | 124 |
117 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { | 125 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { |
118 return GetMainDocument().accessibilityObjectFromID(id); | 126 return GetMainDocument().accessibilityObjectFromID(id); |
119 } | 127 } |
120 | 128 |
121 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { | 129 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { |
122 return node.axID(); | 130 return node.axID(); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width()); | 449 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width()); |
442 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height()); | 450 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height()); |
443 | 451 |
444 const gfx::Size& min_offset = document.minimumScrollOffset(); | 452 const gfx::Size& min_offset = document.minimumScrollOffset(); |
445 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width()); | 453 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width()); |
446 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); | 454 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); |
447 | 455 |
448 const gfx::Size& max_offset = document.maximumScrollOffset(); | 456 const gfx::Size& max_offset = document.maximumScrollOffset(); |
449 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); | 457 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); |
450 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, max_offset.height()); | 458 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 } |
451 } | 475 } |
452 | 476 |
453 if (dst->role == ui::AX_ROLE_TABLE) { | 477 if (dst->role == ui::AX_ROLE_TABLE) { |
454 int column_count = src.columnCount(); | 478 int column_count = src.columnCount(); |
455 int row_count = src.rowCount(); | 479 int row_count = src.rowCount(); |
456 if (column_count > 0 && row_count > 0) { | 480 if (column_count > 0 && row_count > 0) { |
457 std::set<int32> unique_cell_id_set; | 481 std::set<int32> unique_cell_id_set; |
458 std::vector<int32> cell_ids; | 482 std::vector<int32> cell_ids; |
459 std::vector<int32> unique_cell_ids; | 483 std::vector<int32> unique_cell_ids; |
460 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); | 484 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 AddIntListAttributeFromWebObjects( | 567 AddIntListAttributeFromWebObjects( |
544 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); | 568 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); |
545 } | 569 } |
546 | 570 |
547 WebVector<WebAXObject> owns; | 571 WebVector<WebAXObject> owns; |
548 if (src.ariaOwns(owns)) | 572 if (src.ariaOwns(owns)) |
549 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | 573 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); |
550 } | 574 } |
551 | 575 |
552 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 576 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
553 WebView* view = render_frame_->render_view()->GetWebView(); | 577 if (render_frame_ && render_frame_->GetWebFrame()) |
554 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 578 return render_frame_->GetWebFrame()->document(); |
555 | |
556 if (main_frame) | |
557 return main_frame->document(); | |
558 return WebDocument(); | 579 return WebDocument(); |
559 } | 580 } |
560 | 581 |
561 } // namespace content | 582 } // namespace content |
OLD | NEW |