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

Unified Diff: chrome/browser/cocoa/autocomplete_text_field.mm

Issue 525098: [Mac] Implements context menus for Page Actions. Introduces a reusable subcla... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Final changes before submit. Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/autocomplete_text_field.mm
===================================================================
--- chrome/browser/cocoa/autocomplete_text_field.mm (revision 36013)
+++ chrome/browser/cocoa/autocomplete_text_field.mm (working copy)
@@ -70,15 +70,16 @@
// a decoration area and get the expected selection behaviour,
// likewise for multiple clicks in those areas.
- (void)mouseDown:(NSEvent*)theEvent {
- const NSPoint locationInWindow = [theEvent locationInWindow];
- const NSPoint location = [self convertPoint:locationInWindow fromView:nil];
+ const NSPoint location =
+ [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ const NSRect bounds([self bounds]);
AutocompleteTextFieldCell* cell = [self autocompleteTextFieldCell];
- const NSRect textFrame([cell textFrameForFrame:[self bounds]]);
+ const NSRect textFrame([cell textFrameForFrame:bounds]);
// A version of the textFrame which extends across the field's
// entire width.
- const NSRect bounds([self bounds]);
+
const NSRect fullFrame(NSMakeRect(bounds.origin.x, textFrame.origin.y,
bounds.size.width, textFrame.size.height));
@@ -88,8 +89,9 @@
// above/below test is needed because NSTextView treats mouse events
// above/below as select-to-end-in-that-direction, which makes
// things janky.
- if (NSMouseInRect(location, textFrame, [self isFlipped]) ||
- !NSMouseInRect(location, fullFrame, [self isFlipped])) {
+ BOOL flipped = [self isFlipped];
+ if (NSMouseInRect(location, textFrame, flipped) ||
+ !NSMouseInRect(location, fullFrame, flipped)) {
[super mouseDown:theEvent];
// After the event has been handled, if the current event is a
@@ -114,19 +116,19 @@
// If the user clicked the security hint icon in the cell, display the page
// info window.
- const NSRect hintIconFrame = [cell securityImageFrameForFrame:[self bounds]];
- if (NSMouseInRect(location, hintIconFrame, [self isFlipped])) {
+ const NSRect hintIconFrame = [cell securityImageFrameForFrame:bounds];
+ if (NSMouseInRect(location, hintIconFrame, flipped)) {
[cell onSecurityIconMousePressed];
return;
}
- // If the user clicked a Page Action icon, execute its action.
- const NSRect iconFrame([self bounds]);
+ const BOOL ctrlKey = ([theEvent modifierFlags] & NSControlKeyMask) != 0;
+ NSLog(@"Control key pressed? => %d", ctrlKey);
+ // If the user left-clicked a Page Action icon, execute its action.
const size_t pageActionCount = [cell pageActionCount];
for (size_t i = 0; i < pageActionCount; ++i) {
- NSRect pageActionFrame = [cell pageActionFrameForIndex:i inFrame:iconFrame];
- if (NSMouseInRect(location, pageActionFrame, [self isFlipped])) {
- // TODO(pamg): Do we need to send the event?
+ NSRect pageActionFrame = [cell pageActionFrameForIndex:i inFrame:bounds];
+ if (NSMouseInRect(location, pageActionFrame, flipped) && !ctrlKey) {
[cell onPageActionMousePressedIn:pageActionFrame forIndex:i];
return;
}
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698