Changeset 189677 in webkit


Ignore:
Timestamp:
Sep 13, 2015 8:04:47 PM (9 years ago)
Author:
Chris Dumez
Message:

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.

Location:
trunk
Files:
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r189676 r189677  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Node.baseURI should not return null for detached nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=149104
     5        <rdar://problem/22559535>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * dom/xhtml/level3/core/nodegetbaseuri03-expected.txt:
     10        Rebaseline outdated DOM3 test.
     11
     12        * svg/custom/image-base-uri-expected.txt: Removed.
     13        * svg/custom/image-base-uri.svg: Removed.
     14        Drop outdated SVG test. SVG2 no longer support xml:base.
     15
    1162015-09-13  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03-expected.txt

    r21687 r189677  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodegetbaseuri03
    2 Status  Success
     2Status  failure
     3Message nodegetbaseuri03: assertTrue failed
  • trunk/LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03.js

    r41145 r189677  
    100100      baseURI = docType.baseURI;
    101101
    102       assertNull("nodegetbaseuri03",baseURI);
     102      assertTrue("nodegetbaseuri03", baseURI == null);
    103103   
    104104}
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r189676 r189677  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Node.baseURI should not return null for detached nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=149104
     5        <rdar://problem/22559535>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Rebaseline W3C test now that more checks are passing.
     10
     11        * web-platform-tests/dom/nodes/Node-baseURI-expected.txt:
     12
    1132015-09-13  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-baseURI-expected.txt

    r189471 r189677  
    11
    22PASS For elements belonging to document, baseURI should be document url
    3 FAIL For elements unassigned to document, baseURI should be document url assert_equals: expected (string) "http://localhost:8800/dom/nodes/Node-baseURI.html" but got (object) null
    4 FAIL For elements belonging to document fragments, baseURI should be document url assert_equals: expected (string) "http://localhost:8800/dom/nodes/Node-baseURI.html" but got (object) null
     3PASS For elements unassigned to document, baseURI should be document url
     4PASS For elements belonging to document fragments, baseURI should be document url
    55PASS After inserting fragment into document, element baseURI should be document url
    66
  • trunk/Source/WebCore/ChangeLog

    r189676 r189677  
     12015-09-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Node.baseURI should not return null for detached nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=149104
     5        <rdar://problem/22559535>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Node.baseURI should not return null for detached nodes. It should return
     10        the node document's base URL. The node document is set when the node is
     11        created so it is valid even if the node is detached [1]:
     12        https://dom.spec.whatwg.org/#dom-node-baseuri
     13
     14        WebKit was traversing the ancestors to find the base URL, which only
     15        works if the node is attached. Also, WebKit was taking into account
     16        the xml:base attribute when computing the baseURI.
     17
     18        Both Chrome and Firefox already dropped support for xml:base:
     19        https://code.google.com/p/chromium/issues/detail?id=341854
     20        https://bugzilla.mozilla.org/show_bug.cgi?id=903372
     21
     22        Firefox complies with the specification. Chrome's baseURI still only
     23        works for attached Nodes as their implementation still traverses the
     24        DOM tree, despite dropping support for xml:base.
     25
     26        This patch drops support xml:base when computing Node.baseURI, as
     27        Firefox, Chrome and the latest DOM specification do. It also makes
     28        Node.baseURI work for detached Nodes by returning the base URL of the
     29        node Document. This means we no longer have to traverse the Node's
     30        ancestors in the DOM tree. This is consistent with the behavior of
     31        Firefox and the latest DOM specification.
     32
     33        This patch does not drop the SVGElement.xmlbase attribute yet. However,
     34        we should probably consider making this change as well given that:
     35        - The SVG2 specification dropped it
     36        - Chrome dropped it.
     37        - It no longers impacts Node.baseURI
     38
     39        [1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=20976
     40
     41        No new tests, already covered by existing test.
     42
     43        * dom/Document.cpp:
     44        (WebCore::Document::setContent): Deleted.
     45        * dom/Document.h:
     46        (WebCore::Document::inputCursor): Deleted.
     47        * dom/DocumentType.cpp:
     48        (WebCore::DocumentType::nodeName): Deleted.
     49        * dom/DocumentType.h:
     50        * dom/Element.cpp:
     51        (WebCore::Element::imageSourceURL): Deleted.
     52        (WebCore::Element::rendererIsNeeded): Deleted.
     53        (WebCore::Element::createElementRenderer): Deleted.
     54        (WebCore::Element::insertedInto): Deleted.
     55        * dom/Element.h:
     56        * dom/Node.cpp:
     57        (WebCore::Node::baseURI):
     58        * dom/Node.h:
     59        * svg/SVGElement.idl:
     60
    1612015-09-13  Chris Dumez  <cdumez@apple.com>
    262
  • trunk/Source/WebCore/dom/Document.cpp

    r189576 r189677  
    13201320}
    13211321
    1322 URL Document::baseURI() const
    1323 {
    1324     return m_baseURL;
    1325 }
    1326 
    13271322void Document::setContent(const String& content)
    13281323{
  • trunk/Source/WebCore/dom/Document.h

    r189576 r189677  
    433433    void setDocumentURI(const String&);
    434434
    435     virtual URL baseURI() const override final;
    436 
    437435#if ENABLE(WEB_REPLAY)
    438436    JSC::InputCursor& inputCursor() const { return *m_inputCursor; }
  • trunk/Source/WebCore/dom/DocumentType.cpp

    r189576 r189677  
    3737}
    3838
    39 URL DocumentType::baseURI() const
    40 {
    41     return URL();
    42 }
    43 
    4439String DocumentType::nodeName() const
    4540{
  • trunk/Source/WebCore/dom/DocumentType.h

    r189576 r189677  
    5050    DocumentType(Document&, const String& name, const String& publicId, const String& systemId);
    5151
    52     virtual URL baseURI() const override;
    5352    virtual String nodeName() const override;
    5453    virtual NodeType nodeType() const override;
  • trunk/Source/WebCore/dom/Element.cpp

    r189676 r189677  
    14691469}
    14701470
    1471 URL Element::baseURI() const
    1472 {
    1473     const AtomicString& baseAttribute = getAttribute(baseAttr);
    1474     URL base(URL(), baseAttribute);
    1475     if (!base.protocol().isEmpty())
    1476         return base;
    1477 
    1478     ContainerNode* parent = parentNode();
    1479     if (!parent)
    1480         return base;
    1481 
    1482     const URL& parentBase = parent->baseURI();
    1483     if (parentBase.isNull())
    1484         return base;
    1485 
    1486     return URL(parentBase, baseAttribute);
    1487 }
    1488 
    14891471const AtomicString& Element::imageSourceURL() const
    14901472{
  • trunk/Source/WebCore/dom/Element.h

    r189576 r189677  
    198198    virtual const AtomicString& namespaceURI() const override final { return m_tagName.namespaceURI(); }
    199199
    200     virtual URL baseURI() const override final;
    201 
    202200    virtual String nodeName() const override;
    203201
  • trunk/Source/WebCore/dom/Node.cpp

    r189676 r189677  
    11661166URL Node::baseURI() const
    11671167{
    1168     return parentNode() ? parentNode()->baseURI() : URL();
     1168    return document().baseURL();
    11691169}
    11701170
  • trunk/Source/WebCore/dom/Node.h

    r189576 r189677  
    183183    Node* pseudoAwareLastChild() const;
    184184
    185     virtual URL baseURI() const;
     185    URL baseURI() const;
    186186   
    187187    void getSubresourceURLs(ListHashSet<URL>&) const;
  • trunk/Source/WebCore/svg/SVGElement.idl

    r168313 r189677  
    2424    JSGenerateToNativeObject,
    2525] interface SVGElement : Element {
     26    // FIXME: the xmlbase attribute is no longer part of SVG2 and Chrome already dropped it.
    2627    [TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlbase;
     28
    2729    readonly attribute SVGSVGElement ownerSVGElement;
    2830    readonly attribute SVGElement viewportElement;
Note: See TracChangeset for help on using the changeset viewer.