]> khamidou — GitHub mirrors - electron.git/commitdiff
Do not manually convert Object to WebInputEvent
authorCheng Zhao <zcbenz@gmail.com>
Fri, 18 Sep 2015 06:09:31 +0000 (14:09 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 18 Sep 2015 06:09:31 +0000 (14:09 +0800)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/common/event_types.cc [deleted file]
atom/common/event_types.h [deleted file]
atom/common/native_mate_converters/blink_converter.cc
atom/common/native_mate_converters/blink_converter.h
atom/common/options_switches.cc
atom/common/options_switches.h
filenames.gypi

index b8d2c463eb4c1afbdbd95d496f6e8b6c57e0ef5f..a2851415d198beecd472c5e1cc4ec91ff6b9da4b 100644 (file)
@@ -9,16 +9,18 @@
 #include "atom/browser/browser.h"
 #include "atom/browser/native_window.h"
 #include "atom/common/node_includes.h"
-#include "atom/common/event_types.h"
+#include "atom/common/native_mate_converters/blink_converter.h"
 #include "atom/common/native_mate_converters/callback.h"
 #include "atom/common/native_mate_converters/gfx_converter.h"
 #include "atom/common/native_mate_converters/gurl_converter.h"
 #include "atom/common/native_mate_converters/image_converter.h"
 #include "atom/common/native_mate_converters/string16_converter.h"
 #include "atom/common/options_switches.h"
+#include "content/public/browser/native_web_keyboard_event.h"
 #include "content/public/browser/render_process_host.h"
 #include "native_mate/constructor.h"
 #include "native_mate/dictionary.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
 #include "ui/gfx/geometry/rect.h"
 
 #if defined(OS_WIN)
@@ -462,14 +464,6 @@ void Window::CapturePage(mate::Arguments* args) {
       rect, base::Bind(&OnCapturePageDone, args->isolate(), callback));
 }
 
-void Window::BeginFrameSubscription() {
-  window_->SetFrameSubscription(true);
-}
-
-void Window::EndFrameSubscription() {
-  window_->SetFrameSubscription(false);
-}
-
 void Window::SetProgressBar(double progress) {
   window_->SetProgressBar(progress);
 }
@@ -546,125 +540,39 @@ bool Window::IsVisibleOnAllWorkspaces() {
   return window_->IsVisibleOnAllWorkspaces();
 }
 
-void Window::SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& data){
-  auto type = blink::WebInputEvent::Type::Char;
-  int modifiers = 0;
-  int keycode = 0;
-  int native = 0;
-  std::string type_str = "";
-  mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
-
-  data.Get(switches::kEventType, &type_str);
-  data.Get(switches::kModifiers, &modifier_list);
-  data.Get(switches::kKeyCode, &keycode);
-  data.Get(switches::kNativeKeyCode, &native);
-
-  if(type_str.compare(event_types::kKeyDown) == 0){
-    type = blink::WebInputEvent::Type::KeyDown;
-  }else if(type_str.compare(event_types::kKeyUp) == 0){
-    type = blink::WebInputEvent::Type::KeyUp;
-  }else if(type_str.compare(event_types::kChar) == 0){
-    type = blink::WebInputEvent::Type::Char;
-  }
-
-  std::map<std::string, bool> modifier_types;
-  modifier_types[event_types::kModifierIsKeyPad] = false;
-  modifier_types[event_types::kModifierIsAutoRepeat] = false;
-  modifier_types[event_types::kModifierIsLeft] = false;
-  modifier_types[event_types::kModifierIsRight] = false;
-  modifier_types[event_types::kModifierShiftKey] = false;
-  modifier_types[event_types::kModifierControlKey] = false;
-  modifier_types[event_types::kModifierAltKey] = false;
-  modifier_types[event_types::kModifierMetaKey] = false;
-  modifier_types[event_types::kModifierCapsLockOn] = false;
-  modifier_types[event_types::kModifierNumLockOn] = false;
-
-  for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
-    modifier_list.Get(it->first,&(it->second));
-
-    if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
-  }
-
-  window_->SendKeyboardEvent(type, modifiers, keycode, native);
-}
-
-void Window::SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data){
-  int x, y, movementX, movementY, clickCount;
-  std::string type_str = "";
-  std::string button_str = "";
-  mate::Dictionary modifier_list = mate::Dictionary::CreateEmpty(isolate);
-
-  blink::WebInputEvent::Type type = blink::WebInputEvent::Type::MouseMove;
-  blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::ButtonNone;
-  int modifiers = 0;
-
-  data.Get(switches::kEventType, &type_str);
-  data.Get(switches::kMouseEventButton, &button_str);
-  data.Get(switches::kModifiers, &modifier_list);
-
-  if(type_str.compare(event_types::kMouseDown) == 0){
-    type = blink::WebInputEvent::Type::MouseDown;
-  }else if(type_str.compare(event_types::kMouseUp) == 0){
-    type = blink::WebInputEvent::Type::MouseUp;
-  }else if(type_str.compare(event_types::kMouseMove) == 0){
-    type = blink::WebInputEvent::Type::MouseMove;
-  }else if(type_str.compare(event_types::kMouseEnter) == 0){
-    type = blink::WebInputEvent::Type::MouseEnter;
-  }else if(type_str.compare(event_types::kMouseLeave) == 0){
-    type = blink::WebInputEvent::Type::MouseLeave;
-  }else if(type_str.compare(event_types::kContextMenu) == 0){
-    type = blink::WebInputEvent::Type::ContextMenu;
-  }else if(type_str.compare(event_types::kMouseWheel) == 0){
-    type = blink::WebInputEvent::Type::MouseWheel;
-  }
-
-  std::map<std::string, bool> modifier_types;
-  modifier_types[event_types::kMouseLeftButton] = false;
-  modifier_types[event_types::kMouseRightButton] = false;
-  modifier_types[event_types::kMouseMiddleButton] = false;
-  modifier_types[event_types::kModifierLeftButtonDown] = false;
-  modifier_types[event_types::kModifierMiddleButtonDown] = false;
-  modifier_types[event_types::kModifierRightButtonDown] = false;
-  modifier_types[event_types::kModifierShiftKey] = false;
-  modifier_types[event_types::kModifierControlKey] = false;
-  modifier_types[event_types::kModifierAltKey] = false;
-  modifier_types[event_types::kModifierMetaKey] = false;
-  modifier_types[event_types::kModifierCapsLockOn] = false;
-  modifier_types[event_types::kModifierNumLockOn] = false;
-
-  for(std::map<std::string, bool>::iterator it = modifier_types.begin(); it != modifier_types.end(); ++it){
-    modifier_list.Get(it->first,&(it->second));
-
-    if(it->second) modifiers = modifiers & event_types::modifierStrToWebModifier(it->first);
+void Window::SendInputEvent(v8::Isolate* isolate,
+                            v8::Local<v8::Value> input_event) {
+  int type = mate::GetWebInputEventType(isolate, input_event);
+  if (blink::WebInputEvent::isMouseEventType(type)) {
+    blink::WebMouseEvent mouse_event;
+    if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
+      window_->SendInputEvent(mouse_event);
+      return;
+    }
+  } else if (blink::WebInputEvent::isKeyboardEventType(type)) {
+    content::NativeWebKeyboardEvent keyboard_event;;
+    if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
+      window_->SendInputEvent(keyboard_event);
+      return;
+    }
+  } else if (type == blink::WebInputEvent::MouseWheel) {
+    blink::WebMouseWheelEvent mouse_wheel_event;
+    if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
+      window_->SendInputEvent(mouse_wheel_event);
+      return;
+    }
   }
 
-  if(type == blink::WebInputEvent::Type::MouseWheel){
-    bool precise = true;
-
-    x = 0;
-    y = 0;
-    data.Get(switches::kX, &x);
-    data.Get(switches::kY, &y);
-    data.Get(switches::kMouseWheelPrecise, &precise);
-
-    window_->SendMouseWheelEvent(modifiers, x, y, precise);
-  }else{
-    if (data.Get(switches::kX, &x) && data.Get(switches::kY, &y)) {
-      if(!data.Get(switches::kMovementX, &movementX)){
-        movementX = 0;
-      }
-
-      if(!data.Get(switches::kMovementY, &movementY)){
-        movementY = 0;
-      }
+  isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
+      isolate, "Invalid event type")));
+}
 
-      if(!data.Get(switches::kClickCount, &clickCount)){
-        clickCount = 0;
-      }
+void Window::BeginFrameSubscription() {
+  window_->SetFrameSubscription(true);
+}
 
-      window_->SendMouseEvent(type, modifiers, button, x, y, movementX, movementY, clickCount);
-    }
-  }
+void Window::EndFrameSubscription() {
+  window_->SetFrameSubscription(false);
 }
 
 int32_t Window::ID() const {
@@ -751,8 +659,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
                  &Window::SetVisibleOnAllWorkspaces)
       .SetMethod("isVisibleOnAllWorkspaces",
                  &Window::IsVisibleOnAllWorkspaces)
-      .SetMethod("sendMouseEvent", &Window::SendMouseEvent)
-      .SetMethod("sendKeyboardEvent", &Window::SendKeyboardEvent)
+      .SetMethod("sendInputEvent", &Window::SendInputEvent)
       .SetMethod("beginFrameSubscription", &Window::BeginFrameSubscription)
       .SetMethod("endFrameSubscription", &Window::EndFrameSubscription)
 #if defined(OS_MACOSX)
index 6dfcbee8bc885fd24f5afb76b4ac410ba503b1be..507bbb43849cc90d6f10d9dad4e665258056d1c8 100644 (file)
@@ -142,8 +142,7 @@ class Window : public mate::TrackableObject<Window>,
   bool IsMenuBarVisible();
   void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
 
-  void SendKeyboardEvent(v8::Isolate* isolate, const mate::Dictionary& data);
-  void SendMouseEvent(v8::Isolate* isolate, const mate::Dictionary& data);
+  void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
   void BeginFrameSubscription();
   void EndFrameSubscription();
 
index 4a78ec85fe0970a690350cf719d63a2e6af47468..55fe206ff18fb2bcf98ba62899c4e1e38365c1b3 100644 (file)
@@ -8,10 +8,6 @@
 #include <utility>
 #include <vector>
 
-#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
-#include "content/public/browser/native_web_keyboard_event.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "media/base/video_frame.h"
 #include "media/base/yuv_convert.h"
 #include "atom/browser/atom_browser_context.h"
 #include "atom/browser/atom_browser_main_parts.h"
@@ -43,7 +39,6 @@
 #include "ui/gfx/geometry/size.h"
 #include "ui/gfx/screen.h"
 #include "ui/gl/gpu_switching_manager.h"
-#include "ui/events/event.h"
 
 using content::NavigationEntry;
 using content::RenderWidgetHostView;
@@ -312,6 +307,38 @@ void NativeWindow::SetFrameSubscription(bool isOffscreen) {
   }
 }
 
+void NativeWindow::SendInputEvent(const blink::WebMouseEvent& mouse_event) {
+  const auto view = web_contents()->GetRenderWidgetHostView();
+  if (!view)
+    return;
+  const auto host = view->GetRenderWidgetHost();
+  if (!host)
+    return;
+  host->ForwardMouseEvent(mouse_event);
+}
+
+void NativeWindow::SendInputEvent(
+    const blink::WebMouseWheelEvent& mouse_wheel_event) {
+  const auto view = web_contents()->GetRenderWidgetHostView();
+  if (!view)
+    return;
+  const auto host = view->GetRenderWidgetHost();
+  if (!host)
+    return;
+  host->ForwardWheelEvent(mouse_wheel_event);
+}
+
+void NativeWindow::SendInputEvent(
+    const content::NativeWebKeyboardEvent& keyboard_event) {
+  const auto view = web_contents()->GetRenderWidgetHostView();
+  if (!view)
+    return;
+  const auto host = view->GetRenderWidgetHost();
+  if (!host)
+    return;
+  host->ForwardKeyboardEvent(keyboard_event);
+}
+
 void NativeWindow::RequestToClosePage() {
   bool prevent_default = false;
   FOR_EACH_OBSERVER(NativeWindowObserver,
@@ -454,65 +481,6 @@ void NativeWindow::DevToolsClosed() {
   FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsClosed());
 }
 
-void NativeWindow::SendKeyboardEvent(blink::WebInputEvent::Type type, int modifiers, int keycode, int nativeKeycode){
-  auto keyb_event = new content::NativeWebKeyboardEvent;
-
-  keyb_event->nativeKeyCode = nativeKeycode;
-  keyb_event->windowsKeyCode = keycode;
-  keyb_event->setKeyIdentifierFromWindowsKeyCode();
-  keyb_event->type = type;
-  keyb_event->modifiers = modifiers;
-  keyb_event->isSystemKey = false;
-  keyb_event->timeStampSeconds = base::Time::Now().ToDoubleT();
-  keyb_event->skip_in_browser = false;
-
-  if (type == blink::WebInputEvent::Char || type == blink::WebInputEvent::RawKeyDown) {
-    keyb_event->text[0] = keycode;
-    keyb_event->unmodifiedText[0] = keycode;
-  }
-
-  const auto view = web_contents()->GetRenderWidgetHostView();
-  const auto host = view ? view->GetRenderWidgetHost() : nullptr;
-
-  host->ForwardKeyboardEvent(*keyb_event);
-}
-
-void NativeWindow::SendMouseEvent(blink::WebInputEvent::Type type, int modifiers, blink::WebMouseEvent::Button button, int x, int y, int movementX, int movementY, int clickCount){
-  auto mouse_event = new blink::WebMouseEvent();
-
-  mouse_event->x = x;
-  mouse_event->y = y;
-  mouse_event->windowX = x;
-  mouse_event->windowY = y;
-  mouse_event->clickCount = clickCount;
-  mouse_event->type = type;
-  mouse_event->modifiers = modifiers;
-  mouse_event->button = button;
-
-  mouse_event->timeStampSeconds = base::Time::Now().ToDoubleT();
-
-  const auto view = web_contents()->GetRenderWidgetHostView();
-  const auto host = view ? view->GetRenderWidgetHost() : nullptr;
-  host->ForwardMouseEvent(*mouse_event);
-}
-
-void NativeWindow::SendMouseWheelEvent(int modifiers, int x, int y, bool precise){
-  auto wheel_event = new blink::WebMouseWheelEvent();
-
-  wheel_event->type = blink::WebInputEvent::MouseWheel;
-  wheel_event->deltaX = x;
-  wheel_event->deltaY = y;
-  if(x) wheel_event->wheelTicksX = x > 0.0f ? 1.0f : -1.0f;
-  if(y) wheel_event->wheelTicksY = y > 0.0f ? 1.0f : -1.0f;
-  wheel_event->modifiers = modifiers;
-  wheel_event->hasPreciseScrollingDeltas = precise;
-  wheel_event->canScroll = true;
-
-  const auto view = web_contents()->GetRenderWidgetHostView();
-  const auto host = view ? view->GetRenderWidgetHost() : nullptr;
-  host->ForwardWheelEvent(*wheel_event);
-}
-
 void NativeWindow::RenderViewCreated(
     content::RenderViewHost* render_view_host) {
   if (!transparent_)
index 5784743af86aeb9f415f99dac77394277d80816e..1eabd5e693d16d4be7c63c9a07253a70ab2cf1fe 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "media/base/video_frame.h"
 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
-#include "content/public/browser/native_web_keyboard_event.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
 #include "atom/browser/native_window_observer.h"
 #include "atom/browser/ui/accelerator_util.h"
 #include "base/cancelable_callback.h"
 
 class SkRegion;
 
+namespace blink {
+class WebMouseEvent;
+class WebMouseWheelEvent;
+}
+
 namespace brightray {
 class InspectableWebContents;
 }
@@ -173,6 +176,14 @@ class NativeWindow : public content::WebContentsObserver,
   gfx::Size GetAspectRatioExtraSize();
   void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
 
+  // Subscribe to the frame updates.
+  void SetFrameSubscription(bool isOffscreen);
+
+  // Send the WebInputEvent to the page.
+  void SendInputEvent(const blink::WebMouseEvent& mouse_event);
+  void SendInputEvent(const blink::WebMouseWheelEvent& mouse_wheel_event);
+  void SendInputEvent(const content::NativeWebKeyboardEvent& keyboard_event);
+
   base::WeakPtr<NativeWindow> GetWeakPtr() {
     return weak_factory_.GetWeakPtr();
   }
@@ -229,12 +240,6 @@ class NativeWindow : public content::WebContentsObserver,
 
   void OnFrameReceived(bool result, scoped_refptr<media::VideoFrame> frame);
 
-  void SendKeyboardEvent(blink::WebInputEvent::Type type, int modifiers, int keycode, int nativeKeycode);
-  void SendMouseEvent(blink::WebInputEvent::Type type, int modifiers, blink::WebMouseEvent::Button button, int x, int y, int movementX, int movementY, int clickCount);
-  void SendMouseWheelEvent(int modifiers, int x, int y, bool clickCount);
-
-  void SetFrameSubscription(bool isOffscreen);
-
  protected:
   NativeWindow(brightray::InspectableWebContents* inspectable_web_contents,
                const mate::Dictionary& options);
diff --git a/atom/common/event_types.cc b/atom/common/event_types.cc
deleted file mode 100644 (file)
index be08481..0000000
+++ /dev/null
@@ -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
diff --git a/atom/common/event_types.h b/atom/common/event_types.h
deleted file mode 100644 (file)
index d4769db..0000000
+++ /dev/null
@@ -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_
index afafa10b11d339b2965c96a37420319f2f0de157..a406059cf6295bab88429d69b57e7e1836b49836 100644 (file)
@@ -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) {
index fd631983d4327d318c48c9804cf38e20044c971c..17bb108d349e9a5ef9b4b4117a4fc94162099351 100644 (file)
@@ -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,
index 2268a4039513d702b77ace3765587afc51d72cfe..c70e1ba4afa6e362ca9605a5bae9feb01e62ef0e 100644 (file)
@@ -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
index eb7842e787691977a273eb914752b1b0cca72ad0..e62f3116661aaba12a60cca1a3255e2120da0c6c 100644 (file)
@@ -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
index acdea0c25e0a73992793b3ab5ad5f066aa22e202..f25ec4a8a587e5de7722a6b6c8713dabdd05d9c4 100644 (file)
       'atom/common/node_includes.h',
       'atom/common/options_switches.cc',
       'atom/common/options_switches.h',
-      'atom/common/event_types.cc',
-      'atom/common/event_types.h',
       'atom/common/platform_util.h',
       'atom/common/platform_util_linux.cc',
       'atom/common/platform_util_mac.mm',