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

Side by Side Diff: ui/events/cocoa/events_mac.mm

Issue 1331013004: [KeyEvent Mac] Move WebInputEventFactory into chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove forward declare as the bot got updated Created 5 years, 3 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 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 #include "ui/events/event_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/mac_util.h" 10 #import "base/mac/mac_util.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) { 227 uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) {
228 return static_cast<uint32>(KeyboardCodeFromNSEvent(native_event)); 228 return static_cast<uint32>(KeyboardCodeFromNSEvent(native_event));
229 } 229 }
230 230
231 uint16 TextFromNative(const base::NativeEvent& native_event) { 231 uint16 TextFromNative(const base::NativeEvent& native_event) {
232 NSString* text = @""; 232 NSString* text = @"";
233 if ([native_event type] != NSFlagsChanged) 233 if ([native_event type] != NSFlagsChanged)
234 text = [native_event characters]; 234 text = [native_event characters];
235 235
236 // These exceptions are based on WebInputEventFactoryMac.mm: 236 // These exceptions are based on web_input_event_builders_mac.mm:
237 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); 237 uint32 windows_keycode = WindowsKeycodeFromNative(native_event);
238 if (windows_keycode == '\r') 238 if (windows_keycode == '\r')
239 text = @"\r"; 239 text = @"\r";
240 if ([text isEqualToString:@"\x7F"]) 240 if ([text isEqualToString:@"\x7F"])
241 text = @"\x8"; 241 text = @"\x8";
242 if (windows_keycode == 9) 242 if (windows_keycode == 9)
243 text = @"\x9"; 243 text = @"\x9";
244 244
245 uint16 return_value; 245 uint16 return_value;
246 [text getCharacters:&return_value]; 246 [text getCharacters:&return_value];
247 return return_value; 247 return return_value;
248 } 248 }
249 249
250 uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) { 250 uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) {
251 NSString* text = @""; 251 NSString* text = @"";
252 if ([native_event type] != NSFlagsChanged) 252 if ([native_event type] != NSFlagsChanged)
253 text = [native_event charactersIgnoringModifiers]; 253 text = [native_event charactersIgnoringModifiers];
254 254
255 // These exceptions are based on WebInputEventFactoryMac.mm: 255 // These exceptions are based on web_input_event_builders_mac.mm:
256 uint32 windows_keycode = WindowsKeycodeFromNative(native_event); 256 uint32 windows_keycode = WindowsKeycodeFromNative(native_event);
257 if (windows_keycode == '\r') 257 if (windows_keycode == '\r')
258 text = @"\r"; 258 text = @"\r";
259 if ([text isEqualToString:@"\x7F"]) 259 if ([text isEqualToString:@"\x7F"])
260 text = @"\x8"; 260 text = @"\x8";
261 if (windows_keycode == 9) 261 if (windows_keycode == 9)
262 text = @"\x9"; 262 text = @"\x9";
263 263
264 uint16 return_value; 264 uint16 return_value;
265 [text getCharacters:&return_value]; 265 [text getCharacters:&return_value];
266 return return_value; 266 return return_value;
267 } 267 }
268 268
269 bool IsCharFromNative(const base::NativeEvent& native_event) { 269 bool IsCharFromNative(const base::NativeEvent& native_event) {
270 return false; 270 return false;
271 } 271 }
272 272
273 } // namespace ui 273 } // namespace ui
OLDNEW
« no previous file with comments | « tools/copyright_scanner/third_party_files_whitelist.txt ('k') | ui/events/keycodes/keyboard_code_conversion_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698