WebCore:
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jul 2008 04:51:40 +0000 (04:51 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jul 2008 04:51:40 +0000 (04:51 +0000)
        Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives

        <https://bugs.webkit.org/show_bug.cgi?id=15290>
        <rdar://problem/5509173>

        Reviewed by Dan Bernstein.

        Tests: webarchive/archive-empty-frame-dom-expected.txt
               webarchive/doctype.html

        * editing/markup.cpp:
        (WebCore::createFullMarkup): If the Node is a Document or a
        DocumentType, don't prepend the <!DOCTYPE> tag since that will
        cause it to be duplicated.
        * loader/archive/cf/LegacyWebArchive.cpp:
        (WebCore::LegacyWebArchive::create): Ditto.

LayoutTests:

        Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives

        <https://bugs.webkit.org/show_bug.cgi?id=15290>
        <rdar://problem/5509173>

        Reviewed by Dan Bernstein.

        * webarchive/archive-empty-frame-dom-expected.txt: Updated test
        results now that we don't emit two <!DOCTYPE> tags.
        * webarchive/doctype-expected.txt: Added.
        * webarchive/doctype.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35006 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webarchive/archive-empty-frame-dom-expected.txt
LayoutTests/webarchive/doctype-expected.txt [new file with mode: 0644]
LayoutTests/webarchive/doctype.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/markup.cpp
WebCore/loader/archive/cf/LegacyWebArchive.cpp

index a3bf669..ab6e24b 100644 (file)
@@ -1,3 +1,17 @@
+2008-07-04  David D. Kilzer  <ddkilzer@webkit.org>
+
+        Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives
+
+        <https://bugs.webkit.org/show_bug.cgi?id=15290>
+        <rdar://problem/5509173>
+
+        Reviewed by Dan Bernstein.
+
+        * webarchive/archive-empty-frame-dom-expected.txt: Updated test
+        results now that we don't emit two <!DOCTYPE> tags.
+        * webarchive/doctype-expected.txt: Added.
+        * webarchive/doctype.html: Added.
+
 2008-07-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by John Sullivan.
index 913a356..bfb14aa 100644 (file)
@@ -5,7 +5,7 @@
        <key>WebMainResource</key>
        <dict>
                <key>WebResourceData</key>
-               <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;html&gt;&lt;head&gt;
+               <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;html&gt;&lt;head&gt;
 &lt;title&gt;Empty iFrame causes archive exception&lt;/title&gt;
 &lt;script&gt;
     if (window.layoutTestController)
diff --git a/LayoutTests/webarchive/doctype-expected.txt b/LayoutTests/webarchive/doctype-expected.txt
new file mode 100644 (file)
index 0000000..7e778c9
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>WebMainResource</key>
+       <dict>
+               <key>WebResourceData</key>
+               <string>&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Test for Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives&lt;/title&gt;
+&lt;/head&gt;
+&lt;script&gt;
+    if (window.layoutTestController)
+        layoutTestController.dumpSourceAsWebArchive();
+&lt;/script&gt;
+&lt;body&gt;
+&lt;div&gt;
+&lt;a href="https://bugs.webkit.org/show_bug.cgi?id=15290"&gt;Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives&lt;/a&gt;
+&lt;/div&gt;
+&lt;div&gt;
+This test checks that only one &amp;lt;!DOCTYPE&amp;gt; tag is written to a webarchive.
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+</string>
+               <key>WebResourceFrameName</key>
+               <string></string>
+               <key>WebResourceMIMEType</key>
+               <string>text/html</string>
+               <key>WebResourceURL</key>
+               <string>file:///LayoutTests/webarchive/doctype.html</string>
+       </dict>
+</dict>
+</plist>
diff --git a/LayoutTests/webarchive/doctype.html b/LayoutTests/webarchive/doctype.html
new file mode 100644 (file)
index 0000000..d580beb
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test for Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives</title>
+</head>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpSourceAsWebArchive();
+</script>
+<body>
+<div>
+<a href="https://bugs.webkit.org/show_bug.cgi?id=15290">Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives</a>
+</div>
+<div>
+This test checks that only one &lt;!DOCTYPE&gt; tag is written to a webarchive.
+</div>
+</body>
+</html>
index b755615..aa6d0d0 100644 (file)
@@ -1,3 +1,22 @@
+2008-07-04  David D. Kilzer  <ddkilzer@webkit.org>
+
+        Bug 15290: REGRESSION (r14184-r14216): Duplicate DOCTYPE definitions when saving files as webarchives
+
+        <https://bugs.webkit.org/show_bug.cgi?id=15290>
+        <rdar://problem/5509173>
+
+        Reviewed by Dan Bernstein.
+
+        Tests: webarchive/archive-empty-frame-dom-expected.txt
+               webarchive/doctype.html
+
+        * editing/markup.cpp:
+        (WebCore::createFullMarkup): If the Node is a Document or a
+        DocumentType, don't prepend the <!DOCTYPE> tag since that will
+        cause it to be duplicated.
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::create): Ditto.
+
 2008-07-04  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Gtk build fix
index 37fbc85..b067002 100644 (file)
@@ -1187,7 +1187,12 @@ String createFullMarkup(const Node* node)
         return String();
 
     // FIXME: This is never "for interchange". Is that right?    
-    return frame->documentTypeString() + createMarkup(node, IncludeNode, 0);
+    String markupString = createMarkup(node, IncludeNode, 0);
+    Node::NodeType nodeType = node->nodeType();
+    if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
+        markupString = frame->documentTypeString() + markupString;
+
+    return markupString;
 }
 
 String createFullMarkup(const Range* range)
index 50707c0..9d99588 100644 (file)
@@ -415,7 +415,10 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node)
         return create();
         
     Vector<Node*> nodeList;
-    String markupString = frame->documentTypeString() + createMarkup(node, IncludeNode, &nodeList);
+    String markupString = createMarkup(node, IncludeNode, &nodeList);
+    Node::NodeType nodeType = node->nodeType();
+    if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
+        markupString = frame->documentTypeString() + markupString;
 
     return create(markupString, frame, nodeList);
 }