[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:32:34 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 0ccc2f10ac9ae292e6fc015d620cefc509dd925e
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Mar 31 19:35:48 2003 +0000
Fixed: 3178058 - Plug-ins are stopped/reloaded when switching tabs
Made the "Enable plug-ins" preference toggle in real-time again.
No events including null events are sent when a plug-in is in a non-frontmost tab. This causes Flash movies to pause (which is nice) and QT movies to continue to play.
Reviewed by darin.
* Plugins.subproj/WebBaseNetscapePluginView.h:
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView saveAndSetPortStateForUpdate:]): use the current window, clip out the plug-in when not in an actual window
(-[WebBaseNetscapePluginView restorePortState:]): use the current window
(-[WebBaseNetscapePluginView sendEvent:]): added asserts
(-[WebBaseNetscapePluginView sendActivateEvent:]): tweak
(-[WebBaseNetscapePluginView sendNullEvent]): tweak
(-[WebBaseNetscapePluginView restartNullEvents]): tweak
(-[WebBaseNetscapePluginView isInResponderChain]): tweak
(-[WebBaseNetscapePluginView performKeyEquivalent:]): tweak
(-[WebBaseNetscapePluginView canStart]): new, implemented by subclasses
(-[WebBaseNetscapePluginView didStart]): new, implemented by subclasses
(-[WebBaseNetscapePluginView addWindowObservers]): new
(-[WebBaseNetscapePluginView removeWindowObservers]): new
(-[WebBaseNetscapePluginView start]): check pref, call canStart, addWindowObservers and didStart
(-[WebBaseNetscapePluginView stop]): call removeWindowObservers
(-[WebBaseNetscapePluginView currentWindow]): new, returns the actual window else the host window
(-[WebBaseNetscapePluginView initWithFrame:]): observer pref change notifications
(-[WebBaseNetscapePluginView dealloc]): call removeObserver
(-[WebBaseNetscapePluginView viewWillMoveToWindow:]): stop if there is no host window
(-[WebBaseNetscapePluginView viewDidMoveToWindow]): start if we moved to a window
(-[WebBaseNetscapePluginView viewWillMoveToHostWindow:]): stop if there will be no windows
(-[WebBaseNetscapePluginView viewDidMoveToHostWindow]): start if there is a window
(-[WebBaseNetscapePluginView preferencesHaveChanged:]): renamed, start or stop
(-[WebBaseNetscapePluginView destroyStream:reason:]): tweak
(-[NSData _web_locationAfterFirstBlankLine]): tweak
* Plugins.subproj/WebNetscapePluginDocumentView.m:
(-[WebNetscapePluginDocumentView initWithFrame:]): call setAutoresizingMask here
(-[WebNetscapePluginDocumentView canStart]): new, return YES if there is a data source
(-[WebNetscapePluginDocumentView didStart]): redeliver the stream if there is any data
(-[WebNetscapePluginDocumentView setDataSource:]): start if there is a current window
(-[WebNetscapePluginDocumentView layout]): no need to call setWindow, this is done in the superclass
(-[WebNetscapePluginDocumentView viewWillMoveToHostWindow:]): forward to super to make compiler happy
(-[WebNetscapePluginDocumentView viewDidMoveToHostWindow]): forward to super to make compiler happy
* Plugins.subproj/WebNetscapePluginEmbeddedView.m:
(-[WebNetscapePluginEmbeddedView didStart]): start the load
(-[WebNetscapePluginEmbeddedView dataSource]): tweak
* WebView.subproj/WebDocument.h: added viewWillMoveToHostWindow: and viewDidMoveToHostWindow
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _viewWillMoveToHostWindow:]): forward to document view and subframes
(-[WebFrame _viewDidMoveToHostWindow]): forward to document view and subframes
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView viewWillMoveToHostWindow:]): forward to plug-in views
(-[WebHTMLView viewDidMoveToHostWindow]): forward to plug-in views
(-[NSArray _web_makePluginViewsPerformSelector:withObject:]): new
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _reset]): don't stop plug-ins here. WebBaseNetscapePluginView can handle that
* WebView.subproj/WebImageView.m:
(-[WebImageView viewWillMoveToHostWindow:]): implement new WebDocumentView methods
(-[WebImageView viewDidMoveToHostWindow]): implement new WebDocumentView methods
* WebView.subproj/WebTextView.m:
(-[WebTextView viewWillMoveToHostWindow:]): implement new WebDocumentView methods
(-[WebTextView viewDidMoveToHostWindow]): implement new WebDocumentView methods
* WebView.subproj/WebView.h:
* WebView.subproj/WebView.m:
(-[WebView setHostWindow:]): new
(-[WebView hostWindow]): new
* WebView.subproj/WebViewPrivate.h:
* WebView.subproj/WebViewPrivate.m:
(-[WebViewPrivate dealloc]): release the host window
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3970 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index afd8627..e364e20 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,74 @@
+2003-03-29 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: 3178058 - Plug-ins are stopped/reloaded when switching tabs
+ Made the "Enable plug-ins" preference toggle in real-time again.
+
+ No events including null events are sent when a plug-in is in a non-frontmost tab. This causes Flash movies to pause (which is nice) and QT movies to continue to play.
+
+ Reviewed by darin.
+
+ * Plugins.subproj/WebBaseNetscapePluginView.h:
+ * Plugins.subproj/WebBaseNetscapePluginView.m:
+ (-[WebBaseNetscapePluginView saveAndSetPortStateForUpdate:]): use the current window, clip out the plug-in when not in an actual window
+ (-[WebBaseNetscapePluginView restorePortState:]): use the current window
+ (-[WebBaseNetscapePluginView sendEvent:]): added asserts
+ (-[WebBaseNetscapePluginView sendActivateEvent:]): tweak
+ (-[WebBaseNetscapePluginView sendNullEvent]): tweak
+ (-[WebBaseNetscapePluginView restartNullEvents]): tweak
+ (-[WebBaseNetscapePluginView isInResponderChain]): tweak
+ (-[WebBaseNetscapePluginView performKeyEquivalent:]): tweak
+ (-[WebBaseNetscapePluginView canStart]): new, implemented by subclasses
+ (-[WebBaseNetscapePluginView didStart]): new, implemented by subclasses
+ (-[WebBaseNetscapePluginView addWindowObservers]): new
+ (-[WebBaseNetscapePluginView removeWindowObservers]): new
+ (-[WebBaseNetscapePluginView start]): check pref, call canStart, addWindowObservers and didStart
+ (-[WebBaseNetscapePluginView stop]): call removeWindowObservers
+ (-[WebBaseNetscapePluginView currentWindow]): new, returns the actual window else the host window
+ (-[WebBaseNetscapePluginView initWithFrame:]): observer pref change notifications
+ (-[WebBaseNetscapePluginView dealloc]): call removeObserver
+ (-[WebBaseNetscapePluginView viewWillMoveToWindow:]): stop if there is no host window
+ (-[WebBaseNetscapePluginView viewDidMoveToWindow]): start if we moved to a window
+ (-[WebBaseNetscapePluginView viewWillMoveToHostWindow:]): stop if there will be no windows
+ (-[WebBaseNetscapePluginView viewDidMoveToHostWindow]): start if there is a window
+ (-[WebBaseNetscapePluginView preferencesHaveChanged:]): renamed, start or stop
+ (-[WebBaseNetscapePluginView destroyStream:reason:]): tweak
+ (-[NSData _web_locationAfterFirstBlankLine]): tweak
+ * Plugins.subproj/WebNetscapePluginDocumentView.m:
+ (-[WebNetscapePluginDocumentView initWithFrame:]): call setAutoresizingMask here
+ (-[WebNetscapePluginDocumentView canStart]): new, return YES if there is a data source
+ (-[WebNetscapePluginDocumentView didStart]): redeliver the stream if there is any data
+ (-[WebNetscapePluginDocumentView setDataSource:]): start if there is a current window
+ (-[WebNetscapePluginDocumentView layout]): no need to call setWindow, this is done in the superclass
+ (-[WebNetscapePluginDocumentView viewWillMoveToHostWindow:]): forward to super to make compiler happy
+ (-[WebNetscapePluginDocumentView viewDidMoveToHostWindow]): forward to super to make compiler happy
+ * Plugins.subproj/WebNetscapePluginEmbeddedView.m:
+ (-[WebNetscapePluginEmbeddedView didStart]): start the load
+ (-[WebNetscapePluginEmbeddedView dataSource]): tweak
+ * WebView.subproj/WebDocument.h: added viewWillMoveToHostWindow: and viewDidMoveToHostWindow
+ * WebView.subproj/WebFramePrivate.h:
+ * WebView.subproj/WebFramePrivate.m:
+ (-[WebFrame _viewWillMoveToHostWindow:]): forward to document view and subframes
+ (-[WebFrame _viewDidMoveToHostWindow]): forward to document view and subframes
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView viewWillMoveToHostWindow:]): forward to plug-in views
+ (-[WebHTMLView viewDidMoveToHostWindow]): forward to plug-in views
+ (-[NSArray _web_makePluginViewsPerformSelector:withObject:]): new
+ * WebView.subproj/WebHTMLViewPrivate.m:
+ (-[WebHTMLView _reset]): don't stop plug-ins here. WebBaseNetscapePluginView can handle that
+ * WebView.subproj/WebImageView.m:
+ (-[WebImageView viewWillMoveToHostWindow:]): implement new WebDocumentView methods
+ (-[WebImageView viewDidMoveToHostWindow]): implement new WebDocumentView methods
+ * WebView.subproj/WebTextView.m:
+ (-[WebTextView viewWillMoveToHostWindow:]): implement new WebDocumentView methods
+ (-[WebTextView viewDidMoveToHostWindow]): implement new WebDocumentView methods
+ * WebView.subproj/WebView.h:
+ * WebView.subproj/WebView.m:
+ (-[WebView setHostWindow:]): new
+ (-[WebView hostWindow]): new
+ * WebView.subproj/WebViewPrivate.h:
+ * WebView.subproj/WebViewPrivate.m:
+ (-[WebViewPrivate dealloc]): release the host window
+
2003-03-31 Darin Adler <darin at apple.com>
Reviewed by John.
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
index 82a30cb..bafb2a5 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.h
@@ -29,7 +29,6 @@
NP_Port nPort;
NPP_t instanceStruct;
- BOOL canRestart;
BOOL isStarted;
BOOL inSetWindow;
@@ -58,17 +57,15 @@
+ (WebBaseNetscapePluginView *)currentPluginView;
- (BOOL)start;
-- (void)stop;
- (BOOL)isStarted;
- (WebFrame *)webFrame;
- (WebDataSource *)dataSource;
- (WebView *)controller;
+- (NSWindow *)currentWindow;
- (NPP)pluginPointer;
-- (void)setWindow;
-
- (WebNetscapePluginPackage *)plugin;
- (void)setPlugin:(WebNetscapePluginPackage *)thePlugin;
- (void)setMIMEType:(NSString *)theMIMEType;
@@ -76,4 +73,7 @@
- (void)setAttributes:(NSDictionary *)attributes;
- (void)setMode:(int)theMode;
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
+- (void)viewDidMoveToHostWindow;
+
@end
diff --git a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
index 86d385b..53f28e8 100644
--- a/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
+++ b/WebKit/Plugins.subproj/WebBaseNetscapePluginView.m
@@ -9,13 +9,14 @@
#import <WebKit/WebDataSource.h>
#import <WebKit/WebDefaultWindowOperationsDelegate.h>
#import <WebKit/WebFrame.h>
-#import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebFrameView.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebNetscapePluginStream.h>
#import <WebKit/WebNullPluginView.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebNetscapePluginPackage.h>
+#import <WebKit/WebPreferences.h>
#import <WebKit/WebViewPrivate.h>
#import <WebKit/WebWindowOperationsDelegate.h>
@@ -32,7 +33,7 @@
// This is not yet in QuickdrawPriv.h, although it's supposed to be.
void CallDrawingNotifications(CGrafPtr port, Rect *mayDrawIntoThisRect, int drawingType);
-// Send null events 50 times a second when active so plug-ins like Flash get high frame rates.
+// Send null events 50 times a second when active, so plug-ins like Flash get high frame rates.
#define NullEventIntervalActive 0.02
#define NullEventIntervalNotActive 0.25
@@ -147,7 +148,9 @@ typedef struct {
- (PortState)saveAndSetPortStateForUpdate:(BOOL)forUpdate
{
- WindowRef windowRef = [[self window] windowRef];
+ ASSERT([self currentWindow]);
+
+ WindowRef windowRef = [[self currentWindow] windowRef];
CGrafPtr port = GetWindowPort(windowRef);
Rect portBounds;
@@ -160,7 +163,7 @@ typedef struct {
// Flip Y to convert NSWindow coordinates to top-left-based window coordinates.
- float borderViewHeight = [[self window] frame].size.height;
+ float borderViewHeight = [[self currentWindow] frame].size.height;
boundsInWindow.origin.y = borderViewHeight - NSMaxY(boundsInWindow);
visibleRectInWindow.origin.y = borderViewHeight - NSMaxY(visibleRectInWindow);
@@ -189,8 +192,15 @@ typedef struct {
window.clipRect.top = (uint16)visibleRectInWindow.origin.y;
window.clipRect.left = (uint16)visibleRectInWindow.origin.x;
- window.clipRect.bottom = (uint16)(visibleRectInWindow.origin.y + visibleRectInWindow.size.height);
- window.clipRect.right = (uint16)(visibleRectInWindow.origin.x + visibleRectInWindow.size.width);
+
+ // Clip out the plug-in when it's not really in a window.
+ if ([self window]) {
+ window.clipRect.bottom = (uint16)(visibleRectInWindow.origin.y + visibleRectInWindow.size.height);
+ window.clipRect.right = (uint16)(visibleRectInWindow.origin.x + visibleRectInWindow.size.width);
+ } else {
+ window.clipRect.bottom = window.clipRect.top;
+ window.clipRect.left = window.clipRect.right;
+ }
window.type = NPWindowTypeWindow;
@@ -251,7 +261,9 @@ typedef struct {
- (void)restorePortState:(PortState)portState
{
- WindowRef windowRef = [[self window] windowRef];
+ ASSERT([self currentWindow]);
+
+ WindowRef windowRef = [[self currentWindow] windowRef];
CGrafPtr port = GetWindowPort(windowRef);
if (portState.forUpdate) {
@@ -274,9 +286,13 @@ typedef struct {
- (BOOL)sendEvent:(EventRecord *)event
{
- if (!isStarted || !NPP_HandleEvent) {
+ ASSERT([self window]);
+
+ if (!isStarted) {
return NO;
}
+
+ ASSERT(NPP_HandleEvent);
// Make sure we don't call NPP_HandleEvent while we're inside NPP_SetWindow.
// We probably don't want more general reentrancy protection; we are really
@@ -323,8 +339,9 @@ typedef struct {
event.what = activateEvt;
WindowRef windowRef = [[self window] windowRef];
event.message = (UInt32)windowRef;
- if (activate)
+ if (activate) {
event.modifiers |= activeFlag;
+ }
BOOL acceptedEvent;
acceptedEvent = [self sendEvent:&event];
@@ -357,8 +374,9 @@ typedef struct {
// Plug-in should not react to cursor position when not active or when a menu is down.
MenuTrackingData trackingData;
OSStatus error = GetMenuTrackingData(NULL, &trackingData);
-
- if (![_window isKeyWindow] || (error == noErr && trackingData.menu)) {
+
+ // Plug-in should not react to cursor position when the actual window is not key.
+ if (![[self window] isKeyWindow] || (error == noErr && trackingData.menu)) {
// FIXME: Does passing a v and h of -1 really prevent it from reacting to the cursor position?
event.where.v = -1;
event.where.h = -1;
@@ -376,15 +394,16 @@ typedef struct {
- (void)restartNullEvents
{
- if(nullEventTimer){
+ if (nullEventTimer) {
[self stopNullEvents];
}
NSTimeInterval interval;
-
- if ([_window isKeyWindow]){
+
+ // Send null events less frequently when the actual window is not key.
+ if ([[self window] isKeyWindow]) {
interval = NullEventIntervalActive;
- }else{
+ } else {
interval = NullEventIntervalNotActive;
}
@@ -558,8 +577,8 @@ typedef struct {
{
NSResponder *responder = [[self window] firstResponder];
- while(responder != nil){
- if(responder == self){
+ while (responder != nil) {
+ if (responder == self) {
return YES;
}
responder = [responder nextResponder];
@@ -575,7 +594,7 @@ typedef struct {
{
EventRecord event;
- if(![self isInResponderChain]){
+ if (![self isInResponderChain]) {
return NO;
}
@@ -652,63 +671,95 @@ typedef struct {
return currentPluginView;
}
-- (BOOL)start
+- (BOOL)canStart
+{
+ return YES;
+}
+
+- (void)didStart
+{
+ // Do nothing. Overridden by subclasses.
+}
+
+- (void)addWindowObservers
{
ASSERT([self window]);
+
+ NSWindow *theWindow = [self window];
+
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ NSView *view;
+ for (view = self; view; view = [view superview]) {
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:NSViewFrameDidChangeNotification object:view];
+ [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
+ name:NSViewBoundsDidChangeNotification object:view];
+ }
+ [notificationCenter addObserver:self selector:@selector(windowWillClose:)
+ name:NSWindowWillCloseNotification object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowBecameKey:)
+ name:NSWindowDidBecomeKeyNotification object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowResignedKey:)
+ name:NSWindowDidResignKeyNotification object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowDidMiniaturize:)
+ name:NSWindowDidMiniaturizeNotification object:theWindow];
+ [notificationCenter addObserver:self selector:@selector(windowDidDeminiaturize:)
+ name:NSWindowDidDeminiaturizeNotification object:theWindow];
+}
+
+- (void)removeWindowObservers
+{
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter removeObserver:self name:NSViewFrameDidChangeNotification object:nil];
+ [notificationCenter removeObserver:self name:NSViewBoundsDidChangeNotification object:nil];
+ [notificationCenter removeObserver:self name:NSWindowWillCloseNotification object:nil];
+ [notificationCenter removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil];
+ [notificationCenter removeObserver:self name:NSWindowDidResignKeyNotification object:nil];
+ [notificationCenter removeObserver:self name:NSWindowDidMiniaturizeNotification object:nil];
+ [notificationCenter removeObserver:self name:NSWindowDidDeminiaturizeNotification object:nil];
+}
+
+- (BOOL)start
+{
+ ASSERT([self currentWindow]);
if (isStarted) {
return YES;
}
- if (!canRestart || NPP_New == 0) {
+ if (![[WebPreferences standardPreferences] arePlugInsEnabled] || ![self canStart]) {
return NO;
}
+ ASSERT(NPP_New);
+
[[self class] setCurrentPluginView:self];
-
NPError npErr = NPP_New((char *)[MIMEType cString], instance, mode, argsCount, cAttributes, cValues, NULL);
+ [[self class] setCurrentPluginView:nil];
+
LOG(Plugins, "NPP_New: %d", npErr);
if (npErr != NPERR_NO_ERROR) {
ERROR("NPP_New failed with error: %d", npErr);
return NO;
}
- [[self class] setCurrentPluginView:nil];
-
isStarted = YES;
[self setWindow];
-
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
- NSView *view;
- for (view = self; view; view = [view superview]) {
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
- name:NSViewFrameDidChangeNotification object:view];
- [notificationCenter addObserver:self selector:@selector(viewHasMoved:)
- name:NSViewBoundsDidChangeNotification object:view];
- }
- [notificationCenter addObserver:self selector:@selector(windowWillClose:)
- name:NSWindowWillCloseNotification object:_window];
- [notificationCenter addObserver:self selector:@selector(windowBecameKey:)
- name:NSWindowDidBecomeKeyNotification object:_window];
- [notificationCenter addObserver:self selector:@selector(windowResignedKey:)
- name:NSWindowDidResignKeyNotification object:_window];
- [notificationCenter addObserver:self selector:@selector(defaultsHaveChanged:)
- name:NSUserDefaultsDidChangeNotification object:nil];
- [notificationCenter addObserver:self selector:@selector(windowDidMiniaturize:)
- name:NSWindowDidMiniaturizeNotification object:_window];
- [notificationCenter addObserver:self selector:@selector(windowDidDeminiaturize:)
- name:NSWindowDidDeminiaturizeNotification object:_window];
- if ([_window isKeyWindow]) {
- [self sendActivateEvent:YES];
- }
-
- if (![_window isMiniaturized]) {
- [self restartNullEvents];
+ if ([self window]) {
+ [self addWindowObservers];
+ if ([[self window] isKeyWindow]) {
+ [self sendActivateEvent:YES];
+ }
+ if (![[self window] isMiniaturized]) {
+ [self restartNullEvents];
+ }
}
-
+
[self resetTrackingRect];
+
+ [self didStart];
return YES;
}
@@ -717,7 +768,7 @@ typedef struct {
{
[self removeTrackingRect];
- if (!isStarted){
+ if (!isStarted) {
return;
}
@@ -733,7 +784,7 @@ typedef struct {
[[NSCursor arrowCursor] set];
// Stop notifications and callbacks.
- [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [self removeWindowObservers];
[NSObject cancelPreviousPerformRequestsWithTarget:self];
NPError npErr;
@@ -764,6 +815,11 @@ typedef struct {
return [[self webFrame] webView];
}
+- (NSWindow *)currentWindow
+{
+ return [self window] ? [self window] : [[self controller] hostWindow];
+}
+
- (NPP)pluginPointer
{
return instance;
@@ -849,11 +905,14 @@ typedef struct {
instance = &instanceStruct;
instance->ndata = self;
- canRestart = YES;
-
streams = [[NSMutableArray alloc] init];
streamNotifications = [[NSMutableDictionary alloc] init];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(preferencesHaveChanged:)
+ name:WebPreferencesChangedNotification
+ object:nil];
+
return self;
}
@@ -861,6 +920,8 @@ typedef struct {
{
unsigned i;
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
[self stop];
for (i = 0; i < argsCount; i++) {
@@ -916,19 +977,45 @@ typedef struct {
// We must remove the tracking rect before we move to the new window.
// Once we move to the new window, it will be too late.
[self removeTrackingRect];
+ [self removeWindowObservers];
- [super viewWillMoveToWindow:newWindow];
+ if (!newWindow) {
+ if ([[self controller] hostWindow]) {
+ // View will be moved out of the actual window but it still has a host window.
+ [self stopNullEvents];
+ } else {
+ // View will have no associated windows.
+ [self stop];
+ }
+ }
}
- (void)viewDidMoveToWindow
{
- if (![self window]) {
- [self stop];
- }
-
[self resetTrackingRect];
- [super viewDidMoveToWindow];
+ if ([self window]) {
+ // View moved to an actual window. Start it if not already started.
+ [self start];
+ [self restartNullEvents];
+ [self addWindowObservers];
+ }
+}
+
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+ if (!hostWindow && ![self window]) {
+ // View will have no associated windows.
+ [self stop];
+ }
+}
+
+- (void)viewDidMoveToHostWindow
+{
+ if ([self currentWindow]) {
+ // View now has an associated window. Start it if not already started.
+ [self start];
+ }
}
#pragma mark NOTIFICATIONS
@@ -969,16 +1056,20 @@ typedef struct {
[self restartNullEvents];
}
-- (void)defaultsHaveChanged:(NSNotification *)notification
+- (void)preferencesHaveChanged:(NSNotification *)notification
{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- if ([defaults boolForKey:@"WebKitPluginsEnabled"]) {
- canRestart = YES;
- [self start];
- } else {
- canRestart = NO;
- [self stop];
- [self setNeedsDisplay:YES];
+ WebPreferences *preferences = [[self controller] preferences];
+ BOOL arePlugInsEnabled = [preferences arePlugInsEnabled];
+
+ if ([notification object] == preferences && isStarted != arePlugInsEnabled) {
+ if (arePlugInsEnabled) {
+ if ([self currentWindow]) {
+ [self start];
+ }
+ } else {
+ [self stop];
+ [self setNeedsDisplay:YES];
+ }
}
}
@@ -1227,9 +1318,9 @@ typedef struct {
-(NPError)destroyStream:(NPStream*)stream reason:(NPReason)reason
{
LOG(Plugins, "NPN_DestroyStream");
- if(!stream->ndata)
+ if (!stream->ndata) {
return NPERR_INVALID_INSTANCE_ERROR;
-
+ }
[(WebNetscapePluginStream *)stream->ndata stop];
return NPERR_NO_ERROR;
}
@@ -1326,7 +1417,7 @@ typedef struct {
unsigned i;
for (i = 0; i < length - 2; i++) {
- if (bytes[i] == '\n' && (i == 0 || bytes[i+1] == '\n')){
+ if (bytes[i] == '\n' && (i == 0 || bytes[i+1] == '\n')) {
i++;
while (i < length - 2 && bytes[i] == '\n') {
i++;
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
index c9bd056..fefc18d 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginDocumentView.m
@@ -27,6 +27,7 @@
[super initWithFrame:frame];
[self setFrame:NSZeroRect];
[self setMode:NP_FULL];
+ [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
needsLayout = YES;
return self;
}
@@ -46,15 +47,15 @@
[super drawRect:rect];
}
-- (void)viewDidMoveToWindow
+- (BOOL)canStart
{
- [super viewDidMoveToWindow];
+ return (dataSource != nil);
+}
- // 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]) {
+- (void)didStart
+{
+ if ([[dataSource data] length] > 0) {
+ // Plug-in started after data was received. Redeliver what was already received.
WebNetscapePluginRepresentation *representation = (WebNetscapePluginRepresentation *)[dataSource representation];
ASSERT([representation isKindOfClass:[WebNetscapePluginRepresentation class]]);
[representation redeliverStream];
@@ -81,22 +82,21 @@
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
pluginName:[thePlugin name]
MIMEType:MIME];
-
- WebView *c = [[theDataSource webFrame] webView];
- [[c _resourceLoadDelegateForwarder] webView:c plugInFailedWithError:error dataSource:theDataSource];
-
+ WebView *webView = [[theDataSource webFrame] webView];
+ [[webView _resourceLoadDelegateForwarder] webView:webView
+ plugInFailedWithError:error
+ dataSource:theDataSource];
return;
}
[self setPlugin:thePlugin];
- if ([self window]) {
+ if ([self currentWindow]) {
[self start];
}
}
@@ -113,12 +113,18 @@
- (void)layout
{
NSRect superFrame = [[self _web_superviewOfClass:[WebFrameView class]] frame];
+ [self setFrame:NSMakeRect(0, 0, NSWidth(superFrame), NSHeight(superFrame))];
+ needsLayout = NO;
+}
- [self setFrame:NSMakeRect(0, 0, superFrame.size.width, superFrame.size.height)];
- [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [self setWindow];
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+ [super viewWillMoveToHostWindow:hostWindow];
+}
- needsLayout = NO;
+- (void)viewDidMoveToHostWindow
+{
+ [super viewDidMoveToHostWindow];
}
@end
diff --git a/WebKit/Plugins.subproj/WebNetscapePluginEmbeddedView.m b/WebKit/Plugins.subproj/WebNetscapePluginEmbeddedView.m
index 117abb4..8d26801 100644
--- a/WebKit/Plugins.subproj/WebNetscapePluginEmbeddedView.m
+++ b/WebKit/Plugins.subproj/WebNetscapePluginEmbeddedView.m
@@ -48,11 +48,9 @@
[super dealloc];
}
-- (void)viewDidMoveToWindow
+- (void)didStart
{
- [super viewDidMoveToWindow];
-
- if ([self window] && [self start] && URL) {
+ if (URL) {
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
[self loadRequest:request inTarget:nil withNotifyData:nil];
}
@@ -62,7 +60,6 @@
{
WebFrameView *webFrameView = (WebFrameView *)[self _web_superviewOfClass:[WebFrameView class]];
WebFrame *webFrame = [webFrameView webFrame];
-
return [webFrame dataSource];
}
diff --git a/WebKit/WebView.subproj/WebDocument.h b/WebKit/WebView.subproj/WebDocument.h
index bbf55d4..c19850c 100644
--- a/WebKit/WebView.subproj/WebDocument.h
+++ b/WebKit/WebView.subproj/WebDocument.h
@@ -42,6 +42,20 @@
setting the frame is a sufficient implementation of this method.
*/
- (void)layout;
+
+/*!
+ @method viewWillMoveToHostWindow:
+ @param hostWindow The host window for the document view.
+ @abstract Called before the host window is set on the parent web view.
+*/
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow;
+
+/*!
+ @method viewDidMoveToHostWindow
+ @abstract Called after the host window is set on the parent web view.
+*/
+- (void)viewDidMoveToHostWindow;
+
@end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 8dc570f..7ee4de1 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -148,6 +148,9 @@ typedef enum {
- (void)_defersCallbacksChanged;
+- (void)_viewWillMoveToHostWindow:(NSWindow *)hostWindow;
+- (void)_viewDidMoveToHostWindow;
+
- (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding;
- (void)_addChild:(WebFrame *)child;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 8e40454..b60b963 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -1742,6 +1742,18 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
[[self dataSource] _defersCallbacksChanged];
}
+- (void)_viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+ [[[self frameView] documentView] viewWillMoveToHostWindow:hostWindow];
+ [[self children] makeObjectsPerformSelector:@selector(_viewWillMoveToHostWindow:) withObject:hostWindow];
+}
+
+- (void)_viewDidMoveToHostWindow
+{
+ [[[self frameView] documentView] viewDidMoveToHostWindow];
+ [[self children] makeObjectsPerformSelector:@selector(_viewDidMoveToHostWindow)];
+}
+
- (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding
{
WebDataSource *dataSource = [self dataSource];
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 269beee..50836d5 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -7,19 +7,15 @@
#import <WebKit/WebBridge.h>
#import <WebKit/WebClipView.h>
-#import <WebKit/WebContextMenuDelegate.h>
#import <WebKit/WebDataSourcePrivate.h>
#import <WebKit/WebDOMDocument.h>
-#import <WebKit/WebDynamicScrollBarsView.h>
#import <WebKit/WebException.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebFrameViewPrivate.h>
#import <WebKit/WebHTMLViewPrivate.h>
-#import <WebKit/WebIconDatabase.h>
-#import <WebKit/WebIconLoader.h>
+#import <WebKit/WebNetscapePluginEmbeddedView.h>
#import <WebKit/WebKitLogging.h>
-#import <WebKit/WebNSImageExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSViewExtras.h>
#import <WebKit/WebPluginController.h>
@@ -31,6 +27,10 @@
#import <AppKit/NSResponder_Private.h>
#import <CoreGraphics/CGContextGState.h>
+ at interface NSArray (WebHTMLView)
+- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object;
+ at end
+
@implementation WebHTMLView
+(void)initialize
@@ -249,6 +249,17 @@
}
}
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+ [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewWillMoveToHostWindow:) withObject:hostWindow];
+}
+
+- (void)viewDidMoveToHostWindow
+{
+ [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewDidMoveToHostWindow) withObject:nil];
+}
+
+
- (void)addSubview:(NSView *)view
{
if ([view conformsToProtocol:@protocol(WebPlugin)]) {
@@ -792,3 +803,18 @@
}
@end
+
+ at implementation NSArray (WebHTMLView)
+
+- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object
+{
+ NSEnumerator *enumerator = [self objectEnumerator];
+ WebNetscapePluginEmbeddedView *view;
+ while ((view = [enumerator nextObject]) != nil) {
+ if ([view isKindOfClass:[WebNetscapePluginEmbeddedView class]]) {
+ [view performSelector:selector withObject:object];
+ }
+ }
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index d6b374f..bcb7f55 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -59,7 +59,6 @@ static BOOL forceRealHitTest = NO;
@end
@interface NSView (WebNSViewDisplayExtras)
-- (void)_web_stopIfPluginView;
- (void)_web_propagateDirtyRectToAncestor;
- (void)_web_dumpDirtyRects;
@end
@@ -126,10 +125,6 @@ static BOOL forceRealHitTest = NO;
- (void)_reset
{
- NSArray *subviews = [[self subviews] copy];
- [subviews makeObjectsPerformSelector:@selector(_web_stopIfPluginView)];
- [subviews release];
-
[WebImageRenderer stopAnimationsInView:self];
}
@@ -597,14 +592,6 @@ static WebHTMLView *lastHitView = nil;
@implementation NSView (WebHTMLViewPrivate)
-- (void)_web_stopIfPluginView
-{
- if ([self isKindOfClass:[WebNetscapePluginEmbeddedView class]]) {
- WebNetscapePluginEmbeddedView *pluginView = (WebNetscapePluginEmbeddedView *)self;
- [pluginView stop];
- }
-}
-
- (void)_web_propagateDirtyRectToAncestor
{
[_subviews makeObjectsPerformSelector:@selector(_web_propagateDirtyRectToAncestor)];
diff --git a/WebKit/WebView.subproj/WebImageView.m b/WebKit/WebView.subproj/WebImageView.m
index 214ad7c..2bfdb00 100644
--- a/WebKit/WebView.subproj/WebImageView.m
+++ b/WebKit/WebView.subproj/WebImageView.m
@@ -104,6 +104,16 @@
}
}
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+
+}
+
+- (void)viewDidMoveToHostWindow
+{
+
+}
+
- (void)viewDidMoveToWindow
{
if (![self window]){
diff --git a/WebKit/WebView.subproj/WebTextView.m b/WebKit/WebView.subproj/WebTextView.m
index cab72e3..49978de 100644
--- a/WebKit/WebView.subproj/WebTextView.m
+++ b/WebKit/WebView.subproj/WebTextView.m
@@ -93,6 +93,16 @@
{
}
+- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
+{
+
+}
+
+- (void)viewDidMoveToHostWindow
+{
+
+}
+
- (void)defaultsChanged:(NSNotification *)notification
{
if (![self isRichText]) {
diff --git a/WebKit/WebView.subproj/WebView.h b/WebKit/WebView.subproj/WebView.h
index c1f5c7d..ccee0cf 100644
--- a/WebKit/WebView.subproj/WebView.h
+++ b/WebKit/WebView.subproj/WebView.h
@@ -328,6 +328,21 @@ extern NSString *WebElementLinkLabelKey; // NSString of the text within the anch
*/
- (WebPreferences *)preferences;
+/*!
+ @method setHostWindow:
+ @param hostWindow The host window for the web view.
+ @discussion Parts of WebKit (such as plug-ins and JavaScript) depend on a window to function
+ properly. Set a host window so these parts continue to function even when the web view is
+ not in an actual window.
+*/
+- (void)setHostWindow:(NSWindow *)hostWindow;
+
+/*!
+ @method hostWindow
+ @result The host window for the web view.
+*/
+- (NSWindow *)hostWindow;
+
@end
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 977fe7c..77982bb 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -446,6 +446,21 @@ NSString *WebElementLinkTitleKey = @"WebElementLinkTitle";
return userAgent;
}
+- (void)setHostWindow:(NSWindow *)hostWindow
+{
+ if (hostWindow != _private->hostWindow) {
+ [[self mainFrame] _viewWillMoveToHostWindow:hostWindow];
+ [_private->hostWindow release];
+ _private->hostWindow = [hostWindow retain];
+ [[self mainFrame] _viewDidMoveToHostWindow];
+ }
+}
+
+- (NSWindow *)hostWindow
+{
+ return _private->hostWindow;
+}
+
-(BOOL)acceptsFirstResponder
{
return YES;
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index c218db2..a4bcf0c 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -50,6 +50,8 @@ enum { NumUserAgentStringTypes = WinIE + 1 };
WebCoreSettings *settings;
BOOL lastElementWasNonNil;
+
+ NSWindow *hostWindow;
}
@end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index fbdde33..9a7e197 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -85,6 +85,7 @@
[preferences release];
[settings release];
+ [hostWindow release];
[super dealloc];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list