Add a shim for GetCurrentEventButtonState
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 20:58:19 +0000 (20:58 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Dec 2010 20:58:19 +0000 (20:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=50583

Reviewed by Adam Roben.

* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::getCurrentEventButtonState):
Get the event button state from the plug-in.

(WebKit::PluginProcess::initializeShim):
Add new shim callback.

* PluginProcess/mac/PluginProcessShim.cpp:
(WebKit::shimGetCurrentEventButtonState):
Add shim.

* PluginProcess/mac/PluginProcessShim.h:
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::buttonState):
Return the button state.

(WebKit::NetscapePlugin::platformHandleMouseEvent):
Update the button state. Also, make sure to actually pass the modifiers to NPP_HandleEvent.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73391 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/PluginProcess/mac/PluginProcessMac.mm
WebKit2/PluginProcess/mac/PluginProcessShim.cpp
WebKit2/PluginProcess/mac/PluginProcessShim.h
WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm

index 3e4196c..0ae323b 100644 (file)
@@ -2,6 +2,34 @@
 
         Reviewed by Adam Roben.
 
+        Add a shim for GetCurrentEventButtonState
+        https://bugs.webkit.org/show_bug.cgi?id=50583
+
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::getCurrentEventButtonState):
+        Get the event button state from the plug-in.
+
+        (WebKit::PluginProcess::initializeShim):
+        Add new shim callback.
+
+        * PluginProcess/mac/PluginProcessShim.cpp:
+        (WebKit::shimGetCurrentEventButtonState):
+        Add shim.
+
+        * PluginProcess/mac/PluginProcessShim.h:
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::buttonState):
+        Return the button state.
+
+        (WebKit::NetscapePlugin::platformHandleMouseEvent):
+        Update the button state. Also, make sure to actually pass the modifiers to NPP_HandleEvent.
+        
+
+2010-12-06  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam Roben.
+
         Add a shim for IsWindowActive
         https://bugs.webkit.org/show_bug.cgi?id=50582
 
index 01f0fd4..ccf444c 100644 (file)
@@ -62,11 +62,22 @@ static bool isWindowActive(WindowRef windowRef, bool& result)
     return false;
 }
 
+static UInt32 getCurrentEventButtonState()
+{
+#ifndef NP_NO_CARBON
+    return NetscapePlugin::buttonState();
+#else
+    ASSERT_NOT_REACHED();
+    return 0;
+#endif
+}
+    
 void PluginProcess::initializeShim()
 {
     const PluginProcessShimCallbacks callbacks = {
         shouldCallRealDebugger,
         isWindowActive,
+        getCurrentEventButtonState
     };
 
     PluginProcessShimInitializeFunc initFunc = reinterpret_cast<PluginProcessShimInitializeFunc>(dlsym(RTLD_DEFAULT, "WebKitPluginProcessShimInitialize"));
index 13fb7ce..346ead9 100644 (file)
@@ -53,6 +53,11 @@ static void shimDebugger(void)
     Debugger();
 }
 
+static UInt32 shimGetCurrentEventButtonState()
+{
+    return pluginProcessShimCallbacks.getCurrentEventButtonState();
+}
+
 static Boolean shimIsWindowActive(WindowRef window)
 {
     bool result;
@@ -61,8 +66,9 @@ static Boolean shimIsWindowActive(WindowRef window)
     
     return IsWindowActive(window);
 }
-    
+
 DYLD_INTERPOSE(shimDebugger, Debugger);
+DYLD_INTERPOSE(shimGetCurrentEventButtonState, GetCurrentEventButtonState);
 DYLD_INTERPOSE(shimIsWindowActive, IsWindowActive);
     
 #endif
index 33ad443..0fbee23 100644 (file)
@@ -33,6 +33,7 @@ namespace WebKit {
 struct PluginProcessShimCallbacks {
     bool (*shouldCallRealDebugger)();
     bool (*isWindowActive)(WindowRef, bool& result);
+    UInt32 (*getCurrentEventButtonState)();
 };
 
 typedef void (*PluginProcessShimInitializeFunc)(const PluginProcessShimCallbacks&);
index e85660d..e6d4972 100644 (file)
@@ -61,7 +61,9 @@ public:
     bool isWindowActive() const { return m_isWindowActive; }
 
     static NetscapePlugin* netscapePluginFromWindow(WindowRef);
+    static unsigned buttonState();
 #endif
+
 #elif PLATFORM(WIN)
     HWND containingWindow() const;
 #endif
index 8caf77b..daf1d1f 100644 (file)
@@ -35,6 +35,9 @@ namespace WebKit {
 #ifndef NP_NO_CARBON
 static const double nullEventIntervalActive = 0.02;
 static const double nullEventIntervalNotActive = 0.25;
+
+static unsigned buttonStateFromLastMouseEvent;
+
 #endif
 
 NPError NetscapePlugin::setDrawingModel(NPDrawingModel drawingModel)
@@ -209,6 +212,11 @@ WindowRef NetscapePlugin::windowRef() const
     return reinterpret_cast<WindowRef>(m_npCGContext.window);
 }
 
+unsigned NetscapePlugin::buttonState()
+{
+    return buttonStateFromLastMouseEvent;
+}
+
 static inline EventRecord initializeEventRecord(EventKind eventKind)
 {
     EventRecord eventRecord;
@@ -402,9 +410,11 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
             switch (mouseEvent.type()) {
             case WebEvent::MouseDown:
                 eventKind = mouseDown;
+                buttonStateFromLastMouseEvent |= (1 << buttonNumber(mouseEvent.button()));
                 break;
             case WebEvent::MouseUp:
                 eventKind = mouseUp;
+                buttonStateFromLastMouseEvent &= ~(1 << buttonNumber(mouseEvent.button()));
                 break;
             case WebEvent::MouseMove:
                 eventKind = nullEvent;
@@ -414,8 +424,10 @@ bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
             }
 
             EventRecord event = initializeEventRecord(eventKind);
+            event.modifiers = modifiersForEvent(mouseEvent);
             event.where.h = mouseEvent.globalPosition().x();
             event.where.v = mouseEvent.globalPosition().y();
+
             return NPP_HandleEvent(&event);
         }
 #endif