Add ToV8 converter for NativeWebKeyboardEvent
This commit is contained in:
parent
3237c6751a
commit
7842040d9d
3 changed files with 27 additions and 20 deletions
|
@ -493,27 +493,11 @@ bool WebContents::PreHandleKeyboardEvent(
|
|||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
const char* type =
|
||||
event.type == blink::WebInputEvent::Type::RawKeyDown ? "keyDown" :
|
||||
event.type == blink::WebInputEvent::Type::KeyUp ? "keyUp" :
|
||||
nullptr;
|
||||
DCHECK(type);
|
||||
if (!type) {
|
||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
||||
return Emit("before-input-event", event);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate());
|
||||
dict.Set("type", type);
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(event.domKey));
|
||||
|
||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||
dict.Set("isAutoRepeat", (event.modifiers & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (event.modifiers & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (event.modifiers & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (event.modifiers & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (event.modifiers & Modifiers::MetaKey) != 0);
|
||||
|
||||
return Emit("before-input-event", dict);
|
||||
}
|
||||
|
||||
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue