summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-29 19:11:15 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-29 19:11:15 +0000
commit430122208349518b861bb61b0ff184d2b7ae4f4e (patch)
tree69e759c56af2c0378a60fe02cc739a93578b099f /chrome
parentaa9018cc56bc2dc8313fa963fb6fbc5ff6c87a2c (diff)
downloadchromium_src-430122208349518b861bb61b0ff184d2b7ae4f4e.zip
chromium_src-430122208349518b861bb61b0ff184d2b7ae4f4e.tar.gz
chromium_src-430122208349518b861bb61b0ff184d2b7ae4f4e.tar.bz2
Fix tabbing into web area not focusing first element.
BUG=49738 TEST=as in bug Review URL: http://codereview.chromium.org/3153039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64465 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_focus_uitest.cc2
-rw-r--r--chrome/browser/cocoa/base_view.h7
-rw-r--r--chrome/browser/cocoa/base_view.mm4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm10
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.mm25
5 files changed, 47 insertions, 1 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 9ec19a1..1099103 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -47,7 +47,7 @@
// TODO(jcampan): http://crbug.com/23683
#define MAYBE_TabsRememberFocusFindInPage FAILS_TabsRememberFocusFindInPage
#elif defined(OS_MACOSX)
-// TODO(suzhe): http://crbug.com/49738 (following two tests)
+// TODO(suzhe): http://crbug.com/60973 (following two tests)
#define MAYBE_FocusTraversal DISABLED_FocusTraversal
#define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial
// TODO(suzhe): http://crbug.com/49737
diff --git a/chrome/browser/cocoa/base_view.h b/chrome/browser/cocoa/base_view.h
index c3d49fd..bece608 100644
--- a/chrome/browser/cocoa/base_view.h
+++ b/chrome/browser/cocoa/base_view.h
@@ -35,4 +35,11 @@
@end
+// A notification that a view may issue when it receives first responder status.
+// The name is |kViewDidBecomeFirstResponder|, the object is the view, and the
+// NSSelectionDirection is wrapped in an NSNumber under the key
+// |kSelectionDirection|.
+extern NSString* kViewDidBecomeFirstResponder;
+extern NSString* kSelectionDirection;
+
#endif // CHROME_BROWSER_COCOA_BASE_VIEW_H_
diff --git a/chrome/browser/cocoa/base_view.mm b/chrome/browser/cocoa/base_view.mm
index 4c9f999..433733e7 100644
--- a/chrome/browser/cocoa/base_view.mm
+++ b/chrome/browser/cocoa/base_view.mm
@@ -4,6 +4,10 @@
#include "chrome/browser/cocoa/base_view.h"
+NSString* kViewDidBecomeFirstResponder =
+ @"Chromium.kViewDidBecomeFirstResponder";
+NSString* kSelectionDirection = @"Chromium.kSelectionDirection";
+
@implementation BaseView
- (id)initWithFrame:(NSRect)frame {
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index 9c1b17a..76d2c98 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1667,6 +1667,16 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
// See http://crbug.com/47209
[self cancelComposition];
+ NSNumber* direction = [NSNumber numberWithUnsignedInteger:
+ [[self window] keyViewSelectionDirection]];
+ NSDictionary* userInfo =
+ [NSDictionary dictionaryWithObject:direction
+ forKey:kSelectionDirection];
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:kViewDidBecomeFirstResponder
+ object:self
+ userInfo:userInfo];
+
return YES;
}
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm
index acc9813..10fc91b 100644
--- a/chrome/browser/tab_contents/tab_contents_view_mac.mm
+++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm
@@ -56,6 +56,7 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
offset:(NSPoint)offset;
- (void)cancelDeferredClose;
- (void)closeTabAfterEvent;
+- (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
@end
// static
@@ -346,6 +347,12 @@ void TabContentsViewMac::Observe(NotificationType type,
// by TabContentsController, so we can't just override -viewID method to
// return it.
view_id_util::SetID(self, VIEW_ID_TAB_CONTAINER);
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(viewDidBecomeFirstResponder:)
+ name:kViewDidBecomeFirstResponder
+ object:nil];
}
return self;
}
@@ -358,6 +365,9 @@ void TabContentsViewMac::Observe(NotificationType type,
// This probably isn't strictly necessary, but can't hurt.
[self unregisterDraggedTypes];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
[super dealloc];
}
@@ -482,4 +492,19 @@ void TabContentsViewMac::Observe(NotificationType type,
tabContentsView_->CloseTab();
}
+- (void)viewDidBecomeFirstResponder:(NSNotification*)notification {
+ NSView* view = [notification object];
+ if (![[self subviews] containsObject:view])
+ return;
+
+ NSSelectionDirection direction =
+ [[[notification userInfo] objectForKey:kSelectionDirection]
+ unsignedIntegerValue];
+ if (direction == NSDirectSelection)
+ return;
+
+ [self tabContents]->
+ FocusThroughTabTraversal(direction == NSSelectingPrevious);
+}
+
@end