| 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>* node_to_frame_routing_id_map) { |
| 118 node_to_frame_routing_id_map_ = node_to_frame_routing_id_map; |
| 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 (node_to_frame_routing_id_map_ && !src.equals(GetRoot())) { |
| 461 WebFrame* 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 } |
| 453 } | 475 } |
| 454 | 476 |
| 455 if (dst->role == ui::AX_ROLE_TABLE) { | 477 if (dst->role == ui::AX_ROLE_TABLE) { |
| 456 int column_count = src.columnCount(); | 478 int column_count = src.columnCount(); |
| 457 int row_count = src.rowCount(); | 479 int row_count = src.rowCount(); |
| 458 if (column_count > 0 && row_count > 0) { | 480 if (column_count > 0 && row_count > 0) { |
| 459 std::set<int32> unique_cell_id_set; | 481 std::set<int32> unique_cell_id_set; |
| 460 std::vector<int32> cell_ids; | 482 std::vector<int32> cell_ids; |
| 461 std::vector<int32> unique_cell_ids; | 483 std::vector<int32> unique_cell_ids; |
| 462 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... |
| 545 AddIntListAttributeFromWebObjects( | 567 AddIntListAttributeFromWebObjects( |
| 546 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); | 568 ui::AX_ATTR_LABELLEDBY_IDS, labelledby, dst); |
| 547 } | 569 } |
| 548 | 570 |
| 549 WebVector<WebAXObject> owns; | 571 WebVector<WebAXObject> owns; |
| 550 if (src.ariaOwns(owns)) | 572 if (src.ariaOwns(owns)) |
| 551 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); | 573 AddIntListAttributeFromWebObjects(ui::AX_ATTR_OWNS_IDS, owns, dst); |
| 552 } | 574 } |
| 553 | 575 |
| 554 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 576 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 555 WebView* view = render_frame_->render_view()->GetWebView(); | 577 if (render_frame_ && render_frame_->GetWebFrame()) |
| 556 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 578 return render_frame_->GetWebFrame()->document(); |
| 557 | |
| 558 if (main_frame) | |
| 559 return main_frame->document(); | |
| 560 return WebDocument(); | 579 return WebDocument(); |
| 561 } | 580 } |
| 562 | 581 |
| 563 } // namespace content | 582 } // namespace content |
| OLD | NEW |