Node.baseURI should not return null for detached nodes
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 03:04:47 +0000 (03:04 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Sep 2015 03:04:47 +0000 (03:04 +0000)
commit78d55cd0f0a0ed14728709dd6fbbe0cdc3b8ff27
treeca9697ed9267a518fd84dc005dfa5d618d134a15
parent7b8aba7eb185ba17b5524b5f485be12516800f12
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189677 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03-expected.txt
LayoutTests/dom/xhtml/level3/core/nodegetbaseuri03.js
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-baseURI-expected.txt
LayoutTests/svg/custom/image-base-uri-expected.txt [deleted file]
LayoutTests/svg/custom/image-base-uri.svg [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/DocumentType.cpp
Source/WebCore/dom/DocumentType.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/svg/SVGElement.idl