haikuwebkit/LayoutTests/svg/custom/xlink-prefix-in-attributes-...

3 lines
462 B
Plaintext
Raw Permalink Normal View History

XMLSerializer doesn't include namespaces on nodes in HTML documents https://bugs.webkit.org/show_bug.cgi?id=16496 Patch by Rob Buis <rwlbuis@webkit.org> 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: - elements are self-closing if otherwise this would lead to invalid xml syntax. - the resulting xml is XML namespace-well-formed (http://www.w3.org/TR/xml-names11/#Conformance). 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): * editing/markup.cpp: (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: Canonical link: https://commits.webkit.org/136586@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@152685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-07-16 00:37:02 +00:00
<div xmlns="http://www.w3.org/1999/xhtml" id="target"> <div id="svgoutput"> </div><svg xmlns="http://www.w3.org/2000/svg" svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><image width="20" height="20" xlink:href="resources/green-checker.png"/><image x="0" y="30" width="20" height="20" xlink:href="resources/green-checker.png"/></svg></div> <El xmlns:a="http://www.w3.org/1999/xlink" a:title="C" a:href="H"/>
xmlserializer strips xlink from xlink:html svg image tag https://bugs.webkit.org/show_bug.cgi?id=79586 Reviewed by Nikolas Zimmermann. Source/WebCore: Adding code to ensure the correct prefix on attributes in the xml, xmlns and xlink namespaces. We now follow the rules in http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments (circa the time of this change). Rob Buis wrote the original test for this patch and did the initial work. Tests: fast/dom/XMLSerializer-xml-namespace.html svg/custom/xlink-prefix-in-attributes.html * editing/MarkupAccumulator.cpp: (WebCore::attributeIsInSerializedNamespace): Test for an attribute in a specially serialized namespace: xml, xmlns, xlink. (WebCore): (WebCore::MarkupAccumulator::appendAttribute): Check the namespace of attributes upon serialization, and add any necessary prefixes. * html/parser/HTMLTreeBuilder.cpp: (WebCore::adjustForeignAttributes): Use WTF::xmlAtom etc for AtomicString arguments. Source/WTF: Add WTF::xlinkAtom as a global AtomicString constant. * wtf/text/AtomicString.h: (WTF): Add xlinkAtom. * wtf/text/StringStatics.cpp: (WTF): Add xlinkAtom. (WTF::AtomicString::init): Add xlinkAtom. LayoutTests: Adding code to ensure the correct prefix on attributes in the xml, xmlns and xlink namespaces. We now follow the rules in http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments (circa the time of this change). Rob Buis wrote the original test for this patch and did the initial work. * editing/pasteboard/paste-noscript-svg-expected.txt: Updated. * fast/dom/XMLSerializer-xml-namespace-expected.txt: Added. * fast/dom/XMLSerializer-xml-namespace.html: Added. Tests serializing attributes with the xml namespace. * svg/custom/xlink-prefix-in-attributes-expected.txt: Added. * svg/custom/xlink-prefix-in-attributes.html: Added. Tests serializing attributes in the xmlns and xlink namespaces. Canonical link: https://commits.webkit.org/110585@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-07-31 16:02:14 +00:00