Commit a38e4728 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Move child tree id logic from AutomationManagerAura to WebView

Bug: 888152
Change-Id: I5584ab2c808b26f7363d214bedae38d080ba9735
Reviewed-on: https://chromium-review.googlesource.com/1246168
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595649}
parent 53948175
......@@ -10,7 +10,6 @@
#include "build/build_config.h"
#include "chrome/browser/extensions/api/automation_internal/automation_event_router.h"
#include "chrome/common/extensions/chrome_extension_messages.h"
#include "content/public/browser/ax_event_notification_details.h"
#include "content/public/browser/render_frame_host.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enum_util.h"
......
......@@ -5,8 +5,6 @@
#include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h"
#include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "ui/accessibility/ax_tree_id.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/accessibility/ax_view_obj_wrapper.h"
......@@ -30,19 +28,8 @@ views::AXAuraObjWrapper* AXTreeSourceAura::GetRoot() const {
void AXTreeSourceAura::SerializeNode(views::AXAuraObjWrapper* node,
ui::AXNodeData* out_data) const {
AXTreeSourceViews::SerializeNode(node, out_data);
if (out_data->role == ax::mojom::Role::kWebView) {
views::View* view = static_cast<views::AXViewObjWrapper*>(node)->view();
content::WebContents* contents =
static_cast<views::WebView*>(view)->GetWebContents();
content::RenderFrameHost* rfh = contents->GetMainFrame();
if (rfh) {
ui::AXTreeID ax_tree_id = rfh->GetAXTreeID();
out_data->AddStringAttribute(ax::mojom::StringAttribute::kChildTreeId,
ax_tree_id);
}
} else if (out_data->role == ax::mojom::Role::kWindow ||
out_data->role == ax::mojom::Role::kDialog) {
if (out_data->role == ax::mojom::Role::kWindow ||
out_data->role == ax::mojom::Role::kDialog) {
// Add clips children flag by default to these roles.
out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true);
}
......
......@@ -258,6 +258,10 @@ void WebView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
// provided via other means. Providing it here would be redundant.
// Mark the name as explicitly empty so that accessibility_checks pass.
node_data->SetNameExplicitlyEmpty();
if (child_ax_tree_id_ != ui::AXTreeIDUnknown()) {
node_data->AddStringAttribute(ax::mojom::StringAttribute::kChildTreeId,
child_ax_tree_id_);
}
}
gfx::NativeViewAccessible WebView::GetNativeViewAccessible() {
......@@ -415,8 +419,13 @@ void WebView::UpdateCrashedOverlayView() {
}
void WebView::NotifyAccessibilityWebContentsChanged() {
if (web_contents())
NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false);
content::RenderFrameHost* rfh =
web_contents() ? web_contents()->GetMainFrame() : nullptr;
if (rfh)
child_ax_tree_id_ = rfh->GetAXTreeID();
else
child_ax_tree_id_ = ui::AXTreeIDUnknown();
NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false);
}
std::unique_ptr<content::WebContents> WebView::CreateWebContents(
......
......@@ -211,6 +211,10 @@ class WEBVIEW_EXPORT WebView : public View,
gfx::Size min_size_;
gfx::Size max_size_;
// Tracks the child accessibility tree id which is associated with the
// WebContents's main RenderFrameHost.
ui::AXTreeID child_ax_tree_id_;
DISALLOW_COPY_AND_ASSIGN(WebView);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment