Reviewed by Anders.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Oct 2006 20:42:01 +0000 (20:42 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Oct 2006 20:42:01 +0000 (20:42 +0000)
        - 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

WebKit/ChangeLog
WebKit/Loader/WebDocumentLoadState.h
WebKit/Loader/WebDocumentLoadState.m
WebKit/Loader/WebFrameLoader.h
WebKit/Loader/WebFrameLoader.m
WebKit/WebView/WebDataSource.m
WebKit/WebView/WebDataSourceInternal.h
WebKit/WebView/WebFrame.m

index 21a7b080aa222abcecb2c8146faf9e278248aaa3..dd5fa9224e6f4bd6d8aab5c754f77b3a4f132472 100644 (file)
@@ -1,3 +1,36 @@
+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.
index e69ee2c0676774d3a9138e5547a996f93d458ff2..bf333c141bf38b23f91fd8319dd242d0161e783d 100644 (file)
     
     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
index 80a5cda42c52ea3b856ff1275466c928813a8489..f99a24a63e8e2d657dc5d10ccfd3bf8cf1b8254f 100644 (file)
     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
index 16684052effdc1ceb1188d6e8d734b20690cdc28..01eace46ca793ea90345454b81d136aedf531cf5 100644 (file)
@@ -176,5 +176,7 @@ typedef enum {
 - (void)documentLoadState:(WebDocumentLoadState *)loadState setMainDocumentError:(NSError *)error;
 - (void)documentLoadState:(WebDocumentLoadState *)loadState mainReceivedCompleteError:(NSError *)error;
 - (void)finalSetupForReplaceWithDocumentLoadState:(WebDocumentLoadState *)loadState;
+- (void)prepareForLoadStart;
+- (BOOL)subframeIsLoading;
 
 @end
index bf4543d8cb8b84349314e589c26f451c1d9b1a3a..5ae4b83d8f56ceb278536d7bb0680c2d3f9c3987 100644 (file)
@@ -44,6 +44,7 @@
 #import <WebKit/WebFrameLoadDelegate.h>
 #import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebKitNSStringExtras.h>
+#import <WebKit/WebScriptDebugServerPrivate.h>
 #import "WebNSDictionaryExtras.h"
 
 @implementation WebFrameLoader
@@ -311,10 +312,10 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
 {
     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;
     
@@ -515,7 +516,9 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
         return;
     }
 
-    [ds _setPrimaryLoadComplete:YES];
+    [[self activeDocumentLoadState] setPrimaryLoadComplete:YES];
+    if ([WebScriptDebugServer listenerCount])
+        [[WebScriptDebugServer sharedScriptDebugServer] webView:[webFrame webView] didLoadMainResourceForDataSource:[self activeDataSource]];
     [webFrame _checkLoadComplete];
 
     [self release];
@@ -873,7 +876,9 @@ static BOOL isCaseInsensitiveEqual(NSString *a, NSString *b)
 
 - (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];
 }
 
@@ -882,4 +887,17 @@ static BOOL isCaseInsensitiveEqual(NSString *a, NSString *b)
     [[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
index 98a3539434f1691d14ab4b3c7ce71a4ae9206ced..497262875a1c5b3e8eee70f5ebfd774c20498fb1 100644 (file)
     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];
@@ -213,9 +188,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     }
     
     WebResource *resource = [self subresourceForURL:URL];
-    if (resource) {
+    if (resource)
         return [resource _fileWrapperRepresentation];
-    }
     
     NSCachedURLResponse *cachedResponse = [[self _webView] _cachedResponseForURL:URL];
     if (cachedResponse) {
@@ -426,7 +400,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
 
 - (void)_startLoading
 {
-    [self _prepareForLoadStart];
+    [_private->loadState prepareForLoadStart];
     
     if ([[_private->loadState frameLoader] isLoadingMainResource])
         return;
@@ -449,11 +423,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     _private->stopRecordingResponses = YES;
 }
 
-- (double)_loadingStartedTime
-{
-    return _private->loadingStartedTime;
-}
-
 - (void)_replaceSelectionWithArchive:(WebArchive *)archive selectReplacement:(BOOL)selectReplacement
 {
     DOMDocumentFragment *fragment = [self _documentFragmentWithArchive:archive];
@@ -521,7 +490,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
 
 - (void)_loadFromPageCache:(NSDictionary *)pageCache
 {
-    [self _prepareForLoadStart];
+    [_private->loadState prepareForLoadStart];
     _private->loadingFromPageCache = YES;
     [_private->loadState setCommitted:YES];
     [[self webFrame] _commitProvisionalLoad:pageCache];
@@ -532,11 +501,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     return [_private->unarchivingState popSubframeArchiveWithFrameName:frameName];
 }
 
-- (void)_setIsClientRedirect:(BOOL)flag
-{
-    _private->isClientRedirect = flag;
-}
-
 - (void)_setLastCheckedRequest:(NSURLRequest *)request
 {
     NSURLRequest *oldRequest = _private->lastCheckedRequest;
@@ -585,23 +549,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     [[_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;
@@ -626,11 +573,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     [_private->representation setDataSource:self];
 }
 
-- (BOOL)_isClientRedirect
-{
-    return _private->isClientRedirect;
-}
-
 - (NSURL *)_URLForHistory
 {
     // Return the URL to be used for history and B/F list.
@@ -802,21 +744,9 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     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.
index a9233a7afbf676ec24e550fda99d7313f76e0254..17ad1b9bbbf7d24c39e8b196fef155681f887fa4 100644 (file)
 - (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;
@@ -70,7 +68,6 @@
 - (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;
index 4ea751a9d0c897fa83d5fa15579f9edf322f924b..56bcbed0de391a3464edd8899cba306e9b36c680 100644 (file)
@@ -633,7 +633,7 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge)
                 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]){
@@ -668,7 +668,7 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge)
                 
             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];
@@ -818,7 +818,7 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge)
 // 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];
@@ -853,9 +853,9 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge)
         // 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];
     }
@@ -1681,7 +1681,7 @@ exit:
         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