Reviewed by Adele.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2006 04:15:07 +0000 (04:15 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2006 04:15:07 +0000 (04:15 +0000)
        - started factoring most of the guts of WebDataSource into a new class

        WebDocumentLoadState is decoupled from the rest of WebKit and will
        be moved down to WebCore. I only moved one of the data fields of
        WebDataSource for now.

        * Loader/WebDocumentLoadState.h: Added.
        * Loader/WebDocumentLoadState.m: Added.
        (-[WebDocumentLoadState initWithRequest:]): New class.
        (-[WebDocumentLoadState dealloc]):
        (-[WebDocumentLoadState setFrameLoader:]):
        (-[WebDocumentLoadState setMainResourceData:]):
        (-[WebDocumentLoadState mainResourceData]):
        * Loader/WebFrameLoader.m:
        (-[WebFrameLoader _setDataSource:]): Remove redundant _setWebFrame: call,
        it would have been called already by this point.
        (-[WebFrameLoader _setProvisionalDataSource:]): ditto.
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebDataSource.m:
        (-[WebDataSourcePrivate dealloc]):
        (-[WebDataSource _setWebFrame:]):
        (-[WebDataSource _setPrimaryLoadComplete:]):
        (-[WebDataSource initWithRequest:]):
        (-[WebDataSource data]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16004 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/Loader/WebDocumentLoadState.h [new file with mode: 0644]
WebKit/Loader/WebDocumentLoadState.m [new file with mode: 0644]
WebKit/Loader/WebFrameLoader.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebDataSource.m

index d8782aee9ede09fc745c700ab9bd9fc5d454e539..9d6e4dec342cfb648f3f5c622c97749bd6a3ef82 100644 (file)
@@ -1,3 +1,32 @@
+2006-08-23  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Adele.
+        
+        - started factoring most of the guts of WebDataSource into a new class
+        
+        WebDocumentLoadState is decoupled from the rest of WebKit and will
+        be moved down to WebCore. I only moved one of the data fields of
+        WebDataSource for now.
+
+        * Loader/WebDocumentLoadState.h: Added.
+        * Loader/WebDocumentLoadState.m: Added.
+        (-[WebDocumentLoadState initWithRequest:]): New class.
+        (-[WebDocumentLoadState dealloc]):
+        (-[WebDocumentLoadState setFrameLoader:]):
+        (-[WebDocumentLoadState setMainResourceData:]):
+        (-[WebDocumentLoadState mainResourceData]):
+        * Loader/WebFrameLoader.m:
+        (-[WebFrameLoader _setDataSource:]): Remove redundant _setWebFrame: call,
+        it would have been called already by this point.
+        (-[WebFrameLoader _setProvisionalDataSource:]): ditto.
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebDataSource.m:
+        (-[WebDataSourcePrivate dealloc]):
+        (-[WebDataSource _setWebFrame:]):
+        (-[WebDataSource _setPrimaryLoadComplete:]):
+        (-[WebDataSource initWithRequest:]):
+        (-[WebDataSource data]):
+
 2006-08-23  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Adele.
diff --git a/WebKit/Loader/WebDocumentLoadState.h b/WebKit/Loader/WebDocumentLoadState.h
new file mode 100644 (file)
index 0000000..4272c88
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+@class WebFrameLoader;
+
+@interface WebDocumentLoadState : NSObject
+{
+@public
+    WebFrameLoader *frameLoader;
+    
+    NSData *mainResourceData;
+}
+
+- (id)initWithRequest:(NSURLRequest *)request;
+- (void)setFrameLoader:(WebFrameLoader *)fl;
+- (void)setMainResourceData:(NSData *)data;
+- (NSData *)mainResourceData;
+
+@end
diff --git a/WebKit/Loader/WebDocumentLoadState.m b/WebKit/Loader/WebDocumentLoadState.m
new file mode 100644 (file)
index 0000000..7496b0d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WebDocumentLoadState.h"
+
+#import <JavaScriptCore/Assertions.h>
+#import "WebFrameLoader.h"
+#import "WebDataProtocol.h"
+
+#import <WebKitSystemInterface.h>
+
+@implementation WebDocumentLoadState
+
+- (id)initWithRequest:(NSURLRequest *)request
+{
+    self = [super init];
+    if (!self)
+        return nil;
+    
+    // ignore request for now
+
+    return self;
+}
+
+- (void)dealloc
+{
+    ASSERT(![frameLoader isLoading]);
+
+    [mainResourceData release];
+
+    [super dealloc];
+}    
+
+
+- (void)setFrameLoader:(WebFrameLoader *)fl
+{
+    ASSERT(!fl || !frameLoader);
+    
+    frameLoader = fl;
+}
+
+- (void)setMainResourceData:(NSData *)data
+{
+    [data retain];
+    [mainResourceData release];
+    mainResourceData = data;
+}
+
+- (NSData *)mainResourceData
+{
+    return mainResourceData != nil ? mainResourceData : [frameLoader mainResourceData];
+}
+
+@end
index 2309a4c9ad766f0ebef5c907a46cd19b0c055d89..edf92106a9799eaf2dd94755a688be8f7f96dc68 100644 (file)
     [ds retain];
     [dataSource release];
     dataSource = ds;
-
-    [ds _setWebFrame:webFrame];
 }
 
 - (void)clearDataSource
     [d retain];
     [provisionalDataSource release];
     provisionalDataSource = d;
-
-    [d _setWebFrame:webFrame];
 }
 
 - (void)_clearProvisionalDataSource
index 0bec094bf7fd50ab68f8494e104108b6ca05dc96..313bdc8d22772535a48596437d96c0c5a00a263c 100644 (file)
@@ -57,6 +57,8 @@
                6550B7C7099EFAE90090D781 /* WebArchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6550B7C5099EFAE90090D781 /* WebArchiver.h */; };
                6550B7C8099EFAE90090D781 /* WebArchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6550B7C6099EFAE90090D781 /* WebArchiver.m */; };
                658A40960A14853B005E6987 /* WebDataSourceInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 658A40950A14853B005E6987 /* WebDataSourceInternal.h */; };
+               659044280A9D3B4200E89459 /* WebDocumentLoadState.h in Headers */ = {isa = PBXBuildFile; fileRef = 659044260A9D3B4200E89459 /* WebDocumentLoadState.h */; };
+               659044290A9D3B4200E89459 /* WebDocumentLoadState.m in Sources */ = {isa = PBXBuildFile; fileRef = 659044270A9D3B4200E89459 /* WebDocumentLoadState.m */; };
                65A0006908527D1A005620FA /* libWebKitSystemInterface.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 65A0006808527D1A005620FA /* libWebKitSystemInterface.a */; };
                65A734610A923948001B57E8 /* WebPlugInStreamLoaderDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 65A734600A923948001B57E8 /* WebPlugInStreamLoaderDelegate.h */; };
                65C7F42C0979DE640022E453 /* WebPageBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C7F42A0979DE640022E453 /* WebPageBridge.h */; };
                6578F5DF045F817400000128 /* WebDownload.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDownload.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                65836F5E07EE425900682F95 /* WebPluginContainerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginContainerPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                658A40950A14853B005E6987 /* WebDataSourceInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDataSourceInternal.h; sourceTree = "<group>"; };
+               659044260A9D3B4200E89459 /* WebDocumentLoadState.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDocumentLoadState.h; sourceTree = "<group>"; };
+               659044270A9D3B4200E89459 /* WebDocumentLoadState.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WebDocumentLoadState.m; sourceTree = "<group>"; };
                65A0006808527D1A005620FA /* libWebKitSystemInterface.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libWebKitSystemInterface.a; sourceTree = BUILT_PRODUCTS_DIR; };
                65A734600A923948001B57E8 /* WebPlugInStreamLoaderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlugInStreamLoaderDelegate.h; sourceTree = "<group>"; };
                65A7D44A0568AB2600E70EF6 /* WebUIDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebUIDelegatePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                        isa = PBXGroup;
                        children = (
                                65A734600A923948001B57E8 /* WebPlugInStreamLoaderDelegate.h */,
+                               659044260A9D3B4200E89459 /* WebDocumentLoadState.h */,
+                               659044270A9D3B4200E89459 /* WebDocumentLoadState.m */,
                                6538B1C60A90596D00A07522 /* WebFormDataStream.h */,
                                6538B1C70A90596D00A07522 /* WebFormDataStream.m */,
                                651A93850A83F883007FEDF0 /* WebDataProtocol.h */,
                                51700DAA0A9052A700DAAA8E /* WebIconLoader.h in Headers */,
                                6538B1C80A90596D00A07522 /* WebFormDataStream.h in Headers */,
                                65A734610A923948001B57E8 /* WebPlugInStreamLoaderDelegate.h in Headers */,
+                               659044280A9D3B4200E89459 /* WebDocumentLoadState.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                51E4D39A0A886B5E00ECEE2C /* WebIconDatabaseBridge.m in Sources */,
                                51700DAB0A9052A700DAAA8E /* WebIconLoader.m in Sources */,
                                6538B1C90A90596E00A07522 /* WebFormDataStream.m in Sources */,
+                               659044290A9D3B4200E89459 /* WebDocumentLoadState.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 20c712b5eed863e7dabc88a80d922d245d4e6b85..2058b5023fc862be21d16d95ef4102658bf49716 100644 (file)
 #import <JavaScriptCore/Assertions.h>
 #import <WebKit/DOMHTML.h>
 #import <WebKitSystemInterface.h>
+#import "WebDocumentLoadState.h"
 
 @interface WebDataSourcePrivate : NSObject
 {
     @public
-    NSData *resourceData;
+    
+    WebDocumentLoadState *loadState;
     
     id <WebDocumentRepresentation> representation;
     
 {
     ASSERT(![[webFrame _frameLoader] isLoading]);
 
-    [resourceData release];
+    [loadState release];
+    
     [representation release];
     [request release];
     [originalRequest release];
     _private->representationFinishedLoading = NO;
 }
 
-- (void)_setData:(NSData *)data
-{
-    [data retain];
-    [_private->resourceData release];
-    _private->resourceData = data;
-}
-
 - (void)_loadIcon
 {
     // Don't load an icon if 1) this is not the main frame 2) we ended in error
@@ -727,6 +723,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     [frame retain];
     [_private->webFrame release];
     _private->webFrame = frame;
+
+    [_private->loadState setFrameLoader:[frame _frameLoader]];
     
     [self _defersCallbacksChanged];
     // no need to do _defersCallbacksChanged for subframes since they too
@@ -891,7 +889,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
         [self _loadIcon];
         
         if ([[_private->webFrame _frameLoader] isLoadingMainResource]) {
-            [self _setData:[[_private->webFrame _frameLoader] mainResourceData]];
+            [_private->loadState setMainResourceData:[[_private->webFrame _frameLoader] mainResourceData]];
             [[_private->webFrame _frameLoader] releaseMainResourceLoader];
         }
         
@@ -1040,6 +1038,9 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     }
     
     _private = [[WebDataSourcePrivate alloc] init];
+    
+    _private->loadState = [[WebDocumentLoadState alloc] initWithRequest:request];
+    
     _private->originalRequest = [request retain];
     _private->originalRequestCopy = [request copy];
     
@@ -1070,7 +1071,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
 
 - (NSData *)data
 {
-    return _private->resourceData != nil ? _private->resourceData : [[_private->webFrame _frameLoader] mainResourceData];
+    return [_private->loadState mainResourceData];
 }
 
 - (id <WebDocumentRepresentation>)representation