Changeset 153508 in webkit


Ignore:
Timestamp:
Jul 30, 2013 6:59:00 PM (11 years ago)
Author:
rwlbuis@webkit.org
Message:

XMLSerializer should reset default namespace when necessary
https://bugs.webkit.org/show_bug.cgi?id=16739
XMLSerializer's handling of namespaces seems to be pretty broken
https://bugs.webkit.org/show_bug.cgi?id=106531

Reviewed by Ryosuke Niwa.

Source/WebCore:

Write out empty default namespace declaration if the element is not in any namespace, as
described in http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-serialization-algorithm.

Tests: fast/dom/XMLSerializer-element-empty-namespace.html

fast/dom/XMLSerializer-element-empty-namespace2.html

  • editing/MarkupAccumulator.cpp:

(WebCore::MarkupAccumulator::appendNamespace):
(WebCore::MarkupAccumulator::appendOpenTag):

  • editing/MarkupAccumulator.h:

LayoutTests:

Add tests based on the testcases of both bugs.

  • fast/dom/XMLSerializer-element-empty-namespace-expected.txt: Added.
  • fast/dom/XMLSerializer-element-empty-namespace.html: Added.
  • fast/dom/XMLSerializer-element-empty-namespace2-expected.txt: Added.
  • fast/dom/XMLSerializer-element-empty-namespace2.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r153501 r153508  
     12013-07-30  Rob Buis  <rwlbuis@webkit.org>
     2
     3        XMLSerializer should reset default namespace when necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=16739
     5        XMLSerializer's handling of namespaces seems to be pretty broken
     6        https://bugs.webkit.org/show_bug.cgi?id=106531
     7
     8        Reviewed by Ryosuke Niwa.
     9
     10        Add tests based on the testcases of both bugs.
     11
     12        * fast/dom/XMLSerializer-element-empty-namespace-expected.txt: Added.
     13        * fast/dom/XMLSerializer-element-empty-namespace.html: Added.
     14        * fast/dom/XMLSerializer-element-empty-namespace2-expected.txt: Added.
     15        * fast/dom/XMLSerializer-element-empty-namespace2.html: Added.
     16
    1172013-07-30  Alexey Proskuryakov  <ap@apple.com>
    218
  • trunk/Source/WebCore/ChangeLog

    r153507 r153508  
     12013-07-30  Rob Buis  <rwlbuis@webkit.org>
     2
     3        XMLSerializer should reset default namespace when necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=16739
     5        XMLSerializer's handling of namespaces seems to be pretty broken
     6        https://bugs.webkit.org/show_bug.cgi?id=106531
     7
     8        Reviewed by Ryosuke Niwa.
     9
     10        Write out empty default namespace declaration if the element is not in any namespace, as
     11        described in http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-serialization-algorithm.
     12
     13        Tests: fast/dom/XMLSerializer-element-empty-namespace.html
     14               fast/dom/XMLSerializer-element-empty-namespace2.html
     15
     16        * editing/MarkupAccumulator.cpp:
     17        (WebCore::MarkupAccumulator::appendNamespace):
     18        (WebCore::MarkupAccumulator::appendOpenTag):
     19        * editing/MarkupAccumulator.h:
     20
    1212013-07-30  Chris Fleizach  <cfleizach@apple.com>
    222
  • trunk/Source/WebCore/editing/MarkupAccumulator.cpp

    r152785 r153508  
    294294}
    295295
    296 void MarkupAccumulator::appendNamespace(StringBuilder& result, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces& namespaces)
     296void MarkupAccumulator::appendNamespace(StringBuilder& result, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces& namespaces, bool allowEmptyDefaultNS)
    297297{
    298298    namespaces.checkConsistency();
    299     if (namespaceURI.isEmpty())
    300         return;
     299    if (namespaceURI.isEmpty()) {
     300        // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-serialization-algorithm
     301        if (allowEmptyDefaultNS && namespaces.get(emptyAtom.impl())) {
     302            result.append(' ');
     303            result.append(xmlnsAtom.string());
     304            result.appendLiteral("=\"\"");
     305        }
     306        return;
     307    }
    301308
    302309    // Use emptyAtoms's impl() for both null and empty strings since the HashMap can't handle 0 as a key
     
    440447    result.append(element->nodeNamePreservingCase());
    441448    if ((inXMLFragmentSerialization() || !element->document()->isHTMLDocument()) && namespaces && shouldAddNamespaceElement(element))
    442         appendNamespace(result, element->prefix(), element->namespaceURI(), *namespaces);
     449        appendNamespace(result, element->prefix(), element->namespaceURI(), *namespaces, inXMLFragmentSerialization());
    443450}
    444451
  • trunk/Source/WebCore/editing/MarkupAccumulator.h

    r152685 r153508  
    8989    bool shouldAddNamespaceElement(const Element*);
    9090    bool shouldAddNamespaceAttribute(const Attribute&, Namespaces&);
    91     void appendNamespace(StringBuilder&, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces&);
     91    void appendNamespace(StringBuilder&, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces&, bool allowEmptyDefaultNS = false);
    9292    EntityMask entityMaskForText(Text*) const;
    9393    virtual void appendText(StringBuilder&, Text*);
Note: See TracChangeset for help on using the changeset viewer.