diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 17:26:34 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-22 17:26:34 +0000 |
commit | 8c66c5ae2f67738941f4476fd7d5111a89c337ba (patch) | |
tree | c18d8c1e0e4f707c51554558466cb74204a1b393 /chrome/browser/cocoa/browser_window_controller.mm | |
parent | 1abd61f7cb060fb1e5ccd1546ac1aa157a1801a5 (diff) | |
download | chromium_src-8c66c5ae2f67738941f4476fd7d5111a89c337ba.zip chromium_src-8c66c5ae2f67738941f4476fd7d5111a89c337ba.tar.gz chromium_src-8c66c5ae2f67738941f4476fd7d5111a89c337ba.tar.bz2 |
Make scrollbars and other controls tint/untint upon main window gaining
focus on Mac. This entails the following:
- getting notifications that the main window has become or lost key
window status (in BrowserWindowController) [new]
- ... which tells the RenderWidgetHostView(Mac) to (de)activate [new]
- ... which tells the RenderWidgetHost to (de)activate [new]
- ... which sends a ViewMsg_SetActive message [new message] to the
RenderView [new]
- ... which tells the WebView(Impl) to (de)activate [new]
- ... which tells its page()'s FocusController to (de)activate [new]
- ... which is now in WebKit-land.
N.B.: "Activate" is the nomenclature used in WebKit; "focus"/"blur" can
sometimes (kind of) mean the same thing, but is ambiguous, since "focus"
has a more specific meaning.
Added a WebView unit test, which currently only tests to make sure that
SetActive() (and IsActive() [also new]) work correctly. The changes to
the other classes aren't very testable since they don't actually do
anything (other than pass things along).
BUG=12507
TEST=webkit/glue/webkit_unittest.cc
Patch by viettrungluu@gmail.com (see http://codereview.chromium.org/159048 ),
r=avi
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index f016420..30054d0 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -14,6 +14,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/encoding_menu_controller.h" #include "chrome/browser/profile.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -310,6 +311,28 @@ willPositionSheet:(NSWindow*)sheet [self applyTheme]; } +// Called when we are activated (when we gain focus). +- (void)windowDidBecomeKey:(NSNotification*)notification { + // We need to activate the controls (in the "WebView"). To do this, get the + // selected TabContents's RenderWidgetHostViewMac and tell it to activate. + if (TabContents* contents = browser_->GetSelectedTabContents()) { + if (RenderWidgetHostView* rwhv = contents->render_widget_host_view()) + rwhv->SetActive(true); + } +} + +// Called when we are deactivated (when we lose focus). +- (void)windowDidResignKey:(NSNotification*)notification { + // We need to deactivate the controls (in the "WebView"). To do this, get the + // selected TabContents's RenderWidgetHostView and tell it to deactivate. + if (TabContents* contents = browser_->GetSelectedTabContents()) { + if (RenderWidgetHostView* rwhv = contents->render_widget_host_view()) + rwhv->SetActive(false); + } +} + + + // Called when the user clicks the zoom button (or selects it from the Window // menu). Zoom to the appropriate size based on the content. Make sure we // enforce a minimum width to ensure websites with small intrinsic widths |