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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm

Issue 233623002: Shows the info bubble when the location bar icon is clicked in the origin chip. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comment tweaks. Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_cell.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/mac_logging.h" 9 #include "base/mac/mac_logging.h"
10 #include "chrome/browser/search/search.h" 10 #include "chrome/browser/search/search.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 source:self 485 source:self
486 slideBack:YES]; 486 slideBack:YES];
487 487
488 return YES; 488 return YES;
489 } 489 }
490 490
491 // On mouse-up fall through to mouse-pressed case. 491 // On mouse-up fall through to mouse-pressed case.
492 DCHECK_EQ([event type], NSLeftMouseUp); 492 DCHECK_EQ([event type], NSLeftMouseUp);
493 } 493 }
494 494
495 // Figure out where the click happened inside the decoration.
496 const NSPoint mouseLocation =
497 [controlView convertPoint:[[NSApp currentEvent] locationInWindow]
groby-ooo-7-16 2014/04/10 21:26:09 Why not use the current event that you already hav
macourteau 2014/04/28 19:19:24 Done and Done. :)
498 fromView:nil];
499 const NSPoint clickLocation = { mouseLocation.x - decorationRect.origin.x,
500 mouseLocation.y - decorationRect.origin.y };
501
495 bool handled; 502 bool handled;
496 if (decoration->AsButtonDecoration()) { 503 if (decoration->AsButtonDecoration()) {
497 ButtonDecoration* button = decoration->AsButtonDecoration(); 504 ButtonDecoration* button = decoration->AsButtonDecoration();
498 505
499 button->SetButtonState(ButtonDecoration::kButtonStatePressed); 506 button->SetButtonState(ButtonDecoration::kButtonStatePressed);
500 [controlView setNeedsDisplay:YES]; 507 [controlView setNeedsDisplay:YES];
501 508
502 // Track the mouse until the user releases the button. 509 // Track the mouse until the user releases the button.
503 [self trackMouse:theEvent 510 [self trackMouse:theEvent
504 inRect:cellFrame 511 inRect:cellFrame
505 ofView:controlView 512 ofView:controlView
506 untilMouseUp:YES]; 513 untilMouseUp:YES];
507 514
508 // Post delayed focus notification, if necessary.
509 if (focusEvent.get())
510 [self focusNotificationFor:focusEvent ofView:controlView];
groby-ooo-7-16 2014/04/10 21:26:09 The focus notification should always happen before
macourteau 2014/04/28 19:19:24 Hmm, the problem I'm having is that when the chip
groby-ooo-7-16 2014/04/30 21:55:39 All suggestions are going to amount to evil hacker
macourteau 2014/05/01 19:04:48 The "PreventFocus" trick seems to work. The only p
511
512 // Set the proper state (hover or normal) once the mouse has been released, 515 // Set the proper state (hover or normal) once the mouse has been released,
513 // and call |OnMousePressed| if the button was released while the mouse was 516 // and call |OnMousePressed| if the button was released while the mouse was
514 // within the bounds of the button. 517 // within the bounds of the button.
515 const NSPoint mouseLocation = [[NSApp currentEvent] locationInWindow]; 518 const NSPoint mouseLocation = [[NSApp currentEvent] locationInWindow];
516 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil]; 519 const NSPoint point = [controlView convertPoint:mouseLocation fromView:nil];
517 if (NSMouseInRect(point, decorationRect, [controlView isFlipped])) { 520 if (NSMouseInRect(point, decorationRect, [controlView isFlipped])) {
518 button->SetButtonState(ButtonDecoration::kButtonStateHover); 521 button->SetButtonState(ButtonDecoration::kButtonStateHover);
519 [controlView setNeedsDisplay:YES]; 522 [controlView setNeedsDisplay:YES];
520 handled = decoration->AsButtonDecoration()->OnMousePressed( 523 handled = decoration->AsButtonDecoration()->OnMousePressed(
521 [self frameForDecoration:decoration inFrame:cellFrame]); 524 [self frameForDecoration:decoration inFrame:cellFrame],
525 clickLocation);
522 } else { 526 } else {
523 button->SetButtonState(ButtonDecoration::kButtonStateNormal); 527 button->SetButtonState(ButtonDecoration::kButtonStateNormal);
524 [controlView setNeedsDisplay:YES]; 528 [controlView setNeedsDisplay:YES];
525 handled = true; 529 handled = true;
526 } 530 }
531
532 // Post delayed focus notification, if necessary, after calling the button's
533 // |OnMousePressed|.
534 if (focusEvent.get())
535 [self focusNotificationFor:focusEvent ofView:controlView];
527 } else { 536 } else {
528 handled = decoration->OnMousePressed(decorationRect); 537 handled = decoration->OnMousePressed(decorationRect, clickLocation);
529 } 538 }
530 539
531 return handled ? YES : NO; 540 return handled ? YES : NO;
532 } 541 }
533 542
534 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:| 543 // Helper method for the |mouseEntered:inView:| and |mouseExited:inView:|
535 // messages. Retrieves the |ButtonDecoration| for the specified event (received 544 // messages. Retrieves the |ButtonDecoration| for the specified event (received
536 // from a tracking area), and returns |NULL| if no decoration matches. 545 // from a tracking area), and returns |NULL| if no decoration matches.
537 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent { 546 - (ButtonDecoration*)getButtonDecorationForEvent:(NSEvent*)theEvent {
538 ButtonDecoration* bd = static_cast<ButtonDecoration*>( 547 ButtonDecoration* bd = static_cast<ButtonDecoration*>(
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 focusEvent_.reset([event retain]); 864 focusEvent_.reset([event retain]);
856 return; 865 return;
857 } 866 }
858 } 867 }
859 868
860 // Handle event immediately. 869 // Handle event immediately.
861 [self focusNotificationFor:event ofView:controlView]; 870 [self focusNotificationFor:event ofView:controlView];
862 } 871 }
863 872
864 @end 873 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698