Do not manually convert Object to WebInputEvent
This commit is contained in:
parent
5a599cb6ff
commit
c550546ff1
11 changed files with 90 additions and 396 deletions
|
@ -1,118 +0,0 @@
|
|||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/event_types.h"
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace event_types {
|
||||
|
||||
const char kMouseDown[] = "down";
|
||||
const char kMouseUp[] = "up";
|
||||
const char kMouseMove[] = "move";
|
||||
const char kMouseEnter[] = "enter";
|
||||
const char kMouseLeave[] = "leave";
|
||||
const char kContextMenu[] = "context-menu";
|
||||
const char kMouseWheel[] = "wheel";
|
||||
|
||||
const char kKeyDown[] = "down";
|
||||
const char kKeyUp[] = "up";
|
||||
const char kChar[] = "char";
|
||||
|
||||
const char kMouseLeftButton[] = "left";
|
||||
const char kMouseRightButton[] = "right";
|
||||
const char kMouseMiddleButton[] = "middle";
|
||||
|
||||
const char kModifierLeftButtonDown[] = "left-button-down";
|
||||
const char kModifierMiddleButtonDown[] = "middle-button-down";
|
||||
const char kModifierRightButtonDown[] = "right-button-down";
|
||||
|
||||
const char kModifierShiftKey[] = "shift";
|
||||
const char kModifierControlKey[] = "control";
|
||||
const char kModifierAltKey[] = "alt";
|
||||
const char kModifierMetaKey[] = "meta";
|
||||
const char kModifierCapsLockOn[] = "caps-lock";
|
||||
const char kModifierNumLockOn[] = "num-lock";
|
||||
|
||||
const char kModifierIsKeyPad[] = "keypad";
|
||||
const char kModifierIsAutoRepeat[] = "auto-repeat";
|
||||
const char kModifierIsLeft[] = "left";
|
||||
const char kModifierIsRight[] = "right";
|
||||
|
||||
int modifierStrToWebModifier(std::string modifier){
|
||||
if(modifier.compare(event_types::kModifierLeftButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierMiddleButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierRightButtonDown) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseLeftButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::LeftButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseRightButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::RightButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kMouseMiddleButton) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MiddleButtonDown;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsKeyPad) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsKeyPad;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsAutoRepeat) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsAutoRepeat;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsLeft) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsLeft;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierIsRight) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::IsRight;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierShiftKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::ShiftKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierControlKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::ControlKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierAltKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::AltKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierMetaKey) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::MetaKey;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierCapsLockOn) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::CapsLockOn;
|
||||
|
||||
}else if(modifier.compare(event_types::kModifierNumLockOn) == 0){
|
||||
|
||||
return blink::WebInputEvent::Modifiers::NumLockOn;
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace event_types
|
||||
|
||||
} // namespace atom
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) 2013 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_EVENT_TYPES_H_
|
||||
#define ATOM_COMMON_EVENT_TYPES_H_
|
||||
|
||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace event_types {
|
||||
|
||||
extern const char kMouseDown[];
|
||||
extern const char kMouseUp[];
|
||||
extern const char kMouseMove[];
|
||||
extern const char kMouseEnter[];
|
||||
extern const char kMouseLeave[];
|
||||
extern const char kContextMenu[];
|
||||
extern const char kMouseWheel[];
|
||||
|
||||
extern const char kKeyDown[];
|
||||
extern const char kKeyUp[];
|
||||
extern const char kChar[];
|
||||
|
||||
extern const char kMouseLeftButton[];
|
||||
extern const char kMouseRightButton[];
|
||||
extern const char kMouseMiddleButton[];
|
||||
|
||||
extern const char kModifierLeftButtonDown[];
|
||||
extern const char kModifierMiddleButtonDown[];
|
||||
extern const char kModifierRightButtonDown[];
|
||||
|
||||
extern const char kModifierShiftKey[];
|
||||
extern const char kModifierControlKey[];
|
||||
extern const char kModifierAltKey[];
|
||||
extern const char kModifierMetaKey[];
|
||||
extern const char kModifierCapsLockOn[];
|
||||
extern const char kModifierNumLockOn[];
|
||||
|
||||
extern const char kModifierIsKeyPad[];
|
||||
extern const char kModifierIsAutoRepeat[];
|
||||
extern const char kModifierIsLeft[];
|
||||
extern const char kModifierIsRight[];
|
||||
|
||||
int modifierStrToWebModifier(std::string modifier);
|
||||
|
||||
} // namespace event_types
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_EVENT_TYPES_H_
|
|
@ -112,6 +112,13 @@ struct Converter<blink::WebInputEvent::Modifiers> {
|
|||
}
|
||||
};
|
||||
|
||||
int GetWebInputEventType(v8::Isolate* isolate, v8::Local<v8::Value> val) {
|
||||
int type = -1;
|
||||
mate::Dictionary dict;
|
||||
ConvertFromV8(isolate, val, &dict) && dict.Get("type", &type);
|
||||
return type;
|
||||
}
|
||||
|
||||
bool Converter<blink::WebInputEvent>::FromV8(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
blink::WebInputEvent* out) {
|
||||
|
|
|
@ -24,6 +24,8 @@ struct NativeWebKeyboardEvent;
|
|||
|
||||
namespace mate {
|
||||
|
||||
int GetWebInputEventType(v8::Isolate* isolate, v8::Local<v8::Value> val);
|
||||
|
||||
template<>
|
||||
struct Converter<blink::WebInputEvent> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
|
|
|
@ -116,17 +116,6 @@ const char kRegisterStandardSchemes[] = "register-standard-schemes";
|
|||
// The browser process app model ID
|
||||
const char kAppUserModelId[] = "app-user-model-id";
|
||||
|
||||
const char kModifiers[] = "modifiers";
|
||||
const char kKeyCode[] = "code";
|
||||
const char kNativeKeyCode[] = "native";
|
||||
|
||||
const char kMovementX[] = "movement-x";
|
||||
const char kMovementY[] = "movement-y";
|
||||
const char kClickCount[] = "click-count";
|
||||
const char kEventType[] = "type";
|
||||
const char kMouseEventButton[] = "button";
|
||||
const char kMouseWheelPrecise[] = "precise";
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -62,17 +62,6 @@ extern const char kRegisterStandardSchemes[];
|
|||
|
||||
extern const char kAppUserModelId[];
|
||||
|
||||
extern const char kModifiers[];
|
||||
extern const char kKeyCode[];
|
||||
extern const char kNativeKeyCode[];
|
||||
|
||||
extern const char kMovementX[];
|
||||
extern const char kMovementY[];
|
||||
extern const char kClickCount[];
|
||||
extern const char kEventType[];
|
||||
extern const char kMouseEventButton[];
|
||||
extern const char kMouseWheelPrecise[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace atom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue