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" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { | 106 bool BlinkAXTreeSource::IsInTree(blink::WebAXObject node) const { |
106 const blink::WebAXObject& root = GetRoot(); | 107 const blink::WebAXObject& root = GetRoot(); |
107 while (IsValid(node)) { | 108 while (IsValid(node)) { |
108 if (node.equals(root)) | 109 if (node.equals(root)) |
109 return true; | 110 return true; |
110 node = GetParent(node); | 111 node = GetParent(node); |
111 } | 112 } |
112 return false; | 113 return false; |
113 } | 114 } |
114 | 115 |
116 void BlinkAXTreeSource::CollectChildFrameIdMapping( | |
117 std::map<int32, int>* frame_routing_ids) { | |
118 frame_routing_ids_ = frame_routing_ids; | |
119 } | |
120 | |
115 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { | 121 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { |
116 return GetMainDocument().accessibilityObject(); | 122 return GetMainDocument().accessibilityObject(); |
117 } | 123 } |
118 | 124 |
119 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { | 125 blink::WebAXObject BlinkAXTreeSource::GetFromId(int32 id) const { |
120 return GetMainDocument().accessibilityObjectFromID(id); | 126 return GetMainDocument().accessibilityObjectFromID(id); |
121 } | 127 } |
122 | 128 |
123 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { | 129 int32 BlinkAXTreeSource::GetId(blink::WebAXObject node) const { |
124 return node.axID(); | 130 return node.axID(); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width()); | 449 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scroll_offset.width()); |
444 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height()); | 450 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scroll_offset.height()); |
445 | 451 |
446 const gfx::Size& min_offset = document.frame()->minimumScrollOffset(); | 452 const gfx::Size& min_offset = document.frame()->minimumScrollOffset(); |
447 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width()); | 453 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, min_offset.width()); |
448 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); | 454 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, min_offset.height()); |
449 | 455 |
450 const gfx::Size& max_offset = document.frame()->maximumScrollOffset(); | 456 const gfx::Size& max_offset = document.frame()->maximumScrollOffset(); |
451 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); | 457 dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, max_offset.width()); |
452 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 (frame_routing_ids_ && !src.equals(GetRoot())) { | |
461 WebFrame* frame = document.frame(); | |
462 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); | |
Charlie Reis
2014/08/21 19:23:27
Seems like this would return NULL if frame were a
dmazzoni
2014/08/25 06:49:36
Agreed. The test was passing only because we were
| |
463 frame_routing_ids_->insert(std::pair<int32, int>( | |
464 dst->id, render_frame->GetRoutingID())); | |
465 } | |
453 } | 466 } |
454 | 467 |
455 if (dst->role == ui::AX_ROLE_TABLE) { | 468 if (dst->role == ui::AX_ROLE_TABLE) { |
456 int column_count = src.columnCount(); | 469 int column_count = src.columnCount(); |
457 int row_count = src.rowCount(); | 470 int row_count = src.rowCount(); |
458 if (column_count > 0 && row_count > 0) { | 471 if (column_count > 0 && row_count > 0) { |
459 std::set<int32> unique_cell_id_set; | 472 std::set<int32> unique_cell_id_set; |
460 std::vector<int32> cell_ids; | 473 std::vector<int32> cell_ids; |
461 std::vector<int32> unique_cell_ids; | 474 std::vector<int32> unique_cell_ids; |
462 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); | 475 dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 AddIntListAttributeFromWebObjects( | 558 AddIntListAttributeFromWebObjects( |
546 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); | 559 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); |
547 } | 560 } |
548 | 561 |
549 WebVector<WebAXObject> owns; | 562 WebVector<WebAXObject> owns; |
550 if (src.ariaOwns(owns)) | 563 if (src.ariaOwns(owns)) |
551 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | 564 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); |
552 } | 565 } |
553 | 566 |
554 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 567 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
555 WebView* view = render_frame_->render_view()->GetWebView(); | 568 if (render_frame_ && render_frame_->GetWebFrame()) |
556 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 569 return render_frame_->GetWebFrame()->document(); |
557 | |
558 if (main_frame) | |
559 return main_frame->document(); | |
560 return WebDocument(); | 570 return WebDocument(); |
561 } | 571 } |
562 | 572 |
563 } // namespace content | 573 } // namespace content |
OLD | NEW |