Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/strings/sys_string_conversions.h" | |
| 6 #include "content/browser/devtools/protocol/native_input_event_builder.h" | |
| 7 #include "third_party/WebKit/public/platform/WebInputEvent.h" | |
| 8 #include <Cocoa/Cocoa.h> | |
| 9 | |
| 10 namespace content { | |
| 11 namespace protocol { | |
| 12 | |
| 13 // Mac requires a native event to emulate key events. This method gives | |
| 14 // only crude capabilities (see: crbug.com/667387). | |
| 15 gfx::NativeEvent NativeInputEventBuilder::Build( | |
| 16 const NativeWebKeyboardEvent& event) { | |
| 17 NSEventType type = NSKeyUp; | |
| 18 if (event.type() == blink::WebInputEvent::RawKeyDown || | |
| 19 event.type() == blink::WebInputEvent::KeyDown) | |
| 20 type = NSKeyUp; | |
|
pfeldman
2017/02/10 22:59:08
NSKeyDown
allada
2017/02/14 02:48:06
Done.
| |
| 21 NSString* character = base::SysUTF16ToNSString(base::string16(&event.text[0], | |
| 22 NativeWebKeyboardEvent::textLengthCap)); | |
|
pfeldman
2017/02/10 22:59:08
This will force it to be NativeWebKeyboardEvent::t
allada
2017/02/14 02:48:06
Done.
| |
| 23 int modifiers = event.modifiers(); | |
| 24 NSUInteger flags = | |
| 25 (modifiers & blink::WebInputEvent::ShiftKey ? NSShiftKeyMask : 0) | | |
| 26 (modifiers & blink::WebInputEvent::ControlKey ? NSControlKeyMask : 0) | | |
| 27 (modifiers & blink::WebInputEvent::AltKey ? NSAlternateKeyMask : 0) | | |
| 28 (modifiers & blink::WebInputEvent::MetaKey ? NSCommandKeyMask : 0); | |
| 29 | |
| 30 return [[NSEvent keyEventWithType:type | |
| 31 location:NSZeroPoint | |
| 32 modifierFlags:flags | |
| 33 timestamp:0 | |
|
pfeldman
2017/02/10 22:59:08
There is still no timestamp.
allada
2017/02/14 02:48:06
no change per our offline talk.
| |
| 34 windowNumber:0 | |
| 35 context:nil | |
| 36 characters:character | |
| 37 charactersIgnoringModifiers:character | |
| 38 isARepeat:NO | |
| 39 keyCode:event.nativeKeyCode] retain]; | |
| 40 }; | |
| 41 | |
| 42 } // namespace protocol | |
| 43 } // namespace content | |
| OLD | NEW |