summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-03 22:17:40 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-03 22:17:40 +0000
commita8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f (patch)
tree77ecaf1ab0b57487accad841b2806aaeb1041f18
parent986afae849b2403e0b3b159e9bc567aec6624aaa (diff)
downloadchromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.zip
chromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.tar.gz
chromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.tar.bz2
aura: Ask the WindowDelegate before a Window is Focus()ed.
. In aura, before a window is focused, ask the delegate if it can be focused. . Make a popup RWHVA non-focusable. This is to prevent the focus from moving from the main web-page to the combobox (which causes the combobox to get destroyed). This fixes an issue where comboboxes in the login screen could not be used properly. BUG=105786 TEST=manually Review URL: http://codereview.chromium.org/8770011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112909 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc4
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h1
-rw-r--r--ui/aura/demo/demo_main.cc1
-rw-r--r--ui/aura/test/test_window_delegate.cc4
-rw-r--r--ui/aura/test/test_window_delegate.h1
-rw-r--r--ui/aura/window.cc3
-rw-r--r--ui/aura/window_delegate.h3
-rw-r--r--ui/views/widget/native_widget_aura.cc4
-rw-r--r--ui/views/widget/native_widget_aura.h1
9 files changed, 20 insertions, 2 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 90d23e0..9978862 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -531,6 +531,10 @@ ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent(
return DecideTouchStatus(touch_event_, point);
}
+bool RenderWidgetHostViewAura::CanFocus() {
+ return popup_type_ == WebKit::WebPopupTypeNone;
+}
+
bool RenderWidgetHostViewAura::ShouldActivate(aura::Event* event) {
return false;
}
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 28dfe4e..2cf607d 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -114,6 +114,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE;
+ virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(aura::Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE;
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index f8337ec..0795067 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -53,6 +53,7 @@ class DemoWindowDelegate : public aura::WindowDelegate {
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE {
return ui::TOUCH_STATUS_END;
}
+ virtual bool CanFocus() OVERRIDE { return true; }
virtual bool ShouldActivate(aura::Event* event) OVERRIDE { return true; }
virtual void OnActivated() OVERRIDE {}
virtual void OnLostActive() OVERRIDE {}
diff --git a/ui/aura/test/test_window_delegate.cc b/ui/aura/test/test_window_delegate.cc
index 4244879..4a4f778 100644
--- a/ui/aura/test/test_window_delegate.cc
+++ b/ui/aura/test/test_window_delegate.cc
@@ -56,6 +56,10 @@ ui::TouchStatus TestWindowDelegate::OnTouchEvent(TouchEvent* event) {
return ui::TOUCH_STATUS_UNKNOWN;
}
+bool TestWindowDelegate::CanFocus() {
+ return true;
+}
+
bool TestWindowDelegate::ShouldActivate(Event* event) {
return true;
}
diff --git a/ui/aura/test/test_window_delegate.h b/ui/aura/test/test_window_delegate.h
index febe663..08f1d6f 100644
--- a/ui/aura/test/test_window_delegate.h
+++ b/ui/aura/test/test_window_delegate.h
@@ -30,6 +30,7 @@ class TestWindowDelegate : public WindowDelegate {
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE;
+ virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE;
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index d54a67e..c243997 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -368,8 +368,7 @@ bool Window::HasFocus() const {
// propagation of events that would otherwise be targeted at windows behind it.
// We then perform this same check on every window up to the root.
bool Window::CanFocus() const {
- // TODO(beng): Figure out how to consult the delegate wrt. focusability also.
- if (!IsVisible() || !parent_)
+ if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus()))
return false;
Windows::const_iterator i = std::find(parent_->children().begin(),
diff --git a/ui/aura/window_delegate.h b/ui/aura/window_delegate.h
index 034ad8e..f865511 100644
--- a/ui/aura/window_delegate.h
+++ b/ui/aura/window_delegate.h
@@ -52,6 +52,9 @@ class AURA_EXPORT WindowDelegate {
virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) = 0;
+ // Returns true of the window can be focused.
+ virtual bool CanFocus() = 0;
+
// Returns true if the window should be activated. |event| is either the mouse
// event supplied if the activation is the result of a mouse, or the touch
// event if the activation is the result of a touch, or NULL if activation is
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 26d3392..71500e3f 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -611,6 +611,10 @@ ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) {
return delegate_->OnTouchEvent(touch_event);
}
+bool NativeWidgetAura::CanFocus() {
+ return true;
+}
+
bool NativeWidgetAura::ShouldActivate(aura::Event* event) {
return can_activate_;
}
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index 16c1bef..4a0f11a 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -131,6 +131,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE;
+ virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(aura::Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE;