Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2706)

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm

Issue 1011943002: Mac: Clicking an omnibox decoration should not highlight the omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from shess. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..69cae79dbf4b932bb632100a809480bfcd285c5d 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.
+ 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 && decoration->AcceptsMousePress())
+ return NO;
+ }
+
return [super acceptsFirstResponder];
}

Powered by Google App Engine
This is Rietveld 408576698