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

Side by Side Diff: Source/web/WebInputEventFactoryMac.mm

Issue 788173002: Should set the modifiers for web mouse event on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed Created 6 years 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 | « no previous file | 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 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2006-2009 Google Inc. 3 * Copyright (C) 2006-2009 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 if ([event modifierFlags] & NSControlKeyMask) 715 if ([event modifierFlags] & NSControlKeyMask)
716 modifiers |= WebInputEvent::ControlKey; 716 modifiers |= WebInputEvent::ControlKey;
717 if ([event modifierFlags] & NSShiftKeyMask) 717 if ([event modifierFlags] & NSShiftKeyMask)
718 modifiers |= WebInputEvent::ShiftKey; 718 modifiers |= WebInputEvent::ShiftKey;
719 if ([event modifierFlags] & NSAlternateKeyMask) 719 if ([event modifierFlags] & NSAlternateKeyMask)
720 modifiers |= WebInputEvent::AltKey; 720 modifiers |= WebInputEvent::AltKey;
721 if ([event modifierFlags] & NSCommandKeyMask) 721 if ([event modifierFlags] & NSCommandKeyMask)
722 modifiers |= WebInputEvent::MetaKey; 722 modifiers |= WebInputEvent::MetaKey;
723 if ([event modifierFlags] & NSAlphaShiftKeyMask) 723 if ([event modifierFlags] & NSAlphaShiftKeyMask)
724 modifiers |= WebInputEvent::CapsLockOn; 724 modifiers |= WebInputEvent::CapsLockOn;
725 // TODO(port): Set mouse button states 725
726 // The return value of 1 << 0 corresponds to the left mouse button,
727 // 1 << 1 corresponds to the right mouse button,
728 // 1 << n, n >= 2 correspond to other mouse buttons.
729 NSUInteger pressedButtons = [NSEvent pressedMouseButtons];
730
731 if (pressedButtons & (1 << 0))
732 modifiers |= WebInputEvent::LeftButtonDown;
733 if (pressedButtons & (1 << 1))
734 modifiers |= WebInputEvent::RightButtonDown;
735 if (pressedButtons & (1 << 2))
736 modifiers |= WebInputEvent::MiddleButtonDown;
726 737
727 return modifiers; 738 return modifiers;
728 } 739 }
729 740
730 static inline void setWebEventLocationFromEventInView(WebMouseEvent* result, 741 static inline void setWebEventLocationFromEventInView(WebMouseEvent* result,
731 NSEvent* event, 742 NSEvent* event,
732 NSView* view) { 743 NSView* view) {
733 NSPoint windowLocal = [event locationInWindow]; 744 NSPoint windowLocal = [event locationInWindow];
734 745
735 NSPoint screenLocal = [[view window] convertBaseToScreen:windowLocal]; 746 NSPoint screenLocal = [[view window] convertBaseToScreen:windowLocal];
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 break; 1151 break;
1141 default: 1152 default:
1142 ASSERT_NOT_REACHED(); 1153 ASSERT_NOT_REACHED();
1143 result.type = WebInputEvent::Undefined; 1154 result.type = WebInputEvent::Undefined;
1144 } 1155 }
1145 1156
1146 return result; 1157 return result;
1147 } 1158 }
1148 1159
1149 } // namespace blink 1160 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698