| 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 "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 11 #include "chrome/browser/cocoa/event_utils.h" |
| 11 #include "chrome/browser/cocoa/nsimage_cache.h" | 12 #include "chrome/browser/cocoa/nsimage_cache.h" |
| 12 #import "chrome/common/cocoa_utils.h" | |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // The size delta between the font used for the edit and the result | 16 // The size delta between the font used for the edit and the result |
| 17 // rows. | 17 // rows. |
| 18 const int kEditFontAdjust = -1; | 18 const int kEditFontAdjust = -1; |
| 19 | 19 |
| 20 // How much to adjust the cell sizing up from the default determined | 20 // How much to adjust the cell sizing up from the default determined |
| 21 // by the font. | 21 // by the font. |
| 22 const int kCellHeightAdjust = 7.0; | 22 const int kCellHeightAdjust = 7.0; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 void AutocompletePopupViewMac::AcceptInput() { | 373 void AutocompletePopupViewMac::AcceptInput() { |
| 374 const NSInteger selectedRow = [[popup_ contentView] selectedRow]; | 374 const NSInteger selectedRow = [[popup_ contentView] selectedRow]; |
| 375 | 375 |
| 376 // -1 means no cells were selected. This can happen if the user | 376 // -1 means no cells were selected. This can happen if the user |
| 377 // clicked and then dragged their mouse off the popup before | 377 // clicked and then dragged their mouse off the popup before |
| 378 // releasing, so reset the selection and ignore the event. | 378 // releasing, so reset the selection and ignore the event. |
| 379 if (selectedRow == -1) { | 379 if (selectedRow == -1) { |
| 380 PaintUpdatesNow(); | 380 PaintUpdatesNow(); |
| 381 } else { | 381 } else { |
| 382 model_->SetSelectedLine(selectedRow, false); | 382 model_->SetSelectedLine(selectedRow, false); |
| 383 WindowOpenDisposition disposition = event_utils::DispositionFromEventFlags( | 383 WindowOpenDisposition disposition = |
| 384 [[NSApp currentEvent] modifierFlags]); | 384 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 385 edit_view_->AcceptInput(disposition, false); | 385 edit_view_->AcceptInput(disposition, false); |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 @implementation AutocompleteButtonCell | 389 @implementation AutocompleteButtonCell |
| 390 | 390 |
| 391 - init { | 391 - init { |
| 392 self = [super init]; | 392 self = [super init]; |
| 393 if (self) { | 393 if (self) { |
| 394 [self setImagePosition:NSImageLeft]; | 394 [self setImagePosition:NSImageLeft]; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 DCHECK(popup_view_); | 579 DCHECK(popup_view_); |
| 580 | 580 |
| 581 // TODO(shess): UpdatePopupAppearance() is called frequently, so it | 581 // TODO(shess): UpdatePopupAppearance() is called frequently, so it |
| 582 // should be really cheap, but in this case we could probably make | 582 // should be really cheap, but in this case we could probably make |
| 583 // things even cheaper by refactoring between the popup-placement | 583 // things even cheaper by refactoring between the popup-placement |
| 584 // code and the matrix-population code. | 584 // code and the matrix-population code. |
| 585 popup_view_->UpdatePopupAppearance(); | 585 popup_view_->UpdatePopupAppearance(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 @end | 588 @end |
| OLD | NEW |