Changeset 152685 in webkit
- Timestamp:
- Jul 15, 2013 5:37:02 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r152668 r152685 1 2013-07-15 Rob Buis <rwlbuis@webkit.org> 2 3 XMLSerializer doesn't include namespaces on nodes in HTML documents 4 https://bugs.webkit.org/show_bug.cgi?id=16496 5 6 Reviewed by Ryosuke Niwa. 7 8 The updated tests are progressions and match FF. 9 10 * fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt: 11 * fast/dom/Element/script-tests/getAttribute-check-case-sensitivity.js: 12 * fast/dom/XMLSerializer-xml-namespace-expected.txt: 13 * fast/dom/dom-serialize-namespace-expected.txt: Added. 14 * fast/dom/dom-serialize-namespace.html: Added. 15 * fast/xsl/xslt-processor-expected.txt: 16 * inspector/elements/set-outer-html-expected.txt: 17 * svg/custom/xlink-prefix-in-attributes-expected.txt: 18 1 19 2013-07-15 Ryosuke Niwa <rniwa@webkit.org> 2 20 -
trunk/LayoutTests/fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt
r35931 r152685 14 14 PASS testAttribNodeNamePreservesCaseGetNode2() is "B,B" 15 15 PASS testAttribNodeNameGetMutate() is "1" 16 PASS (new XMLSerializer).serializeToString(node) is "<div myAttrib=\"XXX\"></div>"16 PASS (new XMLSerializer).serializeToString(node) is "<div xmlns=\"http://www.w3.org/1999/xhtml\" myAttrib=\"XXX\"></div>" 17 17 PASS node.getAttributeNode('myAttrib').name is "myAttrib" 18 18 PASS node.getAttributeNode('myattrib').name is "myAttrib" -
trunk/LayoutTests/fast/dom/Element/script-tests/getAttribute-check-case-sensitivity.js
r98407 r152685 136 136 node.setAttributeNode(attrib); 137 137 138 shouldBe("(new XMLSerializer).serializeToString(node)", '"<div myAttrib=\\"XXX\\"></div>"');138 shouldBe("(new XMLSerializer).serializeToString(node)", '"<div xmlns=\\"http://www.w3.org/1999/xhtml\\" myAttrib=\\"XXX\\"></div>"'); 139 139 shouldBe("node.getAttributeNode('myAttrib').name", '"myAttrib"'); 140 140 shouldBe("node.getAttributeNode('myattrib').name", '"myAttrib"'); -
trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace-expected.txt
r124210 r152685 1 <div id="target"> <div id="output"> </div><foo xml:space="preserve"></foo><bar xml:space="default"></bar></div>1 <div xmlns="http://www.w3.org/1999/xhtml" id="target"> <div id="output"> </div><xml:foo xml:space="preserve"/><xml:bar xml:space="default"/></div> 2 2 -
trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt
r127710 r152685 37 37 38 38 1.1 Import two different stylesheets: 39 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" ></head><body>40 CHARACTERS IN XSLT: ééééééééééé <br ><br>SOURCE XML: <<<&тест&>>></body></html>39 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body> 40 CHARACTERS IN XSLT: ééééééééééé <br /><br />SOURCE XML: <<<&тест&>>></body></html> 41 41 1.2 Import same stylesheet twice: 42 42 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> -
trunk/LayoutTests/inspector/elements/set-outer-html-for-xhtml-expected.txt
r146897 r152685 16 16 ==========8<========== 17 17 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 18 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>19 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting not involved</h2>20 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>18 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 19 <h2>Getting not involved</h2> 20 <p id="identity">There are many ways to get involved. You can:</p> 21 21 </div> 22 22 ==========>8========== … … 28 28 ==========8<========== 29 29 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 30 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>31 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>32 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>30 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 31 <h2>Getting involved</h2> 32 <p id="identity">There are many ways to get involved. You can:</p> 33 33 </div> 34 34 ==========>8========== … … 47 47 ==========8<========== 48 48 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 49 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a foo="bar" href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>50 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>51 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>49 <p>WebKit is used by <a foo="bar" href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 50 <h2>Getting involved</h2> 51 <p id="identity">There are many ways to get involved. You can:</p> 52 52 </div> 53 53 ==========>8========== … … 61 61 ==========8<========== 62 62 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 63 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>64 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>65 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>63 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 64 <h2>Getting involved</h2> 65 <p id="identity">There are many ways to get involved. You can:</p> 66 66 </div> 67 67 ==========>8========== … … 78 78 ==========8<========== 79 79 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 80 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>81 <h2 xmlns="http://www.w3.org/1999/xhtml"></h2>82 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>80 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 81 <h2></h2> 82 <p id="identity">There are many ways to get involved. You can:</p> 83 83 </div> 84 84 ==========>8========== … … 90 90 ==========8<========== 91 91 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 92 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>93 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>94 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>92 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 93 <h2>Getting involved</h2> 94 <p id="identity">There are many ways to get involved. You can:</p> 95 95 </div> 96 96 ==========>8========== … … 109 109 ==========8<========== 110 110 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 111 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>112 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting</h2><h2 xmlns="http://www.w3.org/1999/xhtml">involved</h2>113 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>111 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 112 <h2>Getting</h2><h2>involved</h2> 113 <p id="identity">There are many ways to get involved. You can:</p> 114 114 </div> 115 115 ==========>8========== … … 123 123 ==========8<========== 124 124 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 125 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>126 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>127 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>125 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 126 <h2>Getting involved</h2> 127 <p id="identity">There are many ways to get involved. You can:</p> 128 128 </div> 129 129 ==========>8========== … … 141 141 ==========8<========== 142 142 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 143 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>144 <h3 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h3>145 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>143 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 144 <h3>Getting involved</h3> 145 <p id="identity">There are many ways to get involved. You can:</p> 146 146 </div> 147 147 ==========>8========== … … 154 154 ==========8<========== 155 155 <div xmlns="http://www.w3.org/1999/xhtml" id="container" style="display:none"> 156 <p xmlns="http://www.w3.org/1999/xhtml">WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p>157 <h2 xmlns="http://www.w3.org/1999/xhtml">Getting involved</h2>158 <p xmlns="http://www.w3.org/1999/xhtml"id="identity">There are many ways to get involved. You can:</p>156 <p>WebKit is used by <a href="http://www.apple.com/safari/">Safari</a>, Dashboard, etc.</p> 157 <h2>Getting involved</h2> 158 <p id="identity">There are many ways to get involved. You can:</p> 159 159 </div> 160 160 ==========>8========== -
trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes-expected.txt
r136984 r152685 1 <div 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><image x="0" y="30" width="20" height="20" xlink:href="resources/green-checker.png"></image></svg></div> <El xmlns:a="http://www.w3.org/1999/xlink" a:title="C" a:href="H"/>1 <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"/> 2 2 -
trunk/Source/WebCore/ChangeLog
r152673 r152685 1 2013-07-15 Rob Buis <rwlbuis@webkit.org> 2 3 XMLSerializer doesn't include namespaces on nodes in HTML documents 4 https://bugs.webkit.org/show_bug.cgi?id=16496 5 6 Reviewed by Ryosuke Niwa. 7 8 Introduce a xml fragment serialization mode as indicated by 9 http://html5.org/specs/dom-parsing.html#xmlserializer (commit 00b84d2). In this mode 10 the XML fragment serialization algorithm is respected, the changes in this patch do the following: 11 12 - elements are self-closing if otherwise this would lead to invalid xml syntax. 13 - the resulting xml is XML namespace-well-formed (http://www.w3.org/TR/xml-names11/#Conformance). 14 This is achieved by always, when in xml fragment serialization mode, attempting to write out the element/attribute namespace, 15 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. 16 17 The chosen approach matches FireFox 25 behavior. 18 19 Test: fast/dom/dom-serialize-namespace.html 20 21 * WebCore.order: Adapt to changed createMarkup signature. 22 * editing/MarkupAccumulator.cpp: 23 (WebCore::MarkupAccumulator::MarkupAccumulator): 24 (WebCore::MarkupAccumulator::serializeNodesWithNamespaces): makes sure xml namespace/prefix is known so it is never used in namespace declarations. 25 (WebCore::MarkupAccumulator::appendNamespace): Avoid adding namespace declarations that do not differ from current default namespace. 26 (WebCore::MarkupAccumulator::appendOpenTag): Print xml prefix if the element's namespace is XML to avoid conflicts. 27 (WebCore::MarkupAccumulator::appendAttribute): 28 (WebCore::MarkupAccumulator::shouldAddNamespaceAttribute): Also take into account xmlns attributes with no namespace. 29 (WebCore::MarkupAccumulator::shouldSelfClose): Force self-closing to create well-formed XML elements. 30 * editing/MarkupAccumulator.h: Use EFragmentSerialization. 31 (WebCore::MarkupAccumulator::inXMLFragmentSerialization): 32 * editing/markup.cpp: 33 (WebCore::createMarkup): 34 * editing/markup.h: Add EFragmentSerialization enum. 35 * xml/XMLSerializer.cpp: 36 (WebCore::XMLSerializer::serializeToString): 37 1 38 2013-07-15 Ryosuke Niwa <rniwa@webkit.org> 2 39 -
trunk/Source/WebCore/WebCore.order
r152299 r152685 8047 8047 __ZN7WebCore22jsHTMLElementInnerHTMLEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE 8048 8048 __ZNK7WebCore11HTMLElement9innerHTMLEv 8049 __ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsE 8049 __ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsENS_22EFragmentSerializationE 8050 8050 __ZN7WebCore17MarkupAccumulatorC1EPN3WTF6VectorIPNS_4NodeELm0EEENS_13EAbsoluteURLsEPKNS_5RangeE 8051 8051 __ZN7WebCore17MarkupAccumulator14serializeNodesEPNS_4NodeES2_NS_13EChildrenOnlyE -
trunk/Source/WebCore/editing/MarkupAccumulator.cpp
r145818 r152685 101 101 } 102 102 103 MarkupAccumulator::MarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs resolveUrlsMethod, const Range* range )103 MarkupAccumulator::MarkupAccumulator(Vector<Node*>* nodes, EAbsoluteURLs resolveUrlsMethod, const Range* range, EFragmentSerialization fragmentSerialization) 104 104 : m_nodes(nodes) 105 105 , m_range(range) 106 106 , m_resolveURLsMethod(resolveUrlsMethod) 107 , m_fragmentSerialization(fragmentSerialization) 107 108 { 108 109 } … … 138 139 if (namespaces) 139 140 namespaceHash = *namespaces; 141 else if (inXMLFragmentSerialization()) { 142 // Make sure xml prefix and namespace are always known to uphold the constraints listed at http://www.w3.org/TR/xml-names11/#xmlReserved. 143 namespaceHash.set(xmlAtom.impl(), XMLNames::xmlNamespaceURI.impl()); 144 namespaceHash.set(XMLNames::xmlNamespaceURI.impl(), xmlAtom.impl()); 145 } 140 146 141 147 if (!childrenOnly) … … 273 279 274 280 // Don't add namespace attributes twice 275 if (attribute.name() == XMLNSNames::xmlnsAttr) { 281 // HTML Parser will create xmlns attributes without namespace for HTML elements, allow those as well. 282 if (attribute.name().localName() == xmlnsAtom && (attribute.namespaceURI().isEmpty() || attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI)) { 276 283 namespaces.set(emptyAtom.impl(), attribute.value().impl()); 277 284 return false; … … 296 303 AtomicStringImpl* pre = prefix.isEmpty() ? emptyAtom.impl() : prefix.impl(); 297 304 AtomicStringImpl* foundNS = namespaces.get(pre); 298 if (foundNS != namespaceURI.impl() ) {305 if (foundNS != namespaceURI.impl() && !namespaces.get(namespaceURI.impl())) { 299 306 namespaces.set(pre, namespaceURI.impl()); 300 307 result.append(' '); … … 422 429 { 423 430 result.append('<'); 431 if (inXMLFragmentSerialization() && namespaces && element->prefix().isEmpty()) { 432 // According to http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#normalizeDocumentAlgo we now should create 433 // a default namespace declaration to make this namespace well-formed. However, http://www.w3.org/TR/xml-names11/#xmlReserved states 434 // "The prefix xml MUST NOT be declared as the default namespace.", so use the xml prefix explicitly. 435 if (element->namespaceURI() == XMLNames::xmlNamespaceURI) { 436 result.append(xmlAtom); 437 result.append(':'); 438 } 439 } 424 440 result.append(element->nodeNamePreservingCase()); 425 if ( !element->document()->isHTMLDocument() && namespaces && shouldAddNamespaceElement(element))441 if ((inXMLFragmentSerialization() || !element->document()->isHTMLDocument()) && namespaces && shouldAddNamespaceElement(element)) 426 442 appendNamespace(result, element->prefix(), element->namespaceURI(), *namespaces); 427 443 } … … 477 493 } 478 494 479 if ( !documentIsHTML&& namespaces && shouldAddNamespaceAttribute(attribute, *namespaces))495 if ((inXMLFragmentSerialization() || !documentIsHTML) && namespaces && shouldAddNamespaceAttribute(attribute, *namespaces)) 480 496 appendNamespace(result, attribute.prefix(), attribute.namespaceURI(), *namespaces); 481 497 } … … 535 551 bool MarkupAccumulator::shouldSelfClose(const Node* node) 536 552 { 537 if ( node->document()->isHTMLDocument())553 if (!inXMLFragmentSerialization() && node->document()->isHTMLDocument()) 538 554 return false; 539 555 if (node->hasChildNodes()) -
trunk/Source/WebCore/editing/MarkupAccumulator.h
r130795 r152685 67 67 class MarkupAccumulator { 68 68 public: 69 MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = 0 );69 MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = 0, EFragmentSerialization = HTMLFragmentSerialization); 70 70 virtual ~MarkupAccumulator(); 71 71 … … 112 112 void appendQuotedURLAttributeValue(StringBuilder&, const Element*, const Attribute&); 113 113 void serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip); 114 bool inXMLFragmentSerialization() const { return m_fragmentSerialization == XMLFragmentSerialization; } 114 115 115 116 StringBuilder m_markup; 116 117 const EAbsoluteURLs m_resolveURLsMethod; 118 EFragmentSerialization m_fragmentSerialization; 117 119 }; 118 120 -
trunk/Source/WebCore/editing/markup.cpp
r152440 r152685 756 756 } 757 757 758 String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip )758 String createMarkup(const Node* node, EChildrenOnly childrenOnly, Vector<Node*>* nodes, EAbsoluteURLs shouldResolveURLs, Vector<QualifiedName>* tagNamesToSkip, EFragmentSerialization fragmentSerialization) 759 759 { 760 760 if (!node) … … 769 769 } 770 770 #endif 771 MarkupAccumulator accumulator(nodes, shouldResolveURLs );771 MarkupAccumulator accumulator(nodes, shouldResolveURLs, 0, fragmentSerialization); 772 772 return accumulator.serializeNodes(const_cast<Node*>(node), deleteButtonContainerElement, childrenOnly, tagNamesToSkip); 773 773 } -
trunk/Source/WebCore/editing/markup.h
r146264 r152685 48 48 enum EChildrenOnly { IncludeNode, ChildrenOnly }; 49 49 enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs }; 50 enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization }; 50 51 51 52 PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text); … … 65 66 66 67 String createMarkup(const Range*, Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs); 67 String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = 0 );68 String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = 0, EFragmentSerialization = HTMLFragmentSerialization); 68 69 69 70 String createFullMarkup(const Node*); -
trunk/Source/WebCore/xml/XMLSerializer.cpp
r127757 r152685 43 43 } 44 44 45 return createMarkup(node );45 return createMarkup(node, IncludeNode, 0, DoNotResolveURLs, 0, XMLFragmentSerialization); 46 46 } 47 47
Note: See TracChangeset
for help on using the changeset viewer.