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

Side by Side 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: Revert a change to the unit test AutocompleteTextFieldTest.LeftDecorationMouseDown. 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
9 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 9 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // causes a select-all, even if the decoration handles the click. If 385 // causes a select-all, even if the decoration handles the click. If
386 // the field editor is already in place, don't accept first responder 386 // the field editor is already in place, don't accept first responder
387 // again. This allows the selection to be unmodified if the click is 387 // again. This allows the selection to be unmodified if the click is
388 // handled by a decoration or context menu (|-mouseDown:| will still 388 // handled by a decoration or context menu (|-mouseDown:| will still
389 // change it if appropriate). 389 // change it if appropriate).
390 - (BOOL)acceptsFirstResponder { 390 - (BOOL)acceptsFirstResponder {
391 if ([self currentEditor]) { 391 if ([self currentEditor]) {
392 DCHECK_EQ([self currentEditor], [[self window] firstResponder]); 392 DCHECK_EQ([self currentEditor], [[self window] firstResponder]);
393 return NO; 393 return NO;
394 } 394 }
395
396 // If the event is a left-mouse click, and it lands on a decoration, then the
397 // event should not cause the text field to become first responder.
398 NSEvent* event = [NSApp currentEvent];
399 if ([event type] == NSLeftMouseDown) {
400 LocationBarDecoration* decoration =
401 [[self cell] decorationForEvent:event inRect:[self bounds] ofView:self];
402 if (decoration && decoration->AcceptsMousePress())
403 return NO;
404 }
405
395 return [super acceptsFirstResponder]; 406 return [super acceptsFirstResponder];
396 } 407 }
397 408
398 // (Overridden from NSResponder) 409 // (Overridden from NSResponder)
399 - (BOOL)becomeFirstResponder { 410 - (BOOL)becomeFirstResponder {
400 BOOL doAccept = [super becomeFirstResponder]; 411 BOOL doAccept = [super becomeFirstResponder];
401 if (doAccept) { 412 if (doAccept) {
402 [[BrowserWindowController browserWindowControllerForView:self] 413 [[BrowserWindowController browserWindowControllerForView:self]
403 lockBarVisibilityForOwner:self withAnimation:YES delay:NO]; 414 lockBarVisibilityForOwner:self withAnimation:YES delay:NO];
404 415
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 NSMinY(frame), 517 NSMinY(frame),
507 suggestWidth, 518 suggestWidth,
508 NSHeight(frame)); 519 NSHeight(frame));
509 520
510 gfx::ScopedNSGraphicsContextSaveGState saveGState; 521 gfx::ScopedNSGraphicsContextSaveGState saveGState;
511 NSRectClip(suggestRect); 522 NSRectClip(suggestRect);
512 [cell drawInteriorWithFrame:frame inView:controlView]; 523 [cell drawInteriorWithFrame:frame inView:controlView];
513 } 524 }
514 525
515 } // namespace autocomplete_text_field 526 } // namespace autocomplete_text_field
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698