WebCore:

2008-03-26  Brady Eidson  <beidson@apple.com>

        Reviewed by Darin

        When we create a WebArchive, we walk every node from some starting point, asking each node
        along the way "What are your subresource URLs?"

        That logic is currently in DOMNode in WebKitMac - this patch moves that ability down into
        WebCore::Node

        * WebCore.base.exp:
        
        * dom/Node.cpp:
        (WebCore::Node::getSubresourceURLs):
        (WebCore::Node::getSubresourceAttributeStrings):  Virtual and empty.  Subclasses of Node that have 
          subresources will override it.

        * dom/ProcessingInstruction.cpp:
        (WebCore::ProcessingInstruction::getSubresourceAttributeStrings):
        * dom/ProcessingInstruction.h:
        * html/HTMLBodyElement.cpp:
        (WebCore::HTMLBodyElement::getSubresourceAttributeStrings):
        * html/HTMLBodyElement.h:
        * html/HTMLEmbedElement.cpp:
        (WebCore::HTMLEmbedElement::getSubresourceAttributeStrings):
        * html/HTMLEmbedElement.h:
        * html/HTMLImageElement.cpp:
        (WebCore::HTMLImageElement::getSubresourceAttributeStrings):
        * html/HTMLImageElement.h:
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::getSubresourceAttributeStrings):
        * html/HTMLInputElement.h:
        * html/HTMLLinkElement.cpp:
        (WebCore::HTMLLinkElement::getSubresourceAttributeStrings):
        * html/HTMLLinkElement.h:
        * html/HTMLObjectElement.cpp:
        (WebCore::HTMLObjectElement::getSubresourceAttributeStrings):
        * html/HTMLObjectElement.h:
        * html/HTMLParamElement.cpp:
        (WebCore::HTMLParamElement::getSubresourceAttributeStrings):
        * html/HTMLParamElement.h:
        * html/HTMLScriptElement.cpp:
        (WebCore::HTMLScriptElement::getSubresourceAttributeStrings):
        * html/HTMLScriptElement.h:
        * html/HTMLTableCellElement.cpp:
        (WebCore::HTMLTableCellElement::getSubresourceAttributeStrings):
        * html/HTMLTableCellElement.h:
        * html/HTMLTableElement.cpp:
        (WebCore::HTMLTableElement::getSubresourceAttributeStrings):
        * html/HTMLTableElement.h:
        * svg/SVGCursorElement.cpp:
        (WebCore::SVGCursorElement::getSubresourceAttributeStrings):
        * svg/SVGCursorElement.h:
        * svg/SVGFEImageElement.cpp:
        (WebCore::SVGFEImageElement::getSubresourceAttributeStrings):
        * svg/SVGFEImageElement.h:
        * svg/SVGImageElement.cpp:
        (WebCore::SVGImageElement::getSubresourceAttributeStrings):
        * svg/SVGImageElement.h:
        * svg/SVGScriptElement.cpp:
        (WebCore::SVGScriptElement::getSubresourceAttributeStrings):
        * svg/SVGScriptElement.h:

WebKit/mac:

2008-03-26  Brady Eidson  <beidson@apple.com>

        Reviewed by Darin

        When we create a WebArchive, we walk every node from some starting point, asking each node
        along the way "What are your subresource URLs?"

        That logic is currently in DOMNode in WebKitMac - this patch moves that ability down into
        WebCore::Node

        * DOM/WebDOMOperations.mm:
        (-[DOMNode _subresourceURLs]): One generic DOMNode method can now handle all DOMNodes by
          calling into individual WebCore::Node implementations
        * DOM/WebDOMOperationsPrivate.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 04345ac..881e4bd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,66 @@
+2008-03-26  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Darin
+
+        When we create a WebArchive, we walk every node from some starting point, asking each node
+        along the way "What are your subresource URLs?"
+
+        That logic is currently in DOMNode in WebKitMac - this patch moves that ability down into
+        WebCore::Node
+
+        * WebCore.base.exp:
+        
+        * dom/Node.cpp:
+        (WebCore::Node::getSubresourceURLs):
+        (WebCore::Node::getSubresourceAttributeStrings):  Virtual and empty.  Subclasses of Node that have 
+          subresources will override it.
+
+        * dom/ProcessingInstruction.cpp:
+        (WebCore::ProcessingInstruction::getSubresourceAttributeStrings):
+        * dom/ProcessingInstruction.h:
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::getSubresourceAttributeStrings):
+        * html/HTMLBodyElement.h:
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::getSubresourceAttributeStrings):
+        * html/HTMLEmbedElement.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::getSubresourceAttributeStrings):
+        * html/HTMLImageElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::getSubresourceAttributeStrings):
+        * html/HTMLInputElement.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::getSubresourceAttributeStrings):
+        * html/HTMLLinkElement.h:
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::getSubresourceAttributeStrings):
+        * html/HTMLObjectElement.h:
+        * html/HTMLParamElement.cpp:
+        (WebCore::HTMLParamElement::getSubresourceAttributeStrings):
+        * html/HTMLParamElement.h:
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::getSubresourceAttributeStrings):
+        * html/HTMLScriptElement.h:
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::getSubresourceAttributeStrings):
+        * html/HTMLTableCellElement.h:
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::getSubresourceAttributeStrings):
+        * html/HTMLTableElement.h:
+        * svg/SVGCursorElement.cpp:
+        (WebCore::SVGCursorElement::getSubresourceAttributeStrings):
+        * svg/SVGCursorElement.h:
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::getSubresourceAttributeStrings):
+        * svg/SVGFEImageElement.h:
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::getSubresourceAttributeStrings):
+        * svg/SVGImageElement.h:
+        * svg/SVGScriptElement.cpp:
+        (WebCore::SVGScriptElement::getSubresourceAttributeStrings):
+        * svg/SVGScriptElement.h:
+
 2008-03-26  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index 245c6d7..770e150 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -712,6 +712,7 @@
 __ZNK7WebCore4KURL4pathEv
 __ZNK7WebCore4KURLcvP5NSURLEv
 __ZNK7WebCore4Node14isDescendantOfEPKS0_
+__ZNK7WebCore4Node18getSubresourceURLsERN3WTF6VectorINS_4KURLELm0EEE
 __ZNK7WebCore4Page10pluginDataEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore5Frame10isFrameSetEv
@@ -830,7 +831,7 @@
 _wkFontSmoothingModeIsLCD
 _wkGetATSStyleGroup
 _wkGetExtensionsForMIMEType
-_wkGetFontInLanguageForCharacter
+_wkGetFontInLanguageForCharacter  
 _wkGetFontInLanguageForRange
 _wkGetGlyphTransformedAdvances
 _wkGetGlyphVectorFirstRecord
@@ -858,3 +859,4 @@
 _wkSignalCFReadStreamEnd
 _wkSignalCFReadStreamError
 _wkSignalCFReadStreamHasBytes
+__ZN7WebCore16LegacyWebArchive6createEPNS_4NodeE
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 5f4c9d1..d891167 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -1713,6 +1713,20 @@
     return true;
 }
 
+void Node::getSubresourceURLs(Vector<KURL>& urls) const
+{
+    Vector<String> subresourceStrings;
+    getSubresourceAttributeStrings(subresourceStrings);
+    
+    for (unsigned i = 0; i < subresourceStrings.size(); ++i) {
+        String& subresourceString(subresourceStrings[i]);
+        
+        // FIXME: Is parseURL appropriate here?
+        if (subresourceString.length())
+            urls.append(document()->completeURL(parseURL(subresourceString)));
+    }
+}
+
 // --------
 
 } // namespace WebCore
diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h
index 65a78b2..1fce8c4 100644
--- a/WebCore/dom/Node.h
+++ b/WebCore/dom/Node.h
@@ -107,6 +107,8 @@
     virtual NamedAttrMap* attributes() const;
 
     virtual KURL baseURI() const;
+    
+    void getSubresourceURLs(Vector<KURL>&) const;
 
     // These should all actually return a node, but this is only important for language bindings,
     // which will already know and hold a ref on the right node to return. Returning bool allows
@@ -472,6 +474,8 @@
     virtual void willMoveToNewOwnerDocument() { }
     virtual void didMoveToNewOwnerDocument() { }
     
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const { }
+
     OwnPtr<NodeListsNodeData> m_nodeLists;
 
     short m_tabIndex;
diff --git a/WebCore/dom/ProcessingInstruction.cpp b/WebCore/dom/ProcessingInstruction.cpp
index 23d509f..edba96e 100644
--- a/WebCore/dom/ProcessingInstruction.cpp
+++ b/WebCore/dom/ProcessingInstruction.cpp
@@ -255,4 +255,12 @@
     return static_cast<int>(m_data.length());
 }
 
+void ProcessingInstruction::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    if (!sheet())
+        return;
+        
+    urls.append(sheet()->href());
+}
+
 } // namespace
diff --git a/WebCore/dom/ProcessingInstruction.h b/WebCore/dom/ProcessingInstruction.h
index be4a63e..6e34bee 100644
--- a/WebCore/dom/ProcessingInstruction.h
+++ b/WebCore/dom/ProcessingInstruction.h
@@ -70,6 +70,8 @@
     bool isXSL() const { return m_isXSL; }
 #endif
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 private:
     void parseStyleSheet(const String& sheet);
 
diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp
index 0a2b274..69de13b 100644
--- a/WebCore/html/HTMLBodyElement.cpp
+++ b/WebCore/html/HTMLBodyElement.cpp
@@ -291,4 +291,9 @@
     return view ? view->contentsWidth() : 0;    
 }
 
+void HTMLBodyElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(background());
+}
+
 }
diff --git a/WebCore/html/HTMLBodyElement.h b/WebCore/html/HTMLBodyElement.h
index 6fe5b17..2c5ce98 100644
--- a/WebCore/html/HTMLBodyElement.h
+++ b/WebCore/html/HTMLBodyElement.h
@@ -70,6 +70,8 @@
     int scrollHeight() const;
     int scrollWidth() const;
     
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+    
 protected:
     RefPtr<CSSMutableStyleDeclaration> m_linkDecl;
 };
diff --git a/WebCore/html/HTMLEmbedElement.cpp b/WebCore/html/HTMLEmbedElement.cpp
index df73293..b22f462 100644
--- a/WebCore/html/HTMLEmbedElement.cpp
+++ b/WebCore/html/HTMLEmbedElement.cpp
@@ -239,4 +239,9 @@
     setAttribute(typeAttr, value);
 }
 
+void HTMLEmbedElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(src());
+}
+
 }
diff --git a/WebCore/html/HTMLEmbedElement.h b/WebCore/html/HTMLEmbedElement.h
index 5c6ce67..c852bd5 100644
--- a/WebCore/html/HTMLEmbedElement.h
+++ b/WebCore/html/HTMLEmbedElement.h
@@ -72,6 +72,8 @@
     const String& url() const { return m_url; }
     const String& serviceType() const { return m_serviceType; }
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 private:
     String m_url;
     String m_pluginPage;
diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp
index 80c6aa1..58af03d 100644
--- a/WebCore/html/HTMLImageElement.cpp
+++ b/WebCore/html/HTMLImageElement.cpp
@@ -426,4 +426,10 @@
     return m_imageLoader.imageComplete();
 }
 
+void HTMLImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(src().string());
+    urls.append(useMap());
+}
+
 }
diff --git a/WebCore/html/HTMLImageElement.h b/WebCore/html/HTMLImageElement.h
index 5b6ce06..a7a6c62 100644
--- a/WebCore/html/HTMLImageElement.h
+++ b/WebCore/html/HTMLImageElement.h
@@ -114,6 +114,8 @@
 
     bool haveFiredLoadEvent() const { return m_imageLoader.haveFiredLoadEvent(); }
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 private:
     HTMLImageLoader m_imageLoader;
     String usemap;
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 2904e08..cc9329e 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1546,4 +1546,9 @@
     HTMLFormControlElementWithState::didMoveToNewOwnerDocument();
 }
     
+void HTMLInputElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(src().string());  
+}
+
 } // namespace
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index e50274b..49e0ef8 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -187,6 +187,8 @@
     String constrainValue(const String& proposedValue) const;
 
     virtual void didRestoreFromCache();
+
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
     
 protected:
     virtual void willMoveToNewOwnerDocument();
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index 5977e7c..b3a954c 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -347,4 +347,12 @@
     setAttribute(typeAttr, value);
 }
 
+void HTMLLinkElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    if (!m_isStyleSheet && !m_isIcon)
+        return;
+    
+    urls.append(href().string());
+}
+
 }
diff --git a/WebCore/html/HTMLLinkElement.h b/WebCore/html/HTMLLinkElement.h
index 760483c..c9da6dc 100644
--- a/WebCore/html/HTMLLinkElement.h
+++ b/WebCore/html/HTMLLinkElement.h
@@ -93,6 +93,8 @@
     
     static void tokenizeRelAttribute(const AtomicString& value, bool& stylesheet, bool& alternate, bool& icon);
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 protected:
     CachedCSSStyleSheet* m_cachedSheet;
     RefPtr<CSSStyleSheet> m_sheet;
diff --git a/WebCore/html/HTMLObjectElement.cpp b/WebCore/html/HTMLObjectElement.cpp
index 04760fa..7a5b84f 100644
--- a/WebCore/html/HTMLObjectElement.cpp
+++ b/WebCore/html/HTMLObjectElement.cpp
@@ -495,4 +495,11 @@
     return false;
 }
 
+void HTMLObjectElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(data().string());
+    if (useMap().startsWith("#"))
+        urls.append(useMap());
+}
+
 }
diff --git a/WebCore/html/HTMLObjectElement.h b/WebCore/html/HTMLObjectElement.h
index 9ba8bf3..295f6e2 100644
--- a/WebCore/html/HTMLObjectElement.h
+++ b/WebCore/html/HTMLObjectElement.h
@@ -107,6 +107,8 @@
 
     bool containsJavaApplet() const;
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
     String m_serviceType;
     String m_url;
     String m_classId;
diff --git a/WebCore/html/HTMLParamElement.cpp b/WebCore/html/HTMLParamElement.cpp
index e0702c5..0c9d593 100644
--- a/WebCore/html/HTMLParamElement.cpp
+++ b/WebCore/html/HTMLParamElement.cpp
@@ -98,4 +98,14 @@
     setAttribute(valuetypeAttr, value);
 }
 
+void HTMLParamElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    if (!equalIgnoringCase(name(), "data") &&
+        !equalIgnoringCase(name(), "movie") &&
+        !equalIgnoringCase(name(), "src"))
+        return;
+        
+    urls.append(value());
+}
+
 }
diff --git a/WebCore/html/HTMLParamElement.h b/WebCore/html/HTMLParamElement.h
index 3bc1fa1..5e31aed 100644
--- a/WebCore/html/HTMLParamElement.h
+++ b/WebCore/html/HTMLParamElement.h
@@ -55,6 +55,8 @@
     String valueType() const;
     void setValueType(const String&);
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
  protected:
     AtomicString m_name;
     AtomicString m_value;
diff --git a/WebCore/html/HTMLScriptElement.cpp b/WebCore/html/HTMLScriptElement.cpp
index ced0fdc..6778e11 100644
--- a/WebCore/html/HTMLScriptElement.cpp
+++ b/WebCore/html/HTMLScriptElement.cpp
@@ -339,4 +339,9 @@
     return charset;
 }
 
+void HTMLScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(src().string());
+}
+
 }
diff --git a/WebCore/html/HTMLScriptElement.h b/WebCore/html/HTMLScriptElement.h
index 0c82deb..984fd23 100644
--- a/WebCore/html/HTMLScriptElement.h
+++ b/WebCore/html/HTMLScriptElement.h
@@ -78,6 +78,8 @@
     // A charset for loading the script (may be overridden by HTTP headers or a BOM).
     String scriptCharset() const;
     
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 private:
     CachedScript* m_cachedScript;
     bool m_createdByParser;
diff --git a/WebCore/html/HTMLTableCellElement.cpp b/WebCore/html/HTMLTableCellElement.cpp
index 554edcc..c623c94 100644
--- a/WebCore/html/HTMLTableCellElement.cpp
+++ b/WebCore/html/HTMLTableCellElement.cpp
@@ -261,4 +261,9 @@
     setAttribute(widthAttr, value);
 }
 
+void HTMLTableCellElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(getAttribute(HTMLNames::backgroundAttr).string());
+}
+
 }
diff --git a/WebCore/html/HTMLTableCellElement.h b/WebCore/html/HTMLTableCellElement.h
index 1099857..6ac4b29 100644
--- a/WebCore/html/HTMLTableCellElement.h
+++ b/WebCore/html/HTMLTableCellElement.h
@@ -102,6 +102,8 @@
     String width() const;
     void setWidth(const String&);
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 protected:
     int _row;
     int _col;
diff --git a/WebCore/html/HTMLTableElement.cpp b/WebCore/html/HTMLTableElement.cpp
index 22a2d5e..c7791f5 100644
--- a/WebCore/html/HTMLTableElement.cpp
+++ b/WebCore/html/HTMLTableElement.cpp
@@ -756,4 +756,9 @@
     setAttribute(widthAttr, value);
 }
 
+void HTMLTableElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(getAttribute(HTMLNames::backgroundAttr).string());
+}
+
 }
diff --git a/WebCore/html/HTMLTableElement.h b/WebCore/html/HTMLTableElement.h
index 1a8df12..aced79e 100644
--- a/WebCore/html/HTMLTableElement.h
+++ b/WebCore/html/HTMLTableElement.h
@@ -103,6 +103,8 @@
     void addSharedCellDecls(Vector<CSSMutableStyleDeclaration*>&);
     void addSharedGroupDecls(bool rows, Vector<CSSMutableStyleDeclaration*>&);
 
+    virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
 private:
     void addSharedCellBordersDecl(Vector<CSSMutableStyleDeclaration*>&);
     void addSharedCellPaddingDecl(Vector<CSSMutableStyleDeclaration*>&);
diff --git a/WebCore/svg/SVGCursorElement.cpp b/WebCore/svg/SVGCursorElement.cpp
index 7a3e66c..ec1c994 100644
--- a/WebCore/svg/SVGCursorElement.cpp
+++ b/WebCore/svg/SVGCursorElement.cpp
@@ -92,6 +92,11 @@
     }
 }
 
+void SVGCursorElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(href());
+}
+
 }
 
 #endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGCursorElement.h b/WebCore/svg/SVGCursorElement.h
index 23a5894..a646a9a 100644
--- a/WebCore/svg/SVGCursorElement.h
+++ b/WebCore/svg/SVGCursorElement.h
@@ -48,6 +48,8 @@
         virtual void parseMappedAttribute(MappedAttribute*);
         virtual void svgAttributeChanged(const QualifiedName&);
 
+        virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
     protected:
         virtual const SVGElement* contextElement() const { return this; }
 
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
index 6ff83ee..6ff52d3 100644
--- a/WebCore/svg/SVGFEImageElement.cpp
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -103,6 +103,11 @@
     return m_filterEffect;
 }
 
+bool SVGFEImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(href());
+}
+
 }
 
 #endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h
index 1488a64..e977937 100644
--- a/WebCore/svg/SVGFEImageElement.h
+++ b/WebCore/svg/SVGFEImageElement.h
@@ -46,6 +46,8 @@
         virtual void parseMappedAttribute(MappedAttribute*);
         virtual void notifyFinished(CachedResource*);
 
+        virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
     protected:
         virtual SVGFEImage* filterEffect(SVGResourceFilter*) const;
 
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
index 7458bc5..b7c6aea 100644
--- a/WebCore/svg/SVGImageElement.cpp
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -142,6 +142,11 @@
         imageObj->setCachedImage(m_imageLoader.image());
 }
 
+void SVGImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(href());
+}
+
 }
 
 #endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGImageElement.h b/WebCore/svg/SVGImageElement.h
index c069f0f..483d0fd 100644
--- a/WebCore/svg/SVGImageElement.h
+++ b/WebCore/svg/SVGImageElement.h
@@ -54,6 +54,8 @@
 
         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
         
+        virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
     protected:
         virtual bool haveLoadedRequiredResources();
         
diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp
index 1278972..435a587 100644
--- a/WebCore/svg/SVGScriptElement.cpp
+++ b/WebCore/svg/SVGScriptElement.cpp
@@ -63,6 +63,11 @@
     }
 }
 
+void SVGScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
+{
+    urls.append(href());
+}
+
 }
 
 // vim:ts=4:noet
diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h
index c2c92bb..8ea374a6 100644
--- a/WebCore/svg/SVGScriptElement.h
+++ b/WebCore/svg/SVGScriptElement.h
@@ -45,6 +45,8 @@
         // Internal
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
+        virtual void getSubresourceAttributeStrings(Vector<String>&) const;
+
     protected:
         virtual const SVGElement* contextElement() const { return this; }
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index c99ad1a..58eb763 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,5 +1,20 @@
 2008-03-26  Brady Eidson  <beidson@apple.com>
 
+        Reviewed by Darin
+
+        When we create a WebArchive, we walk every node from some starting point, asking each node
+        along the way "What are your subresource URLs?"
+
+        That logic is currently in DOMNode in WebKitMac - this patch moves that ability down into
+        WebCore::Node
+
+        * DOM/WebDOMOperations.mm:
+        (-[DOMNode _subresourceURLs]): One generic DOMNode method can now handle all DOMNodes by
+          calling into individual WebCore::Node implementations
+        * DOM/WebDOMOperationsPrivate.h:
+
+2008-03-26  Brady Eidson  <beidson@apple.com>
+
         Reviewed by Mark Rowe
 
         Part of the continued push to move WebArchive-related code down to WebCore, this
diff --git a/WebKit/mac/DOM/WebDOMOperations.mm b/WebKit/mac/DOM/WebDOMOperations.mm
index 93caf76..c3ef680 100644
--- a/WebKit/mac/DOM/WebDOMOperations.mm
+++ b/WebKit/mac/DOM/WebDOMOperations.mm
@@ -28,6 +28,8 @@
 
 #import "WebDOMOperationsPrivate.h"
 
+#import "DOMNodeInternal.h"
+#import "WebArchiveInternal.h"
 #import "WebArchiver.h"
 #import "WebDataSourcePrivate.h"
 #import "WebFrameInternal.h"
@@ -36,6 +38,7 @@
 #import <JavaScriptCore/Assertions.h>
 #import <WebCore/CSSHelper.h>
 #import <WebCore/Document.h>
+#import <WebCore/LegacyWebArchive.h>
 #import <WebKit/DOMExtensions.h>
 #import <WebKit/DOMHTML.h>
 
@@ -49,7 +52,8 @@
 
 - (WebArchive *)webArchive
 {
-    return [WebArchiver archiveNode:self];
+    WebArchive *archive = [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create([self _node])] autorelease];
+    return archive;
 }
 
 - (NSString *)markupString
@@ -61,37 +65,18 @@
 
 @implementation DOMNode (WebDOMNodeOperationsPrivate)
 
-- (NSArray *)_URLsFromSelectors:(SEL)firstSel, ...
-{
-    NSMutableArray *URLs = [NSMutableArray array];
-    
-    va_list args;
-    va_start(args, firstSel);
-    
-    SEL selector = firstSel;
-    do {
-#if ENABLE(SVG)
-        NSString *string;
-        id attributeValue = [self performSelector:selector];
-        if ([attributeValue isKindOfClass:[DOMSVGAnimatedString class]])
-            string = [(DOMSVGAnimatedString*)attributeValue animVal];
-        else
-            string = attributeValue;
-#else
-        NSString *string = [self performSelector:selector];
-#endif
-        if ([string length] > 0)
-            [URLs addObject:[[self ownerDocument] URLWithAttributeString:string]];
-    } while ((selector = va_arg(args, SEL)) != nil);
-    
-    va_end(args);
-    
-    return URLs;
-}
-
 - (NSArray *)_subresourceURLs
 {
-    return nil;
+    Vector<KURL> urls;
+    [self _node]->getSubresourceURLs(urls);
+    if (!urls.size())
+        return nil;
+
+    NSMutableArray *array = [NSMutableArray arrayWithCapacity:urls.size()];
+    for (unsigned i = 0; i < urls.size(); ++i)
+        [array addObject:(NSURL *)urls[i]];
+        
+    return array;
 }
 
 @end
@@ -145,177 +130,6 @@
 
 @end
 
-@implementation DOMHTMLBodyElement (WebDOMHTMLBodyElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(background), nil];
-}
-
-@end
-
-@implementation DOMHTMLInputElement (WebDOMHTMLInputElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(src), nil];
-}
-
-@end
-
-@implementation DOMHTMLLinkElement (WebDOMHTMLLinkElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    NSString *relName = [self rel];
-    if ([relName _webkit_isCaseInsensitiveEqualToString:@"stylesheet"] || [relName _webkit_isCaseInsensitiveEqualToString:@"icon"]) {
-        return [self _URLsFromSelectors:@selector(href), nil];
-    }
-    return nil;
-}
-
-@end
-
-@implementation DOMHTMLScriptElement (WebDOMHTMLScriptElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(src), nil];
-}
-
-@end
-
-@implementation DOMHTMLImageElement (WebDOMHTMLImageElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    SEL useMapSelector = [[self useMap] hasPrefix:@"#"] ? nil : @selector(useMap);
-    return [self _URLsFromSelectors:@selector(src), useMapSelector, nil];
-}
-
-@end
-
-#if ENABLE(SVG)
-
-@implementation DOMSVGImageElement (WebDOMSVGImageElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(href), nil];
-}
-
-@end
-
-@implementation DOMSVGScriptElement (WebDOMSVGScriptElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(href), nil];
-}
-
-@end
-
-@implementation DOMSVGCursorElement (WebDOMSVGCursorElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(href), nil];
-}
-
-@end
-
-#if ENABLE(SVG_FILTERS)
-@implementation DOMSVGFEImageElement (WebDOMSVGFEImageElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(href), nil];
-}
-
-@end
-#endif
-
-#endif
-
-@implementation DOMProcessingInstruction (WebDOMProcessingInstructionOperationsPrivate)
-
-- (NSString *)_stylesheetURL
-{
-    DOMStyleSheet *styleSheet = [self sheet];
-    if (styleSheet)
-        return [styleSheet href];
-    return nil;
-}
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(_stylesheetURL), nil];
-}
-
-@end
-
-@implementation DOMHTMLEmbedElement (WebDOMHTMLEmbedElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(src), nil];
-}
-
-@end
-
-@implementation DOMHTMLObjectElement (WebDOMHTMLObjectElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    SEL useMapSelector = [[self useMap] hasPrefix:@"#"] ? nil : @selector(useMap);
-    return [self _URLsFromSelectors:@selector(data), useMapSelector, nil];
-}
-
-@end
-
-@implementation DOMHTMLParamElement (WebDOMHTMLParamElementOperationsPrivate)
-
-- (NSArray *)_subresourceURLs
-{
-    NSString *paramName = [self name];
-    if ([paramName _webkit_isCaseInsensitiveEqualToString:@"data"] ||
-        [paramName _webkit_isCaseInsensitiveEqualToString:@"movie"] ||
-        [paramName _webkit_isCaseInsensitiveEqualToString:@"src"]) {
-        return [self _URLsFromSelectors:@selector(value), nil];
-    }
-    return nil;
-}
-
-@end
-
-@implementation DOMHTMLTableElement (WebDOMHTMLTableElementOperationsPrivate)
-
-- (NSString *)_web_background
-{
-    return [self getAttribute:@"background"];
-}
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(_web_background), nil];
-}
-
-@end
-
-@implementation DOMHTMLTableCellElement (WebDOMHTMLTableCellElementOperationsPrivate)
-
-- (NSString *)_web_background
-{
-    return [self getAttribute:@"background"];
-}
-
-- (NSArray *)_subresourceURLs
-{
-    return [self _URLsFromSelectors:@selector(_web_background), nil];
-}
-
-@end
-
 @implementation DOMHTMLFrameElement (WebDOMHTMLFrameElementOperations)
 
 - (WebFrame *)contentFrame
diff --git a/WebKit/mac/DOM/WebDOMOperationsPrivate.h b/WebKit/mac/DOM/WebDOMOperationsPrivate.h
index 107ab5d..19b8a7d 100644
--- a/WebKit/mac/DOM/WebDOMOperationsPrivate.h
+++ b/WebKit/mac/DOM/WebDOMOperationsPrivate.h
@@ -29,7 +29,6 @@
 #import <WebKit/WebDOMOperations.h>
 
 @interface DOMNode (WebDOMNodeOperationsPrivate)
-- (NSArray *)_URLsFromSelectors:(SEL)firstSel, ...;
 - (NSArray *)_subresourceURLs;
 @end