| OLD | NEW |
| 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 "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #import "base/mac/sdk_forward_declarations.h" | 9 #import "base/mac/sdk_forward_declarations.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 458 } |
| 459 | 459 |
| 460 return [super acceptsFirstResponder]; | 460 return [super acceptsFirstResponder]; |
| 461 } | 461 } |
| 462 | 462 |
| 463 // (Overridden from NSResponder) | 463 // (Overridden from NSResponder) |
| 464 - (BOOL)becomeFirstResponder { | 464 - (BOOL)becomeFirstResponder { |
| 465 BOOL doAccept = [super becomeFirstResponder]; | 465 BOOL doAccept = [super becomeFirstResponder]; |
| 466 if (doAccept) { | 466 if (doAccept) { |
| 467 [[BrowserWindowController browserWindowControllerForView:self] | 467 [[BrowserWindowController browserWindowControllerForView:self] |
| 468 lockBarVisibilityForOwner:self withAnimation:YES delay:NO]; | 468 lockBarVisibilityForOwner:self |
| 469 withAnimation:YES]; |
| 469 | 470 |
| 470 // Tells the observer that we get the focus. | 471 // Tells the observer that we get the focus. |
| 471 // But we can't call observer_->OnKillFocus() in resignFirstResponder:, | 472 // But we can't call observer_->OnKillFocus() in resignFirstResponder:, |
| 472 // because the first responder will be immediately set to the field editor | 473 // because the first responder will be immediately set to the field editor |
| 473 // when calling [super becomeFirstResponder], thus we won't receive | 474 // when calling [super becomeFirstResponder], thus we won't receive |
| 474 // resignFirstResponder: anymore when losing focus. | 475 // resignFirstResponder: anymore when losing focus. |
| 475 [[self cell] handleFocusEvent:[NSApp currentEvent] ofView:self]; | 476 [[self cell] handleFocusEvent:[NSApp currentEvent] ofView:self]; |
| 476 } | 477 } |
| 477 return doAccept; | 478 return doAccept; |
| 478 } | 479 } |
| 479 | 480 |
| 480 // (Overridden from NSResponder) | 481 // (Overridden from NSResponder) |
| 481 - (BOOL)resignFirstResponder { | 482 - (BOOL)resignFirstResponder { |
| 482 BOOL doResign = [super resignFirstResponder]; | 483 BOOL doResign = [super resignFirstResponder]; |
| 483 if (doResign) { | 484 if (doResign) { |
| 484 [[BrowserWindowController browserWindowControllerForView:self] | 485 [[BrowserWindowController browserWindowControllerForView:self] |
| 485 releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; | 486 releaseBarVisibilityForOwner:self |
| 487 withAnimation:YES]; |
| 486 } | 488 } |
| 487 return doResign; | 489 return doResign; |
| 488 } | 490 } |
| 489 | 491 |
| 490 - (void)drawRect:(NSRect)rect { | 492 - (void)drawRect:(NSRect)rect { |
| 491 [super drawRect:rect]; | 493 [super drawRect:rect]; |
| 492 autocomplete_text_field::DrawGrayTextAutocompletion( | 494 autocomplete_text_field::DrawGrayTextAutocompletion( |
| 493 [self attributedStringValue], | 495 [self attributedStringValue], |
| 494 suggestText_, | 496 suggestText_, |
| 495 suggestColor_, | 497 suggestColor_, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 NSMinY(frame), | 586 NSMinY(frame), |
| 585 suggestWidth, | 587 suggestWidth, |
| 586 NSHeight(frame)); | 588 NSHeight(frame)); |
| 587 | 589 |
| 588 gfx::ScopedNSGraphicsContextSaveGState saveGState; | 590 gfx::ScopedNSGraphicsContextSaveGState saveGState; |
| 589 NSRectClip(suggestRect); | 591 NSRectClip(suggestRect); |
| 590 [cell drawInteriorWithFrame:frame inView:controlView]; | 592 [cell drawInteriorWithFrame:frame inView:controlView]; |
| 591 } | 593 } |
| 592 | 594 |
| 593 } // namespace autocomplete_text_field | 595 } // namespace autocomplete_text_field |
| OLD | NEW |