[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:29:17 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit ba9aba216794bf0086463d61be203f1479941246
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 11 19:32:20 2004 +0000

    Tests:
    
    	Now that WebArchive is a class, refer to it as such.
    
            Reviewed by kocienda.
    
            * Blot/BlotApp.m:
            (-[BlotApp handleNewMessageEvent:withReplyEvent:]):
            * Blot/BlotDocument.h:
            * Blot/BlotDocument.m:
            (-[BlotDocument loadWebArchive:]):
    
    WebKit:
    
    	Made WebArchive a class instead of a data object. This allows clients to easily get the main resource and subresources from a WebArchive.
    
            Reviewed by kocienda.
    
            * WebKit.exp:
            * WebView.subproj/WebDocumentPrivate.h:
            * WebView.subproj/WebFrame.m:
            (-[WebFrame loadWebArchive:]):
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebHTMLRepresentation.m:
            (-[WebHTMLRepresentation loadWebArchive]):
            (-[WebHTMLRepresentation _webArchiveWithMarkupString:subresourceURLStrings:]):
            (-[WebHTMLRepresentation webArchiveFromNode:]):
            (-[WebHTMLRepresentation webArchiveFromRange:]):
            * WebView.subproj/WebHTMLRepresentationPrivate.h:
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView _selectedWebArchive:]):
            (-[WebHTMLView _writeSelectionToPasteboard:]):
            (-[WebHTMLView _pasteMarkupFromPasteboard:]):
            * WebView.subproj/WebResource.h:
            * WebView.subproj/WebResource.m:
            (-[WebArchivePrivate dealloc]):
            (-[WebResource _response]):
            (-[WebArchive init]):
            (-[WebArchive initWithMainResource:subresources:]):
            (-[WebArchive initWithData:]):
            (-[WebArchive dealloc]):
            (-[WebArchive mainResource]):
            (-[WebArchive subresources]):
            (-[WebArchive dataRepresentation]):
            * WebView.subproj/WebResourcePrivate.h:
    
    WebBrowser:
    
    	Now that WebArchive is a class, refer to it as such.
    
            Reviewed by kocienda.
    
            * BrowserDocument.m:
            (-[BrowserDocument dataRepresentationOfType:]):
            (-[BrowserDocument _mailWebArchiveData:withApplicationAtPath:]):
            (-[BrowserDocument mailPage:]):
            (-[BrowserDocument mailPageAddress:]):
            * English.lproj/InfoPlist.strings:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6204 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index e6975ca..763e5bc 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,37 @@
+2004-03-11  Chris Blumenberg  <cblu at apple.com>
+
+	Made WebArchive a class instead of a data object. This allows clients to easily get the main resource and subresources from a WebArchive.
+
+        Reviewed by kocienda.
+
+        * WebKit.exp:
+        * WebView.subproj/WebDocumentPrivate.h:
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame loadWebArchive:]):
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebHTMLRepresentation.m:
+        (-[WebHTMLRepresentation loadWebArchive]):
+        (-[WebHTMLRepresentation _webArchiveWithMarkupString:subresourceURLStrings:]):
+        (-[WebHTMLRepresentation webArchiveFromNode:]):
+        (-[WebHTMLRepresentation webArchiveFromRange:]):
+        * WebView.subproj/WebHTMLRepresentationPrivate.h:
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _selectedWebArchive:]):
+        (-[WebHTMLView _writeSelectionToPasteboard:]):
+        (-[WebHTMLView _pasteMarkupFromPasteboard:]):
+        * WebView.subproj/WebResource.h:
+        * WebView.subproj/WebResource.m:
+        (-[WebArchivePrivate dealloc]):
+        (-[WebResource _response]):
+        (-[WebArchive init]):
+        (-[WebArchive initWithMainResource:subresources:]):
+        (-[WebArchive initWithData:]):
+        (-[WebArchive dealloc]):
+        (-[WebArchive mainResource]):
+        (-[WebArchive subresources]):
+        (-[WebArchive dataRepresentation]):
+        * WebView.subproj/WebResourcePrivate.h:
+
 2004-03-10  Chris Blumenberg  <cblu at apple.com>
 
 	Made dragging of web archives work.
diff --git a/WebKit/WebKit.exp b/WebKit/WebKit.exp
index fb01712..53d4d9d 100644
--- a/WebKit/WebKit.exp
+++ b/WebKit/WebKit.exp
@@ -1,3 +1,4 @@
+.objc_class_name_WebArchive
 .objc_class_name_WebBackForwardList
 .objc_class_name_WebCoreStatistics
 .objc_class_name_WebDataSource
diff --git a/WebKit/WebView.subproj/WebDocumentPrivate.h b/WebKit/WebView.subproj/WebDocumentPrivate.h
index de517bd..e4b5c5a 100644
--- a/WebKit/WebView.subproj/WebDocumentPrivate.h
+++ b/WebKit/WebView.subproj/WebDocumentPrivate.h
@@ -8,6 +8,7 @@
 @class DOMDocument;
 @class DOMNode;
 @class DOMRange;
+ at class WebArchive;
 
 @protocol WebDocumentImage <NSObject>
 - (NSImage *)image;
@@ -20,7 +21,7 @@
 - (NSString *)markupStringFromNode:(DOMNode *)node;
 - (NSString *)markupStringFromRange:(DOMRange *)range;
 
-- (NSData *)webArchiveFromNode:(DOMNode *)node;
-- (NSData *)webArchiveFromRange:(DOMRange *)range;
+- (WebArchive *)webArchiveFromNode:(DOMNode *)node;
+- (WebArchive *)webArchiveFromRange:(DOMRange *)range;
 
 @end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 2ee4f57..4512525 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -262,17 +262,16 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
     [self _loadHTMLString:string baseURL:URL unreachableURL:unreachableURL];
 }
 
-- (void)loadWebArchive:(NSData *)webArchive
+- (void)loadWebArchive:(WebArchive *)webArchive
 {
-    WebResource *mainResource;
-    NSArray *subresources;
-    if ([WebResource _parseWebArchive:webArchive mainResource:&mainResource subresources:&subresources]) {
+    WebResource *mainResource = [webArchive mainResource];
+    if (mainResource) {
         NSURLRequest *request = [self _webDataRequestForData:[mainResource data] 
                                                     MIMEType:[mainResource MIMEType]
                                             textEncodingName:[mainResource textEncodingName]
                                                      baseURL:[mainResource URL]
                                               unreachableURL:nil];
-        [self _loadRequest:request subresources:subresources];
+        [self _loadRequest:request subresources:[webArchive subresources]];
     }
 }
 
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index c1366fa..1b67d18 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -12,6 +12,7 @@
 @class DOMElement;
 @class NSMutableURLRequest;
 @class NSURLRequest;
+ at class WebArchive;
 @class WebBridge;
 @class WebFormState;
 @class WebFrameBridge;
@@ -117,7 +118,7 @@ extern NSString *WebPageCacheDocumentViewKey;
 @interface WebFrame (WebPrivate)
 
 // API Considerations:
-- (void)loadWebArchive:(NSData *)webArchive;
+- (void)loadWebArchive:(WebArchive *)webArchive;
 
 // unreachableURL represents a URL that couldn't be loaded; the HTML string acts as an error page for that URL
 - (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)URL forUnreachableURL:(NSURL *)unreachableURL;
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
index e9f812c..a6d98b4 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.m
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -87,9 +87,11 @@
 
 - (void)loadWebArchive
 {
-    WebResource *mainResource;
-    NSArray *subresources;
-    if (![WebResource _parseWebArchive:[_private->dataSource data] mainResource:&mainResource subresources:&subresources]) {
+    WebArchive *webArchive = [[WebArchive alloc] initWithData:[_private->dataSource data]];
+    WebResource *mainResource = [webArchive mainResource];
+    NSArray *subresources = [webArchive subresources];
+    [webArchive release];
+    if (!mainResource) {
         return;
     }
     
@@ -206,7 +208,7 @@
     return [_private->bridge matchLabels:labels againstElement:element];
 }
 
-- (NSData *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings
+- (WebArchive *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings
 { 
     NSURLResponse *response = [_private->dataSource response];
     WebResource *mainResource = [[WebResource alloc] initWithData:[markupString dataUsingEncoding:NSUTF8StringEncoding]
@@ -227,7 +229,7 @@
         }
     }
     
-    NSData *webArchive = [WebResource _webArchiveWithMainResource:mainResource subresources:subresources];
+    WebArchive *webArchive = [[[WebArchive alloc] initWithMainResource:mainResource subresources:subresources] autorelease];
     [mainResource release];
     [subresources release];
     
@@ -244,14 +246,14 @@
     return [_private->bridge markupStringFromRange:range subresourceURLStrings:nil];
 }
 
-- (NSData *)webArchiveFromNode:(DOMNode *)node
+- (WebArchive *)webArchiveFromNode:(DOMNode *)node
 {
     NSArray *subresourceURLStrings;
     NSString *markupString = [_private->bridge markupStringFromNode:node subresourceURLStrings:&subresourceURLStrings];
     return [self _webArchiveWithMarkupString:markupString subresourceURLStrings:subresourceURLStrings];
 }
 
-- (NSData *)webArchiveFromRange:(DOMRange *)range
+- (WebArchive *)webArchiveFromRange:(DOMRange *)range
 {
     NSArray *subresourceURLStrings;
     NSString *markupString = [_private->bridge markupStringFromRange:range subresourceURLStrings:&subresourceURLStrings];
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
index c86b21b..63f9e87 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
@@ -10,5 +10,5 @@
 @interface WebHTMLRepresentation (WebPrivate)
 - (WebBridge *)_bridge;
 - (void)printDOMTree;
-- (NSData *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings;
+- (WebArchive *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings;
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 6ff6e49..5a41f99 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -520,7 +520,7 @@ static WebHTMLView *lastHitView = nil;
     return [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSRTFPboardType, NSRTFDPboardType, NSStringPboardType, nil];
 }
 
-- (NSData *)_selectedWebArchive:(NSString **)markupString
+- (WebArchive *)_selectedWebArchive:(NSString **)markupString
 {
     NSArray *subresourceURLStrings;
     WebHTMLRepresentation *rep = [[self _dataSource] representation];
@@ -534,9 +534,9 @@ static WebHTMLView *lastHitView = nil;
 
     // Put HTML on the pasteboard.
     NSString *markupString;
-    NSData *webArchive = [self _selectedWebArchive:&markupString];
+    WebArchive *webArchive = [self _selectedWebArchive:&markupString];
     [pasteboard setString:markupString forType:NSHTMLPboardType];
-    [pasteboard setData:webArchive forType:WebArchivePboardType];
+    [pasteboard setData:[webArchive dataRepresentation] forType:WebArchivePboardType];
     
     // Put attributed string on the pasteboard (RTF format).
     NSAttributedString *attributedString = [self selectedAttributedString];
@@ -572,13 +572,13 @@ static WebHTMLView *lastHitView = nil;
     NSString *markupString = nil;
 	
     if ([types containsObject:WebArchivePboardType]) {
-        NSData *webArchive = [pasteboard dataForType:WebArchivePboardType];
-        WebResource *mainResource;
-        NSArray *subresources;
-        if ([WebResource _parseWebArchive:webArchive mainResource:&mainResource subresources:&subresources]) {
+        WebArchive *webArchive = [[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]];
+        WebResource *mainResource = [webArchive mainResource];
+        if (mainResource) {
             markupString = [[[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding] autorelease];
-            [[self _dataSource] addSubresources:subresources];
+            [[self _dataSource] addSubresources:[webArchive subresources]];
         }
+        [webArchive release];
     }
     
     if (!markupString && [types containsObject:NSHTMLPboardType]) {
diff --git a/WebKit/WebView.subproj/WebResource.h b/WebKit/WebView.subproj/WebResource.h
index 711d7cd..3e74580 100644
--- a/WebKit/WebView.subproj/WebResource.h
+++ b/WebKit/WebView.subproj/WebResource.h
@@ -7,6 +7,7 @@
 
 #import <Foundation/Foundation.h>
 
+ at class WebArchivePrivate;
 @class WebResourcePrivate;
 
 extern NSString *WebArchivePboardType;
@@ -25,3 +26,20 @@ extern NSString *WebArchivePboardType;
 - (NSString *)textEncodingName;
 
 @end
+
+
+ at interface WebArchive : NSObject 
+{
+ at private
+    WebArchivePrivate *_private;
+}
+
+- (id)initWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources;
+- (id)initWithData:(NSData *)data;
+
+- (WebResource *)mainResource;
+- (NSArray *)subresources;
+
+- (NSData *)dataRepresentation;
+
+ at end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebResource.m b/WebKit/WebView.subproj/WebResource.m
index fe6a0b6..b054c24 100644
--- a/WebKit/WebView.subproj/WebResource.m
+++ b/WebKit/WebView.subproj/WebResource.m
@@ -28,6 +28,14 @@ NSString *WebSubresourcesKey =              @"WebSubresources";
 }
 @end
 
+ at interface WebArchivePrivate : NSObject
+{
+    @public
+    WebResource *mainResource;
+    NSArray *subresources;
+}
+ at end
+
 @implementation WebResourcePrivate
 
 - (void)dealloc
@@ -41,6 +49,17 @@ NSString *WebSubresourcesKey =              @"WebSubresources";
 
 @end
 
+ at implementation WebArchivePrivate
+
+- (void)dealloc
+{
+    [mainResource release];
+    [subresources release];
+    [super dealloc];
+}
+
+ at end
+
 @implementation WebResource
 
 - (id)initWithData:(NSData *)data URL:(NSURL *)URL MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName
@@ -129,53 +148,6 @@ NSString *WebSubresourcesKey =              @"WebSubresources";
     return propertyLists;
 }
 
-+ (BOOL)_parseWebArchive:(NSData *)webArchive mainResource:(WebResource **)mainResource subresources:(NSArray **)subresources
-{
-#if !LOG_DISABLED
-    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
-#endif
-    NSDictionary *propertyList = [NSPropertyListSerialization propertyListFromData:webArchive 
-                                                                  mutabilityOption:NSPropertyListImmutable 
-                                                                            format:nil
-                                                                  errorDescription:nil];
-#if !LOG_DISABLED
-    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
-    CFAbsoluteTime duration = end - start;
-#endif
-    LOG(Timing, "Parsing web archive with [NSPropertyListSerialization propertyListFromData::::] took %f seconds", duration);
-    if ([propertyList isKindOfClass:[NSDictionary class]]) {
-        NSDictionary *resourcePropertyList = [propertyList objectForKey:WebMainResourceKey];
-        if (resourcePropertyList) {
-            *mainResource = [[[WebResource alloc] _initWithPropertyList:resourcePropertyList] autorelease];
-            if (*mainResource) {
-                *subresources = [WebResource _resourcesFromPropertyLists:[propertyList objectForKey:WebSubresourcesKey]];
-                return YES;
-            }
-        }
-    }
-    return NO;
-}
-
-+ (NSData *)_webArchiveWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources
-{
-    NSMutableDictionary *propertyList = [NSMutableDictionary dictionary];
-    [propertyList setObject:[mainResource _propertyListRepresentation] forKey:WebMainResourceKey];
-    NSArray *propertyLists = [self _propertyListsFromResources:subresources];
-    if ([propertyLists count] > 0) {
-        [propertyList setObject:propertyLists forKey:WebSubresourcesKey];
-    }
-#if !LOG_DISABLED
-    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
-#endif
-    NSData *webArchive = [NSPropertyListSerialization dataFromPropertyList:propertyList format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
-#if !LOG_DISABLED
-    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
-    CFAbsoluteTime duration = end - start;
-#endif
-    LOG(Timing, "Creating web archive with [NSPropertyListSerialization dataFromPropertyList:::] took %f seconds", duration);
-    return webArchive;
-}
-
 - (id)_initWithPropertyList:(id)propertyList
 {
     if (![propertyList isKindOfClass:[NSDictionary class]]) {
@@ -227,3 +199,99 @@ NSString *WebSubresourcesKey =              @"WebSubresources";
 }
 
 @end
+
+ at implementation WebArchive
+
+- (id)init
+{
+    [super init];
+    _private = [[WebArchivePrivate alloc] init];
+    return self;
+}
+
+- (id)initWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources
+{
+    [self init];
+    
+    _private->mainResource = [mainResource retain];
+    _private->subresources = [subresources retain];
+    
+    if (!_private->mainResource && [_private->subresources count] == 0) {
+        [self release];
+        return nil;
+    }
+    
+    return self;
+}
+
+- (id)initWithData:(NSData *)data
+{
+    [self init];
+    
+#if !LOG_DISABLED
+    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
+#endif
+    NSDictionary *propertyList = [NSPropertyListSerialization propertyListFromData:data 
+                                                                  mutabilityOption:NSPropertyListImmutable 
+                                                                            format:nil
+                                                                  errorDescription:nil];
+#if !LOG_DISABLED
+    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
+    CFAbsoluteTime duration = end - start;
+#endif
+    LOG(Timing, "Parsing web archive with [NSPropertyListSerialization propertyListFromData::::] took %f seconds", duration);
+    if (![propertyList isKindOfClass:[NSDictionary class]]) {
+        [self release];
+        return nil;
+    }
+    
+    _private->mainResource = [[WebResource alloc] _initWithPropertyList:[propertyList objectForKey:WebMainResourceKey]];
+    _private->subresources = [[WebResource _resourcesFromPropertyLists:[propertyList objectForKey:WebSubresourcesKey]] retain];
+    
+    if (!_private->mainResource && [_private->subresources count] == 0) {
+        [self release];
+        return nil;
+    }
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [_private release];
+    [super dealloc];
+}
+
+- (WebResource *)mainResource
+{
+    return [[_private->mainResource retain] autorelease];
+}
+
+- (NSArray *)subresources
+{
+    return [[_private->subresources retain] autorelease];
+}
+
+- (NSData *)dataRepresentation
+{
+    NSMutableDictionary *propertyList = [NSMutableDictionary dictionary];
+    if (_private->mainResource) {
+        [propertyList setObject:[_private->mainResource _propertyListRepresentation] forKey:WebMainResourceKey];
+    }
+    NSArray *propertyLists = [WebResource _propertyListsFromResources:_private->subresources];
+    if ([propertyLists count] > 0) {
+        [propertyList setObject:propertyLists forKey:WebSubresourcesKey];
+    }
+#if !LOG_DISABLED
+    CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
+#endif
+    NSData *data = [NSPropertyListSerialization dataFromPropertyList:propertyList format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
+#if !LOG_DISABLED
+    CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
+    CFAbsoluteTime duration = end - start;
+#endif
+    LOG(Timing, "Serializing web archive with [NSPropertyListSerialization dataFromPropertyList:::] took %f seconds", duration);
+    return data;
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebResourcePrivate.h b/WebKit/WebView.subproj/WebResourcePrivate.h
index 5135669..939e4f0 100644
--- a/WebKit/WebView.subproj/WebResourcePrivate.h
+++ b/WebKit/WebView.subproj/WebResourcePrivate.h
@@ -19,9 +19,6 @@ extern NSString *WebSubresourcesKey;
 + (NSArray *)_resourcesFromPropertyLists:(NSArray *)propertyLists;
 + (NSArray *)_propertyListsFromResources:(NSArray *)resources;
 
-+ (BOOL)_parseWebArchive:(NSData *)webArchive mainResource:(WebResource **)mainResource subresources:(NSArray **)subresources;
-+ (NSData *)_webArchiveWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources;
-
 - (id)_initWithPropertyList:(id)propertyList;
 - (id)_initWithCachedResponse:(NSCachedURLResponse *)response originalURL:(NSURL *)originalURL;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list