Commit 4f74e34e authored by darin's avatar darin
Browse files

Did some minor plugin cleanup, mostly to make sure we don't

	change pages while a plugin is tracking.

        * Plugins.subproj/WebPluginView.h: Add sendEvent and sendUpdateEvent.
	Remove the NPP_HandleEvent method.
        * Plugins.subproj/WebPluginView.m:
        (-[WebNetscapePluginView sendEvent:]): Sets up the "defersCallbacks"
	state, then sends the event.

        * Plugins.subproj/WebNetscapePluginViewPrivate.h: Added.
	This stuff was shared in a different way before, and it
	hadn't even been renamed.
        * WebKit.pbproj/project.pbxproj: Added file.
        * Plugins.subproj/npapi.m: Use the new private header.

        * Plugins.subproj/WebPluginNullEventSender.h: Hold a reference
	to the view.
        * Plugins.subproj/WebPluginNullEventSender.m:
        (-[WebNetscapePluginNullEventSender initWithPluginView:]):
	Retain the view.
        (-[WebNetscapePluginNullEventSender dealloc]): Release the view.
        (-[WebNetscapePluginNullEventSender sendNullEvents]): Use sendEvent:.
        (-[WebNetscapePluginNullEventSender stop]): No need for shouldStop.

        * WebView.subproj/WebDataSourcePrivate.m:
        (-[WebDataSourcePrivate init]): Don't set contentPolicy to an enum value,
	when it's an object reference.
        (-[WebDataSourcePrivate dealloc]): Release contentPolicy to fix a leak.

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView mouseDragged:]): Set draggedURL to nil in the else case,
	it was uninitialized before. Also center the icon better when dragging,
	but shouldn't we be dragging something more than the icon here?

        * Misc.subproj/WebIconDatabase.m: (-[WebIconDatabase defaultIconWithSize:]):
	Add a call to release. Doesn't really plug a leak, but cleaner this way.

        * Plugins.subproj/WebPlugin.m: Tweaks.
        * WebView.subproj/WebMainResourceClient.m: Tweaks only.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b1498730
2002-09-04 Darin Adler <darin@apple.com>
Did some minor plugin cleanup, mostly to make sure we don't
change pages while a plugin is tracking.
* Plugins.subproj/WebPluginView.h: Add sendEvent and sendUpdateEvent.
Remove the NPP_HandleEvent method.
* Plugins.subproj/WebPluginView.m:
(-[WebNetscapePluginView sendEvent:]): Sets up the "defersCallbacks"
state, then sends the event.
* Plugins.subproj/WebNetscapePluginViewPrivate.h: Added.
This stuff was shared in a different way before, and it
hadn't even been renamed.
* WebKit.pbproj/project.pbxproj: Added file.
* Plugins.subproj/npapi.m: Use the new private header.
* Plugins.subproj/WebPluginNullEventSender.h: Hold a reference
to the view.
* Plugins.subproj/WebPluginNullEventSender.m:
(-[WebNetscapePluginNullEventSender initWithPluginView:]):
Retain the view.
(-[WebNetscapePluginNullEventSender dealloc]): Release the view.
(-[WebNetscapePluginNullEventSender sendNullEvents]): Use sendEvent:.
(-[WebNetscapePluginNullEventSender stop]): No need for shouldStop.
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSourcePrivate init]): Don't set contentPolicy to an enum value,
when it's an object reference.
(-[WebDataSourcePrivate dealloc]): Release contentPolicy to fix a leak.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]): Set draggedURL to nil in the else case,
it was uninitialized before. Also center the icon better when dragging,
but shouldn't we be dragging something more than the icon here?
* Misc.subproj/WebIconDatabase.m: (-[WebIconDatabase defaultIconWithSize:]):
Add a call to release. Doesn't really plug a leak, but cleaner this way.
* Plugins.subproj/WebPlugin.m: Tweaks.
* WebView.subproj/WebMainResourceClient.m: Tweaks only.
2002-09-04 Ken Kocienda <kocienda@apple.com>
Made more adjustments for API and behavior change that occurred in WebFoundation,
......
2002-09-04 Darin Adler <darin@apple.com>
Did some minor plugin cleanup, mostly to make sure we don't
change pages while a plugin is tracking.
* Plugins.subproj/WebPluginView.h: Add sendEvent and sendUpdateEvent.
Remove the NPP_HandleEvent method.
* Plugins.subproj/WebPluginView.m:
(-[WebNetscapePluginView sendEvent:]): Sets up the "defersCallbacks"
state, then sends the event.
* Plugins.subproj/WebNetscapePluginViewPrivate.h: Added.
This stuff was shared in a different way before, and it
hadn't even been renamed.
* WebKit.pbproj/project.pbxproj: Added file.
* Plugins.subproj/npapi.m: Use the new private header.
* Plugins.subproj/WebPluginNullEventSender.h: Hold a reference
to the view.
* Plugins.subproj/WebPluginNullEventSender.m:
(-[WebNetscapePluginNullEventSender initWithPluginView:]):
Retain the view.
(-[WebNetscapePluginNullEventSender dealloc]): Release the view.
(-[WebNetscapePluginNullEventSender sendNullEvents]): Use sendEvent:.
(-[WebNetscapePluginNullEventSender stop]): No need for shouldStop.
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSourcePrivate init]): Don't set contentPolicy to an enum value,
when it's an object reference.
(-[WebDataSourcePrivate dealloc]): Release contentPolicy to fix a leak.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]): Set draggedURL to nil in the else case,
it was uninitialized before. Also center the icon better when dragging,
but shouldn't we be dragging something more than the icon here?
* Misc.subproj/WebIconDatabase.m: (-[WebIconDatabase defaultIconWithSize:]):
Add a call to release. Doesn't really plug a leak, but cleaner this way.
* Plugins.subproj/WebPlugin.m: Tweaks.
* WebView.subproj/WebMainResourceClient.m: Tweaks only.
2002-09-04 Ken Kocienda <kocienda@apple.com>
Made more adjustments for API and behavior change that occurred in WebFoundation,
......
......@@ -137,6 +137,7 @@ - (NSImage *)defaultIconWithSize:(NSSize)size
if (pathForDefaultImage != nil) {
NSImage *icon = [[NSImage alloc] initByReferencingFile: pathForDefaultImage];
_private->defaultIcons = [[NSMutableArray arrayWithObject:icon] retain];
[icon release];
}
}
......
//
// WebPluginViewPrivate.h
// WebKit
//
// Created by Darin Adler on Tue Aug 27 2002.
// Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
//
#import <WebPluginView.h>
@interface WebNetscapePluginView (WebNPPCallbacks)
- (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
......@@ -440,7 +440,7 @@ - (NSString *)description{
FunctionPointer functionPointerForTVector(TransitionVector tvp)
{
uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};
const uint32 temp[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420};
uint32 *newGlue = NULL;
if (tvp != NULL) {
......@@ -469,8 +469,3 @@ TransitionVector tVectorForFunctionPointer(FunctionPointer fp)
}
return (TransitionVector)newGlue;
}
......@@ -4,18 +4,16 @@
*/
#import <Foundation/Foundation.h>
#import <npapi.h>
@class WebNetscapePluginView;
@interface WebNetscapePluginNullEventSender : NSObject{
NPP instance;
NPP_HandleEventProcPtr NPP_HandleEvent;
bool shouldStop;
NSWindow *window;
@interface WebNetscapePluginNullEventSender : NSObject
{
WebNetscapePluginView *view;
}
-(id)initWithPluginView:(WebNetscapePluginView *)pluginView;
-(void)sendNullEvents;
-(void)stop;
@end
\ No newline at end of file
@end
......@@ -13,48 +13,41 @@ @implementation WebNetscapePluginNullEventSender
-(id)initWithPluginView:(WebNetscapePluginView *)pluginView
{
[super init];
instance = [pluginView pluginInstance];
NPP_HandleEvent = [pluginView NPP_HandleEvent];
window = [[pluginView window] retain];
view = [pluginView retain];
return self;
}
-(void) dealloc
-(void)dealloc
{
[window release];
[view release];
[super dealloc];
}
-(void)sendNullEvents
{
if (!shouldStop) {
EventRecord event;
BOOL acceptedEvent;
[WebNetscapePluginView 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);
[self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:.01];
EventRecord event;
[WebNetscapePluginView getCarbonEvent:&event];
// plug-in should not react to cursor position when not active.
// FIXME: How does passing a v and h of 0 prevent it from reacting to the cursor position?
if (![[view window] isKeyWindow]) {
event.where.v = 0;
event.where.h = 0;
}
[view sendEvent:&event];
//WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(nullEvent): %d when: %u %d\n", acceptedEvent, (unsigned)event.when, shouldStop);
// FIXME: Why .01? Why not 0? Why not a larger number?
[self performSelector:@selector(sendNullEvents) withObject:nil afterDelay:.01];
}
-(void) stop
-(void)stop
{
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "Stopping null events\n");
shouldStop = TRUE;
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(sendNullEvents) object:nil];
}
@end
......@@ -54,10 +54,14 @@
}
- (id)initWithFrame:(NSRect)r plugin:(WebNetscapePlugin *)plugin URL:(NSURL *)URL baseURL:(NSURL *)baseURL mime:(NSString *)mimeType arguments:(NSDictionary *)arguments;
-(void)stop;
- (void)stop;
- (WebDataSource *)webDataSource;
- (WebController *)webController;
+(void)getCarbonEvent:(EventRecord *)carbonEvent;
+ (void)getCarbonEvent:(EventRecord *)carbonEvent;
- (BOOL)sendEvent:(EventRecord *)event;
- (BOOL)sendUpdateEvent;
- (NPP)pluginInstance;
- (NPP_NewStreamProcPtr)NPP_NewStream;
......@@ -66,6 +70,5 @@
- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile;
- (NPP_DestroyStreamProcPtr)NPP_DestroyStream;
- (NPP_URLNotifyProcPtr)NPP_URLNotify;
- (NPP_HandleEventProcPtr) NPP_HandleEvent;
@end
......@@ -7,6 +7,7 @@
#import <WebKit/WebPluginView.h>
#import <WebKit/WebController.h>
#import <WebKit/WebControllerPrivate.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebDataSource.h>
......@@ -110,10 +111,25 @@ - (UInt32)keyMessageForEvent:(NSEvent *)theEvent
return message;
}
-(void)sendActivateEvent:(BOOL)activate
- (BOOL)sendEvent:(EventRecord *)event
{
BOOL defers = [webController _defersCallbacks];
if (!defers) {
[webController _setDefersCallbacks:YES];
}
BOOL acceptedEvent = NPP_HandleEvent(instance, event);
if (!defers) {
[webController _setDefersCallbacks:NO];
}
return acceptedEvent;
}
- (void)sendActivateEvent:(BOOL)activate
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event];
event.what = activateEvt;
......@@ -122,27 +138,28 @@ -(void)sendActivateEvent:(BOOL)activate
if (activate)
event.modifiers |= activeFlag;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(activateEvent): %d isActive: %d\n", acceptedEvent, (event.modifiers & activeFlag));
}
- (void)sendUpdateEvent
- (BOOL)sendUpdateEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event];
event.what = updateEvt;
WindowRef windowRef = [[self window] _windowRef];
event.message = (UInt32)windowRef;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(updateEvt): %d\n", acceptedEvent);
return acceptedEvent;
}
-(BOOL)acceptsFirstResponder
- (BOOL)acceptsFirstResponder
{
return YES;
}
......@@ -150,12 +167,11 @@ -(BOOL)acceptsFirstResponder
- (BOOL)becomeFirstResponder
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event];
event.what = getFocusEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(getFocusEvent): %d\n", acceptedEvent);
return YES;
......@@ -164,40 +180,36 @@ - (BOOL)becomeFirstResponder
- (BOOL)resignFirstResponder
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event];
event.what = loseFocusEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(loseFocusEvent): %d\n", acceptedEvent);
return YES;
}
-(void)mouseDown:(NSEvent *)theEvent
- (void)mouseDown:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseDown;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
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
- (void)mouseUp:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
event.what = mouseUp;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseUp): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
}
......@@ -205,12 +217,11 @@ -(void)mouseUp:(NSEvent *)theEvent
- (void)mouseEntered:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
event.what = adjustCursorEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseEntered): %d\n", acceptedEvent);
}
......@@ -218,12 +229,11 @@ - (void)mouseEntered:(NSEvent *)theEvent
- (void)mouseExited:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
event.what = adjustCursorEvent;
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(mouseExited): %d\n", acceptedEvent);
......@@ -234,7 +244,6 @@ - (void)mouseExited:(NSEvent *)theEvent
- (void)keyUp:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
event.what = keyUp;
......@@ -243,7 +252,7 @@ - (void)keyUp:(NSEvent *)theEvent
event.message = [self keyMessageForEvent:theEvent];
}
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(keyUp): %d charCode:%c keyCode:%lu\n",
acceptedEvent, (char) (event.message & charCodeMask), (event.message & keyCodeMask));
......@@ -258,7 +267,6 @@ - (void)keyUp:(NSEvent *)theEvent
- (void)keyDown:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
// Some command keys are sent with both performKeyEquivalent and keyDown.
// We should send only 1 keyDown to the plug-in, so we'll ignore this one.
......@@ -273,7 +281,7 @@ - (void)keyDown:(NSEvent *)theEvent
event.message = [self keyMessageForEvent:theEvent];
}
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(keyDown): %d charCode:%c keyCode:%lu\n",
acceptedEvent, (char) (event.message & charCodeMask), (event.message & keyCodeMask));
......@@ -298,10 +306,10 @@ - (BOOL)isInResponderChain
return NO;
}
// Must subclass performKeyEquivalent: for command-modified keys to work.
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
if(![self isInResponderChain]){
return NO;
......@@ -314,7 +322,7 @@ - (BOOL)performKeyEquivalent:(NSEvent *)theEvent
event.message = [self keyMessageForEvent:theEvent];
}
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(performKeyEquivalent): %d charCode:%c keyCode:%lu\n",
acceptedEvent, (char) (event.message & charCodeMask), (event.message & keyCodeMask));
......@@ -326,10 +334,10 @@ - (BOOL)performKeyEquivalent:(NSEvent *)theEvent
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
EventRecord event;
BOOL acceptedEvent;
[self getCarbonEvent:&event withEvent:theEvent];
acceptedEvent = NPP_HandleEvent(instance, &event);
BOOL acceptedEvent = [self sendEvent:&event];
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_HandleEvent(menuForEvent): %d pt.v=%d, pt.h=%d\n", acceptedEvent, event.where.v, event.where.h);
return nil;
......@@ -649,12 +657,10 @@ - (void)provisionalDataSourceChanged:(WebDataSource *)dataSource
- (void)provisionalDataSourceCommitted:(WebDataSource *)dataSource
{
}
- (void)dataSourceUpdated:(WebDataSource *)dataSource
{
}
- (void)layout
......@@ -666,8 +672,6 @@ - (void)layout
[self setUpWindowAndPort];
}
#pragma mark NSVIEW
- (void)drawRect:(NSRect)rect
......@@ -764,6 +768,50 @@ - (void) frameStateChanged:(NSNotification *)notification
#pragma mark PLUGIN-TO-BROWSER
- (NPP)pluginInstance
{
return instance;
}
- (NPP_NewStreamProcPtr)NPP_NewStream
{
return NPP_NewStream;
}
- (NPP_WriteReadyProcPtr)NPP_WriteReady
{
return NPP_WriteReady;
}
- (NPP_WriteProcPtr)NPP_Write
{
return NPP_Write;
}
- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile
{
return NPP_StreamAsFile;
}
- (NPP_DestroyStreamProcPtr)NPP_DestroyStream
{
return NPP_DestroyStream;
}
- (NPP_URLNotifyProcPtr)NPP_URLNotify
{
return NPP_URLNotify;
}
- (NPP_HandleEventProcPtr)NPP_HandleEvent
{
return NPP_HandleEvent;
}
@end
@implementation WebNetscapePluginView (WebNPPCallbacks)
- (NPError) loadURL:(NSString *)URLString inTarget:(NSString *)target withNotifyData:(void *)notifyData andHandleAttributes:(NSDictionary *)attributes
{
WebNetscapePluginStream *stream;
......@@ -947,48 +995,4 @@ -(void)forceRedraw
[self sendUpdateEvent];
}
- (NPP)pluginInstance
{
return instance;
}
- (NPP_NewStreamProcPtr)NPP_NewStream
{
return NPP_NewStream;
}
- (NPP_WriteReadyProcPtr)NPP_WriteReady
{
return NPP_WriteReady;
}
- (NPP_WriteProcPtr)NPP_Write
{
return NPP_Write;
}
- (NPP_StreamAsFileProcPtr)NPP_StreamAsFile
{
return NPP_StreamAsFile;
}
- (NPP_DestroyStreamProcPtr)NPP_DestroyStream
{
return NPP_DestroyStream;
}
- (NPP_URLNotifyProcPtr)NPP_URLNotify
{
return NPP_URLNotify;
}
- (NPP_HandleEventProcPtr) NPP_HandleEvent
{
return NPP_HandleEvent;
}
@end