| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
| 6 | 6 |
| 7 #include "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // autocomplete_popup_contents_view.cc, kGlassPopupTransparency). | 37 // autocomplete_popup_contents_view.cc, kGlassPopupTransparency). |
| 38 const CGFloat kPopupAlpha = 240.0 / 255.0; | 38 const CGFloat kPopupAlpha = 240.0 / 255.0; |
| 39 | 39 |
| 40 // How much space to leave for the left and right margins. | 40 // How much space to leave for the left and right margins. |
| 41 const CGFloat kLeftRightMargin = 8.0; | 41 const CGFloat kLeftRightMargin = 8.0; |
| 42 | 42 |
| 43 // How far to offset the text column from the left. | 43 // How far to offset the text column from the left. |
| 44 const CGFloat kTextXOffset = 33.0; | 44 const CGFloat kTextXOffset = 33.0; |
| 45 | 45 |
| 46 // Animation duration when animating the popup window smaller. | 46 // Animation duration when animating the popup window smaller. |
| 47 const float kShrinkAnimationDuration = 0.1; | 47 const CGFloat kShrinkAnimationDuration = 0.1; |
| 48 | 48 |
| 49 // Maximum fraction of the popup width that can be used to display match | 49 // Maximum fraction of the popup width that can be used to display match |
| 50 // contents. | 50 // contents. |
| 51 const float kMaxContentsFraction = 0.7; | 51 const float kMaxContentsFraction = 0.7; |
| 52 | 52 |
| 53 // NSEvent -buttonNumber for middle mouse button. | 53 // NSEvent -buttonNumber for middle mouse button. |
| 54 const static NSInteger kMiddleButtonNumber(2); | 54 const static NSInteger kMiddleButtonNumber(2); |
| 55 | 55 |
| 56 // Background colors for different states of the popup elements. | 56 // Background colors for different states of the popup elements. |
| 57 NSColor* BackgroundColor() { | 57 NSColor* BackgroundColor() { |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 AutocompleteMatrix* matrix = | 358 AutocompleteMatrix* matrix = |
| 359 [[[AutocompleteMatrix alloc] initWithFrame:NSZeroRect] autorelease]; | 359 [[[AutocompleteMatrix alloc] initWithFrame:NSZeroRect] autorelease]; |
| 360 [matrix setTarget:matrix_target_]; | 360 [matrix setTarget:matrix_target_]; |
| 361 [matrix setAction:@selector(select:)]; | 361 [matrix setAction:@selector(select:)]; |
| 362 [matrix setMiddleClickAction:@selector(middleSelect:)]; | 362 [matrix setMiddleClickAction:@selector(middleSelect:)]; |
| 363 [popup_ setContentView:matrix]; | 363 [popup_ setContentView:matrix]; |
| 364 } | 364 } |
| 365 } | 365 } |
| 366 | 366 |
| 367 void AutocompletePopupViewMac::UpdatePopupAppearance() { | 367 void AutocompletePopupViewMac::UpdatePopupAppearance() { |
| 368 DCHECK([NSThread isMainThread]); |
| 368 const AutocompleteResult& result = model_->result(); | 369 const AutocompleteResult& result = model_->result(); |
| 369 if (result.empty()) { | 370 if (result.empty()) { |
| 370 [[popup_ parentWindow] removeChildWindow:popup_]; | 371 [[popup_ parentWindow] removeChildWindow:popup_]; |
| 371 [popup_ orderOut:nil]; | 372 [popup_ orderOut:nil]; |
| 372 | 373 |
| 373 // Break references to matrix_target_ before releasing popup_. | 374 // Break references to matrix_target_ before releasing popup_. |
| 374 NSMatrix* matrix = [popup_ contentView]; | 375 NSMatrix* matrix = [popup_ contentView]; |
| 375 [matrix setTarget:nil]; | 376 [matrix setTarget:nil]; |
| 376 | 377 |
| 377 popup_.reset(nil); | 378 popup_.reset(nil); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 DCHECK(popup_view_); | 724 DCHECK(popup_view_); |
| 724 popup_view_->OnClick(); | 725 popup_view_->OnClick(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 - (void)middleSelect:(id)sender { | 728 - (void)middleSelect:(id)sender { |
| 728 DCHECK(popup_view_); | 729 DCHECK(popup_view_); |
| 729 popup_view_->OnMiddleClick(); | 730 popup_view_->OnMiddleClick(); |
| 730 } | 731 } |
| 731 | 732 |
| 732 @end | 733 @end |
| OLD | NEW |