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