Commit ce52adc9 authored by James Cook's avatar James Cook Committed by Commit Bot

SingleProcessMash: Fix accessibility serialization of embedded clients

Only display roots are considered root windows. We were doing the right
thing for remote widgets, but not for remote embeds.

This fixes Tast test ui.VirtualKeyboardOmnibox, which was failing
because the virtual keyboard uses embedding but the widget is owned
by ash.

Bug: 931574
Test: added to ash_unittests
Change-Id: I7d3bf1c5fccca596cf075969b2dfafc46426ad68
Reviewed-on: https://chromium-review.googlesource.com/c/1474261Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632717}
parent 4b2bd4b4
......@@ -4,7 +4,11 @@
#include "ash/ws/ax_ash_window_utils.h"
#include <vector>
#include "ash/shell.h"
#include "ash/ws/window_lookup.h"
#include "base/stl_util.h"
#include "ui/views/widget/widget.h"
namespace ash {
......@@ -57,10 +61,12 @@ aura::Window::Windows AXAshWindowUtils::GetChildren(aura::Window* window) {
}
bool AXAshWindowUtils::IsRootWindow(aura::Window* window) const {
if (!window->IsRootWindow())
return false;
// SingleProcessMash behaves like classic ash. Only display roots are
// considered root windows for accessibility, not top-level Widgets.
return window->IsRootWindow() &&
!views::Widget::GetWidgetForNativeWindow(window);
// considered root windows for accessibility, not top-level Widgets or embeds.
std::vector<aura::Window*> roots = Shell::GetAllRootWindows();
return base::ContainsValue(roots, window);
}
views::Widget* AXAshWindowUtils::GetWidgetForNativeView(aura::Window* window) {
......
......@@ -20,6 +20,8 @@
#include "ui/aura/env.h"
#include "ui/aura/mus/window_mus.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/mus/window_tree_host_mus.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "ui/aura/test/mus/change_completion_waiter.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
......@@ -194,5 +196,29 @@ TEST_F(AXAshWindowUtilsTest, SerializeNodeTree) {
EXPECT_EQ(textfield_wrapper, cache->GetFocus());
}
TEST_F(AXAshWindowUtilsTest, IsRootWindow) {
AXAshWindowUtils utils;
// From the client's perspective a widget's root window is a root.
aura::Window* widget_root = widget_->GetNativeWindow()->GetRootWindow();
EXPECT_TRUE(widget_root->IsRootWindow());
// Simulate an embedded remote client window.
aura::WindowTreeHostMus window_tree_host(aura::CreateInitParamsForTopLevel(
views::MusClient::Get()->window_tree_client()));
window_tree_host.InitHost();
window_tree_host.SetBounds(gfx::Rect(0, 0, 100, 200),
viz::LocalSurfaceIdAllocation());
aura::Window* embed_root = window_tree_host.window();
// From the client's perspective the embed is a root.
EXPECT_TRUE(embed_root->IsRootWindow());
// Accessibility serialization only considers display roots to be roots.
EXPECT_TRUE(utils.IsRootWindow(Shell::GetPrimaryRootWindow()));
EXPECT_FALSE(utils.IsRootWindow(embed_root));
EXPECT_FALSE(utils.IsRootWindow(widget_root));
}
} // namespace
} // namespace ash
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