diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-12 19:14:54 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-12 19:14:54 +0000 |
commit | 7e38369f764596be0a38c0a1a7339c5ed43b67de (patch) | |
tree | 5d1c9f4bfc0e51f30cab13fbcfce40ea975a3782 /chrome/browser/renderer_host | |
parent | 9fc286c694089736ee8e7b740302dc4dd080a6aa (diff) | |
download | chromium_src-7e38369f764596be0a38c0a1a7339c5ed43b67de.zip chromium_src-7e38369f764596be0a38c0a1a7339c5ed43b67de.tar.gz chromium_src-7e38369f764596be0a38c0a1a7339c5ed43b67de.tar.bz2 |
Changing the focus manager to not subclass HWNDs (but for the top-windows).Components that have HWND now need to specifically let the FocusManager know when they get the native focus.This is the reason for the new GotFocus() notification on the RenderWidgetHostViewWin class.BUG=NoneTEST=Run the interactive tests, the unit-tests. Test that the focus is remembered correctly when switching windows, switching tabs. Test that focus traversal in the browser and in the option dialog works as expected.
Review URL: http://codereview.chromium.org/122002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
6 files changed, 22 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 5e4fd06..d7d787e 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -664,6 +664,14 @@ void RenderViewHost::MakeNavigateParams(const NavigationEntry& entry, params->request_time = base::Time::Now(); } +void RenderViewHost::GotFocus() { + RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. + + RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); + if (view) + view->GotFocus(); +} + bool RenderViewHost::CanBlur() const { return delegate_->CanBlur(); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index efe3b39..0407e1b 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -418,6 +418,7 @@ class RenderViewHost : public RenderWidgetHost { virtual void Shutdown(); virtual bool IsRenderView() { return true; } virtual void OnMessageReceived(const IPC::Message& msg); + virtual void GotFocus(); virtual bool CanBlur() const; virtual void ForwardMouseEvent(const WebKit::WebMouseEvent& mouse_event); virtual gfx::Rect GetRootWindowResizerRect() const; diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 8c8ffe1..b91b69b 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -110,6 +110,9 @@ class RenderViewHostDelegate { // |is_drop_target| is true if the mouse is over a valid drop target. virtual void UpdateDragCursor(bool is_drop_target) = 0; + // Notification that view for this delegate got the focus. + virtual void GotFocus() = 0; + // Callback to inform the browser it should take back focus. If reverse is // true, it means the focus was retrieved by doing a Shift-Tab. virtual void TakeFocus(bool reverse) = 0; diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index fb6303b..fccd45d 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -188,6 +188,10 @@ void RenderWidgetHost::WasResized() { resize_ack_pending_ = false; } +void RenderWidgetHost::GotFocus() { + Focus(); +} + void RenderWidgetHost::Focus() { Send(new ViewMsg_SetFocus(routing_id_, true)); } diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 8ac2376..0645496 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -165,6 +165,11 @@ class RenderWidgetHost : public IPC::Channel::Listener { // Called to notify the RenderWidget that it has been resized. void WasResized(); + // Called to notify the RenderWidget that its associated native window got + // focused. + virtual void GotFocus(); + + // Tells the renderer it got/lost focus. void Focus(); void Blur(); void LostCapture(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index c786e70..9c33865 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -791,7 +791,7 @@ LRESULT RenderWidgetHostViewWin::OnSetCursor(HWND window, UINT hittest_code, } void RenderWidgetHostViewWin::OnSetFocus(HWND window) { - render_widget_host_->Focus(); + render_widget_host_->GotFocus(); } void RenderWidgetHostViewWin::OnKillFocus(HWND window) { |