+2006-10-09 Darin Adler <darin@apple.com>
+
+ Reviewed by Brady.
+
+ - eliminated WebFrameLoader dependency on WebDataSourceInternal.h,
+ WebIconDatabasePrivate.h, and WebKitErrorsPrivate.h, along with
+ most but not all references to WebView
+
+ * Loader/WebFrameLoader.h:
+ * Loader/WebFrameLoader.m:
+ (-[WebFrameLoader removePlugInStreamLoader:]):
+ (-[WebFrameLoader _receivedMainResourceError:complete:]):
+ (-[WebFrameLoader _notifyIconChanged:]):
+ (-[WebFrameLoader cancelledErrorWithRequest:]):
+ (-[WebFrameLoader fileDoesNotExistErrorWithResponse:]):
+ (-[WebFrameLoader handleUnimplementablePolicyWithError:]):
+ (-[WebFrameLoader cannotShowMIMETypeWithResponse:]):
+ (-[WebFrameLoader interruptForPolicyChangeErrorWithRequest:]):
+ (-[WebFrameLoader _loadRequest:archive:]):
+ (-[WebFrameLoader finishedLoadingDocument:]):
+ (-[WebFrameLoader committedLoadWithDocumentLoader:data:]):
+ (-[WebFrameLoader revertToProvisionalWithDocumentLoader:]):
+ (-[WebFrameLoader documentLoader:setMainDocumentError:]):
+ (-[WebFrameLoader finalSetupForReplaceWithDocumentLoader:]):
+ (-[WebFrameLoader didChangeTitleForDocument:]):
+ (-[WebFrameLoader continueAfterNavigationPolicy:]):
+ (-[WebFrameLoader continueLoadRequestAfterNavigationPolicy:formState:]):
+ (-[WebFrameLoader loadDocumentLoader:withLoadType:formState:]):
+ (-[WebFrameLoader transitionToCommitted:]):
+ (-[WebFrameLoader checkLoadCompleteForThisFrame]):
+ (-[WebFrameLoader requestFromDelegateForRequest:identifier:error:]):
+ (-[WebFrameLoader addExtraFieldsToRequest:mainResource:alwaysFromRequest:]):
+ (-[WebFrameLoader checkLoadComplete]):
+ * Loader/WebFrameLoaderClient.h:
+ * Loader/WebMainResourceLoader.m:
+ (-[WebMainResourceLoader continueAfterContentPolicy:response:]):
+ * WebView/WebFrame.m:
+ (-[WebFrame _addDocumentLoader:toUnarchiveState:]):
+ (-[WebFrame _formDelegate]):
+ (-[WebFrame _finishedLoadingDocument:]):
+ (-[WebFrame _committedLoadWithDocumentLoader:data:]):
+ (-[WebFrame _revertToProvisionalWithDocumentLoader:]):
+ (-[WebFrame _documentLoader:setMainDocumentError:]):
+ (-[WebFrame _finalSetupForReplaceWithDocumentLoader:]):
+ (-[WebFrame _URLForHistoryForDocumentLoader:]):
+ (-[WebFrame _cancelledErrorWithRequest:]):
+ (-[WebFrame _cannotShowURLErrorWithRequest:]):
+ (-[WebFrame _interruptForPolicyChangeErrorWithRequest:]):
+ (-[WebFrame _cannotShowMIMETypeErrorWithResponse:]):
+ (-[WebFrame _fileDoesNotExistErrorWithResponse:]):
+ (-[WebFrame _shouldFallBackForError:]):
+ (-[WebFrame _hasWebView]):
+ (-[WebFrame _mainFrameURL]):
+ * WebView/WebFrameInternal.h:
+
2006-10-09 Maciej Stachowiak <mjs@apple.com>
Reviewed, landed, tweaked a bit by Darin.
#import <JavaScriptCore/Assertions.h>
#import <WebKit/DOMHTML.h>
#import <WebCore/WebCoreFrameBridge.h>
+#import <WebCore/WebCoreIconDatabaseBridge.h>
#import <WebCore/WebCoreSystemInterface.h>
-#import "WebDataSourceInternal.h"
#import "WebFrameInternal.h"
-#import "WebIconDatabasePrivate.h"
-#import "WebKitErrorsPrivate.h"
#import "WebNSURLExtras.h"
#import "WebResourcePrivate.h"
#import "WebViewInternal.h"
{
[plugInStreamLoaders removeObject:loader];
[[self activeDocumentLoader] updateLoading];
-}
+}
- (void)defersCallbacksChanged
{
// that both data sources on the frame are either self or nil.
// Can't call _bridge because we might not have commited yet
[bridge stop];
- // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent loading plugin content twice. See <rdar://problem/4258008>
- if ([error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad)
+ if ([cli _shouldFallBackForError:error])
[bridge handleFallbackContent];
}
- (void)_notifyIconChanged:(NSURL *)iconURL
{
- ASSERT([[WebIconDatabase sharedIconDatabase] _isEnabled]);
- NSImage *icon = [[WebIconDatabase sharedIconDatabase] iconForURL:[[[self activeDocumentLoader] URL] _web_originalDataAsString] withSize:WebIconSmallSize];
+ ASSERT([[WebCoreIconDatabaseBridge sharedInstance] _isEnabled]);
+ NSImage *icon = [[WebCoreIconDatabaseBridge sharedInstance]
+ iconForPageURL:[[[self activeDocumentLoader] URL] _web_originalDataAsString]
+ withSize:NSMakeSize(16, 16)];
[client _dispatchDidReceiveIcon:icon];
}
- (NSError *)cancelledErrorWithRequest:(NSURLRequest *)request
{
- return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
+ return [client _cancelledErrorWithRequest:request];
}
- (NSError *)fileDoesNotExistErrorWithResponse:(NSURLResponse *)response
{
- return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]];
+ return [client _fileDoesNotExistErrorWithResponse:response];
}
- (void)clearArchivedResources
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(deliverArchivedResources) object:nil];
}
-- (void)cannotShowMIMETypeForURL:(NSURL *)URL
+- (void)handleUnimplementablePolicyWithError:(NSError *)error
+{
+ delegateIsHandlingUnimplementablePolicy = YES;
+ [client _dispatchUnableToImplementPolicyWithError:error];
+ delegateIsHandlingUnimplementablePolicy = NO;
+}
+
+- (void)cannotShowMIMETypeWithResponse:(NSURLResponse *)response
{
- [self handleUnimplementablePolicyWithErrorCode:WebKitErrorCannotShowMIMEType forURL:URL];
+ [self handleUnimplementablePolicyWithError:[client _cannotShowMIMETypeErrorWithResponse:response]];
}
- (NSError *)interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request
{
- return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]];
+ return [client _interruptForPolicyChangeErrorWithRequest:request];
}
- (BOOL)isHostedByObjectElement
ASSERT(!policyDocumentLoader);
policyDocumentLoader = [client _createDocumentLoaderWithRequest:request];
- WebDataSource *newDataSource = [client _dataSourceForDocumentLoader:policyDocumentLoader];
- NSMutableURLRequest *r = [newDataSource request];
+ NSMutableURLRequest *r = [policyDocumentLoader request];
[self addExtraFieldsToRequest:r mainResource:YES alwaysFromRequest:NO];
if ([client _shouldTreatURLAsSameAsCurrent:[request URL]]) {
[r setCachePolicy:NSURLRequestReloadIgnoringCacheData];
type = FrameLoadTypeStandard;
[policyDocumentLoader setOverrideEncoding:[[self documentLoader] overrideEncoding]];
- [newDataSource _addToUnarchiveState:archive];
+ [client _addDocumentLoader:policyDocumentLoader toUnarchiveState:archive];
// When we loading alternate content for an unreachable URL that we're
// visiting in the b/f list, we treat it as a reload so the b/f list
- (void)finishedLoadingDocument:(WebDocumentLoader *)loader
{
- [[client _dataSourceForDocumentLoader:loader] _finishedLoading];
+ [client _finishedLoadingDocument:loader];
}
- (void)committedLoadWithDocumentLoader:(WebDocumentLoader *)loader data:(NSData *)data
{
- [[client _dataSourceForDocumentLoader:loader] _receivedData:data];
+ [client _committedLoadWithDocumentLoader:loader data:data];
}
- (BOOL)isReplacing
- (void)revertToProvisionalWithDocumentLoader:(WebDocumentLoader *)loader
{
- [[client _dataSourceForDocumentLoader:loader] _revertToProvisionalState];
+ [client _revertToProvisionalWithDocumentLoader:loader];
}
- (void)documentLoader:(WebDocumentLoader *)loader setMainDocumentError:(NSError *)error
{
- [[client _dataSourceForDocumentLoader:loader] _setMainDocumentError:error];
+ [client _documentLoader:loader setMainDocumentError:error];
}
- (void)documentLoader:(WebDocumentLoader *)loader mainReceivedCompleteError:(NSError *)error
- (void)finalSetupForReplaceWithDocumentLoader:(WebDocumentLoader *)loader
{
- [[client _dataSourceForDocumentLoader:loader] _clearUnarchivingState];
+ [client _finalSetupForReplaceWithDocumentLoader:loader];
}
- (void)prepareForLoadStart
// The title doesn't get communicated to the WebView until we are committed.
if ([loader isCommitted]) {
- NSURL *URLForHistory = [[client _dataSourceForDocumentLoader:loader] _URLForHistory];
+ NSURL *URLForHistory = [client _URLForHistoryForDocumentLoader:loader];
if (URLForHistory != nil) {
// Must update the entries in the back-forward list too.
// This must go through the WebFrame because it has the right notion of the current b/f item.
break;
case WebPolicyUse:
if (![WebView _canHandleRequest:request]) {
- [self handleUnimplementablePolicyWithErrorCode:WebKitErrorCannotShowURL forURL:[request URL]];
+ [self handleUnimplementablePolicyWithError:[client _cannotShowURLErrorWithRequest:request]];
request = nil;
}
break;
[dl release];
[self setPolicyDocumentLoader:nil];
- if (isBackForwardLoadType(type)) {
- if ([client _loadProvisionalItemFromPageCache])
- return;
- }
+ if (isBackForwardLoadType(type) && [client _loadProvisionalItemFromPageCache])
+ return;
if (formState) {
// It's a bit of a hack to reuse the WebPolicyDecisionListener for the continuation
// mechanism across the willSubmitForm callout.
listener = [[WebPolicyDecisionListener alloc] _initWithTarget:self action:@selector(continueAfterWillSubmitForm:)];
- [[[client webView] _formDelegate] frame:client sourceFrame:[(WebFrameBridge *)[formState sourceFrame] webFrame] willSubmitForm:[formState form] withValues:[formState values] submissionListener:listener];
+ [[client _formDelegate] frame:client sourceFrame:[(WebFrameBridge *)[formState sourceFrame] webFrame]
+ willSubmitForm:[formState form] withValues:[formState values] submissionListener:listener];
} else
[self continueAfterWillSubmitForm:WebPolicyUse];
}
- (void)loadDocumentLoader:(WebDocumentLoader *)loader withLoadType:(FrameLoadType)type formState:(WebFormState *)formState
{
- ASSERT([client webView] != nil);
+ ASSERT([client _hasWebView]);
// Unfortunately the view must be non-nil, this is ultimately due
// to parser requiring a FrameView. We should fix this dependency.
WebFrame *parentFrame = [client parentFrame];
if (parentFrame)
- [loader setOverrideEncoding:[[[parentFrame dataSource] _documentLoader] overrideEncoding]];
+ [loader setOverrideEncoding:[[[parentFrame _frameLoader] documentLoader] overrideEncoding]];
[loader setFrameLoader:self];
withSelector:@selector(continueLoadRequestAfterNavigationPolicy:formState:)];
}
-- (void)handleUnimplementablePolicyWithErrorCode:(int)code forURL:(NSURL *)URL
-{
- NSError *error = [NSError _webKitErrorWithDomain:WebKitErrorDomain code:code URL:URL];
- delegateIsHandlingUnimplementablePolicy = YES;
- [client _dispatchUnableToImplementPolicyWithError:error];
- delegateIsHandlingUnimplementablePolicy = NO;
-}
-
- (void)didFirstLayout
{
if (isBackForwardLoadType(loadType) && [client _hasBackForwardList])
- (void)transitionToCommitted:(NSDictionary *)pageCache
{
- ASSERT([client webView] != nil);
+ ASSERT([client _hasWebView]);
ASSERT([self state] == WebFrameStateProvisional);
if ([self state] != WebFrameStateProvisional)
- (void)checkLoadCompleteForThisFrame
{
- ASSERT([client webView] != nil);
+ ASSERT([client _hasWebView]);
switch ([self state]) {
case WebFrameStateProvisional: {
NSURLRequest *newRequest = [client _dispatchResource:*identifier willSendRequest:request redirectResponse:nil fromDocumentLoader:documentLoader];
if (newRequest == nil)
- *error = [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
+ *error = [client _cancelledErrorWithRequest:request];
else
*error = nil;
if (mainResource && ([self isLoadingMainFrame] || f))
[request setMainDocumentURL:[request URL]];
else
- [request setMainDocumentURL:[[[[client webView] mainFrame] dataSource] _URL]];
+ [request setMainDocumentURL:[client _mainFrameURL]];
}
if (mainResource)
// Called every time a resource is completely loaded, or an error is received.
- (void)checkLoadComplete
{
- ASSERT([client webView] != nil);
+ ASSERT([client _hasWebView]);
WebFrame *parent;
for (WebFrame *frame = client; frame; frame = parent) {
}
}
+- (void)_addDocumentLoader:(WebDocumentLoader *)loader toUnarchiveState:(WebArchive *)archive
+{
+ [dataSource(loader) _addToUnarchiveState:archive];
+}
+
+- (id <WebFormDelegate>)_formDelegate
+{
+ return [[self webView] _formDelegate];
+}
+
@end
@implementation WebFrame (WebPrivate)
[[self webView] _downloadURL:[request URL]];
}
+- (void)_finishedLoadingDocument:(WebDocumentLoader *)loader
+{
+ [dataSource(loader) _finishedLoading];
+}
+
+- (void)_committedLoadWithDocumentLoader:(WebDocumentLoader *)loader data:(NSData *)data
+{
+ [dataSource(loader) _receivedData:data];
+}
+
+- (void)_revertToProvisionalWithDocumentLoader:(WebDocumentLoader *)loader
+{
+ [dataSource(loader) _revertToProvisionalState];
+}
+
+- (void)_documentLoader:(WebDocumentLoader *)loader setMainDocumentError:(NSError *)error
+{
+ [dataSource(loader) _setMainDocumentError:error];
+}
+
+- (void)_finalSetupForReplaceWithDocumentLoader:(WebDocumentLoader *)loader
+{
+ [dataSource(loader) _clearUnarchivingState];
+}
+
+- (NSURL *)_URLForHistoryForDocumentLoader:(WebDocumentLoader *)loader
+{
+ return [dataSource(loader) _URLForHistory];
+}
+
+- (NSError *)_cancelledErrorWithRequest:(NSURLRequest *)request
+{
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:[request URL]];
+}
+
+- (NSError *)_cannotShowURLErrorWithRequest:(NSURLRequest *)request
+{
+ return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:[request URL]];
+}
+
+- (NSError *)_interruptForPolicyChangeErrorWithRequest:(NSURLRequest *)request
+{
+ return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:[request URL]];
+}
+
+- (NSError *)_cannotShowMIMETypeErrorWithResponse:(NSURLResponse *)response
+{
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:[response URL]];
+}
+
+- (NSError *)_fileDoesNotExistErrorWithResponse:(NSURLResponse *)response
+{
+ return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:[response URL]];
+}
+
+- (BOOL)_shouldFallBackForError:(NSError *)error
+{
+ // FIXME: Needs to check domain.
+ // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent
+ // loading plugin content twice. See <rdar://problem/4258008>
+ return [error code] != NSURLErrorCancelled && [error code] != WebKitErrorPlugInWillHandleLoad;
+}
+
+- (BOOL)_hasWebView
+{
+ return [self webView] != nil;
+}
+
+- (NSURL *)_mainFrameURL
+{
+ return [[[[self webView] mainFrame] dataSource] _URL];
+}
+
@end