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

4 lines
301 B
Plaintext
Raw Permalink Normal View History

Namespace prefix is blindly followed when serializing https://bugs.webkit.org/show_bug.cgi?id=19121 Serializer doesn't handling inconsistent prefixes properly https://bugs.webkit.org/show_bug.cgi?id=117764 Attribute namespaces are serialized as if they were element ones https://bugs.webkit.org/show_bug.cgi?id=22958 Reviewed by Ryosuke Niwa. Source/WebCore: Add code to make sure unique prefixes and namespace declarations are generated. Unique prefix generation happens when: - the same prefix is used to map to different namespaces or - no prefix is given but the attribute is in a namespace. This is done in order to not violate constraints listed in http://www.w3.org/TR/xml-names11/. In general the pseudo code listed in http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#normalizeDocumentAlgo is used, doing the following for attributes: if the attribute has a namespace then if the attribute has no prefix OR prefix is not declared OR conflicts with existing prefix mapping to different NS then try to find the matching in-scope declaration by looking up the prefix in the namespace -> prefix mapping, if found use that prefix else if the attribute prefix is not null AND not mapped in-scope, declare the prefix else generate a unique prefix for the namespace To keep track of in-scope namespaces a prefix to namespace mapping is used. Tests: fast/dom/XMLSerializer-attribute-namespace-prefix-conflicts.html fast/dom/XMLSerializer-same-prefix-different-namespaces-conflict.html fast/dom/XMLSerializer-setAttributeNS-namespace-no-prefix.html svg/custom/xlink-prefix-generation-in-attributes.html * editing/MarkupAccumulator.cpp: (WebCore::MarkupAccumulator::MarkupAccumulator): (WebCore::MarkupAccumulator::shouldAddNamespaceAttribute): (WebCore::MarkupAccumulator::appendNamespace): (WebCore::MarkupAccumulator::generateUniquePrefix): (WebCore::MarkupAccumulator::appendAttribute): * editing/MarkupAccumulator.h: LayoutTests: Add tests to make sure unique prefixes and namespace declarations are generated for the case when the same prefix is used to map to different namespaces. All testcases are based on the testcases attached to the bugs. * fast/dom/XMLSerializer-attribute-namespace-prefix-conflicts-expected.txt: Added. * fast/dom/XMLSerializer-attribute-namespace-prefix-conflicts.html: Added. * fast/dom/XMLSerializer-same-prefix-different-namespaces-conflict-expected.txt: Added. * fast/dom/XMLSerializer-same-prefix-different-namespaces-conflict.html: Added. * fast/dom/XMLSerializer-setAttributeNS-namespace-no-prefix-expected.txt: Added. * fast/dom/XMLSerializer-setAttributeNS-namespace-no-prefix.html: Added. * svg/custom/xlink-prefix-generation-in-attributes-expected.txt: Added. * svg/custom/xlink-prefix-generation-in-attributes.html: Added. Canonical link: https://commits.webkit.org/138413@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-08-28 22:25:19 +00:00
<svg xmlns="http://www.w3.org/2000/svg" NS1:href="#foo" xmlns:NS1="http://www.w3.org/1999/xlink"/>
<svg xmlns="http://www.w3.org/2000/svg" NS1:href="#foo" xmlns:NS1="http://www.w3.org/1999/xlink"/>
<svg xmlns="http://www.w3.org/2000/svg" xlink:href="#foo" xmlns:xlink="http://www.w3.org/1999/xlink"/>