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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm

Issue 3300004: OS X: Clicking on search keyword autocomplete result should update the omnibox (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 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 | « chrome/browser/autocomplete/autocomplete_popup_view_mac.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <cmath> 5 #include <cmath>
6 6
7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" 7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "app/text_elider.h" 10 #include "app/text_elider.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Update the selection before placing (and displaying) the window. 441 // Update the selection before placing (and displaying) the window.
442 PaintUpdatesNow(); 442 PaintUpdatesNow();
443 443
444 // Calculate the matrix size manually rather than using -sizeToCells 444 // Calculate the matrix size manually rather than using -sizeToCells
445 // because actually resizing the matrix messed up the popup size 445 // because actually resizing the matrix messed up the popup size
446 // animation. 446 // animation.
447 DCHECK_EQ([matrix intercellSpacing].height, 0.0); 447 DCHECK_EQ([matrix intercellSpacing].height, 0.0);
448 PositionPopup(rows * cellHeight); 448 PositionPopup(rows * cellHeight);
449 } 449 }
450 450
451 void AutocompletePopupViewMac::SetSelectedLine(size_t line) {
452 model_->SetSelectedLine(line, false);
453 }
454
451 // This is only called by model in SetSelectedLine() after updating 455 // This is only called by model in SetSelectedLine() after updating
452 // everything. Popup should already be visible. 456 // everything. Popup should already be visible.
453 void AutocompletePopupViewMac::PaintUpdatesNow() { 457 void AutocompletePopupViewMac::PaintUpdatesNow() {
454 AutocompleteMatrix* matrix = [popup_ contentView]; 458 AutocompleteMatrix* matrix = [popup_ contentView];
455 [matrix selectCellAtRow:model_->selected_line() column:0]; 459 [matrix selectCellAtRow:model_->selected_line() column:0];
456 } 460 }
457 461
458 AutocompletePopupModel* AutocompletePopupViewMac::GetModel() { 462 AutocompletePopupModel* AutocompletePopupViewMac::GetModel() {
459 return model_.get(); 463 return model_.get();
460 } 464 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 } 670 }
667 } 671 }
668 672
669 // Select cell under |theEvent|, returning YES if a selection is made. 673 // Select cell under |theEvent|, returning YES if a selection is made.
670 - (BOOL)selectCellForEvent:(NSEvent*)theEvent { 674 - (BOOL)selectCellForEvent:(NSEvent*)theEvent {
671 NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil]; 675 NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
672 676
673 NSInteger row, column; 677 NSInteger row, column;
674 if ([self getRow:&row column:&column forPoint:point]) { 678 if ([self getRow:&row column:&column forPoint:point]) {
675 DCHECK_EQ(column, 0); 679 DCHECK_EQ(column, 0);
676 [self selectCellAtRow:row column:column]; 680 DCHECK(popupView_);
681 popupView_->SetSelectedLine(row);
677 return YES; 682 return YES;
678 } 683 }
679 return NO; 684 return NO;
680 } 685 }
681 686
682 // Track the mouse until released, keeping the cell under the mouse 687 // Track the mouse until released, keeping the cell under the mouse
683 // selected. If the mouse wanders off-view, revert to the 688 // selected. If the mouse wanders off-view, revert to the
684 // originally-selected cell. If the mouse is released over a cell, 689 // originally-selected cell. If the mouse is released over a cell,
685 // call |popupView_| to open the row's URL. 690 // call |popupView_| to open the row's URL.
686 - (void)mouseDown:(NSEvent*)theEvent { 691 - (void)mouseDown:(NSEvent*)theEvent {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 yRadius:kPopupRoundingRadius]; 739 yRadius:kPopupRoundingRadius];
735 740
736 // Draw the matrix clipped to our border. 741 // Draw the matrix clipped to our border.
737 [NSGraphicsContext saveGraphicsState]; 742 [NSGraphicsContext saveGraphicsState];
738 [path addClip]; 743 [path addClip];
739 [super drawRect:rect]; 744 [super drawRect:rect];
740 [NSGraphicsContext restoreGraphicsState]; 745 [NSGraphicsContext restoreGraphicsState];
741 } 746 }
742 747
743 @end 748 @end
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_popup_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698