[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 06:13:46 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 92df002fd95bd38fe1d9e677614662f4c1f3e5ed
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon May 20 20:56:24 2002 +0000
WebFoundation:
Added _IF_looksLikeAbsoluteURL.
* Misc.subproj/IFNSStringExtensions.h:
* Misc.subproj/IFNSStringExtensions.m:
(-[NSString _IF_looksLikeAbsoluteURL]):
WebKit:
Summary:
- Drag & Drop support.
- A whole lot of plug-in clean-up and minor bug fixes.
Moved the following functions from npapi to IFPlugin.
* Plugins.subproj/IFPlugin.m:
(functionPointerForTVector):
(tVectorForFunctionPointer):
Only supply mouse coords when active.
* Plugins.subproj/IFPluginNullEventSender.h:
* Plugins.subproj/IFPluginNullEventSender.m:
(-[IFPluginNullEventSender initializeWithNPP:functionPointer:window:]):
(-[IFPluginNullEventSender dealloc]):
(-[IFPluginNullEventSender sendNullEvents]):
Minor clean-ups
* Plugins.subproj/IFPluginStream.mm:
(-[IFPluginStream dealloc]):
(-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
(-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
(-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
Removed the isMouseDown flag from the following functions
as it was unnecessary.
Cleaned up logging.
* Plugins.subproj/IFPluginView.mm:
(-[IFPluginView modifiersForEvent:]):
(-[IFPluginView getCarbonEvent:withEvent:]):
(-[IFPluginView sendUpdateEvent]):
(-[IFPluginView becomeFirstResponder]):
(-[IFPluginView resignFirstResponder]):
(-[IFPluginView mouseDown:]):
(-[IFPluginView mouseUp:]):
(-[IFPluginView mouseExited:]):
(-[IFPluginView setWindow]):
(-[IFPluginView start]):
(-[IFPluginView stop]):
URLForString now uses _IF_looksLikeAbsoluteURL.
(-[IFPluginView URLForString:]):
Implemented the following:
(-[IFPluginView invalidateRect:]):
(-[IFPluginView invalidateRegion:]):
(-[IFPluginView forceRedraw]):
Put implementation of GetValue SetValue in npapi.
* Plugins.subproj/npapi.h:
* Plugins.subproj/npapi.m:
(NPN_GetValue):
(NPN_SetValue):
Added drag & drop support.
* WebView.subproj/IFWebView.mm:
(-[IFWebView initWithFrame:]):
(-[IFWebView setCanDragFrom:]):
(-[IFWebView canDragFrom]):
(-[IFWebView setCanDragTo:]):
(-[IFWebView canDragTo]):
(-[IFWebView draggingEntered:]):
(-[IFWebView prepareForDragOperation:]):
(-[IFWebView performDragOperation:]):
* WebView.subproj/IFWebViewPrivate.h:
* WebView.subproj/IFWebViewPrivate.mm:
(-[IFWebViewPrivate dealloc]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1177 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index e5ddbe2..dedb551 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,86 @@
+2002-05-20 Chris Blumenberg <cblu at apple.com>
+
+ A whole lot of plug-in clean-up.
+
+ Moved the following functions from npapi to IFPlugin.
+
+ * Plugins.subproj/IFPlugin.m:
+ (functionPointerForTVector):
+ (tVectorForFunctionPointer):
+
+
+ Only supply mouse coords when active.
+
+ * Plugins.subproj/IFPluginNullEventSender.h:
+ * Plugins.subproj/IFPluginNullEventSender.m:
+ (-[IFPluginNullEventSender initializeWithNPP:functionPointer:window:]):
+ (-[IFPluginNullEventSender dealloc]):
+ (-[IFPluginNullEventSender sendNullEvents]):
+
+
+ Minor clean-ups
+
+ * Plugins.subproj/IFPluginStream.mm:
+ (-[IFPluginStream dealloc]):
+ (-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
+ (-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
+ (-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
+
+
+ Removed the isMouseDown flag from the following functions
+ as it was unnecessary.
+
+ Cleaned up logging.
+
+ * Plugins.subproj/IFPluginView.mm:
+ (-[IFPluginView modifiersForEvent:]):
+ (-[IFPluginView getCarbonEvent:withEvent:]):
+ (-[IFPluginView sendUpdateEvent]):
+ (-[IFPluginView becomeFirstResponder]):
+ (-[IFPluginView resignFirstResponder]):
+ (-[IFPluginView mouseDown:]):
+ (-[IFPluginView mouseUp:]):
+ (-[IFPluginView mouseExited:]):
+ (-[IFPluginView setWindow]):
+ (-[IFPluginView start]):
+ (-[IFPluginView stop]):
+
+
+ URLForString now uses _IF_looksLikeAbsoluteURL.
+
+ (-[IFPluginView URLForString:]):
+
+
+ Implemented the following:
+
+ (-[IFPluginView invalidateRect:]):
+ (-[IFPluginView invalidateRegion:]):
+ (-[IFPluginView forceRedraw]):
+
+
+ Put implementation of GetValue SetValue in npapi.
+
+ * Plugins.subproj/npapi.h:
+ * Plugins.subproj/npapi.m:
+ (NPN_GetValue):
+ (NPN_SetValue):
+
+
+ Added drag & drop support.
+
+ * WebView.subproj/IFWebView.mm:
+ (-[IFWebView initWithFrame:]):
+ (-[IFWebView setCanDragFrom:]):
+ (-[IFWebView canDragFrom]):
+ (-[IFWebView setCanDragTo:]):
+ (-[IFWebView canDragTo]):
+ (-[IFWebView draggingEntered:]):
+ (-[IFWebView prepareForDragOperation:]):
+ (-[IFWebView performDragOperation:]):
+ * WebView.subproj/IFWebViewPrivate.h:
+ * WebView.subproj/IFWebViewPrivate.mm:
+ (-[IFWebViewPrivate dealloc]):
+
2002-05-20 John Sullivan <sullivan at apple.com>
Support for bookmark separators
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index e5ddbe2..dedb551 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,86 @@
+2002-05-20 Chris Blumenberg <cblu at apple.com>
+
+ A whole lot of plug-in clean-up.
+
+ Moved the following functions from npapi to IFPlugin.
+
+ * Plugins.subproj/IFPlugin.m:
+ (functionPointerForTVector):
+ (tVectorForFunctionPointer):
+
+
+ Only supply mouse coords when active.
+
+ * Plugins.subproj/IFPluginNullEventSender.h:
+ * Plugins.subproj/IFPluginNullEventSender.m:
+ (-[IFPluginNullEventSender initializeWithNPP:functionPointer:window:]):
+ (-[IFPluginNullEventSender dealloc]):
+ (-[IFPluginNullEventSender sendNullEvents]):
+
+
+ Minor clean-ups
+
+ * Plugins.subproj/IFPluginStream.mm:
+ (-[IFPluginStream dealloc]):
+ (-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
+ (-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
+ (-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
+
+
+ Removed the isMouseDown flag from the following functions
+ as it was unnecessary.
+
+ Cleaned up logging.
+
+ * Plugins.subproj/IFPluginView.mm:
+ (-[IFPluginView modifiersForEvent:]):
+ (-[IFPluginView getCarbonEvent:withEvent:]):
+ (-[IFPluginView sendUpdateEvent]):
+ (-[IFPluginView becomeFirstResponder]):
+ (-[IFPluginView resignFirstResponder]):
+ (-[IFPluginView mouseDown:]):
+ (-[IFPluginView mouseUp:]):
+ (-[IFPluginView mouseExited:]):
+ (-[IFPluginView setWindow]):
+ (-[IFPluginView start]):
+ (-[IFPluginView stop]):
+
+
+ URLForString now uses _IF_looksLikeAbsoluteURL.
+
+ (-[IFPluginView URLForString:]):
+
+
+ Implemented the following:
+
+ (-[IFPluginView invalidateRect:]):
+ (-[IFPluginView invalidateRegion:]):
+ (-[IFPluginView forceRedraw]):
+
+
+ Put implementation of GetValue SetValue in npapi.
+
+ * Plugins.subproj/npapi.h:
+ * Plugins.subproj/npapi.m:
+ (NPN_GetValue):
+ (NPN_SetValue):
+
+
+ Added drag & drop support.
+
+ * WebView.subproj/IFWebView.mm:
+ (-[IFWebView initWithFrame:]):
+ (-[IFWebView setCanDragFrom:]):
+ (-[IFWebView canDragFrom]):
+ (-[IFWebView setCanDragTo:]):
+ (-[IFWebView canDragTo]):
+ (-[IFWebView draggingEntered:]):
+ (-[IFWebView prepareForDragOperation:]):
+ (-[IFWebView performDragOperation:]):
+ * WebView.subproj/IFWebViewPrivate.h:
+ * WebView.subproj/IFWebViewPrivate.mm:
+ (-[IFWebViewPrivate dealloc]):
+
2002-05-20 John Sullivan <sullivan at apple.com>
Support for bookmark separators
diff --git a/WebKit/Plugins.subproj/IFPlugin.m b/WebKit/Plugins.subproj/IFPlugin.m
index 29378d4..676c55f 100644
--- a/WebKit/Plugins.subproj/IFPlugin.m
+++ b/WebKit/Plugins.subproj/IFPlugin.m
@@ -26,6 +26,10 @@
#import "IFPlugin.h"
#import "WebKitDebug.h"
+typedef void (* FunctionPointer) (void);
+typedef void (* TransitionVector) (void);
+FunctionPointer functionPointerForTVector(TransitionVector);
+TransitionVector tVectorForFunctionPointer(FunctionPointer);
@implementation IFPlugin
@@ -414,6 +418,40 @@
@end
+// function pointer converters
+
+FunctionPointer functionPointerForTVector(TransitionVector tvp)
+{
+ uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};
+ uint32 *newGlue = NULL;
+
+ if (tvp != NULL) {
+ newGlue = (uint32 *)malloc(sizeof(temp));
+ if (newGlue != NULL) {
+ unsigned i;
+ for (i = 0; i < 6; i++) newGlue[i] = temp[i];
+ newGlue[0] |= ((UInt32)tvp >> 16);
+ newGlue[1] |= ((UInt32)tvp & 0xFFFF);
+ MakeDataExecutable(newGlue, sizeof(temp));
+ }
+ }
+
+ return (FunctionPointer)newGlue;
+}
+
+TransitionVector tVectorForFunctionPointer(FunctionPointer fp)
+{
+ FunctionPointer *newGlue = NULL;
+ if (fp != NULL) {
+ newGlue = (FunctionPointer *)malloc(2 * sizeof(FunctionPointer));
+ if (newGlue != NULL) {
+ newGlue[0] = fp;
+ newGlue[1] = NULL;
+ }
+ }
+ return (TransitionVector)newGlue;
+}
+
diff --git a/WebKit/Plugins.subproj/IFPluginNullEventSender.h b/WebKit/Plugins.subproj/IFPluginNullEventSender.h
index 8ceb994..30e30b2 100644
--- a/WebKit/Plugins.subproj/IFPluginNullEventSender.h
+++ b/WebKit/Plugins.subproj/IFPluginNullEventSender.h
@@ -10,9 +10,10 @@
NPP instance;
NPP_HandleEventProcPtr NPP_HandleEvent;
bool shouldStop;
+ NSWindow *window;
}
--(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)HandleEventFunction;
+-(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)handleEventFunction window:(NSWindow *)theWindow;
-(void)sendNullEvents;
-(void)stop;
@end
\ No newline at end of file
diff --git a/WebKit/Plugins.subproj/IFPluginNullEventSender.m b/WebKit/Plugins.subproj/IFPluginNullEventSender.m
index e05d9b6..591dbf1 100644
--- a/WebKit/Plugins.subproj/IFPluginNullEventSender.m
+++ b/WebKit/Plugins.subproj/IFPluginNullEventSender.m
@@ -10,21 +10,33 @@
@implementation IFPluginNullEventSender
--(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)HandleEventFunction;
+-(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)handleEventFunction window:(NSWindow *)theWindow
{
instance = pluginInstance;
- NPP_HandleEvent = HandleEventFunction;
+ NPP_HandleEvent = handleEventFunction;
shouldStop = FALSE;
+ window = [theWindow retain];
return self;
}
+-(void) dealloc
+{
+ [window release];
+}
+
-(void)sendNullEvents
{
if (!shouldStop) {
EventRecord event;
bool acceptedEvent;
-
+
[IFPluginView getCarbonEvent:&event];
+
+ // plug-in should not react to cursor position when not active.
+ if(![window isKeyWindow]){
+ event.where.v = 0;
+ event.where.h = 0;
+ }
acceptedEvent = NPP_HandleEvent(instance, &event);
//WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(nullEvent): %d when: %u %d\n", acceptedEvent, (unsigned)event.when, shouldStop);
diff --git a/WebKit/Plugins.subproj/IFPluginStream.mm b/WebKit/Plugins.subproj/IFPluginStream.mm
index 256738d..7bd722e 100644
--- a/WebKit/Plugins.subproj/IFPluginStream.mm
+++ b/WebKit/Plugins.subproj/IFPluginStream.mm
@@ -79,9 +79,10 @@ static NSString *getCarbonPath(NSString *posixPath);
[self stop];
NSFileManager *fileManager = [NSFileManager defaultManager];
- if(path)
+ if(path){
[fileManager removeFileAtPath:path handler:nil];
- [path release];
+ [path release];
+ }
free((void *)npStream.url);
[URL release];
[super dealloc];
@@ -150,7 +151,6 @@ static NSString *getCarbonPath(NSString *posixPath);
// FIXME: Need a better way to get a file name from a URL
filename = [[URL absoluteString] lastPathComponent];
-
if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
// FIXME: Need to use something like mkstemp?
path = [[NSString stringWithFormat:@"/tmp/%@", filename] retain];
@@ -183,7 +183,6 @@ static NSString *getCarbonPath(NSString *posixPath);
- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
{
- // Need webController and data source
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = -1;
loadProgress->bytesSoFar = -1;
@@ -197,7 +196,6 @@ static NSString *getCarbonPath(NSString *posixPath);
- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
{
-
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [sender contentLength];
loadProgress->bytesSoFar = [sender contentLengthReceived];
diff --git a/WebKit/Plugins.subproj/IFPluginView.mm b/WebKit/Plugins.subproj/IFPluginView.mm
index 4797cfb..e498bb1 100644
--- a/WebKit/Plugins.subproj/IFPluginView.mm
+++ b/WebKit/Plugins.subproj/IFPluginView.mm
@@ -26,6 +26,7 @@
#import <IFPluginNullEventSender.h>
#import "IFNullPluginView.h"
+#import <WebFoundation/IFNSStringExtensions.h>
@implementation IFPluginView
@@ -47,14 +48,15 @@
[[self class] getCarbonEvent:carbonEvent];
}
-- (EventModifiers)modifiersForEvent:(NSEvent *)event isMouseDown:(BOOL)isMouseDown
+- (EventModifiers)modifiersForEvent:(NSEvent *)event
{
EventModifiers modifiers;
unsigned int modifierFlags = [event modifierFlags];
+ NSEventType eventType = [event type];
modifiers = 0;
- if (!isMouseDown)
+ if (eventType != NSLeftMouseDown && eventType != NSRightMouseDown)
modifiers |= btnState;
if (modifierFlags & NSCommandKeyMask)
@@ -69,13 +71,13 @@
if (modifierFlags & NSAlternateKeyMask)
modifiers |= optionKey;
- if (modifierFlags & NSControlKeyMask)
+ if (modifierFlags & NSControlKeyMask || eventType == NSRightMouseDown)
modifiers |= controlKey;
return modifiers;
}
-- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent isMouseDown:(BOOL)isMouseDown
+- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent
{
NSPoint where;
@@ -86,12 +88,7 @@
carbonEvent->when = (UInt32)([cocoaEvent timestamp] * 60); // seconds to ticks
carbonEvent->where.h = (short)where.x;
carbonEvent->where.v = (short)(NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - where.y);
- carbonEvent->modifiers = [self modifiersForEvent:cocoaEvent isMouseDown:isMouseDown];
-}
-
-- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent
-{
- [self getCarbonEvent:carbonEvent withEvent:cocoaEvent isMouseDown:Button()];
+ carbonEvent->modifiers = [self modifiersForEvent:cocoaEvent];
}
-(void)sendActivateEvent:(BOOL)activate
@@ -121,7 +118,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(updateEvt): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(updateEvt): %d\n", acceptedEvent);
}
-(BOOL)acceptsFirstResponder
@@ -139,7 +136,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(getFocusEvent): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(getFocusEvent): %d\n", acceptedEvent);
return YES;
}
@@ -153,7 +150,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(loseFocusEvent): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(loseFocusEvent): %d\n", acceptedEvent);
return YES;
}
@@ -163,12 +160,12 @@
EventRecord event;
bool acceptedEvent;
- [self getCarbonEvent:&event withEvent:theEvent isMouseDown:YES];
+ [self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseDown;
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%lu\n", acceptedEvent, event.where.v, event.where.h, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
}
-(void)mouseUp:(NSEvent *)theEvent
@@ -176,12 +173,12 @@
EventRecord event;
bool acceptedEvent;
- [self getCarbonEvent:&event withEvent:theEvent isMouseDown:NO];
+ [self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseUp;
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%lu\n", acceptedEvent, event.where.v, event.where.h, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
}
- (void)mouseEntered:(NSEvent *)theEvent
@@ -201,13 +198,16 @@
{
EventRecord event;
bool acceptedEvent;
-
+
[self getCarbonEvent:&event withEvent:theEvent];
event.what = adjustCursorEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseExited): %d\n", acceptedEvent);
+
+ // Set cursor back to arrow cursor.
+ [[NSCursor arrowCursor] set];
}
- (void)keyUp:(NSEvent *)theEvent
@@ -381,7 +381,7 @@ static char *newCString(NSString *string)
window.type = NPWindowTypeWindow;
npErr = NPP_SetWindow(instance, &window);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=%d\n", npErr, (int)nPort.port);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=0x%08lx\n", npErr, (int)nPort.port);
}
@@ -440,7 +440,7 @@ static char *newCString(NSString *string)
}
}
- eventSender = [[IFPluginNullEventSender alloc] initializeWithNPP:instance functionPointer:NPP_HandleEvent];
+ eventSender = [[IFPluginNullEventSender alloc] initializeWithNPP:instance functionPointer:NPP_HandleEvent window:theWindow];
[eventSender sendNullEvents];
trackingTag = [self addTrackingRect:[self bounds] owner:self userData:nil assumeInside:NO];
@@ -458,14 +458,26 @@ static char *newCString(NSString *string)
return;
isStarted = NO;
- [self removeTrackingRect:trackingTag];
+ [self removeTrackingRect:trackingTag];
+
+ // Stop any active streams
[streams makeObjectsPerformSelector:@selector(stop)];
+
+ // Stop the null events
[eventSender stop];
[eventSender release];
+
+ // Set cursor back to arrow cursor
+ [[NSCursor arrowCursor] set];
+
+ // Stop notifications
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ // Release web objects here to avoid circular retain
[webController release];
[webFrame release];
[webDataSource release];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+
npErr = NPP_Destroy(instance, NULL);
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_Destroy: %d\n", npErr);
}
@@ -536,8 +548,7 @@ static char *newCString(NSString *string)
- (NSURL *)URLForString:(NSString *)URLString
{
- //FIXME: Do plug-ins only request http?
- if([URLString hasPrefix:@"http://"])
+ if([URLString _IF_looksLikeAbsoluteURL])
return [NSURL URLWithString:URLString];
else
return [NSURL URLWithString:URLString relativeToURL:baseURL];
@@ -667,30 +678,21 @@ static char *newCString(NSString *string)
}
}
--(NPError)getValue:(NPNVariable)variable value:(void *)value
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_GetValue\n");
- return NPERR_GENERIC_ERROR;
-}
-
--(NPError)setValue:(NPPVariable)variable value:(void *)value
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_SetValue\n");
- return NPERR_GENERIC_ERROR;
-}
-
-(void)invalidateRect:(NPRect *)invalidRect
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_InvalidateRect\n");
}
-(void)invalidateRegion:(NPRegion)invalidateRegion
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_InvalidateRegion\n");
}
-(void)forceRedraw
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "forceRedraw\n");
}
diff --git a/WebKit/Plugins.subproj/WebPlugin.m b/WebKit/Plugins.subproj/WebPlugin.m
index 29378d4..676c55f 100644
--- a/WebKit/Plugins.subproj/WebPlugin.m
+++ b/WebKit/Plugins.subproj/WebPlugin.m
@@ -26,6 +26,10 @@
#import "IFPlugin.h"
#import "WebKitDebug.h"
+typedef void (* FunctionPointer) (void);
+typedef void (* TransitionVector) (void);
+FunctionPointer functionPointerForTVector(TransitionVector);
+TransitionVector tVectorForFunctionPointer(FunctionPointer);
@implementation IFPlugin
@@ -414,6 +418,40 @@
@end
+// function pointer converters
+
+FunctionPointer functionPointerForTVector(TransitionVector tvp)
+{
+ uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};
+ uint32 *newGlue = NULL;
+
+ if (tvp != NULL) {
+ newGlue = (uint32 *)malloc(sizeof(temp));
+ if (newGlue != NULL) {
+ unsigned i;
+ for (i = 0; i < 6; i++) newGlue[i] = temp[i];
+ newGlue[0] |= ((UInt32)tvp >> 16);
+ newGlue[1] |= ((UInt32)tvp & 0xFFFF);
+ MakeDataExecutable(newGlue, sizeof(temp));
+ }
+ }
+
+ return (FunctionPointer)newGlue;
+}
+
+TransitionVector tVectorForFunctionPointer(FunctionPointer fp)
+{
+ FunctionPointer *newGlue = NULL;
+ if (fp != NULL) {
+ newGlue = (FunctionPointer *)malloc(2 * sizeof(FunctionPointer));
+ if (newGlue != NULL) {
+ newGlue[0] = fp;
+ newGlue[1] = NULL;
+ }
+ }
+ return (TransitionVector)newGlue;
+}
+
diff --git a/WebKit/Plugins.subproj/WebPluginNullEventSender.h b/WebKit/Plugins.subproj/WebPluginNullEventSender.h
index 8ceb994..30e30b2 100644
--- a/WebKit/Plugins.subproj/WebPluginNullEventSender.h
+++ b/WebKit/Plugins.subproj/WebPluginNullEventSender.h
@@ -10,9 +10,10 @@
NPP instance;
NPP_HandleEventProcPtr NPP_HandleEvent;
bool shouldStop;
+ NSWindow *window;
}
--(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)HandleEventFunction;
+-(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)handleEventFunction window:(NSWindow *)theWindow;
-(void)sendNullEvents;
-(void)stop;
@end
\ No newline at end of file
diff --git a/WebKit/Plugins.subproj/WebPluginNullEventSender.m b/WebKit/Plugins.subproj/WebPluginNullEventSender.m
index e05d9b6..591dbf1 100644
--- a/WebKit/Plugins.subproj/WebPluginNullEventSender.m
+++ b/WebKit/Plugins.subproj/WebPluginNullEventSender.m
@@ -10,21 +10,33 @@
@implementation IFPluginNullEventSender
--(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)HandleEventFunction;
+-(id)initializeWithNPP:(NPP)pluginInstance functionPointer:(NPP_HandleEventProcPtr)handleEventFunction window:(NSWindow *)theWindow
{
instance = pluginInstance;
- NPP_HandleEvent = HandleEventFunction;
+ NPP_HandleEvent = handleEventFunction;
shouldStop = FALSE;
+ window = [theWindow retain];
return self;
}
+-(void) dealloc
+{
+ [window release];
+}
+
-(void)sendNullEvents
{
if (!shouldStop) {
EventRecord event;
bool acceptedEvent;
-
+
[IFPluginView getCarbonEvent:&event];
+
+ // plug-in should not react to cursor position when not active.
+ if(![window isKeyWindow]){
+ event.where.v = 0;
+ event.where.h = 0;
+ }
acceptedEvent = NPP_HandleEvent(instance, &event);
//WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(nullEvent): %d when: %u %d\n", acceptedEvent, (unsigned)event.when, shouldStop);
diff --git a/WebKit/Plugins.subproj/WebPluginStream.m b/WebKit/Plugins.subproj/WebPluginStream.m
index 256738d..7bd722e 100644
--- a/WebKit/Plugins.subproj/WebPluginStream.m
+++ b/WebKit/Plugins.subproj/WebPluginStream.m
@@ -79,9 +79,10 @@ static NSString *getCarbonPath(NSString *posixPath);
[self stop];
NSFileManager *fileManager = [NSFileManager defaultManager];
- if(path)
+ if(path){
[fileManager removeFileAtPath:path handler:nil];
- [path release];
+ [path release];
+ }
free((void *)npStream.url);
[URL release];
[super dealloc];
@@ -150,7 +151,6 @@ static NSString *getCarbonPath(NSString *posixPath);
// FIXME: Need a better way to get a file name from a URL
filename = [[URL absoluteString] lastPathComponent];
-
if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
// FIXME: Need to use something like mkstemp?
path = [[NSString stringWithFormat:@"/tmp/%@", filename] retain];
@@ -183,7 +183,6 @@ static NSString *getCarbonPath(NSString *posixPath);
- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
{
- // Need webController and data source
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = -1;
loadProgress->bytesSoFar = -1;
@@ -197,7 +196,6 @@ static NSString *getCarbonPath(NSString *posixPath);
- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
{
-
IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
loadProgress->totalToLoad = [sender contentLength];
loadProgress->bytesSoFar = [sender contentLengthReceived];
diff --git a/WebKit/Plugins.subproj/WebPluginView.m b/WebKit/Plugins.subproj/WebPluginView.m
index 4797cfb..e498bb1 100644
--- a/WebKit/Plugins.subproj/WebPluginView.m
+++ b/WebKit/Plugins.subproj/WebPluginView.m
@@ -26,6 +26,7 @@
#import <IFPluginNullEventSender.h>
#import "IFNullPluginView.h"
+#import <WebFoundation/IFNSStringExtensions.h>
@implementation IFPluginView
@@ -47,14 +48,15 @@
[[self class] getCarbonEvent:carbonEvent];
}
-- (EventModifiers)modifiersForEvent:(NSEvent *)event isMouseDown:(BOOL)isMouseDown
+- (EventModifiers)modifiersForEvent:(NSEvent *)event
{
EventModifiers modifiers;
unsigned int modifierFlags = [event modifierFlags];
+ NSEventType eventType = [event type];
modifiers = 0;
- if (!isMouseDown)
+ if (eventType != NSLeftMouseDown && eventType != NSRightMouseDown)
modifiers |= btnState;
if (modifierFlags & NSCommandKeyMask)
@@ -69,13 +71,13 @@
if (modifierFlags & NSAlternateKeyMask)
modifiers |= optionKey;
- if (modifierFlags & NSControlKeyMask)
+ if (modifierFlags & NSControlKeyMask || eventType == NSRightMouseDown)
modifiers |= controlKey;
return modifiers;
}
-- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent isMouseDown:(BOOL)isMouseDown
+- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent
{
NSPoint where;
@@ -86,12 +88,7 @@
carbonEvent->when = (UInt32)([cocoaEvent timestamp] * 60); // seconds to ticks
carbonEvent->where.h = (short)where.x;
carbonEvent->where.v = (short)(NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - where.y);
- carbonEvent->modifiers = [self modifiersForEvent:cocoaEvent isMouseDown:isMouseDown];
-}
-
-- (void)getCarbonEvent:(EventRecord *)carbonEvent withEvent:(NSEvent *)cocoaEvent
-{
- [self getCarbonEvent:carbonEvent withEvent:cocoaEvent isMouseDown:Button()];
+ carbonEvent->modifiers = [self modifiersForEvent:cocoaEvent];
}
-(void)sendActivateEvent:(BOOL)activate
@@ -121,7 +118,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(updateEvt): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(updateEvt): %d\n", acceptedEvent);
}
-(BOOL)acceptsFirstResponder
@@ -139,7 +136,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(getFocusEvent): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(getFocusEvent): %d\n", acceptedEvent);
return YES;
}
@@ -153,7 +150,7 @@
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(loseFocusEvent): %d when: %lu\n", acceptedEvent, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(loseFocusEvent): %d\n", acceptedEvent);
return YES;
}
@@ -163,12 +160,12 @@
EventRecord event;
bool acceptedEvent;
- [self getCarbonEvent:&event withEvent:theEvent isMouseDown:YES];
+ [self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseDown;
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d ticks=%lu\n", acceptedEvent, event.where.v, event.where.h, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseDown): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
}
-(void)mouseUp:(NSEvent *)theEvent
@@ -176,12 +173,12 @@
EventRecord event;
bool acceptedEvent;
- [self getCarbonEvent:&event withEvent:theEvent isMouseDown:NO];
+ [self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseUp;
acceptedEvent = NPP_HandleEvent(instance, &event);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d ticks=%lu\n", acceptedEvent, event.where.v, event.where.h, event.when);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
}
- (void)mouseEntered:(NSEvent *)theEvent
@@ -201,13 +198,16 @@
{
EventRecord event;
bool acceptedEvent;
-
+
[self getCarbonEvent:&event withEvent:theEvent];
event.what = adjustCursorEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseExited): %d\n", acceptedEvent);
+
+ // Set cursor back to arrow cursor.
+ [[NSCursor arrowCursor] set];
}
- (void)keyUp:(NSEvent *)theEvent
@@ -381,7 +381,7 @@ static char *newCString(NSString *string)
window.type = NPWindowTypeWindow;
npErr = NPP_SetWindow(instance, &window);
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=%d\n", npErr, (int)nPort.port);
+ WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_SetWindow: %d, port=0x%08lx\n", npErr, (int)nPort.port);
}
@@ -440,7 +440,7 @@ static char *newCString(NSString *string)
}
}
- eventSender = [[IFPluginNullEventSender alloc] initializeWithNPP:instance functionPointer:NPP_HandleEvent];
+ eventSender = [[IFPluginNullEventSender alloc] initializeWithNPP:instance functionPointer:NPP_HandleEvent window:theWindow];
[eventSender sendNullEvents];
trackingTag = [self addTrackingRect:[self bounds] owner:self userData:nil assumeInside:NO];
@@ -458,14 +458,26 @@ static char *newCString(NSString *string)
return;
isStarted = NO;
- [self removeTrackingRect:trackingTag];
+ [self removeTrackingRect:trackingTag];
+
+ // Stop any active streams
[streams makeObjectsPerformSelector:@selector(stop)];
+
+ // Stop the null events
[eventSender stop];
[eventSender release];
+
+ // Set cursor back to arrow cursor
+ [[NSCursor arrowCursor] set];
+
+ // Stop notifications
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ // Release web objects here to avoid circular retain
[webController release];
[webFrame release];
[webDataSource release];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+
npErr = NPP_Destroy(instance, NULL);
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_Destroy: %d\n", npErr);
}
@@ -536,8 +548,7 @@ static char *newCString(NSString *string)
- (NSURL *)URLForString:(NSString *)URLString
{
- //FIXME: Do plug-ins only request http?
- if([URLString hasPrefix:@"http://"])
+ if([URLString _IF_looksLikeAbsoluteURL])
return [NSURL URLWithString:URLString];
else
return [NSURL URLWithString:URLString relativeToURL:baseURL];
@@ -667,30 +678,21 @@ static char *newCString(NSString *string)
}
}
--(NPError)getValue:(NPNVariable)variable value:(void *)value
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_GetValue\n");
- return NPERR_GENERIC_ERROR;
-}
-
--(NPError)setValue:(NPPVariable)variable value:(void *)value
-{
- WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_SetValue\n");
- return NPERR_GENERIC_ERROR;
-}
-
-(void)invalidateRect:(NPRect *)invalidRect
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_InvalidateRect\n");
}
-(void)invalidateRegion:(NPRegion)invalidateRegion
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPN_InvalidateRegion\n");
}
-(void)forceRedraw
{
+ [self sendUpdateEvent];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "forceRedraw\n");
}
diff --git a/WebKit/Plugins.subproj/npapi.h b/WebKit/Plugins.subproj/npapi.h
index 82fadf7..50cdcaa 100644
--- a/WebKit/Plugins.subproj/npapi.h
+++ b/WebKit/Plugins.subproj/npapi.h
@@ -341,11 +341,6 @@ typedef NPError (* mainFuncPtr)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownPr
typedef NPError (* initializeFuncPtr)(NPNetscapeFuncs*);
typedef NPError (* getEntryPointsFuncPtr)(NPPluginFuncs*);
-typedef void (* FunctionPointer) (void);
-typedef void (* TransitionVector) (void);
-FunctionPointer functionPointerForTVector(TransitionVector);
-TransitionVector tVectorForFunctionPointer(FunctionPointer);
-
/*
* NPN_* functions are provided by the navigator and called by the plugin.
*/
diff --git a/WebKit/Plugins.subproj/npapi.m b/WebKit/Plugins.subproj/npapi.m
index 8747428..44b01e4 100644
--- a/WebKit/Plugins.subproj/npapi.m
+++ b/WebKit/Plugins.subproj/npapi.m
@@ -132,16 +132,17 @@ void NPN_Status(NPP instance, const char* message)
[plugin status:message];
}
+// According to the plug-in API documentation,
+// NPN_GetValue and NPN_SetValue are not used in Mac OS.
+
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
- IFPluginView *plugin = (IFPluginView *)instance->ndata;
- return [plugin getValue:variable value:value];
+ return NPERR_GENERIC_ERROR;
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
- IFPluginView *plugin = (IFPluginView *)instance->ndata;
- return [plugin setValue:variable value:value];
+ return NPERR_GENERIC_ERROR;
}
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
@@ -172,36 +173,3 @@ void* NPN_GetJavaPeer(NPP instance)
return NULL;
}
-// function pointer converters
-
-FunctionPointer functionPointerForTVector(TransitionVector tvp)
-{
- uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};
- uint32 *newGlue = NULL;
-
- if (tvp != NULL) {
- newGlue = (uint32 *)malloc(sizeof(temp));
- if (newGlue != NULL) {
- unsigned i;
- for (i = 0; i < 6; i++) newGlue[i] = temp[i];
- newGlue[0] |= ((UInt32)tvp >> 16);
- newGlue[1] |= ((UInt32)tvp & 0xFFFF);
- MakeDataExecutable(newGlue, sizeof(temp));
- }
- }
-
- return (FunctionPointer)newGlue;
-}
-
-TransitionVector tVectorForFunctionPointer(FunctionPointer fp)
-{
- FunctionPointer *newGlue = NULL;
- if (fp != NULL) {
- newGlue = (FunctionPointer *)malloc(2 * sizeof(FunctionPointer));
- if (newGlue != NULL) {
- newGlue[0] = fp;
- newGlue[1] = NULL;
- }
- }
- return (TransitionVector)newGlue;
-}
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFWebView.mm
index 9637a38..3591dc9 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFWebView.mm
@@ -3,8 +3,10 @@
*/
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFBaseWebController.h>
#import <WebKit/IFDynamicScrollBarsView.h>
#import <WebKit/IFException.h>
@@ -12,6 +14,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/WebKitDebug.h>
+#import <WebFoundation/IFNSStringExtensions.h>
+
// Needed for the mouse move notification.
#import <AppKit/NSResponder_Private.h>
@@ -37,10 +41,14 @@
_private->isFlipped = YES;
_private->needsLayout = YES;
+ _private->canDragTo = YES;
+ _private->canDragFrom = YES;
+ _private->draggingTypes = [[NSArray arrayWithObjects:@"NSFilenamesPboardType", @"NSURLPboardType", @"NSStringPboardType", nil] retain];
+ [self registerForDraggedTypes:_private->draggingTypes];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
-
+
return self;
}
@@ -195,24 +203,87 @@
// Drag and drop links and images. Others?
- (void)setCanDragFrom: (BOOL)flag
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setCanDragFrom: is not implemented"];
+ _private->canDragFrom = flag;
}
- (BOOL)canDragFrom
{
- return NO;
+ return _private->canDragFrom;
}
- (void)setCanDragTo: (BOOL)flag
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setCanDragTo: is not implemented"];
+ _private->canDragTo = flag;
}
- (BOOL)canDragTo
{
- return NO;
+ return _private->canDragTo;
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+ NSString *dragType, *file, *URLString;
+ NSArray *files;
+
+ if(![self canDragTo])
+ return NSDragOperationNone;
+
+ dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
+ if([dragType isEqualToString:@"NSFilenamesPboardType"]){
+ files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
+
+ // FIXME: We only look at the first dragged file (2931225)
+ file = [files objectAtIndex:0];
+
+ // FIXME: Need the file type database to know what files we handle (2927855)
+ if([[file pathExtension] isEqualToString:@"html"] || [[file pathExtension] isEqualToString:@"htm"])
+ return NSDragOperationCopy;
+ }else if([dragType isEqualToString:@"NSURLPboardType"]){
+ return NSDragOperationCopy;
+ }else if([dragType isEqualToString:@"NSStringPboardType"]){
+ URLString = [[sender draggingPasteboard] stringForType:@"NSStringPboardType"];
+ if([URLString _IF_looksLikeAbsoluteURL])
+ return NSDragOperationCopy;
+ }
+ return NSDragOperationNone;
}
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
+{
+ return YES;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+{
+ IFWebDataSource *dataSource;
+ IFWebFrame *frame;
+ NSArray *files;
+ NSString *file, *dragType;
+ NSURL *URL=nil;
+
+ dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
+ if([dragType isEqualToString:@"NSFilenamesPboardType"]){
+ files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
+ file = [files objectAtIndex:0];
+ URL = [NSURL fileURLWithPath:file];
+ }else if([dragType isEqualToString:@"NSURLPboardType"]){
+ // FIXME: Is this the right way to get the URL? How to test?
+ URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSURLPboardType"]];
+ }else if([dragType isEqualToString:@"NSStringPboardType"]){
+ URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSStringPboardType"]];
+ }
+
+ if(!URL)
+ return NO;
+
+ dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
+ frame = [[self controller] frameForView:self];
+ [frame setProvisionalDataSource:dataSource];
+ [frame startLoading];
+
+ return YES;
+}
// Returns an array of built-in context menu items for this node.
// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
diff --git a/WebKit/WebView.subproj/IFWebViewPrivate.h b/WebKit/WebView.subproj/IFWebViewPrivate.h
index d02044b..df47820 100644
--- a/WebKit/WebView.subproj/IFWebViewPrivate.h
+++ b/WebKit/WebView.subproj/IFWebViewPrivate.h
@@ -21,6 +21,9 @@ class KHTMLView;
bool isFlipped;
bool needsLayout;
bool needsToApplyStyles;
+ bool canDragTo;
+ bool canDragFrom;
+ NSArray *draggingTypes;
}
@end
diff --git a/WebKit/WebView.subproj/IFWebViewPrivate.mm b/WebKit/WebView.subproj/IFWebViewPrivate.mm
index 4019b70..2a180d1 100644
--- a/WebKit/WebView.subproj/IFWebViewPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebViewPrivate.mm
@@ -21,7 +21,8 @@
{
[controller release];
[frameScrollView release];
-
+ [draggingTypes release];
+
//if (widget)
// delete widget;
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index 9637a38..3591dc9 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -3,8 +3,10 @@
*/
#import <WebKit/IFWebView.h>
#import <WebKit/IFWebViewPrivate.h>
+#import <WebKit/IFWebFrame.h>
#import <WebKit/IFWebDataSource.h>
#import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFWebController.h>
#import <WebKit/IFBaseWebController.h>
#import <WebKit/IFDynamicScrollBarsView.h>
#import <WebKit/IFException.h>
@@ -12,6 +14,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/WebKitDebug.h>
+#import <WebFoundation/IFNSStringExtensions.h>
+
// Needed for the mouse move notification.
#import <AppKit/NSResponder_Private.h>
@@ -37,10 +41,14 @@
_private->isFlipped = YES;
_private->needsLayout = YES;
+ _private->canDragTo = YES;
+ _private->canDragFrom = YES;
+ _private->draggingTypes = [[NSArray arrayWithObjects:@"NSFilenamesPboardType", @"NSURLPboardType", @"NSStringPboardType", nil] retain];
+ [self registerForDraggedTypes:_private->draggingTypes];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(windowResized:) name: NSWindowDidResizeNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mouseMovedNotification:) name: NSMouseMovedNotification object: nil];
-
+
return self;
}
@@ -195,24 +203,87 @@
// Drag and drop links and images. Others?
- (void)setCanDragFrom: (BOOL)flag
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setCanDragFrom: is not implemented"];
+ _private->canDragFrom = flag;
}
- (BOOL)canDragFrom
{
- return NO;
+ return _private->canDragFrom;
}
- (void)setCanDragTo: (BOOL)flag
{
- [NSException raise:IFMethodNotYetImplemented format:@"IFWebView::setCanDragTo: is not implemented"];
+ _private->canDragTo = flag;
}
- (BOOL)canDragTo
{
- return NO;
+ return _private->canDragTo;
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
+{
+ NSString *dragType, *file, *URLString;
+ NSArray *files;
+
+ if(![self canDragTo])
+ return NSDragOperationNone;
+
+ dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
+ if([dragType isEqualToString:@"NSFilenamesPboardType"]){
+ files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
+
+ // FIXME: We only look at the first dragged file (2931225)
+ file = [files objectAtIndex:0];
+
+ // FIXME: Need the file type database to know what files we handle (2927855)
+ if([[file pathExtension] isEqualToString:@"html"] || [[file pathExtension] isEqualToString:@"htm"])
+ return NSDragOperationCopy;
+ }else if([dragType isEqualToString:@"NSURLPboardType"]){
+ return NSDragOperationCopy;
+ }else if([dragType isEqualToString:@"NSStringPboardType"]){
+ URLString = [[sender draggingPasteboard] stringForType:@"NSStringPboardType"];
+ if([URLString _IF_looksLikeAbsoluteURL])
+ return NSDragOperationCopy;
+ }
+ return NSDragOperationNone;
}
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
+{
+ return YES;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
+{
+ IFWebDataSource *dataSource;
+ IFWebFrame *frame;
+ NSArray *files;
+ NSString *file, *dragType;
+ NSURL *URL=nil;
+
+ dragType = [[sender draggingPasteboard] availableTypeFromArray:_private->draggingTypes];
+ if([dragType isEqualToString:@"NSFilenamesPboardType"]){
+ files = [[sender draggingPasteboard] propertyListForType:@"NSFilenamesPboardType"];
+ file = [files objectAtIndex:0];
+ URL = [NSURL fileURLWithPath:file];
+ }else if([dragType isEqualToString:@"NSURLPboardType"]){
+ // FIXME: Is this the right way to get the URL? How to test?
+ URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSURLPboardType"]];
+ }else if([dragType isEqualToString:@"NSStringPboardType"]){
+ URL = [NSURL URLWithString:[[sender draggingPasteboard] stringForType:@"NSStringPboardType"]];
+ }
+
+ if(!URL)
+ return NO;
+
+ dataSource = [[[IFWebDataSource alloc] initWithURL:URL] autorelease];
+ frame = [[self controller] frameForView:self];
+ [frame setProvisionalDataSource:dataSource];
+ [frame startLoading];
+
+ return YES;
+}
// Returns an array of built-in context menu items for this node.
// Generally called by IFContextMenuHandlers from contextMenuItemsForNode:
diff --git a/WebKit/WebView.subproj/WebFrameViewInternal.h b/WebKit/WebView.subproj/WebFrameViewInternal.h
index d02044b..df47820 100644
--- a/WebKit/WebView.subproj/WebFrameViewInternal.h
+++ b/WebKit/WebView.subproj/WebFrameViewInternal.h
@@ -21,6 +21,9 @@ class KHTMLView;
bool isFlipped;
bool needsLayout;
bool needsToApplyStyles;
+ bool canDragTo;
+ bool canDragFrom;
+ NSArray *draggingTypes;
}
@end
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.h b/WebKit/WebView.subproj/WebFrameViewPrivate.h
index d02044b..df47820 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.h
+++ b/WebKit/WebView.subproj/WebFrameViewPrivate.h
@@ -21,6 +21,9 @@ class KHTMLView;
bool isFlipped;
bool needsLayout;
bool needsToApplyStyles;
+ bool canDragTo;
+ bool canDragFrom;
+ NSArray *draggingTypes;
}
@end
diff --git a/WebKit/WebView.subproj/WebFrameViewPrivate.m b/WebKit/WebView.subproj/WebFrameViewPrivate.m
index 4019b70..2a180d1 100644
--- a/WebKit/WebView.subproj/WebFrameViewPrivate.m
+++ b/WebKit/WebView.subproj/WebFrameViewPrivate.m
@@ -21,7 +21,8 @@
{
[controller release];
[frameScrollView release];
-
+ [draggingTypes release];
+
//if (widget)
// delete widget;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list