Commit 35f4110b authored by Jiawei Li's avatar Jiawei Li Committed by Commit Bot

Revert "[chromecast] Enable element focus for WebContentController"

This reverts commit ffc6f22e.

Reason for revert: key events cannot reach its target with this change. Particular app cannot adjust volume via button.

Bug: Internal b/162242786
Test: manual on device

Original change's description:
> [chromecast] Enable element focus for WebContentController
> 
> Focus did not work due to two distinct problems, both of which caused
> page-level focus to be absent, which in turn meant that blink-level
> focus was suppressed.
> 
> - The aura::Window on which focus was attempted does not have an
>   OnWindowFocused observer. This change focuses the Window that does.
> 
> - Wayland app's aura::Windows are not visible. This change adds a check
>   for an ancestor that is an exo window.
> 
> Bug: b/156123509
> Test: manual on device
> Change-Id: Ib4e8a5101bbc28d2b7a0448aff8142c8cffa2a76
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274201
> Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
> Reviewed-by: Daniel Nicoara <dnicoara@chromium.org>
> Reviewed-by: Albert Chaulk <achaulk@chromium.org>
> Commit-Queue: Kevin Schoedel <kpschoedel@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#786469}

TBR=achaulk@chromium.org,dnicoara@chromium.org,kpschoedel@chromium.org,dcastagna@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: b/156123509
Change-Id: Ifd988ad2469c2797d43e74c9194f2b28b7c31753
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335395
Commit-Queue: Jiawei Li <lijiawei@chromium.org>
Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794641}
parent 3f250a6e
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "chromecast/browser/cast_web_contents.h" #include "chromecast/browser/cast_web_contents.h"
#include "chromecast/browser/webview/proto/webview.pb.h" #include "chromecast/browser/webview/proto/webview.pb.h"
#include "chromecast/browser/webview/webview_navigation_throttle.h" #include "chromecast/browser/webview/webview_navigation_throttle.h"
#include "chromecast/graphics/cast_focus_client_aura.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
...@@ -181,23 +180,14 @@ void WebContentController::AttachTo(aura::Window* window, int window_id) { ...@@ -181,23 +180,14 @@ void WebContentController::AttachTo(aura::Window* window, int window_id) {
void WebContentController::ProcessInputEvent(const webview::InputEvent& ev) { void WebContentController::ProcessInputEvent(const webview::InputEvent& ev) {
content::WebContents* contents = GetWebContents(); content::WebContents* contents = GetWebContents();
DCHECK(contents); DCHECK(contents);
DCHECK(contents->GetNativeView());
// Ensure this web contents has focus before sending it input. if (!contents->GetNativeView()->CanFocus())
// Focus at this level is necessary, or else Blink will ignore
// attempts to focus any elements in the contents.
//
// Via b/156123509: The aura::Window given by |contents->GetNativeView()|
// is not suitable for this purpose, because it has no OnWindowFocused
// observer. The |window| used here is the same one whose |delegate|
// is the EventHandler for this input event.
content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView();
aura::Window* window = rwhv->GetNativeView();
DCHECK(window == contents->GetContentNativeView());
if (!window->CanFocus())
return; return;
if (!window->HasFocus()) // Ensure this web contents has focus before sending it input.
window->Focus(); if (!contents->GetNativeView()->HasFocus())
contents->GetNativeView()->Focus();
content::RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView();
ui::EventHandler* handler = rwhv->GetNativeView()->delegate(); ui::EventHandler* handler = rwhv->GetNativeView()->delegate();
ui::EventType type = static_cast<ui::EventType>(ev.event_type()); ui::EventType type = static_cast<ui::EventType>(ev.event_type());
switch (type) { switch (type) {
......
...@@ -108,10 +108,7 @@ cast_source_set("graphics") { ...@@ -108,10 +108,7 @@ cast_source_set("graphics") {
} }
if (use_ozone) { if (use_ozone) {
deps += [ deps += [ "//ui/ozone" ]
"//components/exo",
"//ui/ozone",
]
} }
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "components/exo/surface.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#define LOG_WINDOW_INFO(top_level, window) \ #define LOG_WINDOW_INFO(top_level, window) \
...@@ -14,19 +13,6 @@ ...@@ -14,19 +13,6 @@
<< "', window: " << (window)->id() << ": '" \ << "', window: " << (window)->id() << ": '" \
<< (window)->GetName() << "'" << (window)->GetName() << "'"
namespace {
bool IsVisibleExoWindow(aura::Window* window) {
for (aura::Window* w = window; w; w = w->parent()) {
if (w->GetProperty(exo::kClientSurfaceIdKey) && w->IsVisible()) {
return true;
}
}
return false;
}
} // namespace
namespace chromecast { namespace chromecast {
CastFocusClientAura::CastFocusClientAura() : focused_window_(nullptr) {} CastFocusClientAura::CastFocusClientAura() : focused_window_(nullptr) {}
...@@ -207,10 +193,7 @@ aura::Window* CastFocusClientAura::GetWindowToFocus() { ...@@ -207,10 +193,7 @@ aura::Window* CastFocusClientAura::GetWindowToFocus() {
aura::Window* next = nullptr; aura::Window* next = nullptr;
aura::Window* next_top_level = nullptr; aura::Window* next_top_level = nullptr;
for (aura::Window* window : focusable_windows_) { for (aura::Window* window : focusable_windows_) {
if (!window->CanFocus()) { if (!window->CanFocus() || !window->IsVisible()) {
continue;
}
if (!window->IsVisible() && !IsVisibleExoWindow(window)) {
continue; continue;
} }
......
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