Reviewed by Darin.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 21:25:16 +0000 (21:25 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Mar 2007 21:25:16 +0000 (21:25 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=12579
        WebKit fails SVG xml:base test

        Implement DOM3 properties baseURI and documentURI to fix
        the testcase in bug 12579.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/xhtml/level3/core/documentgetdocumenturi01-expected.txt
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri01-expected.txt
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri02-expected.txt
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri04-expected.txt
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri06-expected.txt
LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t-expected.checksum
LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t-expected.png
WebCore/bindings/js/kjs_dom.cpp
WebCore/bindings/js/kjs_domnode.h
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/Document.idl
WebCore/dom/DocumentType.cpp
WebCore/dom/DocumentType.h
WebCore/dom/Element.cpp
WebCore/dom/Element.h
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/ksvg2/misc/SVGImageLoader.cpp
WebCore/ksvg2/svg/SVGImageElement.cpp

index f5a07e3dee6bf8b506d588a8ccc68132be352409..edc10c501e98fe9ae4b770399f3fc2102dd84457 100644 (file)
@@ -1,3 +1,19 @@
+2007-03-07  Rob Buis  <buis@kde.org>
+
+        Reviewed by Darin.
+
+        Adjusted tests for:
+        http://bugs.webkit.org/show_bug.cgi?id=12579
+        WebKit fails SVG xml:base test
+
+        * dom/xhtml/level3/core/documentgetdocumenturi01-expected.txt:
+        * dom/xhtml/level3/core/nodegetbaseuri01-expected.txt:
+        * dom/xhtml/level3/core/nodegetbaseuri02-expected.txt:
+        * dom/xhtml/level3/core/nodegetbaseuri04-expected.txt:
+        * dom/xhtml/level3/core/nodegetbaseuri06-expected.txt:
+        * svg/W3C-SVG-1.1/struct-image-07-t-expected.checksum:
+        * svg/W3C-SVG-1.1/struct-image-07-t-expected.png:
+
 2007-03-07  Darin Adler  <darin@apple.com>
 
         Reviewed by Geoff.
index 3b4e7fe449d45a74144278660e1b881811c120dd..22b19878e31909f6f7b437f700a19d0dcf3365a4 100644 (file)
@@ -1,3 +1,2 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentgetdocumenturi01
-Status failure
-Message        documentgetdocumenturi01: assertNotNull failed
+Status Success
index 122f3caf2f1a5b54ed159689f3fdcc931d043367..c5c2668ad1664638d123f122fce1682e981750ba 100644 (file)
@@ -1,4 +1,4 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri01
 Status failure
-Message        notNull: assertNotNull failed
+Message        notNull: assertEquals failed, actual nodegetbaseuri01, expected barfoo.
 
index c5a8f653329e8a71800114cd10d9e3c637778cb8..d2236947e2f8fa5123047f285661aea307913a64 100644 (file)
@@ -1,4 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri02
-Status error
-Message        TypeError: Undefined value
+Status Success
 
index 890773ccf472fa7a4eee0eb5aef085e47ef12cee..a6779d082a7898caf87442a614e06ea9ea476a53 100644 (file)
@@ -1,4 +1,4 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri04
 Status failure
-Message        baseURI: assertNotNull failed
+Message        baseURI: assertEquals failed, actual nodegetbaseuri04, expected barfoo.
 
index 2697c287a9f4d4b0c0343c1720f6c8230c69ff68..3847fc87ccbdb0ea8406884f0f12439b786d9168 100644 (file)
@@ -1,4 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri06
-Status failure
-Message        nodegetbaseuri06: assertNotNull failed
+Status Success
 
index 1eaed2e6e555ce5147c4e21e73ab8f4aeec69228..3d982b150f3d0692361b75d42fe9c83c82632cbb 100644 (file)
@@ -1 +1 @@
-c723a7024015b85fb3ad0c2f2f5aa380
\ No newline at end of file
+25c51ccafb7ed7833b0b8421fc9240d3
\ No newline at end of file
index 2bda3beb7026787c428f9ef38cb58c0695f4f890..cbaccca5c50108b53f7d59f21a957a03a2014c99 100644 (file)
Binary files a/LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t-expected.png and b/LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t-expected.png differ
index 7b4e9475cfb497778a6be1b4b8ed87accb144eaf..49857b9a9b7894a53cef8d20363d582fc5f81eaa 100644 (file)
@@ -187,6 +187,7 @@ bool DOMNode::toBoolean(ExecState* ) const
   previousSibling  DOMNode::PreviousSibling DontDelete|ReadOnly
   nextSibling   DOMNode::NextSibling    DontDelete|ReadOnly
   attributes    DOMNode::Attributes     DontDelete|ReadOnly
+  baseURI       DOMNode::BaseURI        DontDelete|ReadOnly
   namespaceURI  DOMNode::NamespaceURI   DontDelete|ReadOnly
 # DOM2
   prefix        DOMNode::Prefix         DontDelete
@@ -226,6 +227,8 @@ JSValue* DOMNode::getValueProperty(ExecState* exec, int token) const
     return toJS(exec,node.nextSibling());
   case Attributes:
     return toJS(exec,node.attributes());
+  case BaseURI:
+    return jsStringOrNull(node.baseURI());
   case NamespaceURI:
     return jsStringOrNull(node.namespaceURI());
   case Prefix:
index 99cee6e2eb82ff9d5963aad8b2efca1ac2d5e7ad..24271abdb14466108674852d29a57e5773c189a2 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual UString toString(ExecState*) const;
     
     enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
-        ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling,
+        ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling, BaseURI,
         Attributes, NamespaceURI, Prefix, LocalName, OwnerDocument, InsertBefore,
         ReplaceChild, RemoveChild, AppendChild, HasAttributes, HasChildNodes,
         CloneNode, Normalize, IsSupported, Contains, IsSameNode, IsEqualNode, TextContent,
index faf510069c9687f5cbae19e3385e3a269968cf10..326be55d3617d586357cd144658b60980b70896f 100644 (file)
@@ -766,6 +766,21 @@ void Document::setXMLStandalone(bool standalone, ExceptionCode& ec)
     m_xmlStandalone = standalone;
 }
 
+String Document::documentURI() const
+{
+    return m_baseURL;
+}
+
+void Document::setDocumentURI(const String &uri)
+{
+    m_baseURL = uri.deprecatedString();
+}
+
+String Document::baseURI() const
+{
+    return documentURI();
+}
+
 Element* Document::elementFromPoint(int x, int y) const
 {
     if (!renderer())
index cbe2852741e45b28c28fa135af2c8183e3d5446f..172fca0367f01d4b0e1a4bc3492a4833240bcba4 100644 (file)
@@ -193,6 +193,11 @@ public:
     void setXMLVersion(const String&, ExceptionCode&);
     void setXMLStandalone(bool, ExceptionCode&);
 
+    String documentURI() const;
+    void setDocumentURI(const String&);
+
+    virtual String baseURI() const;
+
     PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
     
     PassRefPtr<NameNodeList> getElementsByName(const String& elementName);
index c3b351386575c3839f9898504c438c87985a3b17..6c69ff859ce3368826258fa8977aea35dac66ba6 100644 (file)
@@ -72,6 +72,7 @@ module core {
         Node               adoptNode(in Node source)
             raises (DOMException);
 
+                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString documentURI;
 
         // DOM Level 2 Events (DocumentEvents interface)
 
index ec831dcdf6dfac5d4838baca8bd0455435b60d4d..88dca927f4d7ed1bd74b6efc2e9fbcfb87c896f2 100644 (file)
@@ -74,6 +74,11 @@ String DocumentType::toString() const
     return result;
 }
 
+String DocumentType::baseURI() const
+{
+    return String();
+}
+
 String DocumentType::nodeName() const
 {
     return name();
index f265429ac002d0d28ba7453e4089132d6f09b86a..03a45e7c152f8c845065c289d56234fa08c2e603 100644 (file)
@@ -48,6 +48,8 @@ public:
     String systemId() const { return m_systemId; }
     String internalSubset() const { return m_subset; }
 
+    virtual String baseURI() const;
+
     // Other methods (not part of DOM)
     DOMImplementation *implementation() const { return m_implementation.get(); }
 
index 61b3cb82789f9b25f298c53094dedb5d3ea99198..b1b32a5228b7daa8735c91b75bd21f5fed4f5bb7 100644 (file)
 #include "Frame.h"
 #include "FrameView.h"
 #include "HTMLNames.h"
+#include "KURL.h"
 #include "NamedAttrMap.h"
 #include "Page.h"
 #include "RenderBlock.h"
 #include "SelectionController.h"
 #include "TextIterator.h"
 #include "TextStream.h"
+#include "XMLNames.h"
 
 namespace WebCore {
 
 using namespace HTMLNames;
+using namespace XMLNames;
 
 Element::Element(const QualifiedName& qName, Document *doc)
     : ContainerNode(doc)
@@ -464,6 +467,20 @@ void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
     m_tagName.setPrefix(_prefix);
 }
 
+String Element::baseURI() const
+{
+    KURL xmlbase(getAttribute(baseAttr).deprecatedString());
+
+    if (!xmlbase.protocol().isEmpty())
+        return xmlbase.url();
+
+    Node* parent = parentNode();
+    if (parent)
+        return KURL(parent->baseURI().deprecatedString(), xmlbase.url()).url();
+
+    return xmlbase.url();
+}
+
 Node* Element::insertAdjacentElement(const String& where, Node* newChild, int& exception)
 {
     if (!newChild) {
index e31dc1804957025fd5b1d26ba01b2425c6d78d4a..01a3edd337c40213108b9d666e305d109b2567dd 100644 (file)
@@ -111,7 +111,9 @@ public:
     virtual const AtomicString& prefix() const { return m_tagName.prefix(); }
     virtual void setPrefix(const AtomicString &_prefix, ExceptionCode&);
     virtual const AtomicString& namespaceURI() const { return m_tagName.namespaceURI(); }
-    
+
+    virtual String baseURI() const;
+
     // DOM methods overridden from  parent classes
     virtual NodeType nodeType() const;
     virtual PassRefPtr<Node> cloneNode(bool deep);
index 31f59032045214ad0aaab43dd17c0bb513d29f11..74403a66f16e800360f30429a64513e621e5eb3c 100644 (file)
 #include "ExceptionCode.h"
 #include "Frame.h"
 #include "HTMLNames.h"
+#include "KURL.h"
 #include "Logging.h"
 #include "NamedAttrMap.h"
 #include "RenderObject.h"
 #include "Text.h"
 #include "TextStream.h"
+#include "XMLNames.h"
 #include "htmlediting.h"
 #include "kjs_binding.h"
 
@@ -1217,6 +1219,15 @@ NamedAttrMap *Node::attributes() const
     return 0;
 }
 
+String Node::baseURI() const
+{
+    Node* parent = parentNode();
+    if (parent)
+        return parent->baseURI();
+
+    return String();
+}
+
 bool Node::isEqualNode(Node *other) const
 {
     if (!other)
index 1d3f6479399cf1416bd0fb996ffda0c553ca24a2..3dfaee42e36b1c5484e1fe05b9a4f76a61e43864 100644 (file)
@@ -101,6 +101,8 @@ public:
     virtual bool hasAttributes() const;
     virtual NamedAttrMap* attributes() const;
 
+    virtual String baseURI() 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
     // these methods to be more efficient since they don't need to return a ref
index a57055f56048b86087d3d8322ead6dac1a9debf0..96c490370e5f89087d0e6eb36895806ee780ce78 100644 (file)
@@ -50,8 +50,14 @@ void SVGImageLoader::updateFromElement()
     WebCore::Document* doc = imageElement->ownerDocument();
     
     CachedImage *newImage = 0;
-    if (!imageElement->href().isEmpty())
-        newImage = doc->docLoader()->requestImage(imageElement->href());
+    if (!imageElement->href().isEmpty()) {
+        DeprecatedString uri = imageElement->baseURI().deprecatedString();;
+        if (!uri.isEmpty())
+            uri = KURL(uri, imageElement->href().deprecatedString()).url();
+        else
+            uri = imageElement->href().deprecatedString();
+        newImage = doc->docLoader()->requestImage(uri);
+    }
 
     CachedImage *oldImage = image();
     if (newImage != oldImage) {
index 6ac35f440659551d17ed835039e42c11f8a08386..c7d54677bd8e59fbd0410fed39992355b0961d0a 100644 (file)
@@ -90,7 +90,7 @@ void SVGImageElement::parseMappedAttribute(MappedAttribute *attr)
         if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
             return;
         if (SVGURIReference::parseMappedAttribute(attr)) {
-            if (attr->name().matches(XLinkNames::hrefAttr))
+            if (attr->name().matches(XLinkNames::hrefAttr) && attached())
                 m_imageLoader.updateFromElement();
             return;
         }
@@ -119,6 +119,7 @@ bool SVGImageElement::haveLoadedRequiredResources()
 void SVGImageElement::attach()
 {
     SVGStyledTransformableElement::attach();
+    m_imageLoader.updateFromElement();
     if (RenderSVGImage* imageObj = static_cast<RenderSVGImage*>(renderer()))
         imageObj->setCachedImage(m_imageLoader.image());
 }