2009-04-27 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2009 19:33:51 +0000 (19:33 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Apr 2009 19:33:51 +0000 (19:33 +0000)
        Reviewed by Adam Roben.

        Update the example plug-in for new changes to the Cocoa event model.

        * NetscapeCocoaPlugin/main.m:
        (handleDraw):
        (handleMouseEvent):
        (NPP_HandleEvent):

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

WebKitExamplePlugins/ChangeLog
WebKitExamplePlugins/NetscapeCocoaPlugin/main.m

index b97b749..71fe8a0 100644 (file)
@@ -1,3 +1,14 @@
+2009-04-27  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Update the example plug-in for new changes to the Cocoa event model.
+        
+        * NetscapeCocoaPlugin/main.m:
+        (handleDraw):
+        (handleMouseEvent):
+        (NPP_HandleEvent):
+
 2009-03-13  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Kevin Decker.
index 1f66ac1..afe29c6 100644 (file)
@@ -194,14 +194,13 @@ void NPP_Print(NPP instance, NPPrint* platformPrint)
 
 }
 
-static void handleDraw(PluginObject *obj)
+static void handleDraw(PluginObject *obj, NPCocoaEvent *event)
 {
     NSGraphicsContext *oldContext = [[NSGraphicsContext currentContext] retain];
     
-    NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:((NP_CGContext *)obj->window.window)->context
+    NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:event->data.draw.context
                                                                             flipped:YES];
 
-
     [NSGraphicsContext setCurrentContext:context];
     
     NSRect rect = NSMakeRect(0, 0, obj->window.width, obj->window.height);
@@ -289,7 +288,6 @@ static void handleMouseEvent(PluginObject *obj, NPCocoaEvent *event)
             obj->menuHandler = [[MenuHandler alloc] initWithBrowserFuncs:browser instance:obj->npp];
         
         browser->popupcontextmenu(obj->npp, (NPNSMenu *)[obj->menuHandler menu]);
-        NSLog(@"foo");
     }
 }
 
@@ -328,7 +326,7 @@ int16 NPP_HandleEvent(NPP instance, void* event)
             return 1;
             
         case NPCocoaEventDrawRect:
-            handleDraw(obj);
+            handleDraw(obj, cocoaEvent);
             return 1;
         
         case NPCocoaEventKeyDown: