| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "content/common/accessibility_messages.h" | 14 #include "content/common/accessibility_messages.h" |
| 15 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" | 15 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" |
| 16 #include "content/renderer/accessibility/renderer_accessibility.h" | 16 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 17 #include "content/renderer/browser_plugin/browser_plugin.h" | 17 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 18 #include "content/renderer/render_frame_impl.h" | 18 #include "content/renderer/render_frame_impl.h" |
| 19 #include "content/renderer/render_frame_proxy.h" | 19 #include "content/renderer/render_frame_proxy.h" |
| 20 #include "content/renderer/render_view_impl.h" | 20 #include "content/renderer/render_view_impl.h" |
| 21 #include "content/renderer/web_frame_utils.h" |
| 21 #include "third_party/WebKit/public/platform/WebRect.h" | 22 #include "third_party/WebKit/public/platform/WebRect.h" |
| 22 #include "third_party/WebKit/public/platform/WebSize.h" | 23 #include "third_party/WebKit/public/platform/WebSize.h" |
| 23 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
| 24 #include "third_party/WebKit/public/platform/WebVector.h" | 25 #include "third_party/WebKit/public/platform/WebVector.h" |
| 25 #include "third_party/WebKit/public/web/WebAXEnums.h" | 26 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 26 #include "third_party/WebKit/public/web/WebAXObject.h" | 27 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 27 #include "third_party/WebKit/public/web/WebDocument.h" | 28 #include "third_party/WebKit/public/web/WebDocument.h" |
| 28 #include "third_party/WebKit/public/web/WebElement.h" | 29 #include "third_party/WebKit/public/web/WebElement.h" |
| 29 #include "third_party/WebKit/public/web/WebFormControlElement.h" | 30 #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 30 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 164 } |
| 164 | 165 |
| 165 // Get the tree ID for this frame and the parent frame. | 166 // Get the tree ID for this frame and the parent frame. |
| 166 WebLocalFrame* web_frame = document.frame(); | 167 WebLocalFrame* web_frame = document.frame(); |
| 167 if (web_frame) { | 168 if (web_frame) { |
| 168 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame); | 169 RenderFrame* render_frame = RenderFrame::FromWebFrame(web_frame); |
| 169 tree_data.routing_id = render_frame->GetRoutingID(); | 170 tree_data.routing_id = render_frame->GetRoutingID(); |
| 170 | 171 |
| 171 // Get the tree ID for the parent frame. | 172 // Get the tree ID for the parent frame. |
| 172 blink::WebFrame* parent_web_frame = web_frame->parent(); | 173 blink::WebFrame* parent_web_frame = web_frame->parent(); |
| 173 if (parent_web_frame && parent_web_frame->isWebRemoteFrame()) { | 174 if (parent_web_frame) { |
| 174 RenderFrameProxy* parent_render_frame_proxy = | 175 tree_data.parent_routing_id = |
| 175 RenderFrameProxy::FromWebFrame(parent_web_frame); | 176 GetRoutingIdForFrameOrProxy(parent_web_frame); |
| 176 tree_data.parent_routing_id = parent_render_frame_proxy->routing_id(); | |
| 177 } else if (parent_web_frame && parent_web_frame->isWebLocalFrame()) { | |
| 178 RenderFrame* parent_render_frame = RenderFrame::FromWebFrame( | |
| 179 parent_web_frame); | |
| 180 tree_data.parent_routing_id = parent_render_frame->GetRoutingID(); | |
| 181 } | 177 } |
| 182 } | 178 } |
| 183 | 179 |
| 184 return tree_data; | 180 return tree_data; |
| 185 } | 181 } |
| 186 | 182 |
| 187 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { | 183 blink::WebAXObject BlinkAXTreeSource::GetRoot() const { |
| 188 if (!root_.isNull()) | 184 if (!root_.isNull()) |
| 189 return root_; | 185 return root_; |
| 190 return GetMainDocument().accessibilityObject(); | 186 return GetMainDocument().accessibilityObject(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); | 460 BrowserPlugin* browser_plugin = BrowserPlugin::GetFromNode(element); |
| 465 if (browser_plugin) { | 461 if (browser_plugin) { |
| 466 dst->AddContentIntAttribute( | 462 dst->AddContentIntAttribute( |
| 467 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, | 463 AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID, |
| 468 browser_plugin->browser_plugin_instance_id()); | 464 browser_plugin->browser_plugin_instance_id()); |
| 469 } | 465 } |
| 470 | 466 |
| 471 // Iframe. | 467 // Iframe. |
| 472 if (is_iframe) { | 468 if (is_iframe) { |
| 473 WebFrame* frame = WebFrame::fromFrameOwnerElement(element); | 469 WebFrame* frame = WebFrame::fromFrameOwnerElement(element); |
| 474 if (frame && frame->isWebRemoteFrame()) { | 470 if (frame) { |
| 475 RenderFrameProxy* render_frame_proxy = | |
| 476 RenderFrameProxy::FromWebFrame(frame); | |
| 477 DCHECK(render_frame_proxy); | |
| 478 dst->AddContentIntAttribute( | 471 dst->AddContentIntAttribute( |
| 479 AX_CONTENT_ATTR_CHILD_ROUTING_ID, | 472 AX_CONTENT_ATTR_CHILD_ROUTING_ID, |
| 480 render_frame_proxy->routing_id()); | 473 GetRoutingIdForFrameOrProxy(frame)); |
| 481 } else if (frame && frame->isWebLocalFrame()) { | |
| 482 RenderFrame* render_frame = RenderFrame::FromWebFrame(frame); | |
| 483 DCHECK(render_frame); | |
| 484 dst->AddContentIntAttribute( | |
| 485 AX_CONTENT_ATTR_CHILD_ROUTING_ID, | |
| 486 render_frame->GetRoutingID()); | |
| 487 } | 474 } |
| 488 } | 475 } |
| 489 } | 476 } |
| 490 | 477 |
| 491 if (src.isInLiveRegion()) { | 478 if (src.isInLiveRegion()) { |
| 492 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC, src.liveRegionAtomic()); | 479 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC, src.liveRegionAtomic()); |
| 493 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_BUSY, src.liveRegionBusy()); | 480 dst->AddBoolAttribute(ui::AX_ATTR_LIVE_BUSY, src.liveRegionBusy()); |
| 494 if (src.liveRegionBusy()) | 481 if (src.liveRegionBusy()) |
| 495 dst->state |= (1 << ui::AX_STATE_BUSY); | 482 dst->state |= (1 << ui::AX_STATE_BUSY); |
| 496 if (!src.liveRegionStatus().isEmpty()) { | 483 if (!src.liveRegionStatus().isEmpty()) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 } | 616 } |
| 630 } | 617 } |
| 631 | 618 |
| 632 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { | 619 blink::WebDocument BlinkAXTreeSource::GetMainDocument() const { |
| 633 if (render_frame_ && render_frame_->GetWebFrame()) | 620 if (render_frame_ && render_frame_->GetWebFrame()) |
| 634 return render_frame_->GetWebFrame()->document(); | 621 return render_frame_->GetWebFrame()->document(); |
| 635 return WebDocument(); | 622 return WebDocument(); |
| 636 } | 623 } |
| 637 | 624 |
| 638 } // namespace content | 625 } // namespace content |
| OLD | NEW |