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

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

Issue 184983003: Update WebInputEventFactory on Mac for pinch gesture support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0] ) : 0; 359 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0] ) : 0;
360 if (code) 360 if (code)
361 return code; 361 return code;
362 } 362 }
363 363
364 // Map Mac virtual key code directly to Windows one for any keys not handled above. 364 // Map Mac virtual key code directly to Windows one for any keys not handled above.
365 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboar d ('A') and on Russian keyboard (CYRILLIC LETTER EF). 365 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboar d ('A') and on Russian keyboard (CYRILLIC LETTER EF).
366 return windowsKeyCodeForKeyCode([event keyCode]); 366 return windowsKeyCodeForKeyCode([event keyCode]);
367 } 367 }
368 368
369 static WebInputEvent::Type gestureEventTypeForEvent(NSEvent *event)
370 {
371 switch ([event type]) {
372 case NSEventTypeBeginGesture:
373 return WebInputEvent::GestureScrollBegin;
374 case NSEventTypeEndGesture:
375 return WebInputEvent::GestureScrollEnd;
376 default:
377 ASSERT_NOT_REACHED();
378 return WebInputEvent::GestureScrollEnd;
379 }
380 }
381
382 static inline NSString* textFromEvent(NSEvent* event) 369 static inline NSString* textFromEvent(NSEvent* event)
383 { 370 {
384 if ([event type] == NSFlagsChanged) 371 if ([event type] == NSFlagsChanged)
385 return @""; 372 return @"";
386 return [event characters]; 373 return [event characters];
387 } 374 }
388 375
389 static inline NSString* unmodifiedTextFromEvent(NSEvent* event) 376 static inline NSString* unmodifiedTextFromEvent(NSEvent* event)
390 { 377 {
391 if ([event type] == NSFlagsChanged) 378 if ([event type] == NSFlagsChanged)
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1118
1132 // Use a temporary WebMouseEvent to get the location. 1119 // Use a temporary WebMouseEvent to get the location.
1133 WebMouseEvent temp; 1120 WebMouseEvent temp;
1134 1121
1135 setWebEventLocationFromEventInView(&temp, event, view); 1122 setWebEventLocationFromEventInView(&temp, event, view);
1136 result.x = temp.x; 1123 result.x = temp.x;
1137 result.y = temp.y; 1124 result.y = temp.y;
1138 result.globalX = temp.globalX; 1125 result.globalX = temp.globalX;
1139 result.globalY = temp.globalY; 1126 result.globalY = temp.globalY;
1140 1127
1141 result.type = gestureEventTypeForEvent(event);
1142 result.modifiers = modifiersFromEvent(event); 1128 result.modifiers = modifiersFromEvent(event);
1143 result.timeStampSeconds = [event timestamp]; 1129 result.timeStampSeconds = [event timestamp];
1144 1130
1131 // MacOS X gestures are used only for pinch support.
1132 result.sourceDevice = WebGestureEvent::Touchpad;
1133 switch ([event type]) {
1134 case NSEventTypeMagnify:
1135 result.type = WebInputEvent::GesturePinchUpdate;
1136 result.data.pinchUpdate.scale = [event magnification];
1137 break;
1138 default:
1139 ASSERT_NOT_REACHED();
1140 result.type = WebInputEvent::Undefined;
1141 }
1142
1145 return result; 1143 return result;
1146 } 1144 }
1147 1145
1148 } // namespace blink 1146 } // 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