diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/base_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/base_view.mm | 4 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.mm | 10 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 25 |
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 |