- moved more data from WebDataSource to WebDocumentLoadState
* Loader/WebDocumentLoadState.h:
* Loader/WebDocumentLoadState.m:
(-[WebDocumentLoadState commitLoadWithData:]):
(-[WebDocumentLoadState prepareForLoadStart]):
(-[WebDocumentLoadState loadingStartedTime]):
(-[WebDocumentLoadState setIsClientRedirect:]):
(-[WebDocumentLoadState isClientRedirect]):
(-[WebDocumentLoadState setPrimaryLoadComplete:]):
(-[WebDocumentLoadState isLoadingInAPISense]):
* Loader/WebFrameLoader.h:
* Loader/WebFrameLoader.m:
(-[WebFrameLoader _setState:]):
(-[WebFrameLoader _finishedLoading]):
(-[WebFrameLoader documentLoadState:mainReceivedCompleteError:]):
(-[WebFrameLoader prepareForLoadStart]):
(-[WebFrameLoader subframeIsLoading]):
* WebView/WebDataSource.m:
(-[WebDataSource _fileWrapperForURL:]):
(-[WebDataSource _startLoading]):
(-[WebDataSource _loadFromPageCache:]):
(-[WebDataSource isLoading]):
* WebView/WebDataSourceInternal.h:
* WebView/WebFrame.m:
(-[WebFrame _transitionToCommitted:]):
(-[WebFrame _opened]):
(-[WebFrame _loadURL:referrer:loadType:target:triggeringEvent:form:formValues:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16857
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-10-06 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - moved more data from WebDataSource to WebDocumentLoadState
+
+ * Loader/WebDocumentLoadState.h:
+ * Loader/WebDocumentLoadState.m:
+ (-[WebDocumentLoadState commitLoadWithData:]):
+ (-[WebDocumentLoadState prepareForLoadStart]):
+ (-[WebDocumentLoadState loadingStartedTime]):
+ (-[WebDocumentLoadState setIsClientRedirect:]):
+ (-[WebDocumentLoadState isClientRedirect]):
+ (-[WebDocumentLoadState setPrimaryLoadComplete:]):
+ (-[WebDocumentLoadState isLoadingInAPISense]):
+ * Loader/WebFrameLoader.h:
+ * Loader/WebFrameLoader.m:
+ (-[WebFrameLoader _setState:]):
+ (-[WebFrameLoader _finishedLoading]):
+ (-[WebFrameLoader documentLoadState:mainReceivedCompleteError:]):
+ (-[WebFrameLoader prepareForLoadStart]):
+ (-[WebFrameLoader subframeIsLoading]):
+ * WebView/WebDataSource.m:
+ (-[WebDataSource _fileWrapperForURL:]):
+ (-[WebDataSource _startLoading]):
+ (-[WebDataSource _loadFromPageCache:]):
+ (-[WebDataSource isLoading]):
+ * WebView/WebDataSourceInternal.h:
+ * WebView/WebFrame.m:
+ (-[WebFrame _transitionToCommitted:]):
+ (-[WebFrame _opened]):
+ (-[WebFrame _loadURL:referrer:loadType:target:triggeringEvent:form:formValues:]):
+
2006-10-06 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
NSError *mainDocumentError;
+ // The time when the data source was told to start loading.
+ double loadingStartedTime;
+
BOOL committed; // This data source has been committed
BOOL stopping;
BOOL loading; // self and webView are retained while loading
BOOL gotFirstByte; // got first byte
+ BOOL primaryLoadComplete;
+ BOOL isClientRedirect;
}
- (id)initWithRequest:(NSURLRequest *)request;
- (void)mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
- (void)setResponse:(NSURLResponse *)resp;
- (void)detachFromFrameLoader;
+- (void)prepareForLoadStart;
+- (double)loadingStartedTime;
+- (BOOL)isClientRedirect;
+- (void)setIsClientRedirect:(BOOL)flag;
+- (BOOL)isLoadingInAPISense;
+- (void)setPrimaryLoadComplete:(BOOL)flag;
+
@end
frameLoader = nil;
}
+- (void)prepareForLoadStart
+{
+ ASSERT(!stopping);
+ [self setPrimaryLoadComplete:NO];
+ ASSERT(frameLoader != nil);
+ [self clearErrors];
+
+ // Mark the start loading time.
+ loadingStartedTime = CFAbsoluteTimeGetCurrent();
+
+ [self setLoading:YES];
+
+ [frameLoader prepareForLoadStart];
+}
+
+- (double)loadingStartedTime
+{
+ return loadingStartedTime;
+}
+
+- (void)setIsClientRedirect:(BOOL)flag
+{
+ isClientRedirect = flag;
+}
+
+- (BOOL)isClientRedirect
+{
+ return isClientRedirect;
+}
+
+- (void)setPrimaryLoadComplete:(BOOL)flag
+{
+ primaryLoadComplete = flag;
+
+ if (flag) {
+ if ([frameLoader isLoadingMainResource]) {
+ [self setMainResourceData:[frameLoader mainResourceData]];
+ [frameLoader releaseMainResourceLoader];
+ }
+
+ [self updateLoading];
+ }
+}
+
+- (BOOL)isLoadingInAPISense
+{
+ // Once a frame has loaded, we no longer need to consider subresources,
+ // but we still need to consider subframes.
+ if ([frameLoader state] != WebFrameStateComplete) {
+ if (!primaryLoadComplete && [self isLoading])
+ return YES;
+ if ([frameLoader isLoadingSubresources])
+ return YES;
+ if (![[frameLoader bridge] doneProcessingData])
+ return YES;
+ }
+
+ return [frameLoader subframeIsLoading];
+}
+
@end
- (void)documentLoadState:(WebDocumentLoadState *)loadState setMainDocumentError:(NSError *)error;
- (void)documentLoadState:(WebDocumentLoadState *)loadState mainReceivedCompleteError:(NSError *)error;
- (void)finalSetupForReplaceWithDocumentLoadState:(WebDocumentLoadState *)loadState;
+- (void)prepareForLoadStart;
+- (BOOL)subframeIsLoading;
@end
#import <WebKit/WebFrameLoadDelegate.h>
#import <WebKit/WebDataProtocol.h>
#import <WebKit/WebKitNSStringExtras.h>
+#import <WebKit/WebScriptDebugServerPrivate.h>
#import "WebNSDictionaryExtras.h"
@implementation WebFrameLoader
{
LOG(Loading, "%@: transition from %s to %s", [webFrame name], stateNames[state], stateNames[newState]);
if ([webFrame webView])
- LOG(Timing, "%@: transition from %s to %s, %f seconds since start of document load", [webFrame name], stateNames[state], stateNames[newState], CFAbsoluteTimeGetCurrent() - [[[[webFrame webView] mainFrame] dataSource] _loadingStartedTime]);
+ LOG(Timing, "%@: transition from %s to %s, %f seconds since start of document load", [webFrame name], stateNames[state], stateNames[newState], CFAbsoluteTimeGetCurrent() - [[[[[webFrame webView] mainFrame] dataSource] _documentLoadState] loadingStartedTime]);
if (newState == WebFrameStateComplete && webFrame == [[webFrame webView] mainFrame])
- LOG(DocumentLoad, "completed %@ (%f seconds)", [[[self dataSource] request] URL], CFAbsoluteTimeGetCurrent() - [[self dataSource] _loadingStartedTime]);
+ LOG(DocumentLoad, "completed %@ (%f seconds)", [[[self dataSource] request] URL], CFAbsoluteTimeGetCurrent() - [[[self dataSource] _documentLoadState] loadingStartedTime]);
state = newState;
return;
}
- [ds _setPrimaryLoadComplete:YES];
+ [[self activeDocumentLoadState] setPrimaryLoadComplete:YES];
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:[webFrame webView] didLoadMainResourceForDataSource:[self activeDataSource]];
[webFrame _checkLoadComplete];
[self release];
- (void)documentLoadState:(WebDocumentLoadState *)loadState mainReceivedCompleteError:(NSError *)error
{
- [[webFrame _dataSourceForDocumentLoadState:loadState] _setPrimaryLoadComplete:YES];
+ [loadState setPrimaryLoadComplete:YES];
+ if ([WebScriptDebugServer listenerCount])
+ [[WebScriptDebugServer sharedScriptDebugServer] webView:[webFrame webView] didLoadMainResourceForDataSource:[self activeDataSource]];
[webFrame _checkLoadComplete];
}
[[webFrame _dataSourceForDocumentLoadState:loadState] _clearUnarchivingState];
}
+- (void)prepareForLoadStart
+{
+ [[webFrame webView] _progressStarted:webFrame];
+ [[webFrame webView] _didStartProvisionalLoadForFrame:webFrame];
+ [[[webFrame webView] _frameLoadDelegateForwarder] webView:[webFrame webView]
+ didStartProvisionalLoadForFrame:webFrame];
+}
+
+- (BOOL)subframeIsLoading
+{
+ return [webFrame _subframeIsLoading];
+}
+
@end
BOOL loadingFromPageCache;
WebUnarchivingState *unarchivingState;
NSMutableDictionary *subresources;
-
- // The time when the data source was told to start loading.
- double loadingStartedTime;
-
- BOOL primaryLoadComplete;
-
- BOOL isClientRedirect;
-
+ BOOL representationFinishedLoading;
+
NSString *pageTitle;
NSString *encoding;
NSString *overrideEncoding;
- BOOL representationFinishedLoading;
-
// The action that triggered loading of this data source -
// we keep this around for the benefit of the various policy
// handlers.
_private->representationFinishedLoading = NO;
}
-- (void)_prepareForLoadStart
-{
- ASSERT(![_private->loadState isStopping]);
- [self _setPrimaryLoadComplete:NO];
- ASSERT([self webFrame] != nil);
- [_private->loadState clearErrors];
-
- // Mark the start loading time.
- _private->loadingStartedTime = CFAbsoluteTimeGetCurrent();
-
- [_private->loadState setLoading:YES];
- [[self _webView] _progressStarted:[self webFrame]];
- [[self _webView] _didStartProvisionalLoadForFrame:[self webFrame]];
- [[[self _webView] _frameLoadDelegateForwarder] webView:[self _webView]
- didStartProvisionalLoadForFrame:[self webFrame]];
-}
-
static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class, NSArray *supportTypes)
{
NSEnumerator *enumerator = [supportTypes objectEnumerator];
}
WebResource *resource = [self subresourceForURL:URL];
- if (resource) {
+ if (resource)
return [resource _fileWrapperRepresentation];
- }
NSCachedURLResponse *cachedResponse = [[self _webView] _cachedResponseForURL:URL];
if (cachedResponse) {
- (void)_startLoading
{
- [self _prepareForLoadStart];
+ [_private->loadState prepareForLoadStart];
if ([[_private->loadState frameLoader] isLoadingMainResource])
return;
_private->stopRecordingResponses = YES;
}
-- (double)_loadingStartedTime
-{
- return _private->loadingStartedTime;
-}
-
- (void)_replaceSelectionWithArchive:(WebArchive *)archive selectReplacement:(BOOL)selectReplacement
{
DOMDocumentFragment *fragment = [self _documentFragmentWithArchive:archive];
- (void)_loadFromPageCache:(NSDictionary *)pageCache
{
- [self _prepareForLoadStart];
+ [_private->loadState prepareForLoadStart];
_private->loadingFromPageCache = YES;
[_private->loadState setCommitted:YES];
[[self webFrame] _commitProvisionalLoad:pageCache];
return [_private->unarchivingState popSubframeArchiveWithFrameName:frameName];
}
-- (void)_setIsClientRedirect:(BOOL)flag
-{
- _private->isClientRedirect = flag;
-}
-
- (void)_setLastCheckedRequest:(NSURLRequest *)request
{
NSURLRequest *oldRequest = _private->lastCheckedRequest;
[[_private->loadState frameLoader] stopLoadingWithError:error];
}
-- (void)_setPrimaryLoadComplete:(BOOL)flag
-{
- _private->primaryLoadComplete = flag;
-
- if (flag) {
- if ([[_private->loadState frameLoader] isLoadingMainResource]) {
- [_private->loadState setMainResourceData:[[_private->loadState frameLoader] mainResourceData]];
- [[_private->loadState frameLoader] releaseMainResourceLoader];
- }
-
- [_private->loadState updateLoading];
-
- if ([WebScriptDebugServer listenerCount])
- [[WebScriptDebugServer sharedScriptDebugServer] webView:[[self webFrame] webView] didLoadMainResourceForDataSource:self];
- }
-}
-
- (NSArray *)_responses
{
return _private->responses;
[_private->representation setDataSource:self];
}
-- (BOOL)_isClientRedirect
-{
- return _private->isClientRedirect;
-}
-
- (NSURL *)_URLForHistory
{
// Return the URL to be used for history and B/F list.
return textEncodingName;
}
-// Returns YES if there are any pending loads.
- (BOOL)isLoading
{
- // Once a frame has loaded, we no longer need to consider subresources,
- // but we still need to consider subframes.
- if ([[[self webFrame] _frameLoader] state] != WebFrameStateComplete) {
- if (!_private->primaryLoadComplete && [_private->loadState isLoading])
- return YES;
- if ([[_private->loadState frameLoader] isLoadingSubresources])
- return YES;
- if (![[[self webFrame] _bridge] doneProcessingData])
- return YES;
- }
-
- return [[self webFrame] _subframeIsLoading];
+ return [_private->loadState isLoadingInAPISense];
}
// Returns nil or the page title.
- (void)_setOverrideEncoding:(NSString *)overrideEncoding;
- (void)_addToUnarchiveState:(WebArchive *)archive;
- (NSURL *)_URLForHistory;
-- (BOOL)_isClientRedirect;
- (void)_makeRepresentation;
- (BOOL)_loadingFromPageCache;
- (NSArray *)_responses;
-- (void)_setPrimaryLoadComplete:(BOOL)flag;
- (BOOL)_isDocumentHTML;
- (void)_setTriggeringAction:(NSDictionary *)action;
- (NSDictionary *)_triggeringAction;
- (void)_stopLoadingWithError:(NSError *)error;
- (NSURLRequest *)_lastCheckedRequest;
- (void)_setLastCheckedRequest:(NSURLRequest *)request;
-- (void)_setIsClientRedirect:(BOOL)flag;
- (WebArchive *)_popSubframeArchiveWithName:(NSString *)frameName;
- (void)_loadFromPageCache:(NSDictionary *)pageCache;
- (NSURL *)_URL;
- (DOMDocumentFragment *)_documentFragmentWithArchive:(WebArchive *)archive;
+ (NSMutableDictionary *)_repTypesAllowImageTypeOmission:(BOOL)allowImageTypeOmission;
- (void)_replaceSelectionWithArchive:(WebArchive *)archive selectReplacement:(BOOL)selectReplacement;
-- (double)_loadingStartedTime;
- (void)_stopRecordingResponses;
- (void)_startLoading;
- (WebResource *)_archivedSubresourceForURL:(NSURL *)URL;
-- (double)_loadingStartedTime;
- (void)_stopRecordingResponses;
- (void)_startLoading;
- (WebResource *)_archivedSubresourceForURL:(NSURL *)URL;
break;
case WebFrameLoadTypeStandard:
- if (![ds _isClientRedirect]) {
+ if (![[ds _documentLoadState] isClientRedirect]) {
// Add item to history and BF list
NSURL *URL = [ds _URLForHistory];
if (URL && ![URL _web_isEmpty]){
case WebFrameLoadTypeInternal:
// Add an item to the item tree for this frame
- ASSERT(![ds _isClientRedirect]);
+ ASSERT(![[ds _documentLoadState] isClientRedirect]);
WebFrame *parentFrame = [self parentFrame];
if (parentFrame) {
WebHistoryItem *parentItem = [parentFrame->_private currentItem];
// Called after we send an openURL:... down to WebCore.
- (void)_opened
{
- if ([self _loadType] == WebFrameLoadTypeStandard && [[self dataSource] _isClientRedirect]) {
+ if ([self _loadType] == WebFrameLoadTypeStandard && [[[self dataSource] _documentLoadState] isClientRedirect]) {
// Clear out form data so we don't try to restore it into the incoming page. Must happen after
// khtml has closed the URL and saved away the form state.
WebHistoryItem *item = [_private currentItem];
// reset when we leave this page. The core side of the page cache
// will have already been invalidated by the bridge to prevent
// premature release.
- [[_private currentItem] setHasPageCache: NO];
+ [[_private currentItem] setHasPageCache:NO];
- [[self dataSource] _setPrimaryLoadComplete: YES];
+ [[_private->frameLoader documentLoadState] setPrimaryLoadComplete:YES];
// why only this frame and not parent frames?
[self _checkLoadCompleteForThisFrame];
}
if (isRedirect) {
LOG(Redirect, "%@(%p) _private->quickRedirectComing was %d", [self name], self, (int)isRedirect);
_private->quickRedirectComing = NO;
- [[self provisionalDataSource] _setIsClientRedirect:YES];
+ [[[self provisionalDataSource] _documentLoadState] setIsClientRedirect:YES];
} else if (sameURL) {
// Example of this case are sites that reload the same URL with a different cookie
// driving the generated content, or a master frame with links that drive a target