[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 11:28:16 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6ba845ca2e0f2f4c085aba3eb8af50b64ad0fa52
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 19:41:59 2010 +0000

    Deliver mouse and wheel events to plug-ins
    https://bugs.webkit.org/show_bug.cgi?id=42988
    
    Reviewed by Sam Weinig.
    
    * Shared/WebEvent.h:
    (WebKit::WebMouseEvent::WebMouseEvent):
    (WebKit::WebMouseEvent::deltaX):
    (WebKit::WebMouseEvent::deltaY):
    (WebKit::WebMouseEvent::deltaZ):
    * Shared/mac/WebEventFactory.mm:
    (WebKit::WebEventFactory::createWebMouseEvent):
    Add deltaX, deltaY and deltaZ member variables to WebMosueEvent.
    
    * WebKit2.xcodeproj/project.pbxproj:
    Rename NetscapePluginMac.cpp to NetscapePluginMac.mm.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::NPP_HandleEvent):
    Add NPP_ wrapper.
    
    (WebKit::NetscapePlugin::handleMouseEvent):
    (WebKit::NetscapePlugin::handleWheelEvent):
    Call the platform variants.
    
    * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: Added.
    (WebKit::modifierFlags):
    (WebKit::buttonNumber):
    (WebKit::initializeMouseEvent):
    (WebKit::NetscapePlugin::platformHandleMouseEvent):
    Create an NPCocoaEvent and send it to the plug-in.
    
    (WebKit::NetscapePlugin::platformHandleWheelEvent):
    Ditto.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::handleEvent):
    Get the current WebEvent and send it to the plug-in if necessary.
    
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::currentEvent):
    (WebKit::CurrentEvent::CurrentEvent):
    (WebKit::CurrentEvent::~CurrentEvent):
    (WebKit::WebPage::mouseEvent):
    (WebKit::WebPage::wheelEvent):
    (WebKit::WebPage::keyEvent):
    * WebProcess/WebPage/WebPage.h:
    Add RAII object for keeping track of the current event.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64063 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index dc43224..c53e400 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -27,6 +27,57 @@
 
         Reviewed by Sam Weinig.
 
+        Deliver mouse and wheel events to plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=42988
+
+        * Shared/WebEvent.h:
+        (WebKit::WebMouseEvent::WebMouseEvent):
+        (WebKit::WebMouseEvent::deltaX):
+        (WebKit::WebMouseEvent::deltaY):
+        (WebKit::WebMouseEvent::deltaZ):
+        * Shared/mac/WebEventFactory.mm:
+        (WebKit::WebEventFactory::createWebMouseEvent):
+        Add deltaX, deltaY and deltaZ member variables to WebMosueEvent.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Rename NetscapePluginMac.cpp to NetscapePluginMac.mm.
+        
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NPP_HandleEvent):
+        Add NPP_ wrapper.
+
+        (WebKit::NetscapePlugin::handleMouseEvent):
+        (WebKit::NetscapePlugin::handleWheelEvent):
+        Call the platform variants.
+    
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: Added.
+        (WebKit::modifierFlags):        
+        (WebKit::buttonNumber):
+        (WebKit::initializeMouseEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseEvent):
+        Create an NPCocoaEvent and send it to the plug-in.
+        
+        (WebKit::NetscapePlugin::platformHandleWheelEvent):
+        Ditto.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::handleEvent):
+        Get the current WebEvent and send it to the plug-in if necessary.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::currentEvent):
+        (WebKit::CurrentEvent::CurrentEvent):
+        (WebKit::CurrentEvent::~CurrentEvent):
+        (WebKit::WebPage::mouseEvent):
+        (WebKit::WebPage::wheelEvent):
+        (WebKit::WebPage::keyEvent):
+        * WebProcess/WebPage/WebPage.h:
+        Add RAII object for keeping track of the current event.
+
+2010-07-26  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Clean up event handling functions
         https://bugs.webkit.org/show_bug.cgi?id=42977
 
diff --git a/WebKit2/Shared/WebEvent.h b/WebKit2/Shared/WebEvent.h
index 1e5d67c..5050eaf 100644
--- a/WebKit2/Shared/WebEvent.h
+++ b/WebKit2/Shared/WebEvent.h
@@ -120,13 +120,16 @@ public:
     {
     }
 
-    WebMouseEvent(Type type, Button button, int x, int y, int globalX, int globalY, int clickCount, Modifiers modifiers, double timestamp)
+    WebMouseEvent(Type type, Button button, int x, int y, int globalX, int globalY, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers modifiers, double timestamp)
         : WebEvent(type, modifiers, timestamp)
         , m_button(button)
         , m_positionX(x)
         , m_positionY(y)
         , m_globalPositionX(globalX)
         , m_globalPositionY(globalY)
+        , m_deltaX(deltaX)
+        , m_deltaY(deltaY)
+        , m_deltaZ(deltaZ)
         , m_clickCount(clickCount)
     {
         ASSERT(isMouseEventType(type));
@@ -137,6 +140,9 @@ public:
     int positionY() const { return m_positionY; }
     int globalPositionX() const { return m_globalPositionX; }
     int globalPositionY() const { return m_globalPositionY; }
+    float deltaX() const { return m_deltaX; }
+    float deltaY() const { return m_deltaY; }
+    float deltaZ() const { return m_deltaZ; }
     int clickCount() const { return m_clickCount; }
 
     void encode(CoreIPC::ArgumentEncoder& encoder) const
@@ -160,6 +166,9 @@ private:
     int m_positionY;
     int m_globalPositionX;
     int m_globalPositionY;
+    float m_deltaX;
+    float m_deltaY;
+    float m_deltaZ;
     int m_clickCount;
 };
 
diff --git a/WebKit2/Shared/mac/WebEventFactory.mm b/WebKit2/Shared/mac/WebEventFactory.mm
index 9ca488e..5dc594c 100644
--- a/WebKit2/Shared/mac/WebEventFactory.mm
+++ b/WebKit2/Shared/mac/WebEventFactory.mm
@@ -963,11 +963,14 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(NSEvent *event, NSView *windo
     int positionY                           = position.y;
     int globalPositionX                     = globalPosition.x;
     int globalPositionY                     = globalPosition.y;
+    float deltaX                            = [event deltaX];
+    float deltaY                            = [event deltaY];
+    float deltaZ                            = [event deltaZ];
     int clickCount                          = clickCountForEvent(event);
     WebEvent::Modifiers modifiers           = modifiersForEvent(event);
     double timestamp                        = [event timestamp];
 
-    return WebMouseEvent(type, button, positionX, positionY, globalPositionX, globalPositionY, clickCount, modifiers, timestamp);
+    return WebMouseEvent(type, button, positionX, positionY, globalPositionX, globalPositionY, deltaX, deltaY, deltaZ, clickCount, modifiers, timestamp);
 }
 
 WebWheelEvent WebEventFactory::createWebWheelEvent(NSEvent *event, NSView *windowView)
diff --git a/WebKit2/Shared/win/WebEventFactory.cpp b/WebKit2/Shared/win/WebEventFactory.cpp
index 2b6798a..02cc77c 100644
--- a/WebKit2/Shared/win/WebEventFactory.cpp
+++ b/WebKit2/Shared/win/WebEventFactory.cpp
@@ -403,7 +403,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(HWND hWnd, UINT message, WPAR
     int clickCount = WebKit::clickCount(type, button, positionX, positionY, timestamp);
     WebEvent::Modifiers modifiers = modifiersForEvent(wParam);
 
-    return WebMouseEvent(type, button, positionX, positionY, globalPositionX, globalPositionY, clickCount, modifiers, timestamp);
+    return WebMouseEvent(type, button, positionX, positionY, globalPositionX, globalPositionY, 0, 0, 0, clickCount, modifiers, timestamp);
 }
 
 WebWheelEvent WebEventFactory::createWebWheelEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index b0160b9..cde27ed 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -73,7 +73,7 @@
 		1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */; };
 		1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
 		1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE117F511DBB30900981615 /* ProcessLauncher.cpp */; };
-		1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */; };
+		1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */; };
 		1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */; };
 		1AEFCC1311D01F96008219D3 /* PluginInfoStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */; };
 		1AEFCCBD11D02C5E008219D3 /* PluginInfoStoreMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEFCCBC11D02C5E008219D3 /* PluginInfoStoreMac.mm */; };
@@ -358,7 +358,7 @@
 		1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginStream.cpp; sourceTree = "<group>"; };
 		1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
 		1AE117F511DBB30900981615 /* ProcessLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessLauncher.cpp; sourceTree = "<group>"; };
-		1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginMac.cpp; sourceTree = "<group>"; };
+		1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginMac.mm; sourceTree = "<group>"; };
 		1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; };
 		1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInfoStore.cpp; sourceTree = "<group>"; };
 		1AEFCCBC11D02C5E008219D3 /* PluginInfoStoreMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginInfoStoreMac.mm; sourceTree = "<group>"; };
@@ -708,7 +708,7 @@
 		1A6FBA0111E6812B00DB1371 /* mac */ = {
 			isa = PBXGroup;
 			children = (
-				1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.cpp */,
+				1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */,
 				1A6FBA0211E6813E00DB1371 /* NetscapePluginModuleMac.cpp */,
 			);
 			path = mac;
@@ -1401,7 +1401,7 @@
 				0F5265BC11DD37860006D33C /* LayerBackedDrawingAreaProxyMac.mm in Sources */,
 				1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */,
 				1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */,
-				1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.cpp in Sources */,
+				1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */,
 				1A6FB90C11E66FBC00DB1371 /* NetscapePluginModule.cpp in Sources */,
 				1A6FBA0311E6813E00DB1371 /* NetscapePluginModuleMac.cpp in Sources */,
 				1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */,
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
index 7fbd9d5..d9d663a 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
@@ -95,4 +95,14 @@ void DummyPlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
 {
 }
 
+bool DummyPlugin::handleMouseEvent(const WebMouseEvent&)
+{
+    return false;
+}
+
+bool DummyPlugin::handleWheelEvent(const WebWheelEvent&)
+{
+    return false;
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.h b/WebKit2/WebProcess/Plugins/DummyPlugin.h
index bb5a942..fb60057 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.h
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.h
@@ -54,7 +54,9 @@ private:
     virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
     virtual void streamDidFinishLoading(uint64_t streamID);
     virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
-
+    virtual bool handleMouseEvent(const WebMouseEvent&);
+    virtual bool handleWheelEvent(const WebWheelEvent&);
+    
     virtual PluginController* controller();
 };
 
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 6f78b66..8b24b9d 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -205,6 +205,11 @@ int32_t NetscapePlugin::NPP_Write(NPStream* stream, int32_t offset, int32_t len,
     return m_pluginModule->pluginFuncs().write(&m_npp, stream, offset, len, buffer);
 }
 
+int16_t NetscapePlugin::NPP_HandleEvent(void* event)
+{
+    return m_pluginModule->pluginFuncs().event(&m_npp, event);
+}
+
 void NetscapePlugin::NPP_URLNotify(const char* url, NPReason reason, void* notifyData)
 {
     m_pluginModule->pluginFuncs().urlnotify(&m_npp, url, reason, notifyData);
@@ -408,6 +413,16 @@ void NetscapePlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
         pluginStream->didFail(wasCancelled);
 }
 
+bool NetscapePlugin::handleMouseEvent(const WebMouseEvent& mouseEvent)
+{
+    return platformHandleMouseEvent(mouseEvent);
+}
+    
+bool NetscapePlugin::handleWheelEvent(const WebWheelEvent& wheelEvent)
+{
+    return platformHandleWheelEvent(wheelEvent);
+}
+
 PluginController* NetscapePlugin::controller()
 {
     return m_pluginController;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 5d13604..7dd52f5 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -74,9 +74,9 @@ public:
     NPError NPP_NewStream(NPMIMEType, NPStream*, NPBool seekable, uint16_t* stype);
     NPError NPP_DestroyStream(NPStream*, NPReason);
     void NPP_StreamAsFile(NPStream*, const char* filename);
-
     int32_t NPP_WriteReady(NPStream*);
     int32_t NPP_Write(NPStream*, int32_t offset, int32_t len, void* buffer);
+    int16_t NPP_HandleEvent(void* event);
     void NPP_URLNotify(const char* url, NPReason, void* notifyData);
     NPError NPP_GetValue(NPPVariable, void *value);
 
@@ -92,6 +92,9 @@ private:
     bool platformPostInitialize();
     void platformPaint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect);
 
+    bool platformHandleMouseEvent(const WebMouseEvent&);
+    bool platformHandleWheelEvent(const WebWheelEvent&);
+
     // Plugin
     virtual bool initialize(PluginController*, const Parameters&);
     virtual void destroy();
@@ -105,6 +108,8 @@ private:
     virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
     virtual void streamDidFinishLoading(uint64_t streamID);
     virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
+    virtual bool handleMouseEvent(const WebMouseEvent&);
+    virtual bool handleWheelEvent(const WebWheelEvent&);
 
     virtual PluginController* controller();
 
@@ -145,6 +150,17 @@ inline bool NetscapePlugin::platformPostInitialize()
 inline void NetscapePlugin::platformPaint(WebCore::GraphicsContext*, const WebCore::IntRect&)
 {
 }
+
+bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent&)
+{
+    return false;
+}
+
+bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent&)
+{
+    return false;
+}
+
 #endif
 
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp
deleted file mode 100644
index 9f95453..0000000
--- a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "NetscapePlugin.h"
-
-#include <WebCore/GraphicsContext.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-NPError NetscapePlugin::setDrawingModel(NPDrawingModel drawingModel)
-{
-    // The drawing model can only be set from NPP_New.
-    if (!m_inNPPNew)
-        return NPERR_GENERIC_ERROR;
-
-    switch (drawingModel) {
-#ifndef NP_NO_QUICKDRAW
-        case NPDrawingModelQuickDraw:
-#endif
-        case NPDrawingModelCoreGraphics:
-        case NPDrawingModelCoreAnimation:
-            m_drawingModel = drawingModel;
-            break;
-
-        default:
-            return NPERR_GENERIC_ERROR;
-    }
-
-    return NPERR_NO_ERROR;
-}
-    
-NPError NetscapePlugin::setEventModel(NPEventModel eventModel)
-{
-    // The event model can only be set from NPP_New.
-    if (!m_inNPPNew)
-        return NPERR_GENERIC_ERROR;
-
-    switch (eventModel) {
-#ifndef NP_NO_CARBON
-        case NPEventModelCarbon:
-#endif
-        case NPEventModelCocoa:
-            m_eventModel = eventModel;
-            break;
-
-        default:
-            return NPERR_GENERIC_ERROR;
-    }
-    
-    return NPERR_NO_ERROR;
-}
-
-bool NetscapePlugin::platformPostInitialize()
-{
-    if (m_drawingModel == static_cast<NPDrawingModel>(-1)) {
-#ifndef NP_NO_QUICKDRAW
-        // Default to QuickDraw if the plugin did not specify a drawing model.
-        m_drawingModel = NPDrawingModelQuickDraw;
-#else
-        // QuickDraw is not available, so we can't default to it. Instead, default to CoreGraphics.
-        m_drawingModel = NPDrawingModelCoreGraphics;
-#endif
-    }
-    
-    if (m_eventModel == static_cast<NPEventModel>(-1)) {
-        // If the plug-in did not specify a drawing model we default to Carbon when it is available.
-#ifndef NP_NO_CARBON
-        m_eventModel = NPEventModelCarbon;
-#else
-        m_eventModel = NPEventModelCocoa;
-#endif // NP_NO_CARBON
-    }
-
-#if !defined(NP_NO_CARBON) && !defined(NP_NO_QUICKDRAW)
-    // The CA drawing model does not work with the Carbon event model.
-    if (m_drawingModel == NPDrawingModelCoreAnimation && m_eventModel == NPEventModelCarbon)
-        return false;
-    
-    // The Cocoa event model does not work with the QuickDraw drawing model.
-    if (m_eventModel == NPEventModelCocoa && m_drawingModel == NPDrawingModelQuickDraw)
-        return false;
-#endif
-    
-#ifndef NP_NO_QUICKDRAW
-    // Right now we don't support the QuickDraw drawing model at all
-    if (m_drawingModel == NPDrawingModelQuickDraw)
-        return false;
-#endif
-
-    return true;
-}
-
-static inline NPCocoaEvent initializeEvent(NPCocoaEventType type)
-{
-    NPCocoaEvent event;
-    
-    event.type = type;
-    event.version = 0;
-    
-    return event;
-}
-
-void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
-{
-    switch (m_eventModel) {
-        case NPEventModelCocoa: {
-            NPCocoaEvent event = initializeEvent(NPCocoaEventDrawRect);
-
-            event.data.draw.context = context->platformContext();
-            event.data.draw.x = dirtyRect.x() - m_frameRect.x();
-            event.data.draw.y = dirtyRect.y() - m_frameRect.y();
-            event.data.draw.width = dirtyRect.width();
-            event.data.draw.height = dirtyRect.height();
-            
-            m_pluginModule->pluginFuncs().event(&m_npp, &event);
-            break;
-        }
-        
-        default:
-            ASSERT_NOT_REACHED();
-    }
-}
-
-} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
new file mode 100644
index 0000000..c49c93c
--- /dev/null
+++ b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "NetscapePlugin.h"
+
+#include <AppKit/AppKit.h>
+#include "WebEvent.h"
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+NPError NetscapePlugin::setDrawingModel(NPDrawingModel drawingModel)
+{
+    // The drawing model can only be set from NPP_New.
+    if (!m_inNPPNew)
+        return NPERR_GENERIC_ERROR;
+
+    switch (drawingModel) {
+#ifndef NP_NO_QUICKDRAW
+        case NPDrawingModelQuickDraw:
+#endif
+        case NPDrawingModelCoreGraphics:
+        case NPDrawingModelCoreAnimation:
+            m_drawingModel = drawingModel;
+            break;
+
+        default:
+            return NPERR_GENERIC_ERROR;
+    }
+
+    return NPERR_NO_ERROR;
+}
+    
+NPError NetscapePlugin::setEventModel(NPEventModel eventModel)
+{
+    // The event model can only be set from NPP_New.
+    if (!m_inNPPNew)
+        return NPERR_GENERIC_ERROR;
+
+    switch (eventModel) {
+#ifndef NP_NO_CARBON
+        case NPEventModelCarbon:
+#endif
+        case NPEventModelCocoa:
+            m_eventModel = eventModel;
+            break;
+
+        default:
+            return NPERR_GENERIC_ERROR;
+    }
+    
+    return NPERR_NO_ERROR;
+}
+
+bool NetscapePlugin::platformPostInitialize()
+{
+    if (m_drawingModel == static_cast<NPDrawingModel>(-1)) {
+#ifndef NP_NO_QUICKDRAW
+        // Default to QuickDraw if the plugin did not specify a drawing model.
+        m_drawingModel = NPDrawingModelQuickDraw;
+#else
+        // QuickDraw is not available, so we can't default to it. Instead, default to CoreGraphics.
+        m_drawingModel = NPDrawingModelCoreGraphics;
+#endif
+    }
+    
+    if (m_eventModel == static_cast<NPEventModel>(-1)) {
+        // If the plug-in did not specify a drawing model we default to Carbon when it is available.
+#ifndef NP_NO_CARBON
+        m_eventModel = NPEventModelCarbon;
+#else
+        m_eventModel = NPEventModelCocoa;
+#endif // NP_NO_CARBON
+    }
+
+#if !defined(NP_NO_CARBON) && !defined(NP_NO_QUICKDRAW)
+    // The CA drawing model does not work with the Carbon event model.
+    if (m_drawingModel == NPDrawingModelCoreAnimation && m_eventModel == NPEventModelCarbon)
+        return false;
+    
+    // The Cocoa event model does not work with the QuickDraw drawing model.
+    if (m_eventModel == NPEventModelCocoa && m_drawingModel == NPDrawingModelQuickDraw)
+        return false;
+#endif
+    
+#ifndef NP_NO_QUICKDRAW
+    // Right now we don't support the QuickDraw drawing model at all
+    if (m_drawingModel == NPDrawingModelQuickDraw)
+        return false;
+#endif
+
+    return true;
+}
+
+static inline NPCocoaEvent initializeEvent(NPCocoaEventType type)
+{
+    NPCocoaEvent event;
+    
+    event.type = type;
+    event.version = 0;
+    
+    return event;
+}
+
+void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
+{
+    switch (m_eventModel) {
+        case NPEventModelCocoa: {
+            NPCocoaEvent event = initializeEvent(NPCocoaEventDrawRect);
+
+            event.data.draw.context = context->platformContext();
+            event.data.draw.x = dirtyRect.x() - m_frameRect.x();
+            event.data.draw.y = dirtyRect.y() - m_frameRect.y();
+            event.data.draw.width = dirtyRect.width();
+            event.data.draw.height = dirtyRect.height();
+            
+            NPP_HandleEvent(&event);
+            break;
+        }
+        
+        default:
+            ASSERT_NOT_REACHED();
+    }
+}
+
+static uint32_t modifierFlags(const WebEvent& event)
+{
+    uint32_t modifiers = 0;
+
+    if (event.shiftKey())
+        modifiers |= NSShiftKeyMask;
+    if (event.controlKey())
+        modifiers |= NSControlKeyMask;
+    if (event.altKey())
+        modifiers |= NSAlternateKeyMask;
+    if (event.metaKey())
+        modifiers |= NSCommandKeyMask;
+    
+    return modifiers;
+}
+    
+static int32_t buttonNumber(WebMouseEvent::Button button)
+{
+    switch (button) {
+    case WebMouseEvent::NoButton:
+    case WebMouseEvent::LeftButton:
+        return 0;
+    case WebMouseEvent::RightButton:
+        return 1;
+    case WebMouseEvent::MiddleButton:
+        return 2;
+    }
+
+    ASSERT_NOT_REACHED();
+    return -1;
+}
+
+static NPCocoaEvent initializeMouseEvent(const WebMouseEvent& mouseEvent, const WebCore::IntPoint& pluginLocation)
+{
+    NPCocoaEventType eventType;
+
+    switch (mouseEvent.type()) {
+    case WebEvent::MouseDown:
+        eventType = NPCocoaEventMouseDown;
+        break;
+    case WebEvent::MouseUp:
+        eventType = NPCocoaEventMouseUp;
+        break;
+    case WebEvent::MouseMove:
+        if (mouseEvent.button() == WebMouseEvent::NoButton)
+            eventType = NPCocoaEventMouseMoved;
+        else
+            eventType = NPCocoaEventMouseDragged;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        return NPCocoaEvent();
+    }
+
+    NPCocoaEvent event = initializeEvent(eventType);
+    
+    event.data.mouse.modifierFlags = modifierFlags(mouseEvent);
+    event.data.mouse.pluginX = mouseEvent.positionX() - pluginLocation.x();
+    event.data.mouse.pluginY = mouseEvent.positionY() - pluginLocation.y();
+    event.data.mouse.buttonNumber = buttonNumber(mouseEvent.button());
+    event.data.mouse.clickCount = mouseEvent.clickCount();
+    event.data.mouse.deltaX = mouseEvent.deltaX();
+    event.data.mouse.deltaY = mouseEvent.deltaY();
+    event.data.mouse.deltaZ = mouseEvent.deltaZ();
+
+    return event;
+}
+
+bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent& mouseEvent)
+{
+    switch (m_eventModel) {
+        case NPEventModelCocoa: {
+            NPCocoaEvent event = initializeMouseEvent(mouseEvent, m_frameRect.location());
+            return NPP_HandleEvent(&event);
+        }
+
+        default:
+            ASSERT_NOT_REACHED();
+    }
+    
+    return false;
+}
+
+bool NetscapePlugin::platformHandleWheelEvent(const WebWheelEvent& wheelEvent)
+{
+    switch (m_eventModel) {
+        case NPEventModelCocoa: {
+            NPCocoaEvent event = initializeEvent(NPCocoaEventScrollWheel);
+            
+            event.data.mouse.modifierFlags = modifierFlags(wheelEvent);
+            event.data.mouse.pluginX = wheelEvent.positionX() - m_frameRect.x();
+            event.data.mouse.pluginY = wheelEvent.positionY() - m_frameRect.y();
+            event.data.mouse.buttonNumber = 0;
+            event.data.mouse.clickCount = 0;
+            event.data.mouse.deltaX = wheelEvent.deltaX();
+            event.data.mouse.deltaY = wheelEvent.deltaY();
+            event.data.mouse.deltaZ = 0;
+            
+            return NPP_HandleEvent(&event);
+        }
+
+        default:
+            ASSERT_NOT_REACHED();
+    }
+
+    return false;
+}
+    
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index 18ce87c..b3c836e 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -37,6 +37,9 @@ namespace WebCore {
 
 namespace WebKit {
 
+class WebMouseEvent;
+class WebWheelEvent;
+    
 class PluginController;
 
 class Plugin : public RefCounted<Plugin> {
@@ -86,6 +89,12 @@ public:
     // Tells the plug-in that a stream has failed to load, either because of network errors or because the load was cancelled.
     virtual void streamDidFail(uint64_t streamID, bool wasCancelled) = 0;
 
+    // Tells the plug-in to handle the passed in mouse event. The plug-in should return true if it processed the event.
+    virtual bool handleMouseEvent(const WebMouseEvent&) = 0;
+
+    // Tells the plug-in to handle the passed in wheel event. The plug-in should return true if it processed the event.
+    virtual bool handleWheelEvent(const WebWheelEvent&) = 0;
+
     // Returns the plug-in controller for this plug-in.
     // FIXME: We could just have the controller be a member variable of Plugin.
     virtual PluginController* controller() = 0;
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 77a98f1..ce5a7a0 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -26,6 +26,8 @@
 #include "PluginView.h"
 
 #include "Plugin.h"
+#include "WebEvent.h"
+#include "WebPage.h"
 #include <WebCore/DocumentLoader.h>
 #include <WebCore/Event.h>
 #include <WebCore/FrameLoadRequest.h>
@@ -318,9 +320,26 @@ void PluginView::setParent(ScrollView* scrollView)
     viewGeometryDidChange();
 }
 
-void PluginView::handleEvent(Event*)
+void PluginView::handleEvent(Event* event)
 {
-    // FIXME: Implement.
+    const WebEvent* currentEvent = WebPage::currentEvent();
+    if (!currentEvent)
+        return;
+
+    bool didHandleEvent = false;
+
+    if ((event->type() == eventNames().mousemoveEvent && currentEvent->type() == WebEvent::MouseMove) 
+        || (event->type() == eventNames().mousedownEvent && currentEvent->type() == WebEvent::MouseDown)
+        || (event->type() == eventNames().mouseupEvent && currentEvent->type() == WebEvent::MouseUp)) {
+        // We have a mouse event.
+        didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
+    } else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel) {
+        // We have a wheel event.
+        didHandleEvent = m_plugin->handleWheelEvent(static_cast<const WebWheelEvent&>(*currentEvent));
+    }
+
+    if (didHandleEvent)
+        event->setDefaultHandled();
 }
     
 void PluginView::viewGeometryDidChange()
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 8bbb194..7206072 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -277,8 +277,37 @@ void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
 
 // Events 
 
+static const WebEvent* g_currentEvent = 0;
+
+// FIXME: WebPage::currentEvent is used by the plug-in code to avoid having to convert from DOM events back to
+// WebEvents. When we get the event handling sorted out, this should go away and the Widgets should get the correct
+// platform events passed to the event handler code.
+const WebEvent* WebPage::currentEvent()
+{
+    return g_currentEvent;
+}
+
+class CurrentEvent {
+public:
+    explicit CurrentEvent(const WebEvent& event)
+        : m_previousCurrentEvent(g_currentEvent)
+    {
+        g_currentEvent = &event;
+    }
+
+    ~CurrentEvent()
+    {
+        g_currentEvent = m_previousCurrentEvent;
+    }
+
+private:
+    const WebEvent* m_previousCurrentEvent;
+};
+
 void WebPage::mouseEvent(const WebMouseEvent& mouseEvent)
 {
+    CurrentEvent currentEvent(mouseEvent);
+
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In(static_cast<uint32_t>(mouseEvent.type())));
 
     if (!m_mainFrame->coreFrame()->view())
@@ -304,6 +333,8 @@ void WebPage::mouseEvent(const WebMouseEvent& mouseEvent)
 
 void WebPage::wheelEvent(const WebWheelEvent& wheelEvent)
 {
+    CurrentEvent currentEvent(wheelEvent);
+
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In(static_cast<uint32_t>(wheelEvent.type())));
     if (!m_mainFrame->coreFrame()->view())
         return;
@@ -314,6 +345,8 @@ void WebPage::wheelEvent(const WebWheelEvent& wheelEvent)
 
 void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
 {
+    CurrentEvent currentEvent(keyboardEvent);
+
     WebProcess::shared().connection()->send(WebPageProxyMessage::DidReceiveEvent, m_pageID, CoreIPC::In(static_cast<uint32_t>(keyboardEvent.type())));
 
     if (!m_mainFrame->coreFrame()->view())
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index aa556fc..82b09b1 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -54,6 +54,7 @@ namespace WebCore {
 namespace WebKit {
 
 class DrawingArea;
+class WebEvent;
 class WebFrame;
 class WebKeyboardEvent;
 class WebMouseEvent;
@@ -109,6 +110,8 @@ public:
     void exitAcceleratedCompositingMode();
 #endif
 
+    static const WebEvent* currentEvent();
+
 private:
     WebPage(uint64_t pageID, const WebCore::IntSize& viewSize, const WebPreferencesStore&, DrawingArea::Type);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list