[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:54:11 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c31e1636bfdfdef33993271c12fc98cb1f902f09
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 18 00:45:29 2002 +0000

    Added remaining mouse events to WKPluginView. Attributes (HTML tags) are now passed to plug-ins. Routed instance-specific plug-in to browser calls to WKPluginView
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@539 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index 314c0df..1e0f0c6 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -804,10 +804,11 @@ void RenderPartObject::updateWidget()
      }
 
      KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
-
+     #ifdef _KWQ_
+     #else
      o->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );
      o->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );
-
+     #endif
      part->requestObject( this, url, serviceType, o->param );
 
   } else {
diff --git a/WebCore/kwq/KWQPlugin.h b/WebCore/kwq/KWQPlugin.h
index 0b390c1..12112e0 100644
--- a/WebCore/kwq/KWQPlugin.h
+++ b/WebCore/kwq/KWQPlugin.h
@@ -52,7 +52,6 @@ public:
     ~KWQPlugin();
 
     // member functions --------------------------------------------------------
-    void *getPort();
     
     // operators ---------------------------------------------------------------
 
diff --git a/WebCore/kwq/KWQPlugin.mm b/WebCore/kwq/KWQPlugin.mm
index 267e298..7144b0f 100644
--- a/WebCore/kwq/KWQPlugin.mm
+++ b/WebCore/kwq/KWQPlugin.mm
@@ -27,15 +27,24 @@
 #include <KWQView.h>
 #include <kwqdebug.h>
 
-KWQPlugin::KWQPlugin(QWidget *parent, WKPlugin *plugin, const QString &url, const QString &serviceType,
-                    const QStringList &args)
+KWQPlugin::KWQPlugin(QWidget *parent, WKPlugin *plugin, const QString &url, const QString &serviceType, const QStringList &args)
 {
-    setView ([[[WKPluginView alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this plugin: plugin url:QSTRING_TO_NSSTRING(url) mime:QSTRING_TO_NSSTRING(serviceType) ] autorelease]);
-}
-
-void * KWQPlugin::getPort()
-{
-    return [(WKPluginView *)getView() qdPort];
+    NSMutableDictionary *arguments;
+    NSString *arg;
+    NSRange r1, r2, r3;
+    uint i;
+    
+    arguments = [NSMutableDictionary dictionaryWithCapacity:10];
+    for(i=0; i<args.count(); i++){
+    arg = QSTRING_TO_NSSTRING(args[i]);
+        r1 = [arg rangeOfString:@"="]; // parse out attributes and values
+        r2 = [arg rangeOfString:@"\""];
+        r3.location = r2.location + 1;
+        r3.length = [arg length] - r2.location - 2; // don't include quotes
+        [arguments setObject:[arg substringWithRange:r3] forKey:[arg substringToIndex:r1.location]];
+    }
+    
+    setView([[[WKPluginView alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this plugin: plugin url:QSTRING_TO_NSSTRING(url) mime:QSTRING_TO_NSSTRING(serviceType) arguments:arguments] autorelease]);
 }
 
 KWQPlugin::~KWQPlugin()
diff --git a/WebCore/kwq/WKPlugin.h b/WebCore/kwq/WKPlugin.h
index 589ea90..d45a75c 100644
--- a/WebCore/kwq/WKPlugin.h
+++ b/WebCore/kwq/WKPlugin.h
@@ -46,6 +46,7 @@
 - (NPP_NewStreamProcPtr)NPP_NewStream;
 - (NPP_WriteReadyProcPtr)NPP_WriteReady;
 - (NPP_WriteProcPtr)NPP_Write;
+- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile;
 - (NPP_DestroyStreamProcPtr)NPP_DestroyStream;
 - (NPP_HandleEventProcPtr)NPP_HandleEvent;
 - (NSDictionary *)mimeTypes;
diff --git a/WebCore/kwq/WKPlugin.mm b/WebCore/kwq/WKPlugin.mm
index 01927b3..302550b 100644
--- a/WebCore/kwq/WKPlugin.mm
+++ b/WebCore/kwq/WKPlugin.mm
@@ -164,6 +164,9 @@
     return NPP_NewStream;
 }
 
+- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile{
+    return NPP_StreamAsFile;
+}
 - (NPP_DestroyStreamProcPtr)NPP_DestroyStream{
     return NPP_DestroyStream;
 }
@@ -241,5 +244,3 @@ NSMutableDictionary *getMimeTypesForResourceFile(SInt16 resRef){
 
 
 
-
-
diff --git a/WebCore/kwq/WKPluginView.h b/WebCore/kwq/WKPluginView.h
index d7dd66b..37c3e0a 100644
--- a/WebCore/kwq/WKPluginView.h
+++ b/WebCore/kwq/WKPluginView.h
@@ -29,7 +29,8 @@ typedef NPStream* NPS;
     NPWindow window;
     NP_Port nPort;
     uint16 transferMode;
-        
+    char **cAttributes, **cValues;
+    
     NPP_NewProcPtr NPP_New;
     NPP_DestroyProcPtr NPP_Destroy;
     NPP_SetWindowProcPtr NPP_SetWindow;
@@ -46,12 +47,33 @@ typedef NPStream* NPS;
     NPP_ShutdownProcPtr NPP_Shutdown; 
 }
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mime;
+- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mime arguments:(NSDictionary *)arguments;
 -(void)drawRect:(NSRect)rect;
 -(BOOL)acceptsFirstResponder;
 -(void)sendNullEvents;
 -(void)mouseDown:(NSEvent *)theEvent;
 -(void)mouseUp:(NSEvent *)theEvent;
+- (void)mouseDragged:(NSEvent *)theEvent;
+- (void)mouseEntered:(NSEvent *)theEvent;
+- (void)mouseExited:(NSEvent *)theEvent;
+- (void)mouseMoved:(NSEvent *)theEvent;
+- (void)keyDown:(NSEvent *)theEvent;
+- (void)keyUp:(NSEvent *)theEvent;
 -(void)dealloc;
 
+// plug-in to browser calls
+-(NPError)getURLNotify:(const char *)url target:(const char *)target notifyData:(void *)notifyData;
+-(NPError)getURL:(const char *)url target:(const char *)target;
+-(NPError)postURLNotify:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData;
+-(NPError)postURL:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file;
+-(NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream;
+-(NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer;
+-(NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason;
+-(void)status:(const char *)message;
+-(NPError)getValue:(NPNVariable)variable value:(void *)value;
+-(NPError)setValue:(NPPVariable)variable value:(void *)value;
+-(void)invalidateRect:(NPRect *)invalidRect;
+-(void)invalidateRegion:(NPRegion)invalidateRegion;
+-(void)forceRedraw;
+
 @end
diff --git a/WebCore/kwq/WKPluginView.mm b/WebCore/kwq/WKPluginView.mm
index 1db88c0..d97b702 100644
--- a/WebCore/kwq/WKPluginView.mm
+++ b/WebCore/kwq/WKPluginView.mm
@@ -14,15 +14,19 @@
 
 @implementation WKPluginView
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mimeType
+- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mimeType  arguments:(NSDictionary *)arguments
 {
     NPError npErr;
-    char cMime[200];
+    char cMime[200], *s;
     NPSavedData saved;
+    NSArray *attributes, *values;
+    NSString *attributeString;
+    uint i;
     
     [super initWithFrame: r];
 
     instance = &instanceStruct;
+    instance->ndata = self;
     stream = &streamStruct;
     streamOffset = 0;
 
@@ -35,13 +39,31 @@
     NPP_NewStream = 	[plugin NPP_NewStream];
     NPP_WriteReady = 	[plugin NPP_WriteReady];
     NPP_Write = 	[plugin NPP_Write];
+    NPP_StreamAsFile = 	[plugin NPP_StreamAsFile];
     NPP_DestroyStream = [plugin NPP_DestroyStream];
     NPP_HandleEvent = 	[plugin NPP_HandleEvent];
-
+    
+    attributes = [arguments allKeys];
+    values = [arguments allValues];
+    cAttributes = malloc(sizeof(char *) * [arguments count]);
+    cValues = malloc(sizeof(char *) * [arguments count]);
+    
+    for(i=0; i<[arguments count]; i++){ // convert dictionary to 2 string arrays
+        attributeString = [attributes objectAtIndex:i];
+        s = malloc([attributeString length]+1);
+        [attributeString getCString:s];
+        cAttributes[i] = s;
+        
+        attributeString = [values objectAtIndex:i];
+        s = malloc([attributeString length]+1);
+        [attributeString getCString:s];
+        cValues[i] = s;
+    }
     [mime getCString:cMime];
-    npErr = NPP_New(cMime, instance, NP_EMBED, 0, NULL, NULL, &saved); //need to pass parameters to plug-in
+    npErr = NPP_New(cMime, instance, NP_EMBED, [arguments count], cAttributes, cValues, &saved); // need to pass attributes to plug-in
     KWQDebug("NPP_New: %d\n", npErr);
     transferred = FALSE;
+    [[self window] setAcceptsMouseMovedEvents:YES];
     [self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:0];
     return self;
 }
@@ -53,15 +75,12 @@
     NSRect frame;
     
     frame = [self frame];
-    
     nPort.port = [self qdPort];
     nPort.portx = (int32)rect.origin.x;
     nPort.porty = (int32)rect.origin.y;
     window.window = &nPort;
     window.x = 0; 
     window.y = 0;
-    //window.x = (uint32)frame.origin.x; //top-left corner of the plug-in relative to page
-    //window.y = (uint32)frame.origin.y;
     window.width = (uint32)frame.size.width;
     window.height = (uint32)frame.size.height;
     window.clipRect.top = (uint16)rect.origin.y; // clip rect
@@ -70,10 +89,6 @@
     window.clipRect.right = (uint16)rect.size.width;
     window.type = NPWindowTypeDrawable;
     
-    //SetPort(nPort.port);
-    //LineTo((int)frame.size.width, (int)frame.size.height);
-    //MoveTo(0,0);
-    
     npErr = NPP_SetWindow(instance, &window);
     KWQDebug("NPP_SetWindow: %d rect.size.height=%d rect.size.width=%d port=%d rect.origin.x=%f rect.origin.y=%f\n", npErr, (int)rect.size.height, (int)rect.size.width, (int)nPort.port, rect.origin.x, rect.origin.y);
     KWQDebug("frame.size.height=%d frame.size.width=%d frame.origin.x=%f frame.origin.y=%f\n", (int)frame.size.height, (int)frame.size.width, frame.origin.x, frame.origin.y);
@@ -86,19 +101,24 @@
         stream->notifyData = NULL;
         [mime getCString:cMime];
         
-        npErr = NPP_NewStream(instance, cMime, stream, TRUE, &transferMode);
+        npErr = NPP_NewStream(instance, cMime, stream, FALSE, &transferMode);
         KWQDebug("NPP_NewStream: %d\n", npErr);
         
         cache = WCGetDefaultURICache();
         if(transferMode == NP_NORMAL){
             KWQDebug("Stream type: NP_NORMAL\n");
+            transferMode = NP_ASFILEONLY;
             [cache requestWithString:url requestor:self userData:nil];
         }else if(transferMode == NP_ASFILEONLY){
             KWQDebug("Stream type: NP_ASFILEONLY not yet supported\n");
+            transferMode = NP_ASFILEONLY;
         }else if(transferMode == NP_ASFILE){
-            KWQDebug("Stream type: NP_ASFILE not yet supported\n");
+            KWQDebug("Stream type: NP_ASFILE not fully supported\n");
+            transferMode = NP_ASFILE;
+            [cache requestWithString:url requestor:self userData:nil];
         }else if(transferMode == NP_SEEK){
             KWQDebug("Stream type: NP_SEEK not yet supported\n");
+            transferMode = NP_SEEK;
         }
         transferred = TRUE;
     }
@@ -122,7 +142,11 @@
 -(void)cacheFinished:(NSNotification *)notification
 {
     NPError npErr;
+    
     streamOffset = 0;
+    if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY){
+        NPP_StreamAsFile(instance, stream, NULL);
+    }
     npErr = NPP_DestroyStream(instance, stream, NPRES_DONE);
     KWQDebug("NPP_DestroyStream: %d\n", npErr);
 }
@@ -132,14 +156,19 @@
     return true;
 }
 
+// event methods
+
 -(void)sendNullEvents
 {
     EventRecord event;
     bool acceptedEvent;
+    UnsignedWide msecs;
     
     event.what = nullEvent;
-    acceptedEvent = NPP_HandleEvent(instance, &event);
-    //KWQDebug("NPP_HandleEvent: %d\n", acceptedEvent);
+    Microseconds(&msecs);
+    event.when = (uint32)((double)UnsignedWideToUInt64(msecs) / 1000000 * 60); // microseconds to ticks
+    acceptedEvent = NPP_HandleEvent(instance, &event); 
+    //KWQDebug("NPP_HandleEvent(nullEvent): %d  when: %u\n", acceptedEvent, event.when);
     [self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:0];
 }
 
@@ -158,9 +187,9 @@
     pt.h = (short)viewPoint.x;
     event.what = mouseDown;
     event.where = pt;
-    event.when = (uint32)[theEvent timestamp] / 60; // seconds to ticks
+    event.when = (uint32)([theEvent timestamp] * 60); // seconds to ticks
     acceptedEvent = NPP_HandleEvent(instance, &event);
-    KWQDebug("NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%d\n", acceptedEvent, pt.v, pt.h, event.when);
+    KWQDebug("NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
 }
 
 -(void)mouseUp:(NSEvent *)theEvent
@@ -178,11 +207,160 @@
     pt.h = (short)viewPoint.x;
     event.what = mouseUp;
     event.where = pt;
-    event.when = (uint32)[theEvent timestamp] / 60; // seconds to ticks
+    event.when = (uint32)([theEvent timestamp] * 60); 
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    Point pt;
+    NSPoint viewPoint;
+    NSRect frame;
+    
+    viewPoint = [self convertPoint:[theEvent locationInWindow] fromView:[[theEvent window] contentView]];
+    frame = [self frame];
+    
+    pt.v = (short)viewPoint.y; 
+    pt.h = (short)viewPoint.x;
+    event.what = osEvt;
+    event.where = pt;
+    event.when = (uint32)([theEvent timestamp] * 60); // seconds to ticks
+    event.message = mouseMovedMessage;
     acceptedEvent = NPP_HandleEvent(instance, &event);
-    KWQDebug("NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%d\n", acceptedEvent, pt.v, pt.h, event.when);
+    KWQDebug("NPP_HandleEvent(mouseDragged): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
 }
 
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = adjustCursorEvent;
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseEntered): %dn", acceptedEvent);
+}
+
+- (void)mouseExited:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = adjustCursorEvent;
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseExited): %d\n", acceptedEvent);
+}
+
+- (void)mouseMoved:(NSEvent *)theEvent{
+    KWQDebug("mouseMoved\n");
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ 
+    EventRecord event;
+    bool acceptedEvent;
+
+    event.what = keyUp;
+    event.message = [theEvent keyCode];
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(keyUp): %d key:%d\n", acceptedEvent, event.message);
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = keyDown;
+    event.message = [theEvent keyCode];
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(keyDown): %d key:%d\n", acceptedEvent, event.message);
+}
+
+// plug-in to browser calls
+
+-(NPError)getURLNotify:(const char *)url target:(const char *)target notifyData:(void *)notifyData
+{
+    KWQDebug("getURLNotify\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)getURL:(const char *)url target:(const char *)target
+{
+    KWQDebug("getURL\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)postURLNotify:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData
+{
+    KWQDebug("postURLNotify\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)postURL:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file
+{
+    KWQDebug("postURL\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream
+{
+    KWQDebug("newStream\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer
+{
+    KWQDebug("write\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason
+{
+    KWQDebug("destroyStream\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(void)status:(const char *)message
+{
+    KWQDebug("status\n");
+}
+
+-(NPError)getValue:(NPNVariable)variable value:(void *)value
+{
+    KWQDebug("getValue\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)setValue:(NPPVariable)variable value:(void *)value
+{
+    KWQDebug("setValue\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(void)invalidateRect:(NPRect *)invalidRect
+{
+    KWQDebug("invalidateRect\n");
+}
+
+-(void)invalidateRegion:(NPRegion)invalidateRegion
+{
+    KWQDebug("invalidateRegion\n");
+}
+
+-(void)forceRedraw
+{
+    KWQDebug("forceRedraw\n");
+}
+
+
 -(void)dealloc
 {
     NPError npErr;
diff --git a/WebCore/kwq/npapi.h b/WebCore/kwq/npapi.h
index 493a08a..2207892 100644
--- a/WebCore/kwq/npapi.h
+++ b/WebCore/kwq/npapi.h
@@ -111,6 +111,15 @@ typedef struct NP_Port
     int32		porty;
 } NP_Port;
 
+
+/*
+ *  Non-standard event types that can be passed to HandleEvent
+ */
+#define getFocusEvent	    (osEvt + 16)
+#define loseFocusEvent	    (osEvt + 17)
+#define adjustCursorEvent   (osEvt + 18)
+
+
 /*
  * List of variable names for which NPP_GetValue shall be implemented
  */
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp b/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
index 314c0df..1e0f0c6 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
@@ -804,10 +804,11 @@ void RenderPartObject::updateWidget()
      }
 
      KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
-
+     #ifdef _KWQ_
+     #else
      o->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );
      o->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );
-
+     #endif
      part->requestObject( this, url, serviceType, o->param );
 
   } else {
diff --git a/WebCore/src/kwq/KWQPlugin.h b/WebCore/src/kwq/KWQPlugin.h
index 0b390c1..12112e0 100644
--- a/WebCore/src/kwq/KWQPlugin.h
+++ b/WebCore/src/kwq/KWQPlugin.h
@@ -52,7 +52,6 @@ public:
     ~KWQPlugin();
 
     // member functions --------------------------------------------------------
-    void *getPort();
     
     // operators ---------------------------------------------------------------
 
diff --git a/WebCore/src/kwq/KWQPlugin.mm b/WebCore/src/kwq/KWQPlugin.mm
index 267e298..7144b0f 100644
--- a/WebCore/src/kwq/KWQPlugin.mm
+++ b/WebCore/src/kwq/KWQPlugin.mm
@@ -27,15 +27,24 @@
 #include <KWQView.h>
 #include <kwqdebug.h>
 
-KWQPlugin::KWQPlugin(QWidget *parent, WKPlugin *plugin, const QString &url, const QString &serviceType,
-                    const QStringList &args)
+KWQPlugin::KWQPlugin(QWidget *parent, WKPlugin *plugin, const QString &url, const QString &serviceType, const QStringList &args)
 {
-    setView ([[[WKPluginView alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this plugin: plugin url:QSTRING_TO_NSSTRING(url) mime:QSTRING_TO_NSSTRING(serviceType) ] autorelease]);
-}
-
-void * KWQPlugin::getPort()
-{
-    return [(WKPluginView *)getView() qdPort];
+    NSMutableDictionary *arguments;
+    NSString *arg;
+    NSRange r1, r2, r3;
+    uint i;
+    
+    arguments = [NSMutableDictionary dictionaryWithCapacity:10];
+    for(i=0; i<args.count(); i++){
+    arg = QSTRING_TO_NSSTRING(args[i]);
+        r1 = [arg rangeOfString:@"="]; // parse out attributes and values
+        r2 = [arg rangeOfString:@"\""];
+        r3.location = r2.location + 1;
+        r3.length = [arg length] - r2.location - 2; // don't include quotes
+        [arguments setObject:[arg substringWithRange:r3] forKey:[arg substringToIndex:r1.location]];
+    }
+    
+    setView([[[WKPluginView alloc] initWithFrame: NSMakeRect (0,0,0,0) widget: this plugin: plugin url:QSTRING_TO_NSSTRING(url) mime:QSTRING_TO_NSSTRING(serviceType) arguments:arguments] autorelease]);
 }
 
 KWQPlugin::~KWQPlugin()
diff --git a/WebCore/src/kwq/WKPlugin.h b/WebCore/src/kwq/WKPlugin.h
index 589ea90..d45a75c 100644
--- a/WebCore/src/kwq/WKPlugin.h
+++ b/WebCore/src/kwq/WKPlugin.h
@@ -46,6 +46,7 @@
 - (NPP_NewStreamProcPtr)NPP_NewStream;
 - (NPP_WriteReadyProcPtr)NPP_WriteReady;
 - (NPP_WriteProcPtr)NPP_Write;
+- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile;
 - (NPP_DestroyStreamProcPtr)NPP_DestroyStream;
 - (NPP_HandleEventProcPtr)NPP_HandleEvent;
 - (NSDictionary *)mimeTypes;
diff --git a/WebCore/src/kwq/WKPlugin.mm b/WebCore/src/kwq/WKPlugin.mm
index 01927b3..302550b 100644
--- a/WebCore/src/kwq/WKPlugin.mm
+++ b/WebCore/src/kwq/WKPlugin.mm
@@ -164,6 +164,9 @@
     return NPP_NewStream;
 }
 
+- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile{
+    return NPP_StreamAsFile;
+}
 - (NPP_DestroyStreamProcPtr)NPP_DestroyStream{
     return NPP_DestroyStream;
 }
@@ -241,5 +244,3 @@ NSMutableDictionary *getMimeTypesForResourceFile(SInt16 resRef){
 
 
 
-
-
diff --git a/WebCore/src/kwq/WKPluginView.h b/WebCore/src/kwq/WKPluginView.h
index d7dd66b..37c3e0a 100644
--- a/WebCore/src/kwq/WKPluginView.h
+++ b/WebCore/src/kwq/WKPluginView.h
@@ -29,7 +29,8 @@ typedef NPStream* NPS;
     NPWindow window;
     NP_Port nPort;
     uint16 transferMode;
-        
+    char **cAttributes, **cValues;
+    
     NPP_NewProcPtr NPP_New;
     NPP_DestroyProcPtr NPP_Destroy;
     NPP_SetWindowProcPtr NPP_SetWindow;
@@ -46,12 +47,33 @@ typedef NPStream* NPS;
     NPP_ShutdownProcPtr NPP_Shutdown; 
 }
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mime;
+- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mime arguments:(NSDictionary *)arguments;
 -(void)drawRect:(NSRect)rect;
 -(BOOL)acceptsFirstResponder;
 -(void)sendNullEvents;
 -(void)mouseDown:(NSEvent *)theEvent;
 -(void)mouseUp:(NSEvent *)theEvent;
+- (void)mouseDragged:(NSEvent *)theEvent;
+- (void)mouseEntered:(NSEvent *)theEvent;
+- (void)mouseExited:(NSEvent *)theEvent;
+- (void)mouseMoved:(NSEvent *)theEvent;
+- (void)keyDown:(NSEvent *)theEvent;
+- (void)keyUp:(NSEvent *)theEvent;
 -(void)dealloc;
 
+// plug-in to browser calls
+-(NPError)getURLNotify:(const char *)url target:(const char *)target notifyData:(void *)notifyData;
+-(NPError)getURL:(const char *)url target:(const char *)target;
+-(NPError)postURLNotify:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData;
+-(NPError)postURL:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file;
+-(NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream;
+-(NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer;
+-(NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason;
+-(void)status:(const char *)message;
+-(NPError)getValue:(NPNVariable)variable value:(void *)value;
+-(NPError)setValue:(NPPVariable)variable value:(void *)value;
+-(void)invalidateRect:(NPRect *)invalidRect;
+-(void)invalidateRegion:(NPRegion)invalidateRegion;
+-(void)forceRedraw;
+
 @end
diff --git a/WebCore/src/kwq/WKPluginView.mm b/WebCore/src/kwq/WKPluginView.mm
index 1db88c0..d97b702 100644
--- a/WebCore/src/kwq/WKPluginView.mm
+++ b/WebCore/src/kwq/WKPluginView.mm
@@ -14,15 +14,19 @@
 
 @implementation WKPluginView
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mimeType
+- initWithFrame: (NSRect) r widget: (QWidget *)w plugin: (WKPlugin *)plug url: (NSString *)location mime:(NSString *)mimeType  arguments:(NSDictionary *)arguments
 {
     NPError npErr;
-    char cMime[200];
+    char cMime[200], *s;
     NPSavedData saved;
+    NSArray *attributes, *values;
+    NSString *attributeString;
+    uint i;
     
     [super initWithFrame: r];
 
     instance = &instanceStruct;
+    instance->ndata = self;
     stream = &streamStruct;
     streamOffset = 0;
 
@@ -35,13 +39,31 @@
     NPP_NewStream = 	[plugin NPP_NewStream];
     NPP_WriteReady = 	[plugin NPP_WriteReady];
     NPP_Write = 	[plugin NPP_Write];
+    NPP_StreamAsFile = 	[plugin NPP_StreamAsFile];
     NPP_DestroyStream = [plugin NPP_DestroyStream];
     NPP_HandleEvent = 	[plugin NPP_HandleEvent];
-
+    
+    attributes = [arguments allKeys];
+    values = [arguments allValues];
+    cAttributes = malloc(sizeof(char *) * [arguments count]);
+    cValues = malloc(sizeof(char *) * [arguments count]);
+    
+    for(i=0; i<[arguments count]; i++){ // convert dictionary to 2 string arrays
+        attributeString = [attributes objectAtIndex:i];
+        s = malloc([attributeString length]+1);
+        [attributeString getCString:s];
+        cAttributes[i] = s;
+        
+        attributeString = [values objectAtIndex:i];
+        s = malloc([attributeString length]+1);
+        [attributeString getCString:s];
+        cValues[i] = s;
+    }
     [mime getCString:cMime];
-    npErr = NPP_New(cMime, instance, NP_EMBED, 0, NULL, NULL, &saved); //need to pass parameters to plug-in
+    npErr = NPP_New(cMime, instance, NP_EMBED, [arguments count], cAttributes, cValues, &saved); // need to pass attributes to plug-in
     KWQDebug("NPP_New: %d\n", npErr);
     transferred = FALSE;
+    [[self window] setAcceptsMouseMovedEvents:YES];
     [self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:0];
     return self;
 }
@@ -53,15 +75,12 @@
     NSRect frame;
     
     frame = [self frame];
-    
     nPort.port = [self qdPort];
     nPort.portx = (int32)rect.origin.x;
     nPort.porty = (int32)rect.origin.y;
     window.window = &nPort;
     window.x = 0; 
     window.y = 0;
-    //window.x = (uint32)frame.origin.x; //top-left corner of the plug-in relative to page
-    //window.y = (uint32)frame.origin.y;
     window.width = (uint32)frame.size.width;
     window.height = (uint32)frame.size.height;
     window.clipRect.top = (uint16)rect.origin.y; // clip rect
@@ -70,10 +89,6 @@
     window.clipRect.right = (uint16)rect.size.width;
     window.type = NPWindowTypeDrawable;
     
-    //SetPort(nPort.port);
-    //LineTo((int)frame.size.width, (int)frame.size.height);
-    //MoveTo(0,0);
-    
     npErr = NPP_SetWindow(instance, &window);
     KWQDebug("NPP_SetWindow: %d rect.size.height=%d rect.size.width=%d port=%d rect.origin.x=%f rect.origin.y=%f\n", npErr, (int)rect.size.height, (int)rect.size.width, (int)nPort.port, rect.origin.x, rect.origin.y);
     KWQDebug("frame.size.height=%d frame.size.width=%d frame.origin.x=%f frame.origin.y=%f\n", (int)frame.size.height, (int)frame.size.width, frame.origin.x, frame.origin.y);
@@ -86,19 +101,24 @@
         stream->notifyData = NULL;
         [mime getCString:cMime];
         
-        npErr = NPP_NewStream(instance, cMime, stream, TRUE, &transferMode);
+        npErr = NPP_NewStream(instance, cMime, stream, FALSE, &transferMode);
         KWQDebug("NPP_NewStream: %d\n", npErr);
         
         cache = WCGetDefaultURICache();
         if(transferMode == NP_NORMAL){
             KWQDebug("Stream type: NP_NORMAL\n");
+            transferMode = NP_ASFILEONLY;
             [cache requestWithString:url requestor:self userData:nil];
         }else if(transferMode == NP_ASFILEONLY){
             KWQDebug("Stream type: NP_ASFILEONLY not yet supported\n");
+            transferMode = NP_ASFILEONLY;
         }else if(transferMode == NP_ASFILE){
-            KWQDebug("Stream type: NP_ASFILE not yet supported\n");
+            KWQDebug("Stream type: NP_ASFILE not fully supported\n");
+            transferMode = NP_ASFILE;
+            [cache requestWithString:url requestor:self userData:nil];
         }else if(transferMode == NP_SEEK){
             KWQDebug("Stream type: NP_SEEK not yet supported\n");
+            transferMode = NP_SEEK;
         }
         transferred = TRUE;
     }
@@ -122,7 +142,11 @@
 -(void)cacheFinished:(NSNotification *)notification
 {
     NPError npErr;
+    
     streamOffset = 0;
+    if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY){
+        NPP_StreamAsFile(instance, stream, NULL);
+    }
     npErr = NPP_DestroyStream(instance, stream, NPRES_DONE);
     KWQDebug("NPP_DestroyStream: %d\n", npErr);
 }
@@ -132,14 +156,19 @@
     return true;
 }
 
+// event methods
+
 -(void)sendNullEvents
 {
     EventRecord event;
     bool acceptedEvent;
+    UnsignedWide msecs;
     
     event.what = nullEvent;
-    acceptedEvent = NPP_HandleEvent(instance, &event);
-    //KWQDebug("NPP_HandleEvent: %d\n", acceptedEvent);
+    Microseconds(&msecs);
+    event.when = (uint32)((double)UnsignedWideToUInt64(msecs) / 1000000 * 60); // microseconds to ticks
+    acceptedEvent = NPP_HandleEvent(instance, &event); 
+    //KWQDebug("NPP_HandleEvent(nullEvent): %d  when: %u\n", acceptedEvent, event.when);
     [self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:0];
 }
 
@@ -158,9 +187,9 @@
     pt.h = (short)viewPoint.x;
     event.what = mouseDown;
     event.where = pt;
-    event.when = (uint32)[theEvent timestamp] / 60; // seconds to ticks
+    event.when = (uint32)([theEvent timestamp] * 60); // seconds to ticks
     acceptedEvent = NPP_HandleEvent(instance, &event);
-    KWQDebug("NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%d\n", acceptedEvent, pt.v, pt.h, event.when);
+    KWQDebug("NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
 }
 
 -(void)mouseUp:(NSEvent *)theEvent
@@ -178,11 +207,160 @@
     pt.h = (short)viewPoint.x;
     event.what = mouseUp;
     event.where = pt;
-    event.when = (uint32)[theEvent timestamp] / 60; // seconds to ticks
+    event.when = (uint32)([theEvent timestamp] * 60); 
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    Point pt;
+    NSPoint viewPoint;
+    NSRect frame;
+    
+    viewPoint = [self convertPoint:[theEvent locationInWindow] fromView:[[theEvent window] contentView]];
+    frame = [self frame];
+    
+    pt.v = (short)viewPoint.y; 
+    pt.h = (short)viewPoint.x;
+    event.what = osEvt;
+    event.where = pt;
+    event.when = (uint32)([theEvent timestamp] * 60); // seconds to ticks
+    event.message = mouseMovedMessage;
     acceptedEvent = NPP_HandleEvent(instance, &event);
-    KWQDebug("NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%d\n", acceptedEvent, pt.v, pt.h, event.when);
+    KWQDebug("NPP_HandleEvent(mouseDragged): %d pt.v=%d, pt.h=%d ticks=%u\n", acceptedEvent, pt.v, pt.h, event.when);
 }
 
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = adjustCursorEvent;
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseEntered): %dn", acceptedEvent);
+}
+
+- (void)mouseExited:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = adjustCursorEvent;
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(mouseExited): %d\n", acceptedEvent);
+}
+
+- (void)mouseMoved:(NSEvent *)theEvent{
+    KWQDebug("mouseMoved\n");
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ 
+    EventRecord event;
+    bool acceptedEvent;
+
+    event.what = keyUp;
+    event.message = [theEvent keyCode];
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(keyUp): %d key:%d\n", acceptedEvent, event.message);
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+    EventRecord event;
+    bool acceptedEvent;
+    
+    event.what = keyDown;
+    event.message = [theEvent keyCode];
+    event.when = (uint32)([theEvent timestamp] * 60);
+    acceptedEvent = NPP_HandleEvent(instance, &event);
+    KWQDebug("NPP_HandleEvent(keyDown): %d key:%d\n", acceptedEvent, event.message);
+}
+
+// plug-in to browser calls
+
+-(NPError)getURLNotify:(const char *)url target:(const char *)target notifyData:(void *)notifyData
+{
+    KWQDebug("getURLNotify\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)getURL:(const char *)url target:(const char *)target
+{
+    KWQDebug("getURL\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)postURLNotify:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file notifyData:(void *)notifyData
+{
+    KWQDebug("postURLNotify\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)postURL:(const char *)url target:(const char *)target len:(UInt32)len buf:(const char *)buf file:(NPBool)file
+{
+    KWQDebug("postURL\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)newStream:(NPMIMEType)type target:(const char *)target stream:(NPStream**)stream
+{
+    KWQDebug("newStream\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)write:(NPStream*)stream len:(SInt32)len buffer:(void *)buffer
+{
+    KWQDebug("write\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason
+{
+    KWQDebug("destroyStream\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(void)status:(const char *)message
+{
+    KWQDebug("status\n");
+}
+
+-(NPError)getValue:(NPNVariable)variable value:(void *)value
+{
+    KWQDebug("getValue\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(NPError)setValue:(NPPVariable)variable value:(void *)value
+{
+    KWQDebug("setValue\n");
+    return NPERR_GENERIC_ERROR;
+}
+
+-(void)invalidateRect:(NPRect *)invalidRect
+{
+    KWQDebug("invalidateRect\n");
+}
+
+-(void)invalidateRegion:(NPRegion)invalidateRegion
+{
+    KWQDebug("invalidateRegion\n");
+}
+
+-(void)forceRedraw
+{
+    KWQDebug("forceRedraw\n");
+}
+
+
 -(void)dealloc
 {
     NPError npErr;
diff --git a/WebCore/src/kwq/npapi.h b/WebCore/src/kwq/npapi.h
index 493a08a..2207892 100644
--- a/WebCore/src/kwq/npapi.h
+++ b/WebCore/src/kwq/npapi.h
@@ -111,6 +111,15 @@ typedef struct NP_Port
     int32		porty;
 } NP_Port;
 
+
+/*
+ *  Non-standard event types that can be passed to HandleEvent
+ */
+#define getFocusEvent	    (osEvt + 16)
+#define loseFocusEvent	    (osEvt + 17)
+#define adjustCursorEvent   (osEvt + 18)
+
+
 /*
  * List of variable names for which NPP_GetValue shall be implemented
  */

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list