Title: [189802] releases/WebKitGTK/webkit-2.10
Revision
189802
Author
carlo...@webkit.org
Date
2015-09-15 01:37:17 -0700 (Tue, 15 Sep 2015)

Log Message

Merge r189677 - Node.baseURI should not return null for detached nodes
https://bugs.webkit.org/show_bug.cgi?id=149104
<rdar://problem/22559535>

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/dom/nodes/Node-baseURI-expected.txt:

Source/WebCore:

Node.baseURI should not return null for detached nodes. It should return
the node document's base URL. The node document is set when the node is
created so it is valid even if the node is detached [1]:
https://dom.spec.whatwg.org/#dom-node-baseuri

WebKit was traversing the ancestors to find the base URL, which only
works if the node is attached. Also, WebKit was taking into account
the xml:base attribute when computing the baseURI.

Both Chrome and Firefox already dropped support for xml:base:
https://code.google.com/p/chromium/issues/detail?id=341854
https://bugzilla.mozilla.org/show_bug.cgi?id=903372

Firefox complies with the specification. Chrome's baseURI still only
works for attached Nodes as their implementation still traverses the
DOM tree, despite dropping support for xml:base.

This patch drops support xml:base when computing Node.baseURI, as
Firefox, Chrome and the latest DOM specification do. It also makes
Node.baseURI work for detached Nodes by returning the base URL of the
node Document. This means we no longer have to traverse the Node's
ancestors in the DOM tree. This is consistent with the behavior of
Firefox and the latest DOM specification.

This patch does not drop the SVGElement.xmlbase attribute yet. However,
we should probably consider making this change as well given that:
- The SVG2 specification dropped it
- Chrome dropped it.
- It no longers impacts Node.baseURI

[1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=20976

No new tests, already covered by existing test.

* dom/Document.cpp:
(WebCore::Document::setContent): Deleted.
* dom/Document.h:
(WebCore::Document::inputCursor): Deleted.
* dom/DocumentType.cpp:
(WebCore::DocumentType::nodeName): Deleted.
* dom/DocumentType.h:
* dom/Element.cpp:
(WebCore::Element::imageSourceURL): Deleted.
(WebCore::Element::rendererIsNeeded): Deleted.
(WebCore::Element::createElementRenderer): Deleted.
(WebCore::Element::insertedInto): Deleted.
* dom/Element.h:
* dom/Node.cpp:
(WebCore::Node::baseURI):
* dom/Node.h:
* svg/SVGElement.idl:

LayoutTests:

* dom/xhtml/level3/core/nodegetbaseuri03-expected.txt:
Rebaseline outdated DOM3 test.

* svg/custom/image-base-uri-expected.txt: Removed.
* svg/custom/image-base-uri.svg: Removed.
Drop outdated SVG test. SVG2 no longer support xml:base.

Modified Paths

Removed Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,3 +1,18 @@
+2015-09-13  Chris Dumez  <cdu...@apple.com>
+
+        Node.baseURI should not return null for detached nodes
+        https://bugs.webkit.org/show_bug.cgi?id=149104
+        <rdar://problem/22559535>
+
+        Reviewed by Sam Weinig.
+
+        * dom/xhtml/level3/core/nodegetbaseuri03-expected.txt:
+        Rebaseline outdated DOM3 test.
+
+        * svg/custom/image-base-uri-expected.txt: Removed.
+        * svg/custom/image-base-uri.svg: Removed.
+        Drop outdated SVG test. SVG2 no longer support xml:base.
+
 2015-09-10  David Hyatt  <hy...@apple.com>
 
         [New Block-Inside-Inline Model] Self-collapsing block check needs to account for anonymous inline blocks

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03-expected.txt (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03-expected.txt	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03-expected.txt	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,2 +1,3 @@
 Test	http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri03
-Status	Success
+Status	failure
+Message	nodegetbaseuri03: assertTrue failed

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03.js (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03.js	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03.js	2015-09-15 08:37:17 UTC (rev 189802)
@@ -99,7 +99,7 @@
 
       baseURI = docType.baseURI;
 
-      assertNull("nodegetbaseuri03",baseURI);
+      assertTrue("nodegetbaseuri03", baseURI == null);
     
 }
 

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/imported/w3c/ChangeLog (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/imported/w3c/ChangeLog	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/imported/w3c/ChangeLog	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,3 +1,15 @@
+2015-09-13  Chris Dumez  <cdu...@apple.com>
+
+        Node.baseURI should not return null for detached nodes
+        https://bugs.webkit.org/show_bug.cgi?id=149104
+        <rdar://problem/22559535>
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/nodes/Node-baseURI-expected.txt:
+
 2015-09-09  Chris Dumez  <cdu...@apple.com>
 
         Setting document.title when there is no title and no head element should no nothing

Deleted: releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri-expected.txt (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri-expected.txt	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri-expected.txt	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,2 +0,0 @@
-PASS
-

Deleted: releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri.svg (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri.svg	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/svg/custom/image-base-uri.svg	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<svg xmlns="http://www.w3.org/2000/svg">
-  <script type="text/_javascript_">
-  <![CDATA[
-    if (window.testRunner)
-        testRunner.dumpAsText();
-    var txt = document.createElementNS('http://www.w3.org/2000/svg', "text");
-    txt.setAttribute("id", "console");
-    txt.textContent = "PASS";
-    document.rootElement.appendChild(txt);
-    var ie = document.createElementNS('http://www.w3.org/2000/svg', "image");
-    ie._onerror_ = function() { document.getElementById("console").textContent = "FAIL"; }
-    ie.setAttribute("x", "0");
-    ie.setAttribute("y", "0");
-    ie.setAttribute("width", "100");
-    ie.setAttribute("height", "100");
-    ie.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:base", "resources/");
-    ie.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "green-checker.png");
-    document.rootElement.appendChild(ie);
-  ]]>
-  </script>
-</svg>

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1,3 +1,63 @@
+2015-09-13  Chris Dumez  <cdu...@apple.com>
+
+        Node.baseURI should not return null for detached nodes
+        https://bugs.webkit.org/show_bug.cgi?id=149104
+        <rdar://problem/22559535>
+
+        Reviewed by Sam Weinig.
+
+        Node.baseURI should not return null for detached nodes. It should return
+        the node document's base URL. The node document is set when the node is
+        created so it is valid even if the node is detached [1]:
+        https://dom.spec.whatwg.org/#dom-node-baseuri
+
+        WebKit was traversing the ancestors to find the base URL, which only
+        works if the node is attached. Also, WebKit was taking into account
+        the xml:base attribute when computing the baseURI.
+
+        Both Chrome and Firefox already dropped support for xml:base:
+        https://code.google.com/p/chromium/issues/detail?id=341854
+        https://bugzilla.mozilla.org/show_bug.cgi?id=903372
+
+        Firefox complies with the specification. Chrome's baseURI still only
+        works for attached Nodes as their implementation still traverses the
+        DOM tree, despite dropping support for xml:base.
+
+        This patch drops support xml:base when computing Node.baseURI, as
+        Firefox, Chrome and the latest DOM specification do. It also makes
+        Node.baseURI work for detached Nodes by returning the base URL of the
+        node Document. This means we no longer have to traverse the Node's
+        ancestors in the DOM tree. This is consistent with the behavior of
+        Firefox and the latest DOM specification.
+
+        This patch does not drop the SVGElement.xmlbase attribute yet. However,
+        we should probably consider making this change as well given that:
+        - The SVG2 specification dropped it
+        - Chrome dropped it.
+        - It no longers impacts Node.baseURI
+
+        [1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=20976
+
+        No new tests, already covered by existing test.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setContent): Deleted.
+        * dom/Document.h:
+        (WebCore::Document::inputCursor): Deleted.
+        * dom/DocumentType.cpp:
+        (WebCore::DocumentType::nodeName): Deleted.
+        * dom/DocumentType.h:
+        * dom/Element.cpp:
+        (WebCore::Element::imageSourceURL): Deleted.
+        (WebCore::Element::rendererIsNeeded): Deleted.
+        (WebCore::Element::createElementRenderer): Deleted.
+        (WebCore::Element::insertedInto): Deleted.
+        * dom/Element.h:
+        * dom/Node.cpp:
+        (WebCore::Node::baseURI):
+        * dom/Node.h:
+        * svg/SVGElement.idl:
+
 2015-09-10  David Hyatt  <hy...@apple.com>
 
         [New Block-Inside-Inline Model] Self-collapsing block check needs to account for anonymous inline blocks

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.cpp (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.cpp	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.cpp	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1309,11 +1309,6 @@
     updateBaseURL();
 }
 
-URL Document::baseURI() const
-{
-    return m_baseURL;
-}
-
 void Document::setContent(const String& content)
 {
     open();

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.h (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.h	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Document.h	2015-09-15 08:37:17 UTC (rev 189802)
@@ -434,8 +434,6 @@
     String documentURI() const { return m_documentURI; }
     void setDocumentURI(const String&);
 
-    virtual URL baseURI() const override final;
-
 #if ENABLE(WEB_REPLAY)
     JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
     void setInputCursor(PassRefPtr<JSC::InputCursor>);

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.cpp (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.cpp	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.cpp	2015-09-15 08:37:17 UTC (rev 189802)
@@ -36,11 +36,6 @@
 {
 }
 
-URL DocumentType::baseURI() const
-{
-    return URL();
-}
-
 String DocumentType::nodeName() const
 {
     return name();

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.h (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.h	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/DocumentType.h	2015-09-15 08:37:17 UTC (rev 189802)
@@ -49,7 +49,6 @@
 private:
     DocumentType(Document&, const String& name, const String& publicId, const String& systemId);
 
-    virtual URL baseURI() const override;
     virtual String nodeName() const override;
     virtual NodeType nodeType() const override;
     virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.cpp (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.cpp	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.cpp	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1465,24 +1465,6 @@
     m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
 }
 
-URL Element::baseURI() const
-{
-    const AtomicString& baseAttribute = getAttribute(baseAttr);
-    URL base(URL(), baseAttribute);
-    if (!base.protocol().isEmpty())
-        return base;
-
-    ContainerNode* parent = parentNode();
-    if (!parent)
-        return base;
-
-    const URL& parentBase = parent->baseURI();
-    if (parentBase.isNull())
-        return base;
-
-    return URL(parentBase, baseAttribute);
-}
-
 const AtomicString& Element::imageSourceURL() const
 {
     return fastGetAttribute(srcAttr);

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.h (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.h	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Element.h	2015-09-15 08:37:17 UTC (rev 189802)
@@ -197,8 +197,6 @@
     virtual const AtomicString& prefix() const override final { return m_tagName.prefix(); }
     virtual const AtomicString& namespaceURI() const override final { return m_tagName.namespaceURI(); }
 
-    virtual URL baseURI() const override final;
-
     virtual String nodeName() const override;
 
     RefPtr<Element> cloneElementWithChildren(Document&);

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.cpp (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.cpp	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.cpp	2015-09-15 08:37:17 UTC (rev 189802)
@@ -1158,7 +1158,7 @@
 
 URL Node::baseURI() const
 {
-    return parentNode() ? parentNode()->baseURI() : URL();
+    return document().baseURL();
 }
 
 bool Node::isEqualNode(Node* other) const

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.h (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.h	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/dom/Node.h	2015-09-15 08:37:17 UTC (rev 189802)
@@ -182,7 +182,7 @@
     Node* pseudoAwareFirstChild() const;
     Node* pseudoAwareLastChild() const;
 
-    virtual URL baseURI() const;
+    URL baseURI() const;
     
     void getSubresourceURLs(ListHashSet<URL>&) const;
 

Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/svg/SVGElement.idl (189801 => 189802)


--- releases/WebKitGTK/webkit-2.10/Source/WebCore/svg/SVGElement.idl	2015-09-15 08:15:09 UTC (rev 189801)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/svg/SVGElement.idl	2015-09-15 08:37:17 UTC (rev 189802)
@@ -23,7 +23,9 @@
 [
     JSGenerateToNativeObject,
 ] interface SVGElement : Element {
+    // FIXME: the xmlbase attribute is no longer part of SVG2 and Chrome already dropped it.
     [TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlbase;
+
     readonly attribute SVGSVGElement ownerSVGElement;
     readonly attribute SVGElement viewportElement;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to