[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:39:09 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 76ed97037b12118b3cb5633d7b093800de790e07
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed May 12 02:05:30 2004 +0000

    WebCore:
    
    	Support for: <rdar://problem/3616471>: (API: provide way to get from WebFrame to DOMDocument and vice versa)
    
            Reviewed by rjw.
    
            * kwq/DOM.mm:
            (-[DOMDocument _ownerElement]): new
            * kwq/DOMInternal.h:
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge frameElement]): new
    
    WebKit:
    
    	Fixed:
    	<rdar://problem/3616537>: (API: Make WebResource, WebArchive and related API's public)
    	<rdar://problem/3616471>: (API: provide way to get from WebFrame to DOMDocument and vice versa)
    
            Reviewed by rjw.
    
            * DOM.subproj/WebDOMOperations.h:
            * DOM.subproj/WebDOMOperations.m:
            (-[DOMHTMLFrameElement contentFrame]): new
            (-[DOMHTMLIFrameElement contentFrame]): new
            (-[DOMHTMLObjectElement contentFrame]): new
            * DOM.subproj/WebDOMOperationsPrivate.h:
            * Misc.subproj/WebNSImageExtras.m:
            (-[NSImage _web_saveAndOpen]): fixed leak
            * WebKit.pbproj/project.pbxproj:
            * WebView.subproj/WebDataSource.h:
            * WebView.subproj/WebDataSource.m:
            (-[WebDataSource _addSubresources:]): made private
            (-[WebDataSource _archiveWithMarkupString:nodes:]): handle object tags with frame content
            (-[WebDataSource _archiveWithCurrentState:]): renamed from _archive, now takes flag
            (-[WebDataSource _replaceSelectionWithArchive:]): call renamed _addSubresources
            (-[WebDataSource webArchive]): new
            (-[WebDataSource mainResource]): new
            (-[WebDataSource subresources]): made public
            (-[WebDataSource subresourceForURL:]): made public
            (-[WebDataSource addSubresource:]): made public
            * WebView.subproj/WebDataSourcePrivate.h:
            * WebView.subproj/WebDocumentPrivate.h:
            * WebView.subproj/WebFrame.h:
            * WebView.subproj/WebFrame.m:
            (-[WebFrame _loadRequest:subresources:subframeArchives:]): call renamed _addSubresources
            (-[WebFrame DOMDocument]): new
            (-[WebFrame frameElement]): new
            (-[WebFrame loadArchive:]): made public
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebHTMLRepresentation.m:
            (-[WebHTMLRepresentation loadArchive]): call renamed _addSubresources
            * WebView.subproj/WebImageRepresentation.m:
            (-[WebImageRepresentation archive]): call webArchive on WebDataSource
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 44637a7..13b603a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,16 @@
+2004-05-11  Chris Blumenberg  <cblu at apple.com>
+
+	Support for: <rdar://problem/3616471>: (API: provide way to get from WebFrame to DOMDocument and vice versa)
+
+        Reviewed by rjw.
+
+        * kwq/DOM.mm:
+        (-[DOMDocument _ownerElement]): new
+        * kwq/DOMInternal.h:
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge frameElement]): new
+
 2004-05-11  David Hyatt  <hyatt at apple.com>
 
 	Fix makeChildrenNonInline so that it does not wrap floats unless an inline is actually found.
diff --git a/WebCore/kwq/DOM.mm b/WebCore/kwq/DOM.mm
index 72c3147..dbedf6c 100644
--- a/WebCore/kwq/DOM.mm
+++ b/WebCore/kwq/DOM.mm
@@ -1101,6 +1101,12 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
     return static_cast<DocumentImpl *>(DOM_cast<NodeImpl *>(_internal));
 }
 
+- (DOMElement *)_ownerElement
+{
+    ElementImpl *element = [self _documentImpl]->ownerElement();
+    return element ? [DOMElement _elementWithImpl:element] : nil;
+}
+
 @end
 
 //------------------------------------------------------------------------------------------
diff --git a/WebCore/kwq/DOMInternal.h b/WebCore/kwq/DOMInternal.h
index d965658..bf43412 100644
--- a/WebCore/kwq/DOMInternal.h
+++ b/WebCore/kwq/DOMInternal.h
@@ -56,6 +56,7 @@ namespace DOM {
 @interface DOMDocument (WebCoreInternal)
 + (DOMDocument *)_documentWithImpl:(DOM::DocumentImpl *)impl;
 - (DOM::DocumentImpl *)_documentImpl;
+- (DOMElement *)_ownerElement;
 @end
 
 @interface DOMRange (WebCoreInternal)
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 496ab92..25c7c24 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -54,7 +54,7 @@ typedef khtml::RenderPart KHTMLRenderPart;
 @class DOMCSSStyleDeclaration;
 @class DOMDocument;
 @class DOMElement;
- at class DOMHTMLImageElement;
+ at class DOMHTMLElement;
 @class DOMNode;
 @class DOMRange;
 @class WebCoreSettings;
@@ -227,6 +227,7 @@ typedef enum {
 - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)string;
 
 - (DOMDocument *)DOMDocument;
+- (DOMHTMLElement *)frameElement;
 
 - (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset;
 
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 94b15c7..4585cde 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -1080,6 +1080,11 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return [DOMDocument _documentWithImpl:_part->xmlDocImpl()];
 }
 
+- (DOMHTMLElement *)frameElement
+{
+    return (DOMHTMLElement *)[[self DOMDocument] _ownerElement];
+}
+
 - (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int) endOffset
 {
     Position s([start _nodeImpl], startOffset);
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index f1d66e6..c5fc0ad 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,45 @@
+2004-05-11  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed:
+	<rdar://problem/3616537>: (API: Make WebResource, WebArchive and related API's public)
+	<rdar://problem/3616471>: (API: provide way to get from WebFrame to DOMDocument and vice versa)
+
+        Reviewed by rjw.
+
+        * DOM.subproj/WebDOMOperations.h:
+        * DOM.subproj/WebDOMOperations.m:
+        (-[DOMHTMLFrameElement contentFrame]): new
+        (-[DOMHTMLIFrameElement contentFrame]): new
+        (-[DOMHTMLObjectElement contentFrame]): new
+        * DOM.subproj/WebDOMOperationsPrivate.h:
+        * Misc.subproj/WebNSImageExtras.m:
+        (-[NSImage _web_saveAndOpen]): fixed leak
+        * WebKit.pbproj/project.pbxproj:
+        * WebView.subproj/WebDataSource.h:
+        * WebView.subproj/WebDataSource.m:
+        (-[WebDataSource _addSubresources:]): made private
+        (-[WebDataSource _archiveWithMarkupString:nodes:]): handle object tags with frame content
+        (-[WebDataSource _archiveWithCurrentState:]): renamed from _archive, now takes flag
+        (-[WebDataSource _replaceSelectionWithArchive:]): call renamed _addSubresources
+        (-[WebDataSource webArchive]): new
+        (-[WebDataSource mainResource]): new
+        (-[WebDataSource subresources]): made public
+        (-[WebDataSource subresourceForURL:]): made public
+        (-[WebDataSource addSubresource:]): made public
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebDocumentPrivate.h:
+        * WebView.subproj/WebFrame.h:
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame _loadRequest:subresources:subframeArchives:]): call renamed _addSubresources
+        (-[WebFrame DOMDocument]): new
+        (-[WebFrame frameElement]): new
+        (-[WebFrame loadArchive:]): made public
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebHTMLRepresentation.m:
+        (-[WebHTMLRepresentation loadArchive]): call renamed _addSubresources
+        * WebView.subproj/WebImageRepresentation.m:
+        (-[WebImageRepresentation archive]): call webArchive on WebDataSource
+
 2004-05-10  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
diff --git a/WebKit/DOM.subproj/WebDOMOperations.h b/WebKit/DOM.subproj/WebDOMOperations.h
index b740f2d..d10f86f 100644
--- a/WebKit/DOM.subproj/WebDOMOperations.h
+++ b/WebKit/DOM.subproj/WebDOMOperations.h
@@ -6,6 +6,7 @@
 */
 
 #import <WebKit/DOMCore.h>
+#import <WebKit/DOMHTML.h>
 #import <WebKit/DOMRange.h>
 
 @class WebArchive;
@@ -29,15 +30,6 @@
 */
 - (WebFrame *)webFrame;
 
-/*!
-    @method URLWithAttributeString
-    @abstract Constructs a URL given an attribute string.
-    @discussion This method constructs a URL given an attribute string just as WebKit does. 
-    An attribute string is the value of an attribute of an element such as the href attribute on 
-    the DOMHTMLAnchorElement class. This method is only applicable to attributes that refer to URLs.
-*/
-- (NSURL *)URLWithAttributeString:(NSString *)string;
-
 @end
 
 @interface DOMRange (WebDOMRangeOperations)
@@ -48,10 +40,37 @@
 */
 - (WebArchive *)webArchive;
 
+ at end
+
+ at interface DOMHTMLFrameElement (WebDOMHTMLFrameElementOperations)
+
 /*!
-    @method markupString
-    @result A markup string representing the range.
+    @method contentFrame
+    @abstract Returns the content frame of the element.
 */
-- (NSString *)markupString;
+- (WebFrame *)contentFrame;
 
 @end
+
+ at interface DOMHTMLIFrameElement (WebDOMHTMLIFrameElementOperations)
+
+/*!
+    @method contentFrame
+    @abstract Returns the content frame of the element.
+*/
+- (WebFrame *)contentFrame;
+
+ at end
+
+ at interface DOMHTMLObjectElement (WebDOMHTMLObjectElementOperations)
+
+/*!
+    @method contentFrame
+    @abstract Returns the content frame of the element.
+    @discussion Returns non-nil only if the object represents a child frame
+    such as if the data of the object is HTML content.
+*/
+- (WebFrame *)contentFrame;
+
+ at end
+
diff --git a/WebKit/DOM.subproj/WebDOMOperations.m b/WebKit/DOM.subproj/WebDOMOperations.m
index afe16f6..ee96d59 100644
--- a/WebKit/DOM.subproj/WebDOMOperations.m
+++ b/WebKit/DOM.subproj/WebDOMOperations.m
@@ -97,7 +97,7 @@
 
 @end
 
- at implementation DOMHTMLBodyElement (WebDOMHTMLBodyElementOperations)
+ at implementation DOMHTMLBodyElement (WebDOMHTMLBodyElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -106,7 +106,7 @@
 
 @end
 
- at implementation DOMHTMLInputElement (WebDOMHTMLInputElementOperations)
+ at implementation DOMHTMLInputElement (WebDOMHTMLInputElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -115,7 +115,7 @@
 
 @end
 
- at implementation DOMHTMLLinkElement (WebDOMHTMLLinkElementOperations)
+ at implementation DOMHTMLLinkElement (WebDOMHTMLLinkElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -128,7 +128,7 @@
 
 @end
 
- at implementation DOMHTMLScriptElement (WebDOMHTMLScriptElementOperations)
+ at implementation DOMHTMLScriptElement (WebDOMHTMLScriptElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -137,7 +137,7 @@
 
 @end
 
- at implementation DOMHTMLImageElement (WebDOMHTMLImageElementOperations)
+ at implementation DOMHTMLImageElement (WebDOMHTMLImageElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -147,7 +147,7 @@
 
 @end
 
- at implementation DOMHTMLEmbedElement (WebDOMHTMLEmbedElementOperations)
+ at implementation DOMHTMLEmbedElement (WebDOMHTMLEmbedElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -156,7 +156,7 @@
 
 @end
 
- at implementation DOMHTMLObjectElement (WebDOMHTMLObjectElementOperations)
+ at implementation DOMHTMLObjectElement (WebDOMHTMLObjectElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -166,7 +166,7 @@
 
 @end
 
- at implementation DOMHTMLParamElement (WebDOMHTMLParamElementOperations)
+ at implementation DOMHTMLParamElement (WebDOMHTMLParamElementOperationsPrivate)
 
 - (NSArray *)_subresourceURLs
 {
@@ -181,7 +181,7 @@
 
 @end
 
- at implementation DOMHTMLTableElement (WebDOMHTMLTableElementOperations)
+ at implementation DOMHTMLTableElement (WebDOMHTMLTableElementOperationsPrivate)
 
 - (NSString *)_web_background
 {
@@ -195,7 +195,7 @@
 
 @end
 
- at implementation DOMHTMLTableCellElement (WebDOMHTMLTableCellElementOperations)
+ at implementation DOMHTMLTableCellElement (WebDOMHTMLTableCellElementOperationsPrivate)
 
 - (NSString *)_web_background
 {
@@ -208,3 +208,30 @@
 }
 
 @end
+
+ at implementation DOMHTMLFrameElement (WebDOMHTMLFrameElementOperations)
+
+- (WebFrame *)contentFrame
+{
+    return [[self contentDocument] webFrame];
+}
+
+ at end
+
+ at implementation DOMHTMLIFrameElement (WebDOMHTMLIFrameElementOperations)
+
+- (WebFrame *)contentFrame
+{
+    return [[self contentDocument] webFrame];
+}
+
+ at end
+
+ at implementation DOMHTMLObjectElement (WebDOMHTMLObjectElementOperations)
+
+- (WebFrame *)contentFrame
+{
+    return [[self contentDocument] webFrame];
+}
+
+ at end
diff --git a/WebKit/DOM.subproj/WebDOMOperationsPrivate.h b/WebKit/DOM.subproj/WebDOMOperationsPrivate.h
index 2b3a98e..2e89774 100644
--- a/WebKit/DOM.subproj/WebDOMOperationsPrivate.h
+++ b/WebKit/DOM.subproj/WebDOMOperationsPrivate.h
@@ -9,12 +9,36 @@
 
 #import <WebKit/WebDOMOperations.h>
 
+ at interface DOMDocument (ToBeMadePublic)
+
+/*!
+    @method URLWithAttributeString
+    @abstract Constructs a URL given an attribute string.
+    @discussion This method constructs a URL given an attribute string just as WebKit does. 
+    An attribute string is the value of an attribute of an element such as the href attribute on 
+    the DOMHTMLAnchorElement class. This method is only applicable to attributes that refer to URLs.
+*/
+- (NSURL *)URLWithAttributeString:(NSString *)string;
+
+ at end
+
 @interface DOMNode (WebDOMNodeOperationsPrivate)
 - (WebBridge *)_bridge;
 - (NSArray *)_URLsFromSelectors:(SEL)firstSel, ...;
 - (NSArray *)_subresourceURLs;
 @end
 
+ at interface DOMRange (ToBeMadePublic)
+
+/*!
+    @method markupString
+    @result A markup string representing the range.
+*/
+- (NSString *)markupString;
+
+ at end
+
 @interface DOMRange (WebDOMRangeOperationsPrivate)
 - (WebBridge *)_bridge;
- at end
\ No newline at end of file
+ at end
+
diff --git a/WebKit/Misc.subproj/WebNSImageExtras.m b/WebKit/Misc.subproj/WebNSImageExtras.m
index a061198..4c30067 100644
--- a/WebKit/Misc.subproj/WebNSImageExtras.m
+++ b/WebKit/Misc.subproj/WebNSImageExtras.m
@@ -58,14 +58,12 @@
 
 - (void)_web_saveAndOpen
 {
-    char *path = strdup("/tmp/XXXXXX.tiff");
-    
+    char path[] = "/tmp/XXXXXX.tiff";
     int fd = mkstemps(path, 5);
     if (fd != -1) {
         NSData *data = [self TIFFRepresentation];
         write(fd, [data bytes], [data length]);
         close(fd);
-
         [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithCString:path]];
     }
 }
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index db31a0d..6951559 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -2125,7 +2125,7 @@
 			isa = PBXBuildFile;
 			settings = {
 				ATTRIBUTES = (
-					Private,
+					Public,
 				);
 			};
 		};
@@ -2232,7 +2232,7 @@
 			isa = PBXBuildFile;
 			settings = {
 				ATTRIBUTES = (
-					Private,
+					Public,
 				);
 			};
 		};
@@ -2282,7 +2282,7 @@
 			isa = PBXBuildFile;
 			settings = {
 				ATTRIBUTES = (
-					Private,
+					Public,
 				);
 			};
 		};
diff --git a/WebKit/WebView.subproj/WebDataSource.h b/WebKit/WebView.subproj/WebDataSource.h
index 1ad8259..000fb52 100644
--- a/WebKit/WebView.subproj/WebDataSource.h
+++ b/WebKit/WebView.subproj/WebDataSource.h
@@ -9,13 +9,14 @@
 
 #import <WebKit/WebDocument.h>
 
- at class WebDataSourcePrivate;
- at class WebFrame;
+ at class NSMutableURLRequest;
 @class NSURLConnection;
 @class NSURLRequest;
- at class NSMutableURLRequest;
 @class NSURLResponse;
-
+ at class WebArchive;
+ at class WebDataSourcePrivate;
+ at class WebFrame;
+ at class WebResource;
 
 /*!
     @class WebDataSource
@@ -109,4 +110,50 @@
 */
 - (NSURL *)unreachableURL;
 
+/*!
+    @method webArchive
+    @result A WebArchive representing the data source, its subresources and child frames.
+    @description This method constructs a WebArchive using the original downloaded data.
+    In the case of HTML, if the current state of the document is preferred, webArchive should be
+    called on the DOM document instead.
+*/
+- (WebArchive *)webArchive;
+
+/*!
+    @method mainResource
+    @result A WebResource representing the data source.
+    @description This method constructs a WebResource using the original downloaded data.
+    This method can be used to construct a WebArchive in case the archive returned by
+    WebDataSource's webArchive isn't sufficient.
+*/
+- (WebResource *)mainResource;
+
+/*!
+    @method subresources
+    @abstract Returns all the subresources associated with the data source.
+    @description The returned array only contains subresources that have fully downloaded.
+*/
+- (NSArray *)subresources;
+
+/*!
+    method subresourceForURL:
+    @abstract Returns a subresource for a given URL.
+    @param URL The URL of the subresource.
+    @description Returns non-nil if the data source has fully downloaded a subresource with the given URL.
+*/
+- (WebResource *)subresourceForURL:(NSURL *)URL;
+
+/*!
+    @method addSubresource:
+    @abstract Adds a subresource to the data source.
+    @param subresource The subresource to be added.
+    @description addSubresource: adds a subresource to the data source's list of subresources.
+    Later, if something causes the data source to load the URL of the subresource, the data source
+    will load the data from the subresource instead of from the network. For example, if one wants to add
+    an image that is already downloaded to a web page, addSubresource: can be called so that the data source
+    uses the downloaded image rather than accessing the network. NOTE: If the data source already has a
+    subresource with the same URL, addSubresource: will replace it.
+*/
+- (void)addSubresource:(WebResource *)subresource;
+
 @end
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 6cade9d..07f1c19 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -80,22 +80,7 @@
 
 @implementation WebDataSource (WebPrivate)
 
-- (NSArray *)subresources
-{
-    return [_private->subresources allValues];
-}
-
-- (WebResource *)subresourceForURL:(NSURL *)URL
-{
-    return [_private->subresources objectForKey:[URL _web_originalDataAsString]];
-}
-
-- (void)addSubresource:(WebResource *)subresource
-{
-    [_private->subresources setObject:subresource forKey:[[subresource URL] _web_originalDataAsString]];
-}
-
-- (void)addSubresources:(NSArray *)subresources
+- (void)_addSubresources:(NSArray *)subresources
 {
     NSEnumerator *enumerator = [subresources objectEnumerator];
     WebResource *subresource;
@@ -141,8 +126,12 @@
     NSEnumerator *enumerator = [nodes objectEnumerator];
     DOMNode *node;
     while ((node = [enumerator nextObject]) != nil) {
-        if ([node isKindOfClass:[DOMHTMLFrameElement class]] || [node isKindOfClass:[DOMHTMLIFrameElement class]]) {
-            [subframeArchives addObject:[[[[(DOMHTMLFrameElement *)node contentDocument] webFrame] dataSource] _archive]];
+        WebFrame *childFrame;
+        if (([node isKindOfClass:[DOMHTMLFrameElement class]] || 
+             [node isKindOfClass:[DOMHTMLIFrameElement class]] || 
+             [node isKindOfClass:[DOMHTMLObjectElement class]]) &&
+            ((childFrame = [(DOMHTMLFrameElement *)node contentFrame]) != nil)) {
+            [subframeArchives addObject:[[childFrame dataSource] _archiveWithCurrentState:YES]];
         } else {
             NSEnumerator *enumerator = [[node _subresourceURLs] objectEnumerator];
             NSURL *URL;
@@ -165,19 +154,21 @@
     return archive;
 }
 
-- (WebArchive *)_archive
+- (WebArchive *)_archiveWithCurrentState:(BOOL)currentState
 {
-    if ([[self representation] conformsToProtocol:@protocol(WebDocumentDOM)]) {
+    if (currentState && [[self representation] conformsToProtocol:@protocol(WebDocumentDOM)]) {
         return [[(id <WebDocumentDOM>)[self representation] DOMDocument] webArchive];
     } else {
-        NSURLResponse *response = [self response];
-        WebResource *mainResource = [[WebResource alloc] initWithData:[self data]
-                                                                  URL:[response URL] 
-                                                             MIMEType:[response MIMEType]
-                                                     textEncodingName:[response textEncodingName]
-                                                            frameName:[[self webFrame] name]];
-        WebArchive *archive = [[[WebArchive alloc] initWithMainResource:mainResource subresources:nil subframeArchives:nil] autorelease];
-        [mainResource release];
+        NSEnumerator *enumerator = [[[self webFrame] childFrames] objectEnumerator];
+        NSMutableArray *subframeArchives = [[NSMutableArray alloc] init];
+        WebFrame *childFrame;
+        while ((childFrame = [enumerator nextObject]) != nil) {
+            [subframeArchives addObject:[[childFrame dataSource] _archiveWithCurrentState:currentState]];
+        }
+        WebArchive *archive = [[[WebArchive alloc] initWithMainResource:[self mainResource] 
+                                                           subresources:[_private->subresources allValues]
+                                                       subframeArchives:subframeArchives] autorelease];
+        [subframeArchives release];
         return archive;
     }
 }
@@ -231,7 +222,7 @@
         NSString *MIMEType = [mainResource MIMEType];
         if ([WebView canShowMIMETypeAsHTML:MIMEType]) {
             NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding];
-            [self addSubresources:[archive subresources]];
+            [self _addSubresources:[archive subresources]];
             [self _addSubframeArchives:[archive subframeArchives]];
             [self _replaceSelectionWithMarkupString:markupString baseURL:[mainResource URL]];
             [markupString release];
@@ -1140,4 +1131,34 @@
     return [_private->originalRequest _webDataRequestUnreachableURL];
 }
 
+- (WebArchive *)webArchive
+{
+    return [self _archiveWithCurrentState:NO];
+}
+
+- (WebResource *)mainResource
+{
+    NSURLResponse *response = [self response];
+    return [[[WebResource alloc] initWithData:[self data]
+                                          URL:[response URL] 
+                                     MIMEType:[response MIMEType]
+                             textEncodingName:[response textEncodingName]
+                                    frameName:[[self webFrame] name]] autorelease];
+}
+
+- (NSArray *)subresources
+{
+    return [_private->subresources allValues];
+}
+
+- (WebResource *)subresourceForURL:(NSURL *)URL
+{
+    return [_private->subresources objectForKey:[URL _web_originalDataAsString]];
+}
+
+- (void)addSubresource:(WebResource *)subresource
+{
+    [_private->subresources setObject:subresource forKey:[[subresource URL] _web_originalDataAsString]];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 45ee645..41ef331 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -117,42 +117,11 @@
 
 @interface WebDataSource (WebPrivate)
 
-// API Considerations:
-
-/*!
-    @method subresources
-    @abstract Returns all the subresources associated with the data source.
-    @description The returned array only contains subresources that have fully downloaded.
-*/
-- (NSArray *)subresources;
-
-/*!
-    method subresourceForURL:
-    @abstract Returns a subresource for a given URL.
-    @param URL The URL of the subresource.
-    @description Non-nil is returned if the data source has fully downloaded a subresource with the given URL.
-*/
-- (WebResource *)subresourceForURL:(NSURL *)URL;
-
-/*!
-    @method addSubresource:
-    @abstract Adds a subresource to the data source.
-    @param subresource The subresource to be added.
-    @description addSubresource: adds a subresource to the data source's list of subresources.
-    Later, if something causes the data source to load the URL of the subresource, the data source
-    will load the data from the subresource instead of from the network. For example, if one wants to add
-    an image that is already downloaded to a web page, addSubresource: can be called so that the data source
-    uses the downloaded image rather than accessing the network. NOTE: If the data source already has a
-    subresource with the same URL, addSubresource: will replace it.
-*/
-- (void)addSubresource:(WebResource *)subresource;
-
-
 // Other private methods
-- (void)addSubresources:(NSArray *)subresources;
+- (void)_addSubresources:(NSArray *)subresources;
 - (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL;
 
-- (WebArchive *)_archive;
+- (WebArchive *)_archiveWithCurrentState:(BOOL)currentState;
 - (WebArchive *)_archiveWithMarkupString:(NSString *)markupString nodes:(NSArray *)nodes;
 - (void)_addSubframeArchives:(NSArray *)subframeArchives;
 - (WebArchive *)_popSubframeArchiveWithName:(NSString *)frameName;
diff --git a/WebKit/WebView.subproj/WebDocumentPrivate.h b/WebKit/WebView.subproj/WebDocumentPrivate.h
index c9ce9ae..0ab3305 100644
--- a/WebKit/WebView.subproj/WebDocumentPrivate.h
+++ b/WebKit/WebView.subproj/WebDocumentPrivate.h
@@ -14,6 +14,7 @@
 - (NSImage *)image;
 @end
 
+// This method is deprecated as it now lives on WebFrame.
 @protocol WebDocumentDOM <NSObject>
 - (DOMDocument *)DOMDocument;
 @end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebFrame.h b/WebKit/WebView.subproj/WebFrame.h
index 9733650..af04150 100644
--- a/WebKit/WebView.subproj/WebFrame.h
+++ b/WebKit/WebView.subproj/WebFrame.h
@@ -7,11 +7,14 @@
 
 #import <Foundation/Foundation.h>
 
- at class WebView;
+ at class DOMDocument;
+ at class DOMHTMLElement;
+ at class NSURLRequest;
+ at class WebArchive;
 @class WebDataSource;
 @class WebFramePrivate;
 @class WebFrameView;
- at class NSURLRequest;
+ at class WebView;
 
 /*!
     @class WebFrame
@@ -55,6 +58,21 @@
 - (WebFrameView *)frameView;
 
 /*!
+    @method DOMDocument
+    @abstract Returns the DOM document of the frame.
+    @description Returns nil if the frame does not contain a DOM document such as a standalone image.
+*/
+- (DOMDocument *)DOMDocument;
+
+/*!
+    @method frameElement
+    @abstract Returns the frame element of the frame.
+    @description The class of the result is either DOMHTMLFrameElement, DOMHTMLIFrameElement or DOMHTMLObjectElement.
+    Returns nil if the frame is the main frame since there is no frame element for the frame in this case.
+*/
+- (DOMHTMLElement *)frameElement;
+
+/*!
     @method loadRequest:
     @param request The web request to load.
 */
@@ -92,6 +110,13 @@
 - (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL;
 
 /*!
+    @method loadArchive:
+    @abstract Causes WebFrame to load a WebArchive.
+    @param archive The archive to be loaded.
+*/
+- (void)loadArchive:(WebArchive *)archive;
+
+/*!
     @method dataSource
     @discussion Returns the committed data source.  Will return nil if the
     provisional data source hasn't yet been loaded.
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index ed060cc..5a3e274 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -278,19 +278,6 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
 
 @implementation WebFrame (WebPrivate)
 
-- (void)loadArchive:(WebArchive *)archive
-{
-    WebResource *mainResource = [archive mainResource];
-    if (mainResource) {
-        NSURLRequest *request = [self _webDataRequestForData:[mainResource data] 
-                                                    MIMEType:[mainResource MIMEType]
-                                            textEncodingName:[mainResource textEncodingName]
-                                                     baseURL:[mainResource URL]
-                                              unreachableURL:nil];
-        [self _loadRequest:request subresources:[archive subresources] subframeArchives:[archive subframeArchives]];
-    }
-}
-
 - (NSURLRequest *)_webDataRequestForData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName: (NSString *)encodingName baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL
 {
     NSURL *fakeURL = [NSURL _web_uniqueWebDataURL];
@@ -348,7 +335,7 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
     }
     
     [newDataSource _setOverrideEncoding:[[self dataSource] _overrideEncoding]];
-    [newDataSource addSubresources:subresources];
+    [newDataSource _addSubresources:subresources];
     [newDataSource _addSubframeArchives:subframeArchives];
     
     // When we loading alternate content for an unreachable URL that we're
@@ -2601,13 +2588,21 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
     return [_private webView];
 }
 
+- (DOMDocument *)DOMDocument
+{
+    return [[self dataSource] _isDocumentHTML] ? [_private->bridge DOMDocument] : nil;
+}
+
+- (DOMHTMLElement *)frameElement
+{
+    return [[self webView] mainFrame] != self ? [_private->bridge frameElement] : nil;
+}
 
 - (WebDataSource *)provisionalDataSource
 {
     return [_private provisionalDataSource];
 }
 
-
 - (WebDataSource *)dataSource
 {
     return [_private dataSource];
@@ -2660,6 +2655,19 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
     [self _loadHTMLString:string baseURL:URL unreachableURL:unreachableURL];
 }
 
+- (void)loadArchive:(WebArchive *)archive
+{
+    WebResource *mainResource = [archive mainResource];
+    if (mainResource) {
+        NSURLRequest *request = [self _webDataRequestForData:[mainResource data] 
+                                                    MIMEType:[mainResource MIMEType]
+                                            textEncodingName:[mainResource textEncodingName]
+                                                     baseURL:[mainResource URL]
+                                              unreachableURL:nil];
+        [self _loadRequest:request subresources:[archive subresources] subframeArchives:[archive subframeArchives]];
+    }
+}
+
 - (void)stopLoading
 {
     // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 43523af..048e26b 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -122,14 +122,6 @@ extern NSString *WebPageCacheDocumentViewKey;
 
 @interface WebFrame (WebPrivate)
 
-// API Considerations:
-/*!
-    @method loadArchive:
-    @abstract Causes WebFrame to load a WebArchive.
-    @param archive The archive to be loaded.
-*/
-- (void)loadArchive:(WebArchive *)archive;
-
 // Other private methods
 - (NSURLRequest *)_webDataRequestForData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)URL unreachableURL:(NSURL *)unreachableURL;
 - (void)_loadRequest:(NSURLRequest *)request subresources:(NSArray *)subresources subframeArchives:(NSArray *)subframeArchives;
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
index 1536829..ab9860c 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.m
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -102,7 +102,7 @@
     [_private->parsedArchiveData release];
     _private->parsedArchiveData = data;
     
-    [_private->dataSource addSubresources:subresources];
+    [_private->dataSource _addSubresources:subresources];
     [_private->dataSource _addSubframeArchives:subframeArchives];
     [_private->bridge closeURL];
     [_private->bridge openURL:[mainResource URL]
diff --git a/WebKit/WebView.subproj/WebImageRepresentation.m b/WebKit/WebView.subproj/WebImageRepresentation.m
index b79ee2e..ad9b9fc 100644
--- a/WebKit/WebView.subproj/WebImageRepresentation.m
+++ b/WebKit/WebView.subproj/WebImageRepresentation.m
@@ -99,7 +99,7 @@
 
 - (WebArchive *)archive
 {
-    return [dataSource _archive];
+    return [dataSource webArchive];
 }
 
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list