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

Side by Side Diff: ui/views/test/event_generator_delegate_mac.mm

Issue 1559163002: Clean up event flags a bit: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 4 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield_unittest.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 7
8 #import "base/mac/scoped_nsobject.h" 8 #import "base/mac/scoped_nsobject.h"
9 #import "base/mac/scoped_objc_class_swizzler.h" 9 #import "base/mac/scoped_objc_class_swizzler.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 29 matching lines...) Expand all
40 // assume that the contentRect of |target| is at the top-left corner of the 40 // assume that the contentRect of |target| is at the top-left corner of the
41 // screen. 41 // screen.
42 NSRect content_rect = [target contentRectForFrameRect:[target frame]]; 42 NSRect content_rect = [target contentRectForFrameRect:[target frame]];
43 return NSMakePoint(point_in_root.x(), 43 return NSMakePoint(point_in_root.x(),
44 NSHeight(content_rect) - point_in_root.y()); 44 NSHeight(content_rect) - point_in_root.y());
45 } 45 }
46 46
47 // Inverse of ui::EventFlagsFromModifiers(). 47 // Inverse of ui::EventFlagsFromModifiers().
48 NSUInteger EventFlagsToModifiers(int flags) { 48 NSUInteger EventFlagsToModifiers(int flags) {
49 NSUInteger modifiers = 0; 49 NSUInteger modifiers = 0;
50 modifiers |= (flags & ui::EF_CAPS_LOCK_DOWN) ? NSAlphaShiftKeyMask : 0;
51 modifiers |= (flags & ui::EF_SHIFT_DOWN) ? NSShiftKeyMask : 0; 50 modifiers |= (flags & ui::EF_SHIFT_DOWN) ? NSShiftKeyMask : 0;
52 modifiers |= (flags & ui::EF_CONTROL_DOWN) ? NSControlKeyMask : 0; 51 modifiers |= (flags & ui::EF_CONTROL_DOWN) ? NSControlKeyMask : 0;
53 modifiers |= (flags & ui::EF_ALT_DOWN) ? NSAlternateKeyMask : 0; 52 modifiers |= (flags & ui::EF_ALT_DOWN) ? NSAlternateKeyMask : 0;
54 modifiers |= (flags & ui::EF_COMMAND_DOWN) ? NSCommandKeyMask : 0; 53 modifiers |= (flags & ui::EF_COMMAND_DOWN) ? NSCommandKeyMask : 0;
54 modifiers |= (flags & ui::EF_CAPS_LOCK_ON) ? NSAlphaShiftKeyMask : 0;
55 // ui::EF_*_MOUSE_BUTTON not handled here. 55 // ui::EF_*_MOUSE_BUTTON not handled here.
56 // NSFunctionKeyMask, NSNumericPadKeyMask and NSHelpKeyMask not mapped. 56 // NSFunctionKeyMask, NSNumericPadKeyMask and NSHelpKeyMask not mapped.
57 return modifiers; 57 return modifiers;
58 } 58 }
59 59
60 // Picks the corresponding mouse event type for the buttons set in |flags|. 60 // Picks the corresponding mouse event type for the buttons set in |flags|.
61 NSEventType PickMouseEventType(int flags, 61 NSEventType PickMouseEventType(int flags,
62 NSEventType left, 62 NSEventType left,
63 NSEventType right, 63 NSEventType right,
64 NSEventType other) { 64 NSEventType other) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 - (NSEvent*)currentEvent { 483 - (NSEvent*)currentEvent {
484 if (g_current_event) 484 if (g_current_event)
485 return g_current_event; 485 return g_current_event;
486 486
487 // Find the original implementation and invoke it. 487 // Find the original implementation and invoke it.
488 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod(); 488 IMP original = EventGeneratorDelegateMac::GetInstance()->CurrentEventMethod();
489 return original(self, _cmd); 489 return original(self, _cmd);
490 } 490 }
491 491
492 @end 492 @end
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698