Commit c594b671 authored by darin's avatar darin
Browse files

WebKit:

        Reviewed by Trey.

	- fixed 3137287 -- REGRESSION: Java applets don't work when you go back to them (Java 1.4.1 plug-in)

	By attaching the plug-in controller to the frame, we run into trouble.
	It really needs to be attached to the data source, which has the right lifetime
	and is kept around in the page cache.

        * Plugins.subproj/WebPluginController.h: Keep a reference to a data source, not a frame.
	Add a new _started variable. Rename addPluginView: to addPlugin:, get rid of didAddPluginView:,
	replace destroyAllPlugins with dataSourceWillBeDeallocated, add startAllPlugins and stopAllPlugins.
        * Plugins.subproj/WebPluginController.m:
        (-[WebPluginController initWithDataSource:]): Store a data source reference, not a frame reference.
	Don't bother registering for the window will close notification, WebHTMLView handles that fine.
        (-[WebPluginController startAllPlugins]): Do nothing if they are already started, call pluginStart on each otherwise.
        (-[WebPluginController stopAllPlugins]): Do nothing if they are not started, call pluginStop on each otherwise.
        (-[WebPluginController addPlugin:]): Initialize the plugin if it's not already in our list. Also start
	it if we are in "started" mode.
        (-[WebPluginController dataSourceWillBeDeallocated]): Stop all the plugins, then destroy them.
	Also nil out the fields of the object. This is always called before the controller is released so we
	don't need to override dealloc.
        (-[WebPluginController showURL:inFrame:]): Added error checking and changed now that we start with a data source.
        (-[WebPluginController showStatus:]): Ditto.

        * WebCoreSupport.subproj/WebBridge.m: (-[WebBridge pluginViewWithPackage:attributes:baseURL:]):
	Use the data source, not the view. Don't add the plugin here, wait until we are ready to start.

        * WebView.subproj/WebDataSourcePrivate.h: Store a pointer to the plug-in controller here.
        * WebView.subproj/WebDataSourcePrivate.m:
        (-[WebDataSourcePrivate dealloc]): Tell the plug-in controller to go away.
	(-[WebDataSource _makeHandleDelegates:deferCallbacks:]): Remove unused empty method.
        (-[WebDataSource _pluginController]): Create a plug-in controller if needed.

        * WebView.subproj/WebFramePrivate.h: Remove plug-in controller code.
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFramePrivate dealloc]): Remove plug-in controller code.
        (-[WebFrame _detachFromParent]): Remove plug-in controller code.
        (-[WebFrame _transitionToCommitted:]): Remove plug-in controller code.

        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView viewWillMoveToWindow:]): Stop plug-ins when view moves out of a window.
	This includes the case when the window is being destroyed.
        (-[WebHTMLView viewDidMoveToWindow]): Start plug-ins when view moves into a window.
        (-[WebHTMLView addSubview:]): Add plug-ins to the controller as they are added to us.

        * WebView.subproj/WebController.m: Added now-needed include due to header change.
        * WebView.subproj/WebDefaultContextMenuDelegate.m: Ditto.

WebBrowser:

        Reviewed by Don and Ken.

	- worked around 3137387 -- Using Java 1.4.1 plug-in causes world leak (NSDocument close never called)

        * BrowserWindow.m:
        (-[BrowserWindow setDelegate:]): If someone tries to set the delegate to something other than the
	BrowserWindowController, don't let them.
        (-[BrowserWindow setWindowController:]): Same thing for the controller.

	- fixed 3137494 -- loading bad URL with PLT window in "world leak check mode" indicates leak, prevents quit

        Filed bug 3137567 about the AppKit part of this.

        * Test/PageLoadTestRunner.m: (-[NSWindow closeIfBrowserWindow]): Close the sheet, if any, before
	closing the window.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3223 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 01a4cc72
2002-12-31 Darin Adler <darin@apple.com>
Reviewed by Trey.
- fixed 3137287 -- REGRESSION: Java applets don't work when you go back to them (Java 1.4.1 plug-in)
By attaching the plug-in controller to the frame, we run into trouble.
It really needs to be attached to the data source, which has the right lifetime
and is kept around in the page cache.
* Plugins.subproj/WebPluginController.h: Keep a reference to a data source, not a frame.
Add a new _started variable. Rename addPluginView: to addPlugin:, get rid of didAddPluginView:,
replace destroyAllPlugins with dataSourceWillBeDeallocated, add startAllPlugins and stopAllPlugins.
* Plugins.subproj/WebPluginController.m:
(-[WebPluginController initWithDataSource:]): Store a data source reference, not a frame reference.
Don't bother registering for the window will close notification, WebHTMLView handles that fine.
(-[WebPluginController startAllPlugins]): Do nothing if they are already started, call pluginStart on each otherwise.
(-[WebPluginController stopAllPlugins]): Do nothing if they are not started, call pluginStop on each otherwise.
(-[WebPluginController addPlugin:]): Initialize the plugin if it's not already in our list. Also start
it if we are in "started" mode.
(-[WebPluginController dataSourceWillBeDeallocated]): Stop all the plugins, then destroy them.
Also nil out the fields of the object. This is always called before the controller is released so we
don't need to override dealloc.
(-[WebPluginController showURL:inFrame:]): Added error checking and changed now that we start with a data source.
(-[WebPluginController showStatus:]): Ditto.
* WebCoreSupport.subproj/WebBridge.m: (-[WebBridge pluginViewWithPackage:attributes:baseURL:]):
Use the data source, not the view. Don't add the plugin here, wait until we are ready to start.
* WebView.subproj/WebDataSourcePrivate.h: Store a pointer to the plug-in controller here.
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSourcePrivate dealloc]): Tell the plug-in controller to go away.
(-[WebDataSource _makeHandleDelegates:deferCallbacks:]): Remove unused empty method.
(-[WebDataSource _pluginController]): Create a plug-in controller if needed.
* WebView.subproj/WebFramePrivate.h: Remove plug-in controller code.
* WebView.subproj/WebFramePrivate.m:
(-[WebFramePrivate dealloc]): Remove plug-in controller code.
(-[WebFrame _detachFromParent]): Remove plug-in controller code.
(-[WebFrame _transitionToCommitted:]): Remove plug-in controller code.
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView viewWillMoveToWindow:]): Stop plug-ins when view moves out of a window.
This includes the case when the window is being destroyed.
(-[WebHTMLView viewDidMoveToWindow]): Start plug-ins when view moves into a window.
(-[WebHTMLView addSubview:]): Add plug-ins to the controller as they are added to us.
* WebView.subproj/WebController.m: Added now-needed include due to header change.
* WebView.subproj/WebDefaultContextMenuDelegate.m: Ditto.
=== Alexander-47 ===
2002-12-30 Darin Adler <darin@apple.com>
......
......@@ -8,22 +8,24 @@
#import <Foundation/Foundation.h>
#import <WebKit/WebPluginContainer.h>
@class WebFrame;
@class WebDataSource;
@protocol WebPlugin;
@protocol WebPluginContainer;
@interface WebPluginController : NSObject <WebPluginContainer>
{
WebFrame *frame;
NSMutableArray *views;
WebDataSource *_dataSource;
NSMutableArray *_views;
BOOL _started;
}
- initWithWebFrame:(WebFrame *)theFrame;
- (void)addPluginView:(NSView <WebPlugin> *)view;
- (void)didAddPluginView:(NSView <WebPlugin> *)view;
- (void)destroyAllPlugins;
- (id)initWithDataSource:(WebDataSource *)dataSource;
- (void)dataSourceWillBeDeallocated;
- (void)addPlugin:(NSView <WebPlugin> *)view;
- (void)startAllPlugins;
- (void)stopAllPlugins;
@end
......@@ -6,114 +6,119 @@
// Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
//
#import <WebKit/WebPluginController.h>
#import <WebKit/WebController.h>
#import <WebKit/WebDataSource.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebPlugin.h>
#import <WebKit/WebPluginController.h>
#import <WebKit/WebWindowOperationsDelegate.h>
#import <WebKit/WebPluginContainer.h>
#import <WebKit/WebView.h>
#import <WebKit/WebWindowOperationsDelegate.h>
#import <WebFoundation/WebAssertions.h>
#import <WebFoundation/WebResourceRequest.h>
@implementation WebPluginController
- initWithWebFrame:(WebFrame *)theFrame
- initWithDataSource:(WebDataSource *)dataSource
{
[super init];
// Not retained because the frame retains this plug-in controller.
frame = theFrame;
views = [[NSMutableArray array] retain];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillClose:)
name:NSWindowWillCloseNotification
object:nil];
_dataSource = dataSource;
_views = [[NSMutableArray alloc] init];
return self;
}
- (void)dealloc
- (void)startAllPlugins
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
if (_started) {
return;
}
ASSERT([views count] == 0);
[views release];
[super dealloc];
}
LOG(Plugins, "starting all plugins");
- (void)addPluginView:(NSView <WebPlugin> *)view
{
LOG(Plugins, "pluginInitialize: %s", [[view className] lossyCString]);
[views addObject:view];
[view pluginInitialize];
[_views makeObjectsPerformSelector:@selector(pluginStart)];
_started = YES;
}
- (void)didAddPluginView:(NSView <WebPlugin> *)view
- (void)stopAllPlugins
{
LOG(Plugins, "pluginStart: %s", [[view className] lossyCString]);
if (!_started) {
return;
}
[view pluginStart];
}
LOG(Plugins, "stopping all plugins");
- (void)startAllPlugins
{
LOG(Plugins, "pluginStart");
[views makeObjectsPerformSelector:@selector(pluginStart)];
[_views makeObjectsPerformSelector:@selector(pluginStop)];
_started = NO;
}
- (void)stopAllPlugins
- (void)addPlugin:(NSView <WebPlugin> *)view
{
LOG(Plugins, "pluginStop");
if (!_dataSource) {
ERROR("can't add a plug-in to a defunct WebPluginController");
return;
}
[views makeObjectsPerformSelector:@selector(pluginStop)];
if (![_views containsObject:view]) {
[_views addObject:view];
LOG(Plugins, "initializing plug-in %@", view);
[view pluginInitialize];
if (_started) {
LOG(Plugins, "starting plug-in %@", view);
[view pluginStart];
}
}
}
- (void)destroyAllPlugins
- (void)dataSourceWillBeDeallocated
{
LOG(Plugins, "pluginDestroy");
LOG(Plugins, "destroying all plug-ins");
[self stopAllPlugins];
[views makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
[views makeObjectsPerformSelector:@selector(pluginDestroy)];
[views removeAllObjects];
// after this point, do not try to do anything with the frame, even if we get some
// late arriving messages from the plugin
frame = nil;
}
[_views makeObjectsPerformSelector:@selector(removeFromSuperviewWithoutNeedingDisplay)];
[_views makeObjectsPerformSelector:@selector(pluginDestroy)];
[_views release];
_views = nil;
- (void)windowWillClose:(NSNotification *)notification
{
if([notification object] == [[frame webView] window]){
[self destroyAllPlugins];
}
_dataSource = nil;
}
- (void)showURL:(NSURL *)URL inFrame:(NSString *)target
{
if ( !URL || !frame ){
if (!URL) {
ERROR("nil URL passed");
return;
}
WebFrame *otherFrame = [frame findOrCreateFramedNamed:target];
[otherFrame loadRequest:[WebResourceRequest requestWithURL:URL]];
if (!_dataSource) {
ERROR("could not load URL %@ because plug-in has already been destroyed", URL);
return;
}
WebFrame *frame = [_dataSource webFrame];
if (!frame) {
ERROR("could not load URL %@ because plug-in has already been stopped", URL);
return;
}
WebResourceRequest *request = [WebResourceRequest requestWithURL:URL];
if (!request) {
ERROR("could not load URL %@", URL);
return;
}
[[frame findOrCreateFramedNamed:target] loadRequest:request];
}
- (void)showStatus:(NSString *)message
{
if(!message || !frame){
if (!message) {
message = @"";
}
if (!_dataSource) {
ERROR("could not show status message (%@) because plug-in has already been destroyed", message);
return;
}
[[[frame controller] windowOperationsDelegate] setStatusText:message];
[[[_dataSource controller] windowOperationsDelegate] setStatusText:message];
}
@end
......@@ -386,19 +386,17 @@ - (NSString *)requestedURL
attributes:(NSDictionary *)attributes
baseURL:(NSURL *)baseURL
{
WebPluginController *pluginController = [frame _pluginController];
WebPluginController *pluginController = [[self dataSource] _pluginController];
NSDictionary *arguments = [NSDictionary dictionaryWithObjectsAndKeys:
baseURL, WebPluginBaseURLKey,
attributes, WebPluginAttributesKey,
pluginController, WebPluginContainerKey, nil];
pluginController, WebPluginContainerKey,
nil];
LOG(Plugins, "arguments:\n%s", [[arguments description] lossyCString]);
LOG(Plugins, "arguments:\n%@", arguments);
NSView<WebPlugin> *view = [[pluginPackage viewFactory] pluginViewWithArguments:arguments];
[pluginController addPluginView:view];
return view;
return [[pluginPackage viewFactory] pluginViewWithArguments:arguments];
}
- (NSView *)viewForPluginWithURL:(NSString *)URL
......
......@@ -6,6 +6,7 @@
#import <WebKit/WebController.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebBridge.h>
#import <WebKit/WebContextMenuDelegate.h>
#import <WebKit/WebController.h>
#import <WebKit/WebControllerSets.h>
......
......@@ -7,16 +7,15 @@
*/
#import <WebKit/WebDataSource.h>
#import <WebKit/WebBridge.h>
@class WebBridge;
@class WebHistoryItem;
@class WebIconLoader;
@class WebMainResourceClient;
@class WebNetscapePluginStream;
@class WebResourceHandle;
@class WebPluginController;
@class WebResourceRequest;
@class WebResourceResponse;
@class WebSubresourceClient;
@class WebHistoryItem;
@protocol WebDocumentRepresentation;
......@@ -88,6 +87,8 @@
BOOL storedInPageCache;
BOOL loadingFromPageCache;
WebPluginController *pluginController;
}
@end
......@@ -148,5 +149,6 @@
- (void)_setStoredInPageCache:(BOOL)f;
- (BOOL)_storedInPageCache;
- (BOOL)_loadingFromPageCache;
- (WebPluginController *)_pluginController;
@end
......@@ -24,6 +24,7 @@
#import <WebKit/WebLocationChangeDelegate.h>
#import <WebKit/WebMainResourceClient.h>
#import <WebKit/WebNetscapePluginStream.h>
#import <WebKit/WebPluginController.h>
#import <WebKit/WebSubresourceClient.h>
#import <WebKit/WebTextRepresentation.h>
#import <WebKit/WebViewPrivate.h>
......@@ -46,6 +47,8 @@ - (void)dealloc
// retained while loading, so no need to release here
ASSERT(!loading);
[pluginController dataSourceWillBeDeallocated];
[resourceData release];
[representation release];
[request release];
......@@ -62,6 +65,7 @@ - (void)dealloc
[triggeringAction release];
[lastCheckedRequest release];
[downloadPath release];
[pluginController release];
[super dealloc];
}
......@@ -575,12 +579,6 @@ - (void)_setIconURL:(NSURL *)URL withType:(NSString *)iconType
_private->iconURL = [URL retain];
}
- (void)_makeHandleDelegates:(NSArray *)handleDelegates deferCallbacks:(BOOL)deferCallbacks
{
}
- (void)_defersCallbacksChanged
{
BOOL defers = [_private->controller _defersCallbacks];
......@@ -671,5 +669,12 @@ - (BOOL)_loadingFromPageCache
return _private->loadingFromPageCache;
}
@end
- (WebPluginController *)_pluginController
{
if (!_private->pluginController) {
_private->pluginController = [[WebPluginController alloc] initWithDataSource:self];
}
return _private->pluginController;
}
@end
......@@ -4,6 +4,8 @@
*/
#import <WebKit/WebContextMenuDelegate.h>
#import <WebKit/WebBridge.h>
#import <WebKit/WebControllerPolicyDelegate.h>
#import <WebKit/WebControllerPrivate.h>
#import <WebKit/WebDataSourcePrivate.h>
......
......@@ -12,7 +12,6 @@
@class WebBridge;
@class WebFrameBridge;
@class WebHistoryItem;
@class WebPluginController;
@class WebView;
@class WebResourceRequest;
......@@ -62,7 +61,6 @@ typedef enum {
WebFrameLoadType loadType;
WebFrame *parent;
NSMutableArray *children;
WebPluginController *pluginController;
WebHistoryItem *currentItem; // BF item for our current content
WebHistoryItem *provisionalItem; // BF item for where we're trying to go
// (only known when navigating to a pre-existing BF item)
......@@ -141,8 +139,6 @@ typedef enum {
- (NSString *)_generateFrameName;
- (WebPluginController *)_pluginController;
- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
- (WebHistoryItem *)_itemForSavingDocState;
......
......@@ -24,7 +24,6 @@
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebKitErrors.h>
#import <WebKit/WebLocationChangeDelegate.h>
#import <WebKit/WebPluginController.h>
#import <WebKit/WebPreferencesPrivate.h>
#import <WebKit/WebViewPrivate.h>
......@@ -101,8 +100,6 @@ - (void)_scrollToTop;
- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
- (void)_resetBackForwardListToCurrent;
- (void)_destroyPluginController;
@end
@implementation WebFramePrivate
......@@ -133,7 +130,6 @@ - (void)dealloc
[bridge release];
[scheduledLayoutTimer release];
[children release];
[pluginController release];
[currentItem release];
[provisionalItem release];
......@@ -338,9 +334,6 @@ - (void)_detachFromParent
WebBridge *bridge = _private->bridge;
_private->bridge = nil;
// Destroy plug-ins before blowing away the view.
[self _destroyPluginController];
[self stopLoading];
[self _saveScrollPositionToItem:[_private currentItem]];
......@@ -508,9 +501,6 @@ - (void)_transitionToCommitted: (NSDictionary *)pageCache
{
ASSERT([self controller] != nil);
// Destroy plug-ins before blowing away the view.
[self _destroyPluginController];
switch ([self _state]) {
case WebFrameStateProvisional:
{
......@@ -1618,27 +1608,6 @@ - (void)_addChild:(WebFrame *)child
[[child dataSource] _setOverrideEncoding:[[self dataSource] _overrideEncoding]];
}
- (void)_destroyPluginController
{
[_private->pluginController destroyAllPlugins];
// We flush this PluginController, so if a later page requests one we will make a new one
// instead of reusing the old one. Plugin views retain their PluginController, so a
// wayward view might try to message an old controller even after we call destroyAllPlugins.
// We don't want to have a controller that has to both ignore requests from stale views
// and honor those from current views, so it's easiest to make a new controller.
[_private->pluginController release];
_private->pluginController = nil;
}
- (WebPluginController *)_pluginController
{
if(!_private->pluginController){
_private->pluginController = [[WebPluginController alloc] initWithWebFrame:self];
}
return _private->pluginController;
}
- (void)_addFramePathToString:(NSMutableString *)path
{
if ([_private->name hasPrefix:@"<!--framePath "]) {
......
......@@ -240,6 +240,8 @@ - (void)viewWillMoveToWindow:(NSWindow *)window
[self removeWindowObservers];
[self removeSuperviewObservers];
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_updateMouseoverWithFakeEvent) object:nil];
[[[[self _frame] dataSource] _pluginController] stopAllPlugins];
}
- (void)viewDidMoveToWindow
......@@ -248,6 +250,9 @@ - (void)viewDidMoveToWindow
[self addWindowObservers];
[self addSuperviewObservers];
[self addMouseMovedObserver];
[[[[self _frame] dataSource] _pluginController] startAllPlugins];
_private->inWindow = YES;
} else {
// Reset when we are moved out of a window after being moved into one.
......@@ -263,11 +268,11 @@ - (void)viewDidMoveToWindow
- (void)addSubview:(NSView *)view
{
[super addSubview:view];
if ([view conformsToProtocol:@protocol(WebPlugin)]) {
[[[self _frame] _pluginController] didAddPluginView:view];
[[[[self _frame] dataSource] _pluginController] addPlugin:view];
}
[super addSubview:view];
}
- (void)reapplyStyles
......
......@@ -6,6 +6,7 @@
#import <WebKit/WebController.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebBridge.h>
#import <WebKit/WebContextMenuDelegate.h>
#import <WebKit/WebController.h>
#import <WebKit/WebControllerSets.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment