Skip to content

Commit

Permalink
Move child tree id logic from AutomationManagerAura to WebView
Browse files Browse the repository at this point in the history
Bug: 888152
Change-Id: I5584ab2c808b26f7363d214bedae38d080ba9735
Reviewed-on: https://chromium-review.googlesource.com/1246168
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595649}
  • Loading branch information
dtsengchromium authored and Commit Bot committed Oct 1, 2018
1 parent 5394817 commit a38e472
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 2 additions & 15 deletions chrome/browser/ui/aura/accessibility/ax_tree_source_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
}
Expand Down
13 changes: 11 additions & 2 deletions ui/views/controls/webview/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions ui/views/controls/webview/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit a38e472

Please sign in to comment.