Diff
Modified: trunk/LayoutTests/ChangeLog (124209 => 124210)
--- trunk/LayoutTests/ChangeLog 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/LayoutTests/ChangeLog 2012-07-31 16:02:14 UTC (rev 124210)
@@ -1,3 +1,24 @@
+2012-07-31 Stephen Chenney <schen...@chromium.org>
+
+ xmlserializer strips xlink from xlink:html svg image tag
+ https://bugs.webkit.org/show_bug.cgi?id=79586
+
+ Reviewed by Nikolas Zimmermann.
+
+ 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.
+
2012-07-31 Mike Reed <r...@google.com>
skia: switch to conical gradient to match css/svg spec for two-point gradients
Modified: trunk/LayoutTests/editing/pasteboard/paste-noscript-svg-expected.txt (124209 => 124210)
--- trunk/LayoutTests/editing/pasteboard/paste-noscript-svg-expected.txt 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/LayoutTests/editing/pasteboard/paste-noscript-svg-expected.txt 2012-07-31 16:02:14 UTC (rev 124210)
@@ -1,5 +1,5 @@
This test copies the content of an iframe and pastes it in an editable area and verifies that no script, handlers or _javascript_ urls are copied.
Hello
world
-<div id="div1">Hello</div><svg xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" width="5cm" height="3cm" viewBox="0 0 5 3" version="1.1"><a href="" cx="2.5" cy="1.5" rx="2" ry="1" fill="red"></ellipse></a></svg><div id="div2">world</div>
+<div id="div1">Hello</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="5cm" height="3cm" viewBox="0 0 5 3" version="1.1"><a xlink:href="" cx="2.5" cy="1.5" rx="2" ry="1" fill="red"></ellipse></a></svg><div id="div2">world</div>
Added: trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace-expected.txt (0 => 124210)
--- trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace-expected.txt 2012-07-31 16:02:14 UTC (rev 124210)
@@ -0,0 +1,2 @@
+<div id="target"> <div id="output"> </div><foo xml:space="preserve"></foo><bar xml:space="default"></bar></div>
+
Added: trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace.html (0 => 124210)
--- trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace.html (rev 0)
+++ trunk/LayoutTests/fast/dom/XMLSerializer-xml-namespace.html 2012-07-31 16:02:14 UTC (rev 124210)
@@ -0,0 +1,35 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <script type="text/_javascript_">
+ function runTest()
+ {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var target = document.getElementById("target");
+
+ var xmlns = "http://www.w3.org/XML/1998/namespace";
+
+ // XML with correct xml prefix on space
+ var xml1 = document.createElementNS(xmlns, "foo");
+ xml1.setAttributeNS(xmlns, 'xml:space', 'preserve');
+
+ var xml2 = document.createElementNS(xmlns, "bar");
+ xml2.setAttributeNS(xmlns, 'space', 'default');
+
+ target.appendChild(xml1);
+ target.appendChild(xml2);
+
+ var serializer = new XMLSerializer();
+ var xmlString = serializer.serializeToString(target);
+
+ var outputText = document.getElementById("output");
+ outputText.textContent = xmlString;
+ }
+ </script>
+</head>
+ <body _onload_="runTest()">
+ <div id="target"/>
+ <div id="output"/>
+ </body>
+</html>
Added: trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes-expected.txt (0 => 124210)
--- trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes-expected.txt 2012-07-31 16:02:14 UTC (rev 124210)
@@ -0,0 +1,2 @@
+<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="" x="0" y="30" width="20" height="20" xlink:href=""
+
Added: trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes.html (0 => 124210)
--- trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes.html (rev 0)
+++ trunk/LayoutTests/svg/custom/xlink-prefix-in-attributes.html 2012-07-31 16:02:14 UTC (rev 124210)
@@ -0,0 +1,53 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <script type="text/_javascript_">
+ function runTest()
+ {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var target = document.getElementById("target");
+
+ var svgns = "http://www.w3.org/2000/svg";
+ var xmlnsns = "http://www.w3.org/2000/xmlns/";
+ var xlinkns = "http://www.w3.org/1999/xlink";
+
+ // SVG with correct xmlns prefix on xlink
+ var svg = document.createElementNS(svgns, "svg");
+ svg.setAttributeNS(xmlnsns, 'xmlns', svgns);
+ svg.setAttributeNS(null, "svg", svgns);
+ svg.setAttributeNS(xmlnsns, "xmlns:xlink", xlinkns);
+ svg.setAttributeNS(null, "width", "200");
+ svg.setAttributeNS(null, "height", "200");
+
+ // Already correct xlink:href
+ var image = document.createElementNS(svgns, "image");
+ image.setAttributeNS(null, "width", "20");
+ image.setAttributeNS(null, "height", "20");
+ image.setAttributeNS(xlinkns, "xlink:href", "resources/green-checker.png");
+ svg.appendChild(image);
+
+ // Missing prefix from href. Must be added when serialized.
+ var image = document.createElementNS(svgns, "image");
+ image.setAttributeNS(null, "x", "0");
+ image.setAttributeNS(null, "y", "30");
+ image.setAttributeNS(null, "width", "20");
+ image.setAttributeNS(null, "height", "20");
+ image.setAttributeNS(xlinkns, "href", "resources/green-checker.png");
+ svg.appendChild(image);
+
+ target.appendChild(svg);
+
+ var serializer = new XMLSerializer();
+ var xmlString = serializer.serializeToString(target);
+
+ var svgText = document.getElementById("svgoutput");
+ svgText.textContent = xmlString;
+ }
+ </script>
+</head>
+ <body _onload_="runTest()">
+ <div id="target"/>
+ <div id="svgoutput"/>
+ </body>
+</html>
Modified: trunk/Source/WTF/ChangeLog (124209 => 124210)
--- trunk/Source/WTF/ChangeLog 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WTF/ChangeLog 2012-07-31 16:02:14 UTC (rev 124210)
@@ -1,3 +1,18 @@
+2012-07-31 Stephen Chenney <schen...@chromium.org>
+
+ xmlserializer strips xlink from xlink:html svg image tag
+ https://bugs.webkit.org/show_bug.cgi?id=79586
+
+ Reviewed by Nikolas Zimmermann.
+
+ 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.
+
2012-07-30 Patrick Gansterer <par...@webkit.org>
Add WTF_EXPORT_PRIVATE to deleteOwnedPtr()
Modified: trunk/Source/WTF/wtf/text/AtomicString.h (124209 => 124210)
--- trunk/Source/WTF/wtf/text/AtomicString.h 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WTF/wtf/text/AtomicString.h 2012-07-31 16:02:14 UTC (rev 124210)
@@ -210,6 +210,7 @@
extern const WTF_EXPORTDATA AtomicString starAtom;
extern const WTF_EXPORTDATA AtomicString xmlAtom;
extern const WTF_EXPORTDATA AtomicString xmlnsAtom;
+extern const WTF_EXPORTDATA AtomicString xlinkAtom;
inline AtomicString AtomicString::fromUTF8(const char* characters, size_t length)
{
@@ -247,6 +248,7 @@
using WTF::starAtom;
using WTF::xmlAtom;
using WTF::xmlnsAtom;
+using WTF::xlinkAtom;
#endif
#include <wtf/text/StringConcatenate.h>
Modified: trunk/Source/WTF/wtf/text/StringStatics.cpp (124209 => 124210)
--- trunk/Source/WTF/wtf/text/StringStatics.cpp 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WTF/wtf/text/StringStatics.cpp 2012-07-31 16:02:14 UTC (rev 124210)
@@ -59,6 +59,7 @@
WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, starAtom, "*")
WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xmlAtom, "xml")
WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xmlnsAtom, "xmlns")
+WTF_EXPORTDATA DEFINE_GLOBAL(AtomicString, xlinkAtom, "xlink")
NEVER_INLINE unsigned StringImpl::hashSlowCase() const
{
@@ -84,6 +85,7 @@
new (NotNull, (void*)&starAtom) AtomicString("*");
new (NotNull, (void*)&xmlAtom) AtomicString("xml");
new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns");
+ new (NotNull, (void*)&xlinkAtom) AtomicString("xlink");
initialized = true;
}
Modified: trunk/Source/WebCore/ChangeLog (124209 => 124210)
--- trunk/Source/WebCore/ChangeLog 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WebCore/ChangeLog 2012-07-31 16:02:14 UTC (rev 124210)
@@ -1,3 +1,29 @@
+2012-07-31 Stephen Chenney <schen...@chromium.org>
+
+ xmlserializer strips xlink from xlink:html svg image tag
+ https://bugs.webkit.org/show_bug.cgi?id=79586
+
+ Reviewed by Nikolas Zimmermann.
+
+ 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.
+
2012-07-31 Mike Reed <r...@google.com>
skia: switch to conical gradient to match css/svg spec for two-point gradients
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (124209 => 124210)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-07-31 16:02:14 UTC (rev 124210)
@@ -36,7 +36,9 @@
#include "HTMLNames.h"
#include "KURL.h"
#include "ProcessingInstruction.h"
+#include "XLinkNames.h"
#include "XMLNSNames.h"
+#include "XMLNames.h"
#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
@@ -418,16 +420,35 @@
result.append('>');
}
+static inline bool attributeIsInSerializedNamespace(const Attribute& attribute)
+{
+ return attribute.namespaceURI() == XMLNames::xmlNamespaceURI
+ || attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI
+ || attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI;
+}
+
void MarkupAccumulator::appendAttribute(StringBuilder& result, Element* element, const Attribute& attribute, Namespaces* namespaces)
{
bool documentIsHTML = element->document()->isHTMLDocument();
result.append(' ');
- if (documentIsHTML)
+ if (documentIsHTML && !attributeIsInSerializedNamespace(attribute))
result.append(attribute.name().localName());
- else
- result.append(attribute.name().toString());
+ else {
+ QualifiedName prefixedName = attribute.name();
+ if (attribute.namespaceURI() == XLinkNames::xlinkNamespaceURI) {
+ if (attribute.prefix() != xlinkAtom)
+ prefixedName.setPrefix(xlinkAtom);
+ } else if (attribute.namespaceURI() == XMLNames::xmlNamespaceURI) {
+ if (attribute.prefix() != xmlAtom)
+ prefixedName.setPrefix(xmlAtom);
+ } else if (attribute.namespaceURI() == XMLNSNames::xmlnsNamespaceURI) {
+ if (attribute.name() != XMLNSNames::xmlnsAttr && attribute.prefix() != xmlnsAtom)
+ prefixedName.setPrefix(xmlnsAtom);
+ }
+ result.append(prefixedName.toString());
+ }
result.append('=');
Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (124209 => 124210)
--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2012-07-31 15:55:48 UTC (rev 124209)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp 2012-07-31 16:02:14 UTC (rev 124210)
@@ -710,14 +710,15 @@
static PrefixedNameToQualifiedNameMap* map = 0;
if (!map) {
map = new PrefixedNameToQualifiedNameMap;
+
QualifiedName** attrs = XLinkNames::getXLinkAttrs();
- addNamesWithPrefix(map, "xlink", attrs, XLinkNames::XLinkAttrsCount);
+ addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount);
attrs = XMLNames::getXMLAttrs();
- addNamesWithPrefix(map, "xml", attrs, XMLNames::XMLAttrsCount);
+ addNamesWithPrefix(map, xmlAtom, attrs, XMLNames::XMLAttrsCount);
- map->add("xmlns", XMLNSNames::xmlnsAttr);
- map->add("xmlns:xlink", QualifiedName("xmlns", "xlink", XMLNSNames::xmlnsNamespaceURI));
+ map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
+ map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::xmlnsNamespaceURI));
}
for (unsigned i = 0; i < token->attributes().size(); ++i) {