[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 07:29:42 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit cf4c637a4aabd4c923baf94ddaf8dadc33468e29
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 14 19:28:05 2003 +0000
Fixed: 3197872 - Standalone plug-in content isn't restarted when switching tabs
Fixed: 3189675 - assertion in plug-in code fails (nil window) with .swf page displaying standalone in a tab
We start plug-ins when they are added to the window and stop them when they are removed. To restart a plug-in, the data stream must be redelivered. This works in the embedded plug-in case, but in the standalone plug-in case, the stream is delivered by the machinery in WebKit. The stream is only delivered once. This fix addresses that.
Reviewed by trey.
* Plugins.subproj/WebBaseNetscapePluginStream.m:
(-[WebBaseNetscapePluginStream setResponse:]): reset the offset ivar
(-[WebBaseNetscapePluginStream finishedLoadingWithData:]): If we create a file for the plug-in, handle the case where the file is already created.
* Plugins.subproj/WebBaseNetscapePluginView.h:
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView isStarted]): added so the stream knows the state of the view
* Plugins.subproj/WebNetscapePluginDocumentView.m:
(-[WebNetscapePluginDocumentView initWithFrame:]): tweak
(-[WebNetscapePluginDocumentView viewDidMoveToWindow]): call redeliverStream if we are added back to the window
(-[WebNetscapePluginDocumentView setDataSource:]): only start the plug-in if we are in a window, don't assert
* Plugins.subproj/WebNetscapePluginRepresentation.h:
* Plugins.subproj/WebNetscapePluginRepresentation.m:
(-[WebNetscapePluginRepresentation dealloc]): release the retained data source and error
(-[WebNetscapePluginRepresentation setDataSource:]): retain the data source
(-[WebNetscapePluginRepresentation isPluginViewStarted]): new
(-[WebNetscapePluginRepresentation receivedData:withDataSource:]): only do work if isPluginViewStarted
(-[WebNetscapePluginRepresentation receivedError:withDataSource:]): retain the error, only do work if isPluginViewStarted
(-[WebNetscapePluginRepresentation finishedLoadingWithDataSource:]): only do work if isPluginViewStarted
(-[WebNetscapePluginRepresentation redeliverStream]): call receivedData:: with all the received data up to this point. Call receivedError:: or finishedLoadingWithDataSource: if the load is already complete.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7b62f9b..eaa2159 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,32 @@
+2003-03-14 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3197872 - Standalone plug-in content isn't restarted when switching tabs
+ Fixed: 3189675 - assertion in plug-in code fails (nil window) with .swf page displaying standalone in a tab
+
+ We start plug-ins when they are added to the window and stop them when they are removed. To restart a plug-in, the data stream must be redelivered. This works in the embedded plug-in case, but in the standalone plug-in case, the stream is delivered by the machinery in WebKit. The stream is only delivered once. This fix addresses that.
+
+ Reviewed by trey.
+
+ * Plugins.subproj/WebBaseNetscapePluginStream.m:
+ (-[WebBaseNetscapePluginStream setResponse:]): reset the offset ivar
+ (-[WebBaseNetscapePluginStream finishedLoadingWithData:]): If we create a file for the plug-in, handle the case where the file is already created.
+ * Plugins.subproj/WebBaseNetscapePluginView.h:
+ * Plugins.subproj/WebBaseNetscapePluginView.m:
+ (-[WebBaseNetscapePluginView isStarted]): added so the stream knows the state of the view
+ * Plugins.subproj/WebNetscapePluginDocumentView.m:
+ (-[WebNetscapePluginDocumentView initWithFrame:]): tweak
+ (-[WebNetscapePluginDocumentView viewDidMoveToWindow]): call redeliverStream if we are added back to the window
+ (-[WebNetscapePluginDocumentView setDataSource:]): only start the plug-in if we are in a window, don't assert
+ * Plugins.subproj/WebNetscapePluginRepresentation.h:
+ * Plugins.subproj/WebNetscapePluginRepresentation.m:
+ (-[WebNetscapePluginRepresentation dealloc]): release the retained data source and error
+ (-[WebNetscapePluginRepresentation setDataSource:]): retain the data source
+ (-[WebNetscapePluginRepresentation isPluginViewStarted]): new
+ (-[WebNetscapePluginRepresentation receivedData:withDataSource:]): only do work if isPluginViewStarted
+ (-[WebNetscapePluginRepresentation receivedError:withDataSource:]): retain the error, only do work if isPluginViewStarted
+ (-[WebNetscapePluginRepresentation finishedLoadingWithDataSource:]): only do work if isPluginViewStarted
+ (-[WebNetscapePluginRepresentation redeliverStream]): call receivedData:: with all the received data up to this point. Call receivedError:: or finishedLoadingWithDataSource: if the load is already complete.
+
2003-03-13 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
index 888817a..45bd392 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginStream.m
@@ -65,6 +65,8 @@
stream.lastmodified = [[r lastModifiedDate] timeIntervalSince1970];
stream.notifyData = notifyData;
+ offset = 0;
+
// FIXME: Need a way to check if stream is seekable
NPError npErr;
@@ -139,27 +141,32 @@
}
if (transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
- ASSERT(!path);
- path = strdup("/tmp/SafariPlugInStream.XXXXXX");
- int fd = mkstemp(path);
- if (fd == -1) {
- // This should almost never happen.
- ERROR("can't make temporary file, almost certainly a problem with /tmp");
- // This is not a network error, but the only error codes are "network error" and "user break".
- [self destroyStreamWithReason:NPRES_NETWORK_ERR];
- return;
- }
- int dataLength = [data length];
- int byteCount = write(fd, [data bytes], dataLength);
- if (byteCount != dataLength) {
- // This happens only rarely, when we are out of disk space or have a disk I/O error.
- ERROR("error writing to temporary file, errno %d", errno);
+ if (!path) {
+ path = strdup("/tmp/SafariPlugInStream.XXXXXX");
+ int fd = mkstemp(path);
+ if (fd == -1) {
+ // This should almost never happen.
+ ERROR("can't make temporary file, almost certainly a problem with /tmp");
+ // This is not a network error, but the only error codes are "network error" and "user break".
+ [self destroyStreamWithReason:NPRES_NETWORK_ERR];
+ free(path);
+ path = NULL;
+ return;
+ }
+ int dataLength = [data length];
+ int byteCount = write(fd, [data bytes], dataLength);
+ if (byteCount != dataLength) {
+ // This happens only rarely, when we are out of disk space or have a disk I/O error.
+ ERROR("error writing to temporary file, errno %d", errno);
+ close(fd);
+ // This is not a network error, but the only error codes are "network error" and "user break".
+ [self destroyStreamWithReason:NPRES_NETWORK_ERR];
+ free(path);
+ path = NULL;
+ return;
+ }
close(fd);
- // This is not a network error, but the only error codes are "network error" and "user break".
- [self destroyStreamWithReason:NPRES_NETWORK_ERR];
- return;
}
- close(fd);
NSString *carbonPath = [[NSFileManager defaultManager] _web_carbonPathForPath:[NSString stringWithCString:path]];
NPP_StreamAsFile(instance, &stream, [carbonPath cString]);
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
index 07fffd1..eee7c3f 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
@@ -59,6 +59,7 @@
- (BOOL)start;
- (void)stop;
+- (BOOL)isStarted;
- (WebFrame *)webFrame;
- (WebDataSource *)dataSource;
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
index c083341..61213d2 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
@@ -716,7 +716,7 @@ typedef struct {
}
isStarted = NO;
-
+
// Stop any active streams
[streams makeObjectsPerformSelector:@selector(stop)];
@@ -733,6 +733,13 @@ typedef struct {
NPError npErr;
npErr = NPP_Destroy(instance, NULL);
LOG(Plugins, "NPP_Destroy: %d", npErr);
+
+ instance->pdata = NULL;
+}
+
+- (BOOL)isStarted
+{
+ return isStarted;
}
- (WebDataSource *)dataSource
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
index f096835..bba2fd7 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
@@ -9,6 +9,7 @@
#import <WebKit/WebFrame.h>
#import <WebKit/WebKitErrors.h>
#import <WebKit/WebNetscapePluginDocumentView.h>
+#import <WebKit/WebNetscapePluginRepresentation.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebNetscapePluginPackage.h>
#import <WebKit/WebPluginDatabase.h>
@@ -24,13 +25,9 @@
- initWithFrame:(NSRect)frame
{
[super initWithFrame:frame];
-
[self setFrame:NSZeroRect];
-
[self setMode:NP_FULL];
-
needsLayout = YES;
-
return self;
}
@@ -49,15 +46,28 @@
[super drawRect:rect];
}
+- (void)viewDidMoveToWindow
+{
+ [super viewDidMoveToWindow];
+
+ // If viewDidMoveToWindow is called before setDataSource don't deliver the stream here because the loading process
+ // of WebKit handles that for us. If viewDidMoveToWindow is called after setDataSource,
+ // (this happens if plug-in content is loaded without a window), start the plug-in and redeliver the
+ // stream because the view is now in a window.
+ if ([self window] && dataSource && [self start]) {
+ WebNetscapePluginRepresentation *representation = (WebNetscapePluginRepresentation *)[dataSource representation];
+ ASSERT([representation isKindOfClass:[WebNetscapePluginRepresentation class]]);
+ [representation redeliverStream];
+ }
+}
+
- (WebDataSource *)dataSource
{
return dataSource;
}
- (void)setDataSource:(WebDataSource *)theDataSource
-{
- ASSERT([self window]);
-
+{
[dataSource release];
dataSource = [theDataSource retain];
@@ -71,7 +81,7 @@
if (![thePlugin load]){
// FIXME: It would be nice to stop the load here.
-
+
WebPluginError *error = [WebPluginError pluginErrorWithCode:WebKitErrorCannotLoadPlugin
contentURL:[[[theDataSource request] URL] absoluteString]
pluginPageURL:nil
@@ -86,7 +96,9 @@
[self setPlugin:thePlugin];
- [self start];
+ if ([self window]) {
+ [self start];
+ }
}
- (void)dataSourceUpdated:(WebDataSource *)dataSource
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.h b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.h
index 878868c..83f9056 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.h
+++ b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.h
@@ -7,11 +7,16 @@
#import <WebKit/WebBaseNetscapePluginStream.h>
+ at class WebDataSource;
+ at class WebError;
@protocol WebDocumentRepresentation;
@interface WebNetscapePluginRepresentation : WebBaseNetscapePluginStream <WebDocumentRepresentation>
{
-
+ WebDataSource *_dataSource;
+ WebError *_error;
}
+- (void)redeliverStream;
+
@end
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
index 50b8d57..9ea00d3 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginRepresentation.m
@@ -9,31 +9,61 @@
#import <WebKit/WebNetscapePluginRepresentation.h>
#import <WebKit/WebView.h>
+#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebFoundation.h>
@implementation WebNetscapePluginRepresentation
-- (void)setDataSource:(WebDataSource *)dataSource
+- (void)dealloc
{
+ [_dataSource release];
+ [_error release];
+ [super dealloc];
+}
+
+- (void)setDataSource:(WebDataSource *)ds
+{
+ [ds retain];
+ [_dataSource release];
+ _dataSource = ds;
+}
+
+- (BOOL)isPluginViewStarted
+{
+ WebNetscapePluginDocumentView *view = (WebNetscapePluginDocumentView *)[[[_dataSource webFrame] view] documentView];
+ ASSERT([view isKindOfClass:[WebNetscapePluginDocumentView class]]);
+ return [view isStarted];
}
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)ds
{
- if(!instance){
- NSView *view = [[[ds webFrame] view] documentView];
- if([view isKindOfClass:[WebNetscapePluginDocumentView class]]){
- [self setPluginPointer:[(WebNetscapePluginDocumentView *)view pluginPointer]];
- [self setResponse:[ds response]];
- }
+ WebNetscapePluginDocumentView *view = (WebNetscapePluginDocumentView *)[[[_dataSource webFrame] view] documentView];
+ ASSERT([view isKindOfClass:[WebNetscapePluginDocumentView class]]);
+
+ if (![view isStarted]) {
+ return;
}
- if(instance){
- [self receivedData:data];
+
+ if(!instance){
+ [self setPluginPointer:[view pluginPointer]];
+ [self setResponse:[ds response]];
}
+
+ ASSERT(instance);
+ [self receivedData:data];
}
- (void)receivedError:(WebError *)error withDataSource:(WebDataSource *)ds
{
- if([error errorCode] == WebFoundationErrorCancelled){
+ [error retain];
+ [_error release];
+ _error = error;
+
+ if (![self isPluginViewStarted]) {
+ return;
+ }
+
+ if ([error errorCode] == WebFoundationErrorCancelled) {
[self receivedError:NPRES_USER_BREAK];
} else {
[self receivedError:NPRES_NETWORK_ERR];
@@ -41,8 +71,10 @@
}
- (void)finishedLoadingWithDataSource:(WebDataSource *)ds
-{
- [self finishedLoadingWithData:[ds data]];
+{
+ if ([self isPluginViewStarted]) {
+ [self finishedLoadingWithData:[ds data]];
+ }
}
- (BOOL)canProvideDocumentSource
@@ -55,4 +87,22 @@
return nil;
}
+- (void)redeliverStream
+{
+ if (_dataSource && [self isPluginViewStarted]) {
+ instance = NULL;
+ NSData *data = [_dataSource data];
+ if ([data length] > 0) {
+ [self receivedData:data withDataSource:_dataSource];
+ if (![_dataSource isLoading]) {
+ if (_error) {
+ [self receivedError:_error withDataSource:_dataSource];
+ } else {
+ [self finishedLoadingWithDataSource:_dataSource];
+ }
+ }
+ }
+ }
+}
+
@end
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list