Commit 6a96e2b0 authored by mjs's avatar mjs
Browse files

WebKit:

	Change things so the public interface to loading is loadRequest:
	and everything else is private.

        * Plugins.subproj/WebBaseNetscapePluginView.m:
        (-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]):
        * Plugins.subproj/WebPluginController.m:
        (-[WebPluginController showURL:inFrame:]):
        * WebView.subproj/WebController.h:
        * WebView.subproj/WebController.m:
        (-[WebController init]):
        * WebView.subproj/WebControllerPrivate.m:
        (-[WebController _createFrameNamed:inParent:allowsScrolling:]):
        (-[WebController _downloadURL:toPath:]):
        * WebView.subproj/WebFrame.h:
        * WebView.subproj/WebFrame.m:
        (-[WebFrame init]):
        (-[WebFrame initWithName:webView:controller:]):
        (-[WebFrame loadRequest:]):
        (-[WebFrame reload]):
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _timedLayout:]):
        (-[WebFrame _clearProvisionalDataSource]):
        (-[WebFrame _loadItem:fromItem:withLoadType:]):
        (-[WebFrame _loadRequest:triggeringAction:]):
        (-[WebFrame _reloadAllowingStaleDataWithOverrideEncoding:]):
        (-[WebFrame _itemForRestoringDocState]):
        (-[WebFrame _setProvisionalDataSource:]):
        (-[WebFrame _startLoading]):
        (-[WebFrame _downloadRequest:toPath:]):
        * WebView.subproj/WebMainResourceClient.m:
        (-[WebMainResourceClient handle:willSendRequest:]):
        (-[WebMainResourceClient stopLoadingAfterContentPolicy]):
        (-[WebMainResourceClient handle:didReceiveResponse:]):
        * WebView.subproj/WebView.m:
        (-[WebView concludeDragOperation:]):

WebBrowser:

	Change things so the public interface to loading is loadRequest:
	and everything else is private.

        * BrowserDocument.m:
        (-[BrowserDocument goToRequest:]):
        * BrowserWebController.m:
        (-[BrowserWebController initWithBrowserDocument:]):
        * Debug/SnippetController.h:
        * Debug/SnippetController.m:
        (-[SnippetController dealloc]):
        (-[SnippetController windowWillClose:]):
        (-[SnippetController load]):
        (-[SnippetController loadComplete]):
        (-[SnippetController mainDataSource]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5ee8b596
2002-11-14 Maciej Stachowiak <mjs@apple.com>
Change things so the public interface to loading is loadRequest:
and everything else is private.
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]):
* Plugins.subproj/WebPluginController.m:
(-[WebPluginController showURL:inFrame:]):
* WebView.subproj/WebController.h:
* WebView.subproj/WebController.m:
(-[WebController init]):
* WebView.subproj/WebControllerPrivate.m:
(-[WebController _createFrameNamed:inParent:allowsScrolling:]):
(-[WebController _downloadURL:toPath:]):
* WebView.subproj/WebFrame.h:
* WebView.subproj/WebFrame.m:
(-[WebFrame init]):
(-[WebFrame initWithName:webView:controller:]):
(-[WebFrame loadRequest:]):
(-[WebFrame reload]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _timedLayout:]):
(-[WebFrame _clearProvisionalDataSource]):
(-[WebFrame _loadItem:fromItem:withLoadType:]):
(-[WebFrame _loadRequest:triggeringAction:]):
(-[WebFrame _reloadAllowingStaleDataWithOverrideEncoding:]):
(-[WebFrame _itemForRestoringDocState]):
(-[WebFrame _setProvisionalDataSource:]):
(-[WebFrame _startLoading]):
(-[WebFrame _downloadRequest:toPath:]):
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient handle:willSendRequest:]):
(-[WebMainResourceClient stopLoadingAfterContentPolicy]):
(-[WebMainResourceClient handle:didReceiveResponse:]):
* WebView.subproj/WebView.m:
(-[WebView concludeDragOperation:]):
2002-11-14 David Hyatt <hyatt@apple.com>
 
Move text measurement and layout beyond onload. This
......
2002-11-14 Maciej Stachowiak <mjs@apple.com>
Change things so the public interface to loading is loadRequest:
and everything else is private.
* Plugins.subproj/WebBaseNetscapePluginView.m:
(-[WebBaseNetscapePluginView loadRequest:inTarget:withNotifyData:]):
* Plugins.subproj/WebPluginController.m:
(-[WebPluginController showURL:inFrame:]):
* WebView.subproj/WebController.h:
* WebView.subproj/WebController.m:
(-[WebController init]):
* WebView.subproj/WebControllerPrivate.m:
(-[WebController _createFrameNamed:inParent:allowsScrolling:]):
(-[WebController _downloadURL:toPath:]):
* WebView.subproj/WebFrame.h:
* WebView.subproj/WebFrame.m:
(-[WebFrame init]):
(-[WebFrame initWithName:webView:controller:]):
(-[WebFrame loadRequest:]):
(-[WebFrame reload]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _timedLayout:]):
(-[WebFrame _clearProvisionalDataSource]):
(-[WebFrame _loadItem:fromItem:withLoadType:]):
(-[WebFrame _loadRequest:triggeringAction:]):
(-[WebFrame _reloadAllowingStaleDataWithOverrideEncoding:]):
(-[WebFrame _itemForRestoringDocState]):
(-[WebFrame _setProvisionalDataSource:]):
(-[WebFrame _startLoading]):
(-[WebFrame _downloadRequest:toPath:]):
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient handle:willSendRequest:]):
(-[WebMainResourceClient stopLoadingAfterContentPolicy]):
(-[WebMainResourceClient handle:didReceiveResponse:]):
* WebView.subproj/WebView.m:
(-[WebView concludeDragOperation:]):
2002-11-14 David Hyatt <hyatt@apple.com>
 
Move text measurement and layout beyond onload. This
......
......@@ -774,41 +774,34 @@ - (NPError)loadRequest:(WebResourceRequest *)request inTarget:(NSString *)target
{
NSURL *URL = [request URL];
if(!URL){
if (!URL) {
return NPERR_INVALID_URL;
}
if(!target){
if (!target) {
WebNetscapePluginStream *stream = [[WebNetscapePluginStream alloc] initWithRequest:request
pluginPointer:instance
notifyData:notifyData];
if(stream){
if (stream) {
[streams addObject:stream];
[stream start];
[stream release];
}else{
} else {
return NPERR_INVALID_URL;
}
}else{
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:request];
if(dataSource){
WebFrame *frame = [[self webFrame] findOrCreateFramedNamed:target];
if ([frame setProvisionalDataSource:dataSource]) {
if(notifyData){
if(![target isEqualToString:@"_self"] && ![target isEqualToString:@"_current"] &&
![target isEqualToString:@"_parent"] && ![target isEqualToString:@"_top"]){
[streamNotifications setObject:[NSValue valueWithPointer:notifyData] forKey:URL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameStateChanged:) name:WebFrameStateChangedNotification object:frame];
}
}
[frame startLoading];
}
[dataSource release];
}
} else {
WebFrame *frame = [[self webFrame] findOrCreateFramedNamed:target];
[frame loadRequest:request];
if (notifyData) {
if (![target isEqualToString:@"_self"] && ![target isEqualToString:@"_current"] &&
![target isEqualToString:@"_parent"] && ![target isEqualToString:@"_top"]) {
[streamNotifications setObject:[NSValue valueWithPointer:notifyData] forKey:URL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameStateChanged:) name:WebFrameStateChangedNotification object:frame];
}
}
}
return NPERR_NO_ERROR;
......
......@@ -98,16 +98,9 @@ - (void)showURL:(NSURL *)URL inFrame:(NSString *)target
return;
}
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:[WebResourceRequest requestWithURL:URL]];
if(!dataSource){
return;
}
WebFrame *otherFrame = [frame findOrCreateFramedNamed:target];
if([otherFrame setProvisionalDataSource:dataSource]){
[otherFrame startLoading];
}
[otherFrame loadRequest:[WebResourceRequest requestWithURL:URL]];
}
- (void)showStatus:(NSString *)message
......
......@@ -50,12 +50,8 @@ extern NSString *WebElementFrameKey;
WebFrame *mainFrame;
webController = [[WebController alloc] initWithView: webView provisionalDataSource: nil];
dataSource = [[[WebDataSource alloc] initWithURL:url] autorelease];
mainFrame = [webController mainFrame];
if([mainFrame setProvisionalDataSource: dataSource]){
[mainFrame startLoading];
}
[mainFrame loadRequest:request];
</pre>
WebControllers have the following delegates: WebWindowOperationsDelegate,
......@@ -101,7 +97,7 @@ extern NSString *WebElementFrameKey;
+ (BOOL)canShowFile:(NSString *)path;
/*!
@method initWithView:provisionalDataSource:controllerSetName:
@method initWithView:controllerSetName:
@abstract The designated initializer for WebController.
@discussion Initialize a WebController with the supplied parameters. This method
will create a main WebFrame with the view and datasource. The frame will be
......@@ -111,7 +107,7 @@ extern NSString *WebElementFrameKey;
@param name The name of the controller set to which this controller will be added. May be nil.
@result Returns an initialized WebController.
*/
- initWithView: (WebView *)view provisionalDataSource: (WebDataSource *)dataSource controllerSetName: (NSString *)name;
- initWithView: (WebView *)view controllerSetName: (NSString *)name;
/*!
@method setWindowOperationsDelegate:
......
......@@ -42,15 +42,15 @@ @implementation WebController
- init
{
return [self initWithView: nil provisionalDataSource: nil controllerSetName: nil];
return [self initWithView: nil controllerSetName: nil];
}
- initWithView: (WebView *)view provisionalDataSource: (WebDataSource *)dataSource controllerSetName: (NSString *)name;
- initWithView: (WebView *)view controllerSetName: (NSString *)name;
{
[super init];
_private = [[WebControllerPrivate alloc] init];
_private->mainFrame = [[WebFrame alloc] initWithName: @"_top" webView: view provisionalDataSource: dataSource controller: self];
_private->mainFrame = [[WebFrame alloc] initWithName: @"_top" webView: view controller: self];
_private->controllerSetName = [name retain];
if (_private->controllerSetName != nil) {
[WebControllerSets addController:self toSetNamed:_private->controllerSetName];
......
......@@ -85,7 +85,7 @@ - (WebFrame *)_createFrameNamed:(NSString *)fname inParent:(WebFrame *)parent al
[childView _setController:self];
[childView setAllowsScrolling:allowsScrolling];
WebFrame *newFrame = [[WebFrame alloc] initWithName:fname webView:childView provisionalDataSource:nil controller:self];
WebFrame *newFrame = [[WebFrame alloc] initWithName:fname webView:childView controller:self];
[childView release];
......@@ -192,15 +192,11 @@ - (void)_downloadURL:(NSURL *)URL
- (void)_downloadURL:(NSURL *)URL toPath:(NSString *)path
{
WebDataSource *dataSource = [[WebDataSource alloc] initWithURL:URL];
WebResourceRequest *request = [[WebResourceRequest alloc] initWithURL:URL];
WebFrame *webFrame = [self mainFrame];
[dataSource _setIsDownloading:YES];
[dataSource _setDownloadPath:path];
if([webFrame setProvisionalDataSource:dataSource]){
[webFrame startLoading];
}
[dataSource release];
[webFrame _downloadRequest:request toPath:path];
[request release];
}
- (BOOL)_defersCallbacks
......
......@@ -13,6 +13,7 @@
@class WebError;
@class WebFramePrivate;
@class WebView;
@class WebResourceRequest;
/*!
@class WebFrame
......@@ -26,15 +27,14 @@
}
/*!
@method initWithName:webView:provisionalDataSource:controller:
@method initWithName:webView:controller:
@abstract The designated initializer of WebFrame.
@param name The name of the frame.
@param view The view for the frame.
@param dataSource The dataSource for the frame.
@param controller The controller that manages the frame.
@result Returns an initialized WebFrame.
*/
- initWithName: (NSString *)name webView: (WebView *)view provisionalDataSource: (WebDataSource *)dataSource controller: (WebController *)controller;
- initWithName: (NSString *)name webView: (WebView *)view controller: (WebController *)controller;
/*!
@method name
......@@ -67,16 +67,9 @@
- (WebView *)webView;
/*!
@method setProvisionalDataSource:
@discussion Sets the frame's data source. Note that the data source will be
considered 'provisional' until it has been loaded, and at least
~some~ data has been received.
@param dataSource
@result Returns NO and will not set the provisional data source if the controller
disallows by returning a WebURLPolicyIgnore.
@method loadRequest:
*/
- (BOOL)setProvisionalDataSource: (WebDataSource *)dataSource;
-(void)loadRequest:(WebResourceRequest *)request;
/*!
@method dataSource
......@@ -95,16 +88,6 @@
*/
- (WebDataSource *)provisionalDataSource;
/*!
@method startLoading
@discussion If a frame has a provisional data source this method will begin
loading data for that provisional data source. If the frame
has no provisional data source this method will do nothing.
To reload an existing data source call reload.
*/
- (void)startLoading;
/*!
@method stopLoading
@discussion Stop any pending loads on the frame's data source,
......@@ -112,7 +95,6 @@
*/
- (void)stopLoading;
/*!
@method reload
*/
......
......@@ -28,10 +28,10 @@ @implementation WebFrame
- init
{
return [self initWithName: nil webView: nil provisionalDataSource: nil controller: nil];
return [self initWithName: nil webView: nil controller: nil];
}
- initWithName: (NSString *)n webView: (WebView *)v provisionalDataSource: (WebDataSource *)d controller: (WebController *)c
- initWithName: (NSString *)n webView: (WebView *)v controller: (WebController *)c
{
[super init];
......@@ -45,11 +45,6 @@ @implementation WebFrame
[_private setName:n];
if (d && ![self setProvisionalDataSource:d]) {
[self release];
return nil;
}
if (v)
[self setWebView:v];
......@@ -108,58 +103,15 @@ - (WebDataSource *)dataSource
return [_private dataSource];
}
// Will return NO and not set the provisional data source if the controller
// disallows by returning a WebURLPolicyIgnore.
- (BOOL)setProvisionalDataSource: (WebDataSource *)newDataSource
- (void)loadRequest:(WebResourceRequest *)request
{
ASSERT([self controller] != nil);
// Unfortunately the view must be non-nil, this is ultimately due
// to KDE parser requiring a KHTMLView. Once we settle on a final
// KDE drop we should fix this dependency.
ASSERT([self webView] != nil);
if ([self _state] != WebFrameStateComplete) {
[self stopLoading];
}
[self _setLoadType: WebFrameLoadTypeStandard];
// _continueAfterNavigationPolicyForRequest:dataSource: asks the
// client for the URL policies and reports errors if there are any
// returns YES if we should show the data source
if (![self _continueAfterNavigationPolicyForRequest:[newDataSource request] dataSource:newDataSource]) {
return NO;
}
if ([self parent]) {
[newDataSource _setOverrideEncoding:[[[self parent] dataSource] _overrideEncoding]];
WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
if ([self _setProvisionalDataSource:newDataSource]) {
[self _startLoading];
}
[newDataSource _setController:[self controller]];
[_private setProvisionalDataSource:newDataSource];
ASSERT([newDataSource webFrame] == self);
// We tell the documentView provisionalDataSourceChanged:
// once it has been created by the controller.
[self _setState: WebFrameStateProvisional];
return YES;
}
- (void)startLoading
{
if (self == [[self controller] mainFrame])
LOG(DocumentLoad, "loading %@", [[[self provisionalDataSource] request] URL]);
[_private->provisionalDataSource startLoading];
[newDataSource release];
}
- (void)stopLoading
{
if (_private->state != WebFrameStateComplete) {
......@@ -185,9 +137,9 @@ - (void)reload
[newDataSource _setOverrideEncoding:[dataSource _overrideEncoding]];
if ([self setProvisionalDataSource:newDataSource]) {
if ([self _setProvisionalDataSource:newDataSource]) {
[self _setLoadType:WebFrameLoadTypeReload];
[self startLoading];
[self _startLoading];
}
[newDataSource release];
......
......@@ -104,7 +104,7 @@ typedef enum {
- (void)_timedLayout: userInfo;
- (WebBridge *)_bridge;
- (BOOL)_shouldShowRequest:(WebResourceRequest *)request;
- (void)_setProvisionalDataSource:(WebDataSource *)d;
- (void)_clearProvisionalDataSource;
- (void)_setLoadType: (WebFrameLoadType)loadType;
- (WebFrameLoadType)_loadType;
......@@ -139,4 +139,8 @@ typedef enum {
- (WebHistoryItem *)_itemForRestoringDocState;
- (void)_handleUnimplementablePolicy:(WebPolicyAction)policy errorCode:(int)code forURL:(NSURL *)URL;
- (BOOL)_setProvisionalDataSource: (WebDataSource *)dataSource;
- (void)_startLoading;
- (void)_downloadRequest:(WebResourceRequest *)request toPath:(NSString *)path;
@end
......@@ -323,7 +323,8 @@ - (void)_timedLayout: (id)userInfo
if ([documentView isKindOfClass: [NSView class]]) {
NSView *dview = (NSView *)documentView;
NSRect frame = [dview frame];
NSRect frame = [dview frame];
if (frame.size.width == 0 || frame.size.height == 0){
// We must do the layout now, rather than depend on
......@@ -735,9 +736,9 @@ - (BOOL)_shouldShowRequest:(WebResourceRequest *)request
return [self _continueAfterNavigationPolicyForRequest:request dataSource:[self provisionalDataSource]];
}
- (void)_setProvisionalDataSource:(WebDataSource *)d
- (void)_clearProvisionalDataSource
{
[_private setProvisionalDataSource:d];
[_private setProvisionalDataSource:nil];
}
// helper method that determines whether the subframes described by the item's subitems
......@@ -813,11 +814,11 @@ - (void)_loadItem:(WebHistoryItem *)item fromItem:(WebHistoryItem *)fromItem wit
WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
[request release];
[self setProvisionalDataSource:newDataSource];
[self _setProvisionalDataSource:newDataSource];
// Remember this item so we can traverse any child items as child frames load
[_private setProvisionalItem:item];
[self _setLoadType:type];
[self startLoading];
[self _startLoading];
[newDataSource release];
}
}
......@@ -893,8 +894,8 @@ - (void)_loadRequest:(WebResourceRequest *)request triggeringAction:(NSDictionar
WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
[newDataSource _setTriggeringAction:action];
if ([self setProvisionalDataSource:newDataSource]) {
[self startLoading];
if ([self _setProvisionalDataSource:newDataSource]) {
[self _startLoading];
}
[newDataSource release];
}
......@@ -1186,9 +1187,9 @@ - (void)_reloadAllowingStaleDataWithOverrideEncoding:(NSString *)encoding
[newDataSource _setOverrideEncoding:encoding];
if ([self setProvisionalDataSource:newDataSource]) {
if ([self _setProvisionalDataSource:newDataSource]) {
[self _setLoadType:WebFrameLoadTypeReloadAllowingStaleData];
[self startLoading];
[self _startLoading];
}
[newDataSource release];
......@@ -1267,4 +1268,67 @@ - (WebHistoryItem *)_itemForRestoringDocState
return [_private currentItem];
}
// Will return NO and not set the provisional data source if the controller
// disallows by returning a WebURLPolicyIgnore.
- (BOOL)_setProvisionalDataSource: (WebDataSource *)newDataSource
{
ASSERT([self controller] != nil);
// Unfortunately the view must be non-nil, this is ultimately due
// to KDE parser requiring a KHTMLView. Once we settle on a final
// KDE drop we should fix this dependency.
ASSERT([self webView] != nil);
if ([self _state] != WebFrameStateComplete) {
[self stopLoading];
}
[self _setLoadType: WebFrameLoadTypeStandard];
// _continueAfterNavigationPolicyForRequest:dataSource: asks the
// client for the URL policies and reports errors if there are any
// returns YES if we should show the data source
if (![self _continueAfterNavigationPolicyForRequest:[newDataSource request] dataSource:newDataSource]) {
return NO;
}
if ([self parent]) {
[newDataSource _setOverrideEncoding:[[[self parent] dataSource] _overrideEncoding]];
}
[newDataSource _setController:[self controller]];
[_private setProvisionalDataSource:newDataSource];
ASSERT([newDataSource webFrame] == self);
// We tell the documentView provisionalDataSourceChanged:
// once it has been created by the controller.
[self _setState: WebFrameStateProvisional];
return YES;
}
- (void)_startLoading
{
if (self == [[self controller] mainFrame])
LOG(DocumentLoad, "loading %@", [[[self provisionalDataSource] request] URL]);
[_private->provisionalDataSource startLoading];
}
- (void)_downloadRequest:(WebResourceRequest *)request toPath:(NSString *)path
{
WebDataSource *dataSource = [[WebDataSource alloc] initWithRequest:request];
[dataSource _setIsDownloading:YES];
[dataSource _setDownloadPath:path];
if([self _setProvisionalDataSource:dataSource]){
[self _startLoading];
}
[dataSource release];
}
@end
......@@ -29,6 +29,7 @@
#import <WebFoundation/WebLocalizableStrings.h>
#import <WebFoundation/WebNSDictionaryExtras.h>
#import <WebFoundation/WebNSURLExtras.h>
#import <WebFoundation/WebResourceRequest.h>
enum {
SpaceKey = 0x0020
......@@ -166,13 +167,10 @@ - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
NSURL *URL = [[sender draggingPasteboard] _web_bestURL];
if(URL){
WebDataSource *dataSource = [[WebDataSource alloc] initWithURL:URL];
WebFrame *frame = [[self controller] mainFrame];
if ([frame setProvisionalDataSource:dataSource]){
[frame startLoading];
}
[dataSource release];
if (URL) {
WebResourceRequest *request = [[WebResourceRequest alloc] initWithURL:URL];
[[[self controller] mainFrame] loadRequest:request];
[request release];
}
}
......
......@@ -102,7 +102,7 @@ -(WebResourceRequest *)handle:(WebResourceHandle *)h willSendRequest:(WebResourc
if (![[dataSource webFrame] _shouldShowRequest:newRequest]) {
[self cancelQuietly];
[[dataSource webFrame] _setProvisionalDataSource:nil];
[[dataSource webFrame] _clearProvisionalDataSource];
[[[dataSource controller] locationChangeDelegate] locationChangeDone:
[WebError errorWithCode:WebErrorLocationChangeInterruptedByPolicyChange inDomain:WebErrorDomainWebKit failingURL:nil]
forDataSource:dataSource];
......@@ -136,7 +136,7 @@ - (void)notifyDelegatesOfInterruptionByPolicyChange
-(void)stopLoadingAfterContentPolicy
{
[[dataSource webFrame] _setProvisionalDataSource:nil];
[[dataSource webFrame] _clearProvisionalDataSource];
[self notifyDelegatesOfInterruptionByPolicyChange];
[self cancelQuietly];
}
......@@ -178,8 +178,7 @@ -(void)handle:(WebResourceHandle *)h didReceiveResponse:(WebResourceResponse *)r
[dataSource _setDownloadPath:saveFilename];