XMLSerializer doesn't include namespaces on nodes in HTML documents
https://bugs.webkit.org/show_bug.cgi?id=16496
Patch by Rob Buis <[email protected]> on 2013-07-15
Reviewed by Ryosuke Niwa.
Source/WebCore:
Introduce a xml fragment serialization mode as indicated by
http://html5.org/specs/dom-parsing.html#xmlserializer (commit 00b84d2). In this mode
the XML fragment serialization algorithm is respected, the changes in this patch do the following:
This is achieved by always, when in xml fragment serialization mode, attempting to write out the element/attribute namespace,
preventing using the XML namespace as a default namespace and special casing the use of element's in XML namespace by using the xml prefix.
The chosen approach matches FireFox 25 behavior.
Test: fast/dom/dom-serialize-namespace.html
- WebCore.order: Adapt to changed createMarkup signature.
- editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::MarkupAccumulator):
(WebCore::MarkupAccumulator::serializeNodesWithNamespaces): makes sure xml namespace/prefix is known so it is never used in namespace declarations.
(WebCore::MarkupAccumulator::appendNamespace): Avoid adding namespace declarations that do not differ from current default namespace.
(WebCore::MarkupAccumulator::appendOpenTag): Print xml prefix if the element's namespace is XML to avoid conflicts.
(WebCore::MarkupAccumulator::appendAttribute):
(WebCore::MarkupAccumulator::shouldAddNamespaceAttribute): Also take into account xmlns attributes with no namespace.
(WebCore::MarkupAccumulator::shouldSelfClose): Force self-closing to create well-formed XML elements.
- editing/MarkupAccumulator.h: Use EFragmentSerialization.
(WebCore::MarkupAccumulator::inXMLFragmentSerialization):
(WebCore::createMarkup):
- editing/markup.h: Add EFragmentSerialization enum.
- xml/XMLSerializer.cpp:
(WebCore::XMLSerializer::serializeToString):
LayoutTests:
The updated tests are progressions and match FF.
- fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt:
- fast/dom/Element/script-tests/getAttribute-check-case-sensitivity.js:
- fast/dom/XMLSerializer-xml-namespace-expected.txt:
- fast/dom/dom-serialize-namespace-expected.txt: Added.
- fast/dom/dom-serialize-namespace.html: Added.
- fast/xsl/xslt-processor-expected.txt:
- inspector/elements/set-outer-html-expected.txt:
- svg/custom/xlink-prefix-in-attributes-expected.txt: