Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
index 6c25cc82855b4c1f9dfe9e570a413e9aaf04c648..84bb87014cc10ed5e5db8f7a079083abaff3d176 100644 |
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
@@ -5,6 +5,7 @@ |
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
#include "base/logging.h" |
+#include "base/mac/foundation_util.h" |
#import "chrome/browser/ui/cocoa/browser_window_controller.h" |
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
@@ -150,6 +151,12 @@ const CGFloat kAnimationDuration = 0.2; |
// Give the cell a chance to intercept clicks in page-actions and |
// other decorative items. |
if ([cell mouseDown:theEvent inRect:bounds ofView:self]) { |
+ // If a decoration intercepted the click, then the text field should resign |
+ // first responder. |
Scott Hess - ex-Googler
2015/05/08 19:38:28
This doesn't seem right for the case where the fie
erikchen
2015/05/08 20:02:20
Why not? That's the behavior on Windows. Try this
Scott Hess - ex-Googler
2015/05/08 20:34:28
You didn't mention platform. On OSX with the late
erikchen
2015/05/09 01:09:37
Hm, you're right. I've removed this logic.
|
+ NSView* firstResponder = |
+ base::mac::ObjCCast<NSView>([[self window] firstResponder]); |
+ if ([firstResponder isDescendantOf:self]) |
+ [[self window] makeFirstResponder:nil]; |
return; |
} |
@@ -392,6 +399,17 @@ const CGFloat kAnimationDuration = 0.2; |
DCHECK_EQ([self currentEditor], [[self window] firstResponder]); |
return NO; |
} |
+ |
+ // If the event is a left-mouse click, and it lands on a decoration, then the |
+ // event should not cause the text field to become first responder. |
+ NSEvent* event = [NSApp currentEvent]; |
+ if ([event type] == NSLeftMouseDown) { |
+ LocationBarDecoration* decoration = |
+ [[self cell] decorationForEvent:event inRect:[self bounds] ofView:self]; |
+ if (decoration and decoration->AcceptsMousePress()) |
Scott Hess - ex-Googler
2015/05/08 19:38:28
gah! "and"?
erikchen
2015/05/08 20:02:20
I don't even. Fixed.
|
+ return NO; |
+ } |
+ |
return [super acceptsFirstResponder]; |
} |