Commit bf204b1c authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Chromecast should focus on full screen shell surface ax node

Chromecast should focus on the full screen shell surface node
that holds the child tree for the UI.  Otherwise, things like
live regions will fail to find a focused root node and will
not work.

Bug: NONE
Test: Local chromecast build
Change-Id: I5b34eb40fd3c7240b8584fc83bf312727f9e2658
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134568Reviewed-by: default avatarSean Topping <seantopping@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758839}
parent 6ed948be
...@@ -16,6 +16,7 @@ include_rules = [ ...@@ -16,6 +16,7 @@ include_rules = [
"+components/cdm/browser", "+components/cdm/browser",
"+components/crash", "+components/crash",
"+components/download/public/common", "+components/download/public/common",
"+components/exo",
"+components/heap_profiling", "+components/heap_profiling",
"+components/keyed_service", "+components/keyed_service",
"+components/network_hints", "+components/network_hints",
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include "chromecast/browser/accessibility/accessibility_manager.h" #include "chromecast/browser/accessibility/accessibility_manager.h"
#include "chromecast/browser/cast_browser_process.h" #include "chromecast/browser/cast_browser_process.h"
#include "chromecast/browser/ui/aura/accessibility/automation_manager_aura.h" #include "chromecast/browser/ui/aura/accessibility/automation_manager_aura.h"
#include "components/exo/fullscreen_shell_surface.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/surface.h"
#include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_tree_data.h" #include "ui/accessibility/ax_tree_data.h"
...@@ -14,17 +17,20 @@ ...@@ -14,17 +17,20 @@
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/views/accessibility/ax_aura_obj_wrapper.h" #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/accessibility/ax_view_obj_wrapper.h"
AXTreeSourceAura::AXTreeSourceAura(views::AXAuraObjWrapper* root, AXTreeSourceAura::AXTreeSourceAura(views::AXAuraObjWrapper* root,
const ui::AXTreeID& tree_id, const ui::AXTreeID& tree_id,
views::AXAuraObjCache* cache) views::AXAuraObjCache* cache)
: AXTreeSourceViews(root, tree_id, cache) {} : AXTreeSourceViews(root, tree_id, cache), cache_(cache) {}
AXTreeSourceAura::~AXTreeSourceAura() = default; AXTreeSourceAura::~AXTreeSourceAura() = default;
bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const { bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const {
AXTreeSourceViews::GetTreeData(tree_data); AXTreeSourceViews::GetTreeData(tree_data);
// TODO(b/1069055) : This is a temporary solution to override the
// superclass method which does not set the correct focus_id.
aura::Window* root_window = aura::Window* root_window =
chromecast::shell::CastBrowserProcess::GetInstance() chromecast::shell::CastBrowserProcess::GetInstance()
->accessibility_manager() ->accessibility_manager()
...@@ -35,8 +41,37 @@ bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const { ...@@ -35,8 +41,37 @@ bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const {
aura::client::GetFocusClient(root_window); aura::client::GetFocusClient(root_window);
if (focus_client) { if (focus_client) {
aura::Window* window = focus_client->GetFocusedWindow(); aura::Window* window = focus_client->GetFocusedWindow();
tree_data->focus_id = tree_data->focus_id = ui::AXNode::kInvalidAXID;
AutomationManagerAura::GetInstance()->GetIDFromWindow(window);
// Search for the full screen shell surface that holds the child
// tree for our UI. This is the node that should receive focus.
if (window) {
std::stack<aura::Window*> stack;
stack.push(window);
while (!stack.empty()) {
aura::Window* top = stack.top();
stack.pop();
DCHECK(top);
exo::Surface* surface = exo::GetShellMainSurface(top);
if (surface) {
views::Widget* widget =
views::Widget::GetWidgetForNativeWindow(top);
if (widget) {
exo::FullscreenShellSurface* full_screen_shell_surface =
static_cast<exo::FullscreenShellSurface*>(
widget->widget_delegate());
tree_data->focus_id = cache_->GetID(full_screen_shell_surface);
break;
}
}
for (aura::Window* child : top->children())
stack.push(child);
}
if (tree_data->focus_id == -1) {
LOG(ERROR) << "Could not find node to focus in desktop tree.";
}
}
} }
} }
return true; return true;
......
...@@ -25,6 +25,8 @@ class AXTreeSourceAura : public views::AXTreeSourceViews { ...@@ -25,6 +25,8 @@ class AXTreeSourceAura : public views::AXTreeSourceViews {
ui::AXNodeData* out_data) const override; ui::AXNodeData* out_data) const override;
private: private:
views::AXAuraObjCache* cache_;
DISALLOW_COPY_AND_ASSIGN(AXTreeSourceAura); DISALLOW_COPY_AND_ASSIGN(AXTreeSourceAura);
}; };
......
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