Commit a4fb38f9 authored by beidson@apple.com's avatar beidson@apple.com

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
parent 0f1089e8
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.
......@@ -712,6 +712,7 @@ __ZNK7WebCore4KURL4hostEv
__ZNK7WebCore4KURL4pathEv
__ZNK7WebCore4KURLcvP5NSURLEv
__ZNK7WebCore4Node14isDescendantOfEPKS0_
__ZNK7WebCore4Node18getSubresourceURLsERN3WTF6VectorINS_4KURLELm0EEE
__ZNK7WebCore4Page10pluginDataEv
__ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
__ZNK7WebCore5Frame10isFrameSetEv
......@@ -830,7 +831,7 @@ _wkDrawTextFieldCellFocusRing
_wkFontSmoothingModeIsLCD
_wkGetATSStyleGroup
_wkGetExtensionsForMIMEType
_wkGetFontInLanguageForCharacter
_wkGetFontInLanguageForCharacter
_wkGetFontInLanguageForRange
_wkGetGlyphTransformedAdvances
_wkGetGlyphVectorFirstRecord
......@@ -858,3 +859,4 @@ _wkSetUpFontCache
_wkSignalCFReadStreamEnd
_wkSignalCFReadStreamError
_wkSignalCFReadStreamHasBytes
__ZN7WebCore16LegacyWebArchive6createEPNS_4NodeE
......@@ -1713,6 +1713,20 @@ bool NodeListsNodeData::isEmpty() const
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
......
......@@ -107,6 +107,8 @@ public:
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 @@ protected:
virtual void willMoveToNewOwnerDocument() { }
virtual void didMoveToNewOwnerDocument() { }
virtual void getSubresourceAttributeStrings(Vector<String>&) const { }
OwnPtr<NodeListsNodeData> m_nodeLists;
short m_tabIndex;
......
......@@ -255,4 +255,12 @@ int ProcessingInstruction::maxCharacterOffset() const
return static_cast<int>(m_data.length());
}
void ProcessingInstruction::getSubresourceAttributeStrings(Vector<String>& urls) const
{
if (!sheet())
return;
urls.append(sheet()->href());
}
} // namespace
......@@ -70,6 +70,8 @@ public:
bool isXSL() const { return m_isXSL; }
#endif
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
private:
void parseStyleSheet(const String& sheet);
......
......@@ -291,4 +291,9 @@ int HTMLBodyElement::scrollWidth() const
return view ? view->contentsWidth() : 0;
}
void HTMLBodyElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(background());
}
}
......@@ -70,6 +70,8 @@ public:
int scrollHeight() const;
int scrollWidth() const;
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
RefPtr<CSSMutableStyleDeclaration> m_linkDecl;
};
......
......@@ -239,4 +239,9 @@ void HTMLEmbedElement::setType(const String& value)
setAttribute(typeAttr, value);
}
void HTMLEmbedElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(src());
}
}
......@@ -72,6 +72,8 @@ public:
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;
......
......@@ -426,4 +426,10 @@ bool HTMLImageElement::complete() const
return m_imageLoader.imageComplete();
}
void HTMLImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(src().string());
urls.append(useMap());
}
}
......@@ -114,6 +114,8 @@ public:
bool haveFiredLoadEvent() const { return m_imageLoader.haveFiredLoadEvent(); }
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
private:
HTMLImageLoader m_imageLoader;
String usemap;
......
......@@ -1546,4 +1546,9 @@ void HTMLInputElement::didMoveToNewOwnerDocument()
HTMLFormControlElementWithState::didMoveToNewOwnerDocument();
}
void HTMLInputElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(src().string());
}
} // namespace
......@@ -187,6 +187,8 @@ public:
String constrainValue(const String& proposedValue) const;
virtual void didRestoreFromCache();
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
virtual void willMoveToNewOwnerDocument();
......
......@@ -347,4 +347,12 @@ void HTMLLinkElement::setType(const String& value)
setAttribute(typeAttr, value);
}
void HTMLLinkElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
if (!m_isStyleSheet && !m_isIcon)
return;
urls.append(href().string());
}
}
......@@ -93,6 +93,8 @@ public:
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;
......
......@@ -495,4 +495,11 @@ bool HTMLObjectElement::containsJavaApplet() const
return false;
}
void HTMLObjectElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(data().string());
if (useMap().startsWith("#"))
urls.append(useMap());
}
}
......@@ -107,6 +107,8 @@ public:
bool containsJavaApplet() const;
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
String m_serviceType;
String m_url;
String m_classId;
......
......@@ -98,4 +98,14 @@ void HTMLParamElement::setValueType(const String& value)
setAttribute(valuetypeAttr, value);
}
void HTMLParamElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
if (!equalIgnoringCase(name(), "data") &&
!equalIgnoringCase(name(), "movie") &&
!equalIgnoringCase(name(), "src"))
return;
urls.append(value());
}
}
......@@ -55,6 +55,8 @@ public:
String valueType() const;
void setValueType(const String&);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
AtomicString m_name;
AtomicString m_value;
......
......@@ -339,4 +339,9 @@ String HTMLScriptElement::scriptCharset() const
return charset;
}
void HTMLScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(src().string());
}
}
......@@ -78,6 +78,8 @@ public:
// 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;
......
......@@ -261,4 +261,9 @@ void HTMLTableCellElement::setWidth(const String &value)
setAttribute(widthAttr, value);
}
void HTMLTableCellElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(getAttribute(HTMLNames::backgroundAttr).string());
}
}
......@@ -102,6 +102,8 @@ public:
String width() const;
void setWidth(const String&);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
int _row;
int _col;
......
......@@ -756,4 +756,9 @@ void HTMLTableElement::setWidth(const String &value)
setAttribute(widthAttr, value);
}
void HTMLTableElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(getAttribute(HTMLNames::backgroundAttr).string());
}
}
......@@ -103,6 +103,8 @@ public:
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*>&);
......
......@@ -92,6 +92,11 @@ void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName)
}
}
void SVGCursorElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(href());
}
}
#endif // ENABLE(SVG)
......@@ -48,6 +48,8 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void svgAttributeChanged(const QualifiedName&);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
virtual const SVGElement* contextElement() const { return this; }
......
......@@ -103,6 +103,11 @@ SVGFEImage* SVGFEImageElement::filterEffect(SVGResourceFilter* filter) const
return m_filterEffect;
}
bool SVGFEImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(href());
}
}
#endif // ENABLE(SVG)
......
......@@ -46,6 +46,8 @@ namespace WebCore {
virtual void parseMappedAttribute(MappedAttribute*);
virtual void notifyFinished(CachedResource*);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
virtual SVGFEImage* filterEffect(SVGResourceFilter*) const;
......
......@@ -142,6 +142,11 @@ void SVGImageElement::attach()
imageObj->setCachedImage(m_imageLoader.image());
}
void SVGImageElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(href());
}
}
#endif // ENABLE(SVG)
......@@ -54,6 +54,8 @@ namespace WebCore {
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
virtual bool haveLoadedRequiredResources();
......
......@@ -63,6 +63,11 @@ void SVGScriptElement::parseMappedAttribute(MappedAttribute* attr)
}
}
void SVGScriptElement::getSubresourceAttributeStrings(Vector<String>& urls) const
{
urls.append(href());
}
}
// vim:ts=4:noet
......
......@@ -45,6 +45,8 @@ namespace WebCore
// Internal
virtual void parseMappedAttribute(MappedAttribute *attr);
virtual void getSubresourceAttributeStrings(Vector<String>&) const;
protected:
virtual const SVGElement* contextElement() const { return this; }
......
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
......
......@@ -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 @@ using namespace WebCore;
- (WebArchive *)webArchive
{
return [WebArchiver archiveNode:self];
WebArchive *archive = [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create([self _node])] autorelease];
return archive;
}
- (NSString *)markupString
......@@ -61,37 +65,18 @@ using namespace WebCore;
@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 @@ using namespace WebCore;
@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];