Commit a8bb9670 authored by sadrul@chromium.org's avatar sadrul@chromium.org

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
parent 986afae8
...@@ -531,6 +531,10 @@ ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent( ...@@ -531,6 +531,10 @@ ui::TouchStatus RenderWidgetHostViewAura::OnTouchEvent(
return DecideTouchStatus(touch_event_, point); return DecideTouchStatus(touch_event_, point);
} }
bool RenderWidgetHostViewAura::CanFocus() {
return popup_type_ == WebKit::WebPopupTypeNone;
}
bool RenderWidgetHostViewAura::ShouldActivate(aura::Event* event) { bool RenderWidgetHostViewAura::ShouldActivate(aura::Event* event) {
return false; return false;
} }
......
...@@ -114,6 +114,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -114,6 +114,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE; virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE; virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE;
virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(aura::Event* event) OVERRIDE; virtual bool ShouldActivate(aura::Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE; virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE; virtual void OnLostActive() OVERRIDE;
......
...@@ -53,6 +53,7 @@ class DemoWindowDelegate : public aura::WindowDelegate { ...@@ -53,6 +53,7 @@ class DemoWindowDelegate : public aura::WindowDelegate {
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE { virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE {
return ui::TOUCH_STATUS_END; return ui::TOUCH_STATUS_END;
} }
virtual bool CanFocus() OVERRIDE { return true; }
virtual bool ShouldActivate(aura::Event* event) OVERRIDE { return true; } virtual bool ShouldActivate(aura::Event* event) OVERRIDE { return true; }
virtual void OnActivated() OVERRIDE {} virtual void OnActivated() OVERRIDE {}
virtual void OnLostActive() OVERRIDE {} virtual void OnLostActive() OVERRIDE {}
......
...@@ -56,6 +56,10 @@ ui::TouchStatus TestWindowDelegate::OnTouchEvent(TouchEvent* event) { ...@@ -56,6 +56,10 @@ ui::TouchStatus TestWindowDelegate::OnTouchEvent(TouchEvent* event) {
return ui::TOUCH_STATUS_UNKNOWN; return ui::TOUCH_STATUS_UNKNOWN;
} }
bool TestWindowDelegate::CanFocus() {
return true;
}
bool TestWindowDelegate::ShouldActivate(Event* event) { bool TestWindowDelegate::ShouldActivate(Event* event) {
return true; return true;
} }
......
...@@ -30,6 +30,7 @@ class TestWindowDelegate : public WindowDelegate { ...@@ -30,6 +30,7 @@ class TestWindowDelegate : public WindowDelegate {
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE; virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE; virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE;
virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(Event* event) OVERRIDE; virtual bool ShouldActivate(Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE; virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE; virtual void OnLostActive() OVERRIDE;
......
...@@ -368,8 +368,7 @@ bool Window::HasFocus() const { ...@@ -368,8 +368,7 @@ bool Window::HasFocus() const {
// propagation of events that would otherwise be targeted at windows behind it. // 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. // We then perform this same check on every window up to the root.
bool Window::CanFocus() const { bool Window::CanFocus() const {
// TODO(beng): Figure out how to consult the delegate wrt. focusability also. if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus()))
if (!IsVisible() || !parent_)
return false; return false;
Windows::const_iterator i = std::find(parent_->children().begin(), Windows::const_iterator i = std::find(parent_->children().begin(),
......
...@@ -52,6 +52,9 @@ class AURA_EXPORT WindowDelegate { ...@@ -52,6 +52,9 @@ class AURA_EXPORT WindowDelegate {
virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) = 0; 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 // 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 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 // event if the activation is the result of a touch, or NULL if activation is
......
...@@ -611,6 +611,10 @@ ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) { ...@@ -611,6 +611,10 @@ ui::TouchStatus NativeWidgetAura::OnTouchEvent(aura::TouchEvent* event) {
return delegate_->OnTouchEvent(touch_event); return delegate_->OnTouchEvent(touch_event);
} }
bool NativeWidgetAura::CanFocus() {
return true;
}
bool NativeWidgetAura::ShouldActivate(aura::Event* event) { bool NativeWidgetAura::ShouldActivate(aura::Event* event) {
return can_activate_; return can_activate_;
} }
......
...@@ -131,6 +131,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, ...@@ -131,6 +131,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE; virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE;
virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE; virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE;
virtual bool CanFocus() OVERRIDE;
virtual bool ShouldActivate(aura::Event* event) OVERRIDE; virtual bool ShouldActivate(aura::Event* event) OVERRIDE;
virtual void OnActivated() OVERRIDE; virtual void OnActivated() OVERRIDE;
virtual void OnLostActive() OVERRIDE; virtual void OnLostActive() OVERRIDE;
......
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