Update TestNetscapePlugIn to build 64-bit using the Cocoa event model.
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 May 2008 00:44:44 +0000 (00:44 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 May 2008 00:44:44 +0000 (00:44 +0000)
It currently does not attempt to print events which means that plugins/mouse-events.html
will fail when run 64-bit.  All other tests that use this plugin pass.

Reviewed by Anders Carlsson.

* DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp:
(testGetIntIdentifier):
* DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
(NPP_New):
(NPP_HandleEvent):

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

WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp

index a72fff8..b799098 100644 (file)
@@ -1,3 +1,18 @@
+2008-05-09  Mark Rowe  <mrowe@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Update TestNetscapePlugIn to build 64-bit using the Cocoa event model.
+
+        It currently does not attempt to print events which means that plugins/mouse-events.html
+        will fail when run 64-bit.  All other tests that use this plugin pass.
+
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp:
+        (testGetIntIdentifier):
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
+        (NPP_New):
+        (NPP_HandleEvent):
+
 2008-05-09  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Adam Roben
index fe3722d..029517b 100644 (file)
@@ -401,7 +401,7 @@ static bool testGetIntIdentifier(PluginObject*, const NPVariant* args, uint32_t
         return false;
 
     NPIdentifier identifier = browser->getintidentifier((int)NPVARIANT_TO_DOUBLE(args[0]));
-    INT32_TO_NPVARIANT((int32)identifier, *result);
+    INT32_TO_NPVARIANT((int32)(long long)identifier, *result);
     return true;
 }
 
index ebbc9e4..807acb4 100644 (file)
 
 #import "PluginObject.h"
 
+#if __LP64__
+#define USE_COCOA_EVENT_MODEL 1
+#endif
+
 // Mach-o entry points
 extern "C" {
     NPError NP_Initialize(NPNetscapeFuncs *browserFuncs);
@@ -66,6 +70,18 @@ void NP_Shutdown(void)
 
 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
 {
+#if USE_COCOA_EVENT_MODEL
+    // If the browser supports the Cocoa event model, enable it.
+    NPBool supportsCocoa;
+    if (browser->getvalue(instance, NPNVsupportsCocoaBool, &supportsCocoa) != NPERR_NO_ERROR)
+        supportsCocoa = FALSE;
+
+    if (!supportsCocoa)
+        return NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+    browser->setvalue(instance, NPPVpluginEventModel, (void *)NPEventModelCocoa);
+#endif
+
     if (browser->version >= 14) {
         PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
     
@@ -172,7 +188,35 @@ int16 NPP_HandleEvent(NPP instance, void *event)
     PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
     if (!obj->eventLogging)
         return 0;
-    
+
+#if USE_COCOA_EVENT_MODEL
+    // FIXME: Generate output that will match the Carbon event model
+    // so that the layout tests using this plug-in will work in either model.
+    NPCocoaEvent *cocoaEvent = static_cast<NPCocoaEvent*>(event);
+    switch (cocoaEvent->type) {
+        case NPCocoaEventWindowFocusChanged:
+        case NPCocoaEventFocusChanged:
+            return 1;
+
+        case NPCocoaEventDrawRect:
+            return 1;
+
+        case NPCocoaEventKeyDown:
+        case NPCocoaEventKeyUp:
+        case NPCocoaEventFlagsChanged:
+            return 1;
+
+        case NPCocoaEventMouseDown:
+        case NPCocoaEventMouseUp:
+
+        case NPCocoaEventMouseMoved:
+        case NPCocoaEventMouseEntered:
+        case NPCocoaEventMouseExited:
+        case NPCocoaEventMouseDragged:
+        case NPCocoaEventScrollWheel:
+            return 1;
+    }
+#else
     EventRecord* evt = static_cast<EventRecord*>(event);
     Point pt = { evt->where.v, evt->where.h };
     switch (evt->what) {
@@ -234,7 +278,7 @@ int16 NPP_HandleEvent(NPP instance, void *event)
         default:
             printf("PLUGIN: event %d\n", evt->what);
     }
-    
+#endif
     return 0;
 }