[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ojan at chromium.org ojan at chromium.org
Wed Dec 22 11:34:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 155867571990cd70d65eb7f01124f4f53c1e71ba
Author: ojan at chromium.org <ojan at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 29 20:16:52 2010 +0000

    2010-07-27  Ojan Vafai  <ojan at chromium.org>
    
            Reviewed by Adam Barth.
    
            dump-as-markup should have better output
            https://bugs.webkit.org/show_bug.cgi?id=43015
    
            -Merge dom2string into dump-as-markup and pull over all dom2string features (e.g. indent).
            -#-prefix selection markers
    
            * editing/deleting/delete-br-in-last-table-cell-expected.txt:
            * editing/execCommand/crash-indenting-list-item-expected.txt:
            * editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt:
            * editing/execCommand/create-list-from-range-selection-expected.txt:
            * editing/execCommand/hilitecolor-expected.txt:
            * editing/execCommand/indent-pre-expected.txt:
            * editing/execCommand/insert-list-empty-div-expected.txt:
            * editing/selection/dump-as-markup-expected.txt:
            * editing/selection/dump-as-markup.html:
            * editing/selection/home-inside-noneditable-table-expected.txt:
            * editing/style/remove-underline-from-stylesheet-expected.txt:
            * editing/style/style-text-node-without-editable-parent-expected.txt:
            * editing/undo/redo-split-text-node-expected.txt:
            * editing/undo/redo-split-text-with-removal-expected.txt:
            * html5lib/resources/dom2string.js: Removed.
            * html5lib/resources/tests4.dat:
            * html5lib/resources/tests6.dat:
            * html5lib/runner-expected.txt:
            * html5lib/runner.html:
            * html5lib/webkit-resumer.html:
            * resources/dump-as-markup.js:
            (Markup.notifyDone):
            (Markup._get):
            (Markup._namespace):
            (Markup._dumpCalls.0.Markup._indent):
            (Markup._toAsciiLowerCase):
            (Markup._getMarkupForTextNode):
            (Markup._getSelectionMarker):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64303 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b0a615e..309dc56 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,42 @@
+2010-07-27  Ojan Vafai  <ojan at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        dump-as-markup should have better output
+        https://bugs.webkit.org/show_bug.cgi?id=43015
+
+        -Merge dom2string into dump-as-markup and pull over all dom2string features (e.g. indent).
+        -#-prefix selection markers
+
+        * editing/deleting/delete-br-in-last-table-cell-expected.txt:
+        * editing/execCommand/crash-indenting-list-item-expected.txt:
+        * editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt:
+        * editing/execCommand/create-list-from-range-selection-expected.txt:
+        * editing/execCommand/hilitecolor-expected.txt:
+        * editing/execCommand/indent-pre-expected.txt:
+        * editing/execCommand/insert-list-empty-div-expected.txt:
+        * editing/selection/dump-as-markup-expected.txt:
+        * editing/selection/dump-as-markup.html:
+        * editing/selection/home-inside-noneditable-table-expected.txt:
+        * editing/style/remove-underline-from-stylesheet-expected.txt:
+        * editing/style/style-text-node-without-editable-parent-expected.txt:
+        * editing/undo/redo-split-text-node-expected.txt:
+        * editing/undo/redo-split-text-with-removal-expected.txt:
+        * html5lib/resources/dom2string.js: Removed.
+        * html5lib/resources/tests4.dat:
+        * html5lib/resources/tests6.dat:
+        * html5lib/runner-expected.txt:
+        * html5lib/runner.html:
+        * html5lib/webkit-resumer.html:
+        * resources/dump-as-markup.js:
+        (Markup.notifyDone):
+        (Markup._get):
+        (Markup._namespace):
+        (Markup._dumpCalls.0.Markup._indent):
+        (Markup._toAsciiLowerCase):
+        (Markup._getMarkupForTextNode):
+        (Markup._getSelectionMarker):
+
 2010-07-29  Victor Wang  <victorw at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/LayoutTests/editing/deleting/delete-br-in-last-table-cell-expected.txt b/LayoutTests/editing/deleting/delete-br-in-last-table-cell-expected.txt
index da61d09..d4d68f3 100644
--- a/LayoutTests/editing/deleting/delete-br-in-last-table-cell-expected.txt
+++ b/LayoutTests/editing/deleting/delete-br-in-last-table-cell-expected.txt
@@ -1,83 +1,79 @@
-
-<HTML>
-<HEAD>
-<#text>
-</#text>
-<SCRIPT src="../../resources/dump-as-markup.js" type="text/JavaScript"></SCRIPT>
-<#text>
-</#text>
-<SCRIPT src="../editing.js" type="text/JavaScript"></SCRIPT>
-<#text>
-</#text>
-<SCRIPT>
+| <html>
+|   <head>
+|     "
+"
+|     <script>
+|       language="JavaScript"
+|       src="../../resources/dump-as-markup.js"
+|       type="text/JavaScript"
+|     "
+"
+|     <script>
+|       language="JavaScript"
+|       src="../editing.js"
+|       type="text/JavaScript"
+|     "
+"
+|     <script>
+|       "
 function runTest()
 {
-br = document.getElementById("lastBR");
-sel = window.getSelection();
-sel.setBaseAndExtent(br, 0, br, 0);
-deleteCommand();
+    br = document.getElementById("lastBR");
+    sel = window.getSelection();
+    sel.setBaseAndExtent(br, 0, br, 0);
+    deleteCommand();
 }
-</SCRIPT>
-<#text>
-</#text>
-</HEAD>
-<#text>
+"
+|     "
+"
+|   "
 
-</#text>
-<BODY>
-<#text>
-</#text>
-<P>
-<A href="https://bugs.webkit.org/show_bug.cgi?id=35369">
-<#text>Bug 35369</#text>
-</A>
-<#text> and </#text>
-<A href="https://bugs.webkit.org/show_bug.cgi?id=35632">
-<#text>Bug 35632</#text>
-</A>
-</P>
-<#text>
-</#text>
-<P>
-<#text>Executing a delete command when positioned before a BR in a table cell (esp. the last)</#text>
-</P>
-<#text>
-</#text>
-<DIV contentEditable="">
-<#text>
-</#text>
-<TABLE id="table">
-<TBODY>
-<TR>
-<TD>
-<#text>1</#text>
-</TD>
-<TD>
-<#text>2</#text>
-</TD>
-</TR>
-<TR>
-<TD>
-<#text>3</#text>
-</TD>
-<TD>
-<#text>4<selection-caret></#text>
-<BR id="lastBR">
-</TD>
-</TR>
-</TBODY>
-</TABLE>
-<#text>
-</#text>
-</DIV>
-<#text>
-</#text>
-<SCRIPT>
+"
+|   <body>
+|     "
+"
+|     <p>
+|       <a>
+|         href="https://bugs.webkit.org/show_bug.cgi?id=35369"
+|         "Bug 35369"
+|       " and "
+|       <a>
+|         href="https://bugs.webkit.org/show_bug.cgi?id=35632"
+|         "Bug 35632"
+|     "
+"
+|     <p>
+|       "Executing a delete command when positioned before a BR in a table cell (esp. the last)"
+|     "
+"
+|     <div>
+|       contenteditable=""
+|       "
+"
+|       <table>
+|         id="table"
+|         <tbody>
+|           <tr>
+|             <td>
+|               "1"
+|             <td>
+|               "2"
+|           <tr>
+|             <td>
+|               "3"
+|             <td>
+|               "4<#selection-caret>"
+|               <br>
+|                 id="lastBR"
+|       "
+"
+|     "
+"
+|     <script>
+|       "
 runTest();
-</SCRIPT>
-<#text>
+"
+|     "
 
 
-</#text>
-</BODY>
-</HTML>
+"
diff --git a/LayoutTests/editing/execCommand/crash-indenting-list-item-expected.txt b/LayoutTests/editing/execCommand/crash-indenting-list-item-expected.txt
index d349d57..f5e7882 100644
--- a/LayoutTests/editing/execCommand/crash-indenting-list-item-expected.txt
+++ b/LayoutTests/editing/execCommand/crash-indenting-list-item-expected.txt
@@ -1,29 +1,25 @@
-
-<HTML>
-<HEAD>
-</HEAD>
-<BODY>
-<DIV contentEditable="">
-<UL>
-<UL>
-<LI id="foo">
-<#text>PASSED</#text>
-</LI>
-</UL>
-</UL>
-</DIV>
-<#text>
-</#text>
-<SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
-<#text>
-</#text>
-<SCRIPT>
+| <html>
+|   <head>
+|   <body>
+|     <div>
+|       contenteditable=""
+|       <ul>
+|         <ul>
+|           <li>
+|             id="foo"
+|             "PASSED"
+|     "
+"
+|     <script>
+|       src="../../resources/dump-as-markup.js"
+|     "
+"
+|     <script>
+|       "
 window.getSelection().setBaseAndExtent(foo, 0, foo, 0);
 // This test passes if it does not crash.
 document.execCommand('indent', false, null);
 document.getElementById("foo").innerText = "PASSED";
-</SCRIPT>
-<#text>
-</#text>
-</BODY>
-</HTML>
+"
+|     "
+"
diff --git a/LayoutTests/editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt b/LayoutTests/editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt
index d6c06e6..4a9bf15 100644
--- a/LayoutTests/editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt
+++ b/LayoutTests/editing/execCommand/crash-on-enter-in-contentEditable-list-expected.txt
@@ -1,34 +1,32 @@
-
-<HTML>
-<HEAD>
-<SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
-<#text>
-</#text>
-</HEAD>
-<BODY>
-<DIV>
-<#text>This test passes if it doesn't crash.</#text>
-</DIV>
-<#text>
-</#text>
-<UL contentEditable="">
-<#text>
-</#text>
-<LI id="foo">
-</LI>
-<LI id="foo"><selection-caret>
-<BR>
-</LI>
-<#text>
-</#text>
-</UL>
-<#text>
-</#text>
-<SCRIPT>
+| <html>
+|   <head>
+|     <script>
+|       src="../../resources/dump-as-markup.js"
+|     "
+"
+|   <body>
+|     <div>
+|       "This test passes if it doesn't crash."
+|     "
+"
+|     <ul>
+|       contenteditable=""
+|       "
+    "
+|       <li>
+|         id="foo"
+|       <li>
+|         id="foo"
+|         <#selection-caret>
+|         <br>
+|       "
+"
+|     "
+"
+|     <script>
+|       "
 window.getSelection().selectAllChildren(foo);
 document.execCommand('insertParagraph');
-</SCRIPT>
-<#text>
-</#text>
-</BODY>
-</HTML>
+"
+|     "
+"
diff --git a/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt b/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt
index 4fc5e36..472ca10 100644
--- a/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt
+++ b/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt
@@ -1,26 +1,16 @@
-
-<DIV id="test" contentEditable="true">
-<OL>
-<LI>
-<#text>asd</#text>
-<SPAN id="start">
-<#text>fo<selection-anchor>o</#text>
-</SPAN>
-</LI>
-<LI>
-<#text>bar</#text>
-</LI>
-<LI>
-<#text>baz</#text>
-</LI>
-<LI>
-<#text>foo</#text>
-</LI>
-<LI>
-<#text>bar</#text>
-</LI>
-<LI>
-<#text>ba<selection-focus>z</#text>
-</LI>
-</OL>
-</DIV>
+| <ol>
+|   <li>
+|     "asd"
+|     <span>
+|       id="start"
+|       "fo<#selection-anchor>o"
+|   <li>
+|     "bar"
+|   <li>
+|     "baz"
+|   <li>
+|     "foo"
+|   <li>
+|     "bar"
+|   <li>
+|     "ba<#selection-focus>z"
diff --git a/LayoutTests/editing/execCommand/hilitecolor-expected.txt b/LayoutTests/editing/execCommand/hilitecolor-expected.txt
index d1aadf1..d84f2a1 100644
--- a/LayoutTests/editing/execCommand/hilitecolor-expected.txt
+++ b/LayoutTests/editing/execCommand/hilitecolor-expected.txt
@@ -10,11 +10,9 @@ EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
-
-<DIV id="test" contentEditable="true">
-<#text><selection-caret>The </#text>
-<SPAN style="background-color: red;" class="Apple-style-span">
-<#text>second</#text>
-</SPAN>
-<#text> word, and only the second word of this sentence should have a red background color.</#text>
-</DIV>
+| "<#selection-caret>The "
+| <span>
+|   class="Apple-style-span"
+|   style="background-color: red;"
+|   "second"
+| " word, and only the second word of this sentence should have a red background color."
diff --git a/LayoutTests/editing/execCommand/indent-pre-expected.txt b/LayoutTests/editing/execCommand/indent-pre-expected.txt
index 5805289..a0df82b 100644
--- a/LayoutTests/editing/execCommand/indent-pre-expected.txt
+++ b/LayoutTests/editing/execCommand/indent-pre-expected.txt
@@ -1,136 +1,133 @@
 CONSOLE MESSAGE: line 44: Wrong node selected.
 CONSOLE MESSAGE: line 46: Wrong anchor offset: 8 instead of 0
+| <html>
+|   <head>
+|   <body>
+|     <p>
+|       "This test tries to indent lines within pre tags.  This test passes if it
+does not crash."
+|     "
+"
+|     <div>
+|       contenteditable=""
+|       "
+"
+|       <blockquote>
+|         class="webkit-indent-blockquote"
+|         style="margin: 0 0 0 40px; border: none; padding: 0px;"
+|         <pre>
+|           id="pre-basic"
+|           "line one
+"
+|       <pre>
+|         id="pre-basic"
+|         "line two
+"
+|       <blockquote>
+|         class="webkit-indent-blockquote"
+|         style="margin: 0 0 0 40px; border: none; padding: 0px;"
+|         <pre>
+|           id="pre-basic"
+|           "line three
+"
+|         <pre>
+|           id="pre-basic"
+|           "line four"
+|       "
 
-<HTML>
-<HEAD>
-</HEAD>
-<BODY>
-<P>
-<#text>This test tries to indent lines within pre tags. This test passes if it
-does not crash.</#text>
-</P>
-<#text>
-</#text>
-<DIV contentEditable="">
-<#text>
-</#text>
-<BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
-<PRE id="pre-basic">
-<#text>line one
-</#text>
-</PRE>
-</BLOCKQUOTE>
-<PRE id="pre-basic">
-<#text>line two
-</#text>
-</PRE>
-<BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
-<PRE id="pre-basic">
-<#text>line three
-</#text>
-</PRE>
-<PRE id="pre-basic">
-<#text>line four</#text>
-</PRE>
-</BLOCKQUOTE>
-<#text>
+"
+|       <ul>
+|         <li>
+|           <pre>
+|             id="pre-list"
+|             "list one
+"
+|             <blockquote>
+|               class="webkit-indent-blockquote"
+|               style="margin: 0 0 0 40px; border: none; padding: 0px;"
+|               "list two
+"
+|               "list three
+"
+|             "list four
+"
+|       "
 
-</#text>
-<UL>
-<LI>
-<PRE id="pre-list">
-<#text>list one
-</#text>
-<BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
-<#text>list two
-</#text>
-<#text>list three
-</#text>
-</BLOCKQUOTE>
-<#text>list four
-</#text>
-</PRE>
-</LI>
-</UL>
-<#text>
+"
+|       <table>
+|         "
+"
+|         <tbody>
+|           <tr>
+|             <td>
+|               <pre>
+|                 id="pre-table"
+|                 "table one<#selection-anchor>
+"
+|               <blockquote>
+|                 class="webkit-indent-blockquote"
+|                 style="margin: 0 0 0 40px; border: none; padding: 0px;"
+|                 <pre>
+|                   id="pre-table"
+|                   "table two
+"
+|                 <pre>
+|                   id="pre-table"
+|                   "table three<#selection-focus>"
+|             <td>
+|               "right cell"
+|       "
 
-</#text>
-<TABLE>
-<#text>
-</#text>
-<TBODY>
-<TR>
-<TD>
-<PRE id="pre-table">
-<#text>table one<selection-anchor>
-</#text>
-</PRE>
-<BLOCKQUOTE style="margin: 0 0 0 40px; border: none; padding: 0px;" class="webkit-indent-blockquote">
-<PRE id="pre-table">
-<#text>table two
-</#text>
-</PRE>
-<PRE id="pre-table">
-<#text>table three<selection-focus></#text>
-</PRE>
-</BLOCKQUOTE>
-</TD>
-<TD>
-<#text>right cell</#text>
-</TD>
-</TR>
-</TBODY>
-</TABLE>
-<#text>
+"
+|       <div>
+|         id="results"
+|         "PASSED (did not crash)"
+|       "
+"
+|     "
 
-</#text>
-<DIV id="results">
-<#text>PASSED (did not crash)</#text>
-</DIV>
-<#text>
-</#text>
-</DIV>
-<#text>
-
-</#text>
-<A href="javascript:document.execCommand('indent')">
-<#text>indent</#text>
-</A>
-<#text>
-</#text>
-<A href="javascript:document.execCommand('outdent')">
-<#text>outdent</#text>
-</A>
-<#text>
-</#text>
-<SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
-<#text>
-</#text>
-<SCRIPT src="../editing.js"></SCRIPT>
-<#text>
-</#text>
-<SCRIPT>
+"
+|     <a>
+|       href="javascript:document.execCommand('indent')"
+|       "indent"
+|     "
+"
+|     <a>
+|       href="javascript:document.execCommand('outdent')"
+|       "outdent"
+|     "
+"
+|     <script>
+|       src="../../resources/dump-as-markup.js"
+|     "
+"
+|     <script>
+|       src="../editing.js"
+|     "
+"
+|     <script>
+|       "
 function setSelection(node)
 {
-var textNode = node.firstChild;
-if (textNode.nodeType != Node.TEXT_NODE)
-throw "Wrong node type: " + textNode;
-execSetSelectionCommand(textNode, 0, 0);
+    var textNode = node.firstChild;
+    if (textNode.nodeType != Node.TEXT_NODE)
+        throw "Wrong node type: " + textNode;
+    execSetSelectionCommand(textNode, 0, 0);
 }
 
 function verifyTextSelection(startNode, startOffset, endNode, endOffset)
 {
-if (startNode.nodeType != Node.TEXT_NODE)
-console.log("Wrong start node type: " + startNode);
-if (endNode.nodeType != Node.TEXT_NODE)
-console.log("Wrong end node type: " + endNode);
-var sel = window.getSelection();
-if (sel.anchorNode != startNode || sel.focusNode != endNode)
-console.log("Wrong node selected.");
-if (sel.anchorOffset != startOffset)
-console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
-if (sel.focusOffset != endOffset)
-console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
+    if (startNode.nodeType != Node.TEXT_NODE)
+        console.log("Wrong start node type: " + startNode);
+    if (endNode.nodeType != Node.TEXT_NODE)
+        console.log("Wrong end node type: " + endNode);
+    var sel = window.getSelection();
+    if (sel.anchorNode != startNode || sel.focusNode != endNode)
+        console.log("Wrong node selected.");
+    if (sel.anchorOffset != startOffset)
+        console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
+    if (sel.focusOffset != endOffset)
+        console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
 }
 
 // Indent a single line in a pre and make sure the selection is correctly preserved.
@@ -140,7 +137,7 @@ execMoveSelectionForwardByCharacterCommand();
 execExtendSelectionForwardByWordCommand();
 document.execCommand("indent");
 verifyTextSelection(document.getElementsByTagName("pre")[0].firstChild, 1,
-document.getElementsByTagName("pre")[0].firstChild, 4);
+                    document.getElementsByTagName("pre")[0].firstChild, 4);
 
 // Indent 2 lines.
 setSelection(pre);
@@ -149,12 +146,12 @@ execExtendSelectionForwardByLineCommand();
 execExtendSelectionForwardByWordCommand();
 document.execCommand("indent");
 if (document.getElementsByTagName("pre").length > 3) {
-// FIXME: The selection for the anchorNode is wrong. It should stay at
-// the beginning of "line three", but it moves to the end of "line 2".
-verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
-document.getElementsByTagName("pre")[3].firstChild, 4);
+    // FIXME: The selection for the anchorNode is wrong.  It should stay at
+    // the beginning of "line three", but it moves to the end of "line 2".
+    verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
+                        document.getElementsByTagName("pre")[3].firstChild, 4);
 } else {
-console.log("Wrong number of pre nodes.");
+    console.log("Wrong number of pre nodes.");
 }
 
 // Indent <pre> lines in a list.
@@ -165,19 +162,17 @@ execExtendSelectionForwardByLineCommand();
 execExtendSelectionForwardByLineCommand();
 document.execCommand("indent");
 verifyTextSelection(document.getElementsByTagName("blockquote")[2].firstChild, 0,
-document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
+                    document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
 // Indenting <pre> lines in a table.
 pre = document.getElementById("pre-table");
 setSelection(pre);
 execMoveSelectionForwardByLineCommand();
 execExtendSelectionForwardByLineCommand();
 execExtendSelectionForwardByLineCommand();
-// FIXME: This is wrong. The pre tags get copied when they shouldn't be. 
+// FIXME: This is wrong.  The pre tags get copied when they shouldn't be. 
 // See https://bugs.webkit.org/show_bug.cgi?id=42009
 document.execCommand("indent");
 document.getElementById("results").innerText = "PASSED (did not crash)";
-</SCRIPT>
-<#text>
-</#text>
-</BODY>
-</HTML>
+"
+|     "
+"
diff --git a/LayoutTests/editing/execCommand/insert-list-empty-div-expected.txt b/LayoutTests/editing/execCommand/insert-list-empty-div-expected.txt
index aef2ae9..d07245c 100644
--- a/LayoutTests/editing/execCommand/insert-list-empty-div-expected.txt
+++ b/LayoutTests/editing/execCommand/insert-list-empty-div-expected.txt
@@ -1,8 +1,4 @@
-
-<DIV id="div" contentEditable="true">
-<UL>
-<LI><selection-caret>
-<BR>
-</LI>
-</UL>
-</DIV>
+| <ul>
+|   <li>
+|     <#selection-caret>
+|     <br>
diff --git a/LayoutTests/editing/selection/dump-as-markup-expected.txt b/LayoutTests/editing/selection/dump-as-markup-expected.txt
index 43d18e2..b816901 100644
--- a/LayoutTests/editing/selection/dump-as-markup-expected.txt
+++ b/LayoutTests/editing/selection/dump-as-markup-expected.txt
@@ -1,93 +1,86 @@
 Tests basic dump-as-markup functionality.
+| <!DOCTYPE html>
+| <html>
+|   <head>
+|     <script>
+|       src="../../resources/dump-as-markup.js"
+|     "
 
-<HTML>
-<HEAD>
-<SCRIPT src="../../resources/dump-as-markup.js"></SCRIPT>
-<#text>
+"
+|   <body>
+|     <div>
+|       id="bar"
+|       "<#selection-anchor>foo"
+|       <hr>
+|       <#selection-focus>
+|     "
+"
+|     <input>
+|       type="text"
+|     "
+"
+|     <div>
+|       contenteditable=""
+|       id="foo"
+|       "
+  foo"
+|       "   bar
+"
+|     "
+"
+|     <script>
+|       "foo.firstChild.splitText(6);"
+|     "
+"
+|     <span>
+|       "foo"
+|     <span>
+|       "bar"
+|     "
+"
+|     <div>
+|       <div>
+|         <b>
+|           "sdf"
+|         <i>
+|           "sdf"
+|         "sdf"
+|     "
+"
+|     <iframe>
+|       src="data:text/html;charset=utf-8,<!DOCTYPE%20HTML%20PUBLIC%20"-//W3C//DTD%20HTML%204.0//EN">%0D%0A<html%20lang%3D"en">%0D%0A%20<head>%0D%0A%20%20<title>Test</title>%0D%0A%20%20<style%20type%3D"text/css">%0D%0A%20%20</style>%0D%0A%20</head>%0D%0A%20<body>%0D%0A%20%20<p></p>%0D%0A%20</body>%0D%0A</html>%0D%0A"
+|     "
 
-</#text>
-</HEAD>
-<BODY>
-<DIV id="bar">
-<#text><selection-anchor>foo</#text>
-<HR><selection-focus>
-</DIV>
-<#text>
-</#text>
-<INPUT type="text">
-<#text>
-</#text>
-<DIV id="foo" contentEditable="">
-<#text>
-foo</#text>
-<#text> bar
-</#text>
-</DIV>
-<#text>
-</#text>
-<SCRIPT>foo.firstChild.splitText(6);</SCRIPT>
-<#text>
-</#text>
-<SPAN>
-<#text>foo</#text>
-</SPAN>
-<SPAN>
-<#text>bar</#text>
-</SPAN>
-<#text>
-</#text>
-<DIV>
-<DIV>
-<B>
-<#text>sdf</#text>
-</B>
-<I>
-<#text>sdf</#text>
-</I>
-<#text>sdf</#text>
-</DIV>
-</DIV>
-<#text>
-</#text>
-<IFRAME src="data:text/html;charset=utf-8,<!DOCTYPE%20HTML%20PUBLIC%20"-//W3C//DTD%20HTML%204.0//EN">%0D%0A<html%20lang%3D"en">%0D%0A%20<head>%0D%0A%20%20<title>Test</title>%0D%0A%20%20<style%20type%3D"text/css">%0D%0A%20%20</style>%0D%0A%20</head>%0D%0A%20<body>%0D%0A%20%20<p></p>%0D%0A%20</body>%0D%0A</html>%0D%0A"></IFRAME>
-<#text>
-
-</#text>
-<SCRIPT>
+"
+|     <script>
+|       "
 Markup.description("Tests basic dump-as-markup functionality.");
 window.getSelection().selectAllChildren(bar)
-</SCRIPT>
-<#text>
-</#text>
-</BODY>
-</HTML>
+"
+|     "
+"
 
 FRAME 0:
+| <head>
+|   "
+  "
+|   <title>
+|     "Test"
+|   "
+  "
+|   <style>
+|     type="text/css"
+|     "
+  "
+|   "
+ "
+| "
+ "
+| <body>
+|   "
+  "
+|   <p>
+|   "
+ 
 
-<HTML>
-<HEAD>
-<#text>
-</#text>
-<TITLE>
-<#text>Test</#text>
-</TITLE>
-<#text>
-</#text>
-<STYLE type="text/css">
-</STYLE>
-<#text>
-</#text>
-</HEAD>
-<#text>
-</#text>
-<BODY>
-<#text>
-</#text>
-<P>
-</P>
-<#text>
-
-
-</#text>
-</BODY>
-</HTML>
+"
diff --git a/LayoutTests/editing/selection/dump-as-markup.html b/LayoutTests/editing/selection/dump-as-markup.html
index 28bd837..ad390ec 100644
--- a/LayoutTests/editing/selection/dump-as-markup.html
+++ b/LayoutTests/editing/selection/dump-as-markup.html
@@ -1,3 +1,4 @@
+<!DocType html>
 <script src="../../resources/dump-as-markup.js"></script>
 
 <div id="bar">foo<hr></div>
diff --git a/LayoutTests/editing/selection/home-inside-noneditable-table-expected.txt b/LayoutTests/editing/selection/home-inside-noneditable-table-expected.txt
index 9a0a4f2..ca2ecac 100644
--- a/LayoutTests/editing/selection/home-inside-noneditable-table-expected.txt
+++ b/LayoutTests/editing/selection/home-inside-noneditable-table-expected.txt
@@ -1,33 +1,27 @@
 Tests whether home moves the caret to the beginning of line inside a content-editable in an uneditable table.
 
 Dump of markup 1:
-<DIV id="test" contentEditable="true">
-<#text>
-</#text>
-<DIV id="l1">
-<#text>The caret is initially <selection-caret>here but should move to the beginning of the line.</#text>
-</DIV>
-<#text>
-</#text>
-<DIV>
-<#text>dummy text</#text>
-</DIV>
-<#text>
-</#text>
-</DIV>
+| "
+      "
+| <div>
+|   id="l1"
+|   "The caret is initially <#selection-caret>here but should move to the beginning of the line."
+| "
+      "
+| <div>
+|   "dummy text"
+| "
+    "
 
 Dump of markup 2:
-<DIV id="test" contentEditable="true">
-<#text>
-</#text>
-<DIV id="l1">
-<#text><selection-caret>The caret is initially here but should move to the beginning of the line.</#text>
-</DIV>
-<#text>
-</#text>
-<DIV>
-<#text>dummy text</#text>
-</DIV>
-<#text>
-</#text>
-</DIV>
+| "
+      "
+| <div>
+|   id="l1"
+|   "<#selection-caret>The caret is initially here but should move to the beginning of the line."
+| "
+      "
+| <div>
+|   "dummy text"
+| "
+    "
diff --git a/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt b/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt
index 826ffb6..ae5e587 100644
--- a/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt
+++ b/LayoutTests/editing/style/remove-underline-from-stylesheet-expected.txt
@@ -70,11 +70,8 @@ EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
 This tests removing underline from stylesheet (.editing has underline). Because text-decoration that comes from a style rule cannot be pushed down, the underline should stay. (see bug 27809).
-
-<DIV class="editing" id="root" contentEditable="">
-<#text>xxxxxx </#text>
-<#text><selection-anchor>xxxxxx<selection-focus></#text>
-<#text> xxxxxx</#text>
-<SPAN id="test">
-</SPAN>
-</DIV>
+| "xxxxxx "
+| "<#selection-anchor>xxxxxx<#selection-focus>"
+| " xxxxxx"
+| <span>
+|   id="test"
diff --git a/LayoutTests/editing/style/style-text-node-without-editable-parent-expected.txt b/LayoutTests/editing/style/style-text-node-without-editable-parent-expected.txt
index 2165704..d52814c 100644
--- a/LayoutTests/editing/style/style-text-node-without-editable-parent-expected.txt
+++ b/LayoutTests/editing/style/style-text-node-without-editable-parent-expected.txt
@@ -1,289 +1,201 @@
 This tests applying inline style to a text node, which is a child of the editable root. Style should be applied properly and the test should not crash. (See the bug 39989).
 
 bold first:
-<SPAN contentEditable="">
-<B>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</B>
-<#text>world WebKit</#text>
-</SPAN>
+| <b>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 bold middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<B>
-<#text><selection-anchor>world<selection-focus></#text>
-</B>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <b>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 bold last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<B>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</B>
-</SPAN>
+| "hello, world"
+| <b>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 bold all:
-<SPAN contentEditable="">
-<B>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</B>
-</SPAN>
+| <b>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 italic first:
-<SPAN contentEditable="">
-<I>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</I>
-<#text>world WebKit</#text>
-</SPAN>
+| <i>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 italic middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<I>
-<#text><selection-anchor>world<selection-focus></#text>
-</I>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <i>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 italic last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<I>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</I>
-</SPAN>
+| "hello, world"
+| <i>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 italic all:
-<SPAN contentEditable="">
-<I>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</I>
-</SPAN>
+| <i>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 underline first:
-<SPAN contentEditable="">
-<U>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</U>
-<#text>world WebKit</#text>
-</SPAN>
+| <u>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 underline middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<U>
-<#text><selection-anchor>world<selection-focus></#text>
-</U>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <u>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 underline last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<U>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</U>
-</SPAN>
+| "hello, world"
+| <u>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 underline all:
-<SPAN contentEditable="">
-<U>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</U>
-</SPAN>
+| <u>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 strikeThrough first:
-<SPAN contentEditable="">
-<S>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</S>
-<#text>world WebKit</#text>
-</SPAN>
+| <s>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 strikeThrough middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<S>
-<#text><selection-anchor>world<selection-focus></#text>
-</S>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <s>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 strikeThrough last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<S>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</S>
-</SPAN>
+| "hello, world"
+| <s>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 strikeThrough all:
-<SPAN contentEditable="">
-<S>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</S>
-</SPAN>
+| <s>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 foreColor first:
-<SPAN contentEditable="">
-<FONT class="Apple-style-span" color="#0000FF">
-<#text><selection-anchor>hello, <selection-focus></#text>
-</FONT>
-<#text>world WebKit</#text>
-</SPAN>
+| <font>
+|   class="Apple-style-span"
+|   color="#0000FF"
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 foreColor middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<FONT class="Apple-style-span" color="#0000FF">
-<#text><selection-anchor>world<selection-focus></#text>
-</FONT>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <font>
+|   class="Apple-style-span"
+|   color="#0000FF"
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 foreColor last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<FONT class="Apple-style-span" color="#0000FF">
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</FONT>
-</SPAN>
+| "hello, world"
+| <font>
+|   class="Apple-style-span"
+|   color="#0000FF"
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 foreColor all:
-<SPAN contentEditable="">
-<FONT class="Apple-style-span" color="#0000FF">
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</FONT>
-</SPAN>
+| <font>
+|   class="Apple-style-span"
+|   color="#0000FF"
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 hiliteColor first:
-<SPAN contentEditable="">
-<SPAN style="background-color: blue;" class="Apple-style-span">
-<#text><selection-anchor>hello, <selection-focus></#text>
-</SPAN>
-<#text>world WebKit</#text>
-</SPAN>
+| <span>
+|   class="Apple-style-span"
+|   style="background-color: blue;"
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 hiliteColor middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<SPAN style="background-color: blue;" class="Apple-style-span">
-<#text><selection-anchor>world<selection-focus></#text>
-</SPAN>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <span>
+|   class="Apple-style-span"
+|   style="background-color: blue;"
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 hiliteColor last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<SPAN style="background-color: blue;" class="Apple-style-span">
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</SPAN>
-</SPAN>
+| "hello, world"
+| <span>
+|   class="Apple-style-span"
+|   style="background-color: blue;"
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 hiliteColor all:
-<SPAN contentEditable="">
-<SPAN style="background-color: blue;" class="Apple-style-span">
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</SPAN>
-</SPAN>
+| <span>
+|   class="Apple-style-span"
+|   style="background-color: blue;"
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 subscript first:
-<SPAN contentEditable="">
-<SUB>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</SUB>
-<#text>world WebKit</#text>
-</SPAN>
+| <sub>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 subscript middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<SUB>
-<#text><selection-anchor>world<selection-focus></#text>
-</SUB>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <sub>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 subscript last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<SUB>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</SUB>
-</SPAN>
+| "hello, world"
+| <sub>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 subscript all:
-<SPAN contentEditable="">
-<SUB>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</SUB>
-</SPAN>
+| <sub>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 superscript first:
-<SPAN contentEditable="">
-<SUP>
-<#text><selection-anchor>hello, <selection-focus></#text>
-</SUP>
-<#text>world WebKit</#text>
-</SPAN>
+| <sup>
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 superscript middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<SUP>
-<#text><selection-anchor>world<selection-focus></#text>
-</SUP>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <sup>
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 superscript last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<SUP>
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</SUP>
-</SPAN>
+| "hello, world"
+| <sup>
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 superscript all:
-<SPAN contentEditable="">
-<SUP>
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</SUP>
-</SPAN>
+| <sup>
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
 
 createLink first:
-<SPAN contentEditable="">
-<A href="http://webkit.org/">
-<#text><selection-anchor>hello, <selection-focus></#text>
-</A>
-<#text>world WebKit</#text>
-</SPAN>
+| <a>
+|   href="http://webkit.org/"
+|   "<#selection-anchor>hello, <#selection-focus>"
+| "world WebKit"
 
 createLink middle:
-<SPAN contentEditable="">
-<#text>hello, </#text>
-<A href="http://webkit.org/">
-<#text><selection-anchor>world<selection-focus></#text>
-</A>
-<#text> WebKit</#text>
-</SPAN>
+| "hello, "
+| <a>
+|   href="http://webkit.org/"
+|   "<#selection-anchor>world<#selection-focus>"
+| " WebKit"
 
 createLink last:
-<SPAN contentEditable="">
-<#text>hello, world</#text>
-<A href="http://webkit.org/">
-<#text><selection-anchor> WebKit<selection-focus></#text>
-</A>
-</SPAN>
+| "hello, world"
+| <a>
+|   href="http://webkit.org/"
+|   "<#selection-anchor> WebKit<#selection-focus>"
 
 createLink all:
-<SPAN contentEditable="">
-<A href="http://webkit.org/">
-<#text><selection-anchor>hello, world WebKit<selection-focus></#text>
-</A>
-</SPAN>
+| <a>
+|   href="http://webkit.org/"
+|   "<#selection-anchor>hello, world WebKit<#selection-focus>"
diff --git a/LayoutTests/editing/undo/redo-split-text-node-expected.txt b/LayoutTests/editing/undo/redo-split-text-node-expected.txt
index 73a7bfb..a93497e 100644
--- a/LayoutTests/editing/undo/redo-split-text-node-expected.txt
+++ b/LayoutTests/editing/undo/redo-split-text-node-expected.txt
@@ -2,26 +2,16 @@ This test splits a text node by inserting a new paragraph and bolds the the firs
 If splitTextNode correctly reapplied the split, undo and redo should preserve the style. (See bug 42941).
 
 before undo:
-<DIV id="test" contentEditable="">
-<B>
-<#text><selection-anchor>he<selection-focus></#text>
-</B>
-<DIV>
-<#text>llo</#text>
-</DIV>
-</DIV>
+| <b>
+|   "<#selection-anchor>he<#selection-focus>"
+| <div>
+|   "llo"
 
 after undo:
-<DIV id="test" contentEditable="">
-<#text>he<selection-caret>llo</#text>
-</DIV>
+| "he<#selection-caret>llo"
 
 after redo:
-<DIV id="test" contentEditable="">
-<B>
-<#text><selection-anchor>he<selection-focus></#text>
-</B>
-<DIV>
-<#text>llo</#text>
-</DIV>
-</DIV>
+| <b>
+|   "<#selection-anchor>he<#selection-focus>"
+| <div>
+|   "llo"
diff --git a/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt b/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
index 96c4164..ba0693c 100644
--- a/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
+++ b/LayoutTests/editing/undo/redo-split-text-with-removal-expected.txt
@@ -2,27 +2,17 @@ This test splits a text node by inserting a new paragraph and bolds the the firs
 After undoing these two steps, it removes the text node, and then redo. The test should not crash. (See bug 42941).
 
 before undo:
-<DIV id="test" contentEditable="">
-<B>
-<#text><selection-anchor>he<selection-focus></#text>
-</B>
-<DIV>
-<#text>llo</#text>
-</DIV>
-</DIV>
+| <b>
+|   "<#selection-anchor>he<#selection-focus>"
+| <div>
+|   "llo"
 
 after undo:
-<DIV id="test" contentEditable="">
-<#text>he<selection-caret>llo</#text>
-</DIV>
+| "he<#selection-caret>llo"
 
 after node removal:
-<DIV id="test" contentEditable="">
-</DIV>
+| 
 
 after redo:
-<DIV id="test" contentEditable="">
-<DIV>
-<#text>hello</#text>
-</DIV>
-</DIV>
+| <div>
+|   "hello"
diff --git a/LayoutTests/html5lib/resources/dom2string.js b/LayoutTests/html5lib/resources/dom2string.js
deleted file mode 100644
index 3deb658..0000000
--- a/LayoutTests/html5lib/resources/dom2string.js
+++ /dev/null
@@ -1,140 +0,0 @@
-String.prototype.toAsciiLowerCase = function () {
-  var output = "";
-  for (var i = 0, len = this.length; i < len; ++i) {
-    if (this.charCodeAt(i) >= 0x41 && this.charCodeAt(i) <= 0x5A) {
-      output += String.fromCharCode(this.charCodeAt(i) + 0x20)
-    } else {
-      output += this.charAt(i);
-    }
-  }
-  return output;
-}
-
-function indent(ancestors) {
-  var str = "";
-  if (ancestors > 0) {
-    while (ancestors--)
-      str += "  ";
-  }
-  return str;
-}
-
-function dom2string(node, ancestors) {
-  var str = "";
-  if (typeof ancestors == "undefined")
-    var ancestors = 0;
-  if (!node.firstChild)
-    return "| ";
-  var parent = node;
-  var current = node.firstChild;
-  var next = null;
-  var misnested = null;
-  for (;;) {
-    str += "\n| " + indent(ancestors);
-    switch (current.nodeType) {
-      case 10:
-        str += '<!DOCTYPE ' + current.nodeName;
-        if (current.publicId || current.systemId) {
-            str += ' "' + current.publicId + '"';
-            str += ' "' + current.systemId + '"';
-        }
-        str += '>';
-        break;
-      case 8:
-        try {
-          str += '<!-- ' + current.nodeValue + ' -->';
-        } catch (e) {
-          str += '<!--  -->';
-        }
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        }
-        break;
-      case 7:
-        str += '<?' + current.nodeName + current.nodeValue + '>';
-        break;
-      case 4:
-        str += '<![CDATA[ ' + current.nodeValue + ' ]]>';
-        break;
-      case 3:
-        str += '"' + current.nodeValue + '"';
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        }
-        break;
-      case 1:
-        str += "<";
-        switch (current.namespaceURI) {
-          case "http://www.w3.org/2000/svg":
-            str += "svg ";
-            break;
-          case "http://www.w3.org/1998/Math/MathML":
-            str += "math ";
-            break;
-        }
-        if (current.localName && current.namespaceURI && current.namespaceURI != null) {
-          str += current.localName;
-        } else {
-          str += current.nodeName.toAsciiLowerCase();
-        }
-        str += '>';
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        } else {
-          if (current.attributes) {
-            var attrNames = [];
-            var attrPos = {};
-            for (var j = 0; j < current.attributes.length; j += 1) {
-              if (current.attributes[j].specified) {
-                var name = "";
-                switch (current.attributes[j].namespaceURI) {
-                  case "http://www.w3.org/XML/1998/namespace":
-                    name += "xml ";
-                    break;
-                  case "http://www.w3.org/2000/xmlns/":
-                    name += "xmlns ";
-                    break;
-                  case "http://www.w3.org/1999/xlink":
-                    name += "xlink ";
-                    break;
-                }
-                if (current.attributes[j].localName) {
-                  name += current.attributes[j].localName;
-                } else {
-                  name += current.attributes[j].nodeName;
-                }
-                attrNames.push(name);
-                attrPos[name] = j;
-              }
-            }
-            if (attrNames.length > 0) {
-              attrNames.sort();
-              for (var j = 0; j < attrNames.length; j += 1) {
-                str += "\n| " + indent(1 + ancestors) + attrNames[j];
-                str += '="' + current.attributes[attrPos[attrNames[j]]].nodeValue + '"';
-              }
-            }
-          }
-          if (next = current.firstChild) {
-            parent = current;
-            current = next;
-            ancestors++;
-            continue;
-          }
-        }
-        break;
-    }
-    for (;;) {
-      if (next = current.nextSibling) {
-        current = next;
-        break;
-      }
-      current = current.parentNode;
-      parent = parent.parentNode;
-      ancestors--;
-      if (current == node) {
-        return str.substring(1);
-      }
-    }
-  }
-}
diff --git a/LayoutTests/html5lib/runner.html b/LayoutTests/html5lib/runner.html
index 05a493f..655f028 100644
--- a/LayoutTests/html5lib/runner.html
+++ b/LayoutTests/html5lib/runner.html
@@ -21,11 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -->
 <title>html5lib test runner</title>
-<script src=resources/dom2string.js></script>
-<script>
-if (window.layoutTestController)
-    layoutTestController.dumpAsText();
-</script>
+<script src=../resources/dump-as-markup.js></script>
 <style>
 .overview:hover {
 background: #ccc;
@@ -37,6 +33,8 @@ display: none;
 <p>Script did not run</p>
 <iframe></iframe>
 <script>
+Markup.noAutoDump();
+
 var test_files = [
         'resources/tests1.dat',
         'resources/tests2.dat',
@@ -228,7 +226,7 @@ function run_test(input, contextElement, expected)
 
 function process_result(input, result, expected)
 {
-    result = dom2string(result);
+    result = Markup.get(result);
     if (result !== expected)
     {
         fail_list.push(test_number);
diff --git a/LayoutTests/html5lib/webkit-resumer.html b/LayoutTests/html5lib/webkit-resumer.html
index 2d3a017..bd961a4 100644
--- a/LayoutTests/html5lib/webkit-resumer.html
+++ b/LayoutTests/html5lib/webkit-resumer.html
@@ -20,147 +20,7 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 </script>
-<script>
-String.prototype.toAsciiLowerCase = function () {
-  var output = "";
-  for (var i = 0, len = this.length; i < len; ++i) {
-    if (this.charCodeAt(i) >= 0x41 && this.charCodeAt(i) <= 0x5A) {
-      output += String.fromCharCode(this.charCodeAt(i) + 0x20)
-    } else {
-      output += this.charAt(i);
-    }
-  }
-  return output;
-}
-
-function indent(ancestors) {
-  var str = "";
-  if (ancestors > 0) {
-    while (ancestors--)
-      str += "  ";
-  }
-  return str;
-}
-
-function dom2string(node, ancestors) {
-  var str = "";
-  if (typeof ancestors == "undefined")
-    var ancestors = 0;
-  if (!node.firstChild)
-    return "| ";
-  var parent = node;
-  var current = node.firstChild;
-  var next = null;
-  var misnested = null;
-  for (;;) {
-    str += "\n| " + indent(ancestors);
-    switch (current.nodeType) {
-      case 10:
-        str += '<!DOCTYPE ' + current.nodeName + '>';
-        break;
-      case 8:
-        try {
-          str += '<!-- ' + current.nodeValue + ' -->';
-        } catch (e) {
-          str += '<!--  -->';
-        }
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        }
-        break;
-      case 7:
-        str += '<?' + current.nodeName + current.nodeValue + '>';
-        break;
-      case 4:
-        str += '<![CDATA[ ' + current.nodeValue + ' ]]>';
-        break;
-      case 3:
-        str += '"' + current.nodeValue + '"';
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        }
-        break;
-      case 1:
-        str += "<";
-        switch (current.namespaceURI) {
-          case "http://www.w3.org/2000/svg":
-            str += "svg ";
-            break;
-          case "http://www.w3.org/1998/Math/MathML":
-            str += "math ";
-            break;
-        }
-        if (current.localName && current.namespaceURI && current.namespaceURI != null) {
-          str += current.localName;
-        } else {
-          str += current.nodeName.toAsciiLowerCase();
-        }
-        str += '>';
-        if (parent != current.parentNode) {
-          return str += ' (misnested... aborting)';
-        } else {
-          if (current.attributes) {
-            var attrNames = [];
-            var attrPos = {};
-            for (var j = 0; j < current.attributes.length; j += 1) {
-              if (current.attributes[j].specified) {
-                var name = "";
-                switch (current.attributes[j].namespaceURI) {
-                  case "http://www.w3.org/XML/1998/namespace":
-                    name += "xml ";
-                    break;
-                  case "http://www.w3.org/2000/xmlns/":
-                    name += "xmlns ";
-                    break;
-                  case "http://www.w3.org/1999/xlink":
-                    name += "xlink ";
-                    break;
-                }
-                if (current.attributes[j].localName) {
-                  name += current.attributes[j].localName;
-                } else {
-                  name += current.attributes[j].nodeName;
-                }
-                attrNames.push(name);
-                attrPos[name] = j;
-              }
-            }
-            if (attrNames.length > 0) {
-              attrNames.sort();
-              for (var j = 0; j < attrNames.length; j += 1) {
-                str += "\n| " + indent(1 + ancestors) + attrNames[j];
-                str += '="' + current.attributes[attrPos[attrNames[j]]].nodeValue + '"';
-              }
-            }
-          }
-          if (next = current.firstChild) {
-            parent = current;
-            current = next;
-            ancestors++;
-            continue;
-          }
-        }
-        break;
-    }
-    for (;;) {
-      if (next = current.nextSibling) {
-        current = next;
-        break;
-      }
-      current = current.parentNode;
-      parent = parent.parentNode;
-      ancestors--;
-      if (current == node) {
-        return str.substring(1);
-      }
-    }
-  }
-}
-</script>
-<script>
-if (window.layoutTestController)
-    layoutTestController.dumpAsText();
-</script>
+<script src=../resources/dump-as-markup.js></script>
 <style>
 .overview:hover {
 background: #ccc;
@@ -172,6 +32,8 @@ display: none;
 <p>Script did not run</p>
 <iframe></iframe>
 <script>
+Markup.noAutoDump();
+
 var test_files = [
         // 'resources/tests1.dat',
         // 'resources/tests2.dat',
@@ -357,7 +219,7 @@ function run_test(input, contextElement, expected)
 
 function process_result(input, result, expected, async)
 {
-    result = dom2string(result);
+    result = Markup.get(result);
     if (result !== expected)
     {
         fail_list.push(test_number + "." + subtest_number);
diff --git a/LayoutTests/resources/dump-as-markup.js b/LayoutTests/resources/dump-as-markup.js
index eeafce8..b6eee92 100644
--- a/LayoutTests/resources/dump-as-markup.js
+++ b/LayoutTests/resources/dump-as-markup.js
@@ -14,12 +14,11 @@
  *    Optionally specify the node to dump and the description for each call of dump.
  */
 
-if (window.layoutTestController) {
+if (window.layoutTestController)
     layoutTestController.dumpAsText();
-    layoutTestController.waitUntilDone();
-}
 
 // Namespace
+// FIXME: Rename dump-as-markup.js to dump-dom.js and Markup to DOM.
 var Markup = {};
 
 // The description of what this test is testing. Gets prepended to the dumped markup.
@@ -36,7 +35,7 @@ Markup.dump = function(opt_node, opt_description)
     if (typeof opt_node == 'string')
         opt_node = document.getElementById(opt_node);
 
-    var node = opt_node || Markup._node || document.body.parentElement
+    var node = opt_node || Markup._node || document
     var markup = "";
 
     if (Markup._test_description && !Markup._dumpCalls)
@@ -51,7 +50,7 @@ Markup.dump = function(opt_node, opt_description)
             opt_description = "Dump of markup " + Markup._dumpCalls
         if (Markup._dumpCalls > 1)
             markup += '\n';
-        markup += '\n' + opt_description + ':';
+        markup += '\n' + opt_description + ':\n';
     }
 
     markup += Markup.get(node);
@@ -59,7 +58,6 @@ Markup.dump = function(opt_node, opt_description)
     if (!Markup._container) {
         Markup._container = document.createElement('pre');
         Markup._container.style.width = '100%';
-        document.body.appendChild(Markup._container);
     }
 
     // FIXME: Have this respect layoutTestController.dumpChildFramesAsText?
@@ -74,16 +72,24 @@ Markup.dump = function(opt_node, opt_description)
         }
     }
 
-    Markup._container.innerText += markup;
+    Markup._container.appendChild(document.createTextNode(markup));
 }
 
-Markup.waitUntilDone = function()
+Markup.noAutoDump = function()
 {
     window.removeEventListener('load', Markup.notifyDone, false);
 }
 
+Markup.waitUntilDone = function()
+{
+    layoutTestController.waitUntilDone();
+    Markup.noAutoDump();
+}
+
 Markup.notifyDone = function()
 {
+    // Need to waitUntilDone or some tests won't finish appending the markup before the text is dumped.
+    layoutTestController.waitUntilDone();
     Markup._done = true;
 
     // If dump has already been called, don't bother to dump again
@@ -93,8 +99,10 @@ Markup.notifyDone = function()
     // In non-layout test mode, append the results in a pre so that we don't
     // clobber the test itself. But when in layout test mode, we don't want
     // side effects from the test to be included in the results.
-    if (window.layoutTestController)
-        document.body.innerText = Markup._container.innerText;
+    if (window.layoutTestController) {
+        document.body.innerHTML = '';
+        document.body.appendChild(Markup._container);
+    }
 
     if (window.layoutTestController)
         layoutTestController.notifyDone();
@@ -107,98 +115,134 @@ Markup.setNodeToDump = function(node)
     Markup._node = node
 }
 
+Markup.get = function(node)
+{
+    if (!node.firstChild)
+        return '| ';
+
+    // Don't print any markup for the root node.
+    var markup = '';
+    for (var i = 0, len = node.childNodes.length; i < len; i++) {
+        markup += Markup._get(node.childNodes[i], 0);
+    }
+    return markup.substring(1);
+}
+
 // Returns the markup for the given node. To be used for cases where a test needs
 // to get the markup but not clobber the whole page.
-Markup.get = function(node, opt_depth)
+Markup._get = function(node, depth)
 {
-    var depth = opt_depth || 0;
-
-    var attrs = Markup._getAttributes(node);
-    var attrsString = attrs.length ? ' ' + attrs.join(' ') : '';
-
-    var nodeName = node.nodeName;
-    var markup = '<' + nodeName + attrsString + '>';
-
-    var isSpecialNode = Markup._FORBIDS_END_TAG[nodeName];
-    var innerMarkup = '';
-    switch (nodeName) {
-        case '#text':
-        case 'STYLE':
-        case 'SCRIPT':
-        case 'IFRAME':
-        case 'TEXTAREA':
-        case 'XMP':
-            innerMarkup = nodeName == '#text' ? Markup._getMarkupForTextNode(node) : node.innerText;
-            innerMarkup = innerMarkup.replace(/\n/g, '\n' + Markup._spaces(depth))
-            isSpecialNode = true;
-            break;
-        
-        default:
-            for (var i = 0, len = node.childNodes.length; i < len; i++) {
-                innerMarkup += Markup._getSelectionMarker(node, i);
-                innerMarkup += Markup.get(node.childNodes[i], depth + 1);
+    var str = Markup._indent(depth);
+
+    switch (node.nodeType) {
+    case 10:
+        str += '<!DOCTYPE ' + node.nodeName;
+        if (node.publicId || node.systemId) {
+            str += ' "' + node.publicId + '"';
+            str += ' "' + node.systemId + '"';
+        }
+        str += '>';
+        break;
+
+    case 8:
+        try {
+            str += '<!-- ' + node.nodeValue + ' -->';
+        } catch (e) {
+            str += '<!--  -->';
+        }
+        break;
+
+    case 7:
+        str += '<?' + node.nodeName + node.nodeValue + '>';
+        break;
+
+    case 4:
+        str += '<![CDATA[ ' + node.nodeValue + ' ]]>';
+        break;
+
+    case 3:
+        str += '"' + Markup._getMarkupForTextNode(node) + '"';
+        break;
+
+    case 1:
+        str += "<";
+        str += Markup._namespace(node)
+
+        if (node.localName && node.namespaceURI && node.namespaceURI != null)
+            str += node.localName;
+        else
+            str += Markup._toAsciiLowerCase(node.nodeName);
+
+        str += '>';
+
+        if (node.attributes) {
+            var attrNames = [];
+            var attrPos = {};
+            for (var j = 0; j < node.attributes.length; j += 1) {
+                if (node.attributes[j].specified) {
+                    var name = Markup._namespace(node.attributes[j])
+                    name += node.attributes[j].localName || node.attributes[j].nodeName;
+                    attrNames.push(name);
+                    attrPos[name] = j;
+                }
+            }
+            if (attrNames.length > 0) {
+              attrNames.sort();
+              for (var j = 0; j < attrNames.length; j += 1) {
+                str += Markup._indent(depth + 1) + attrNames[j];
+                str += '="' + node.attributes[attrPos[attrNames[j]]].nodeValue + '"';
+              }
             }
-            innerMarkup += Markup._getSelectionMarker(node, i);
+        }
+        break;
     }
 
-    markup = '\n' + Markup._spaces(depth) + markup 
-    if (!isSpecialNode)
-        innerMarkup += '\n' + Markup._spaces(depth);
+    for (var i = 0, len = node.childNodes.length; i < len; i++) {
+        var selection = Markup._getSelectionMarker(node, i);
+        if (selection)
+            str += Markup._indent(depth + 1) + selection;
 
-    markup += innerMarkup;
+        str += Markup._get(node.childNodes[i], depth + 1);
+    }
     
-    if (!Markup._FORBIDS_END_TAG[nodeName])
-        markup += '</' + nodeName + '>';
+    var selection = Markup._getSelectionMarker(node, i);
+    if (selection)
+        str += Markup._indent(depth + 1) + selection;
 
-    return markup;
+    return str;
 }
 
-Markup._dumpCalls = 0
-
-Markup._spaces = function(multiplier)
+Markup._namespace = function(node)
 {
-    return new Array(multiplier * 4 + 1).join(' ');
+    if (Markup._NAMESPACE_URI_MAP[node.namespaceURI])
+        return Markup._NAMESPACE_URI_MAP[node.namespaceURI] + ' ';
+    return '';
 }
 
-// FIXME: Is there a better way to do this than a hard coded list?
-Markup._DUMP_AS_MARKUP_PROPERTIES = ['src', 'type', 'href', 'style', 'class', 'id', 'color', 'bgcolor', 'contentEditable'];
+Markup._dumpCalls = 0
 
-Markup._getAttributes = function(node)
+Markup._indent = function(depth)
 {
-    var props = [];
-    if (!node.hasAttribute)
-        return props;
-
-    for (var i = 0; i < Markup._DUMP_AS_MARKUP_PROPERTIES.length; i++) {
-        var attr = Markup._DUMP_AS_MARKUP_PROPERTIES[i];
-        if (node.hasAttribute(attr)) {
-            props.push(attr + '="' + node.getAttribute(attr) + '"');
-        }
-    }
-    return props;
+    return "\n| " + new Array(depth * 2 + 1).join(' ');
+}
+
+Markup._toAsciiLowerCase = function (str) {
+  var output = "";
+  for (var i = 0, len = this.length; i < len; ++i) {
+    if (str.charCodeAt(i) >= 0x41 && str.charCodeAt(i) <= 0x5A)
+      output += String.fromCharCode(str.charCodeAt(i) + 0x20)
+    else
+      output += str.charAt(i);
+  }
+  return output;
 }
 
-// This list should match all HTML elements that return TagStatusForbidden for endTagRequirement().
-Markup._FORBIDS_END_TAG = {
-    'META': 1,
-    'HR': 1,
-    'AREA': 1,
-    'LINK': 1,
-    'WBR': 1,
-    'BR': 1,
-    'BASE': 1,
-    'TABLECOL': 1,
-    'SOURCE': 1,
-    'INPUT': 1,
-    'PARAM': 1,
-    'EMBED': 1,
-    'FRAME': 1,
-    'CANVAS': 1,
-    'IMG': 1,
-    'ISINDEX': 1,
-    'BASEFONT': 1,
-    'DATAGRIDCELL': 1,
-    'DATAGRIDCOL': 1
+Markup._NAMESPACE_URI_MAP = {
+    "http://www.w3.org/2000/svg": "svg",
+    "http://www.w3.org/1998/Math/MathML": "math",
+    "http://www.w3.org/XML/1998/namespace": "xml",
+    "http://www.w3.org/2000/xmlns/": "xmlns",
+    "http://www.w3.org/1999/xlink": "xlink"
 }
 
 Markup._getSelectionFromNode = function(node)
@@ -206,6 +250,10 @@ Markup._getSelectionFromNode = function(node)
     return node.ownerDocument.defaultView.getSelection();
 }
 
+Markup._SELECTION_FOCUS = '<#selection-focus>';
+Markup._SELECTION_ANCHOR = '<#selection-anchor>';
+Markup._SELECTION_CARET = '<#selection-caret>';
+
 Markup._getMarkupForTextNode = function(node)
 {
     innerMarkup = node.nodeValue;
@@ -215,26 +263,26 @@ Markup._getMarkupForTextNode = function(node)
     if (node == sel.anchorNode && node == sel.focusNode) {
         if (sel.isCollapsed) {
             startOffset = sel.anchorOffset;
-            startText = '<selection-caret>';
+            startText = Markup._SELECTION_CARET;
         } else {
             if (sel.focusOffset > sel.anchorOffset) {
                 startOffset = sel.anchorOffset;
                 endOffset = sel.focusOffset;
-                startText = '<selection-anchor>';
-                endText = '<selection-focus>';
+                startText = Markup._SELECTION_ANCHOR;
+                endText = Markup._SELECTION_FOCUS;
             } else {
                 startOffset = sel.focusOffset;
                 endOffset = sel.anchorOffset;
-                startText = '<selection-focus>';
-                endText = '<selection-anchor>';                        
+                startText = Markup._SELECTION_FOCUS;
+                endText = Markup._SELECTION_ANCHOR;
             }
         }
     } else if (node == sel.focusNode) {
         startOffset = sel.focusOffset;
-        startText = '<selection-focus>';
+        startText = Markup._SELECTION_FOCUS;
     } else if (node == sel.anchorNode) {
         startOffset = sel.anchorOffset;
-        startText = '<selection-anchor>';
+        startText = Markup._SELECTION_ANCHOR;
     }
     
     if (startText && endText)
@@ -247,14 +295,17 @@ Markup._getMarkupForTextNode = function(node)
 
 Markup._getSelectionMarker = function(node, index)
 {
+    if (node.nodeType != 1)
+        return '';
+
     var sel = Markup._getSelectionFromNode(node);;
     if (index == sel.anchorOffset && node == sel.anchorNode) {
         if (sel.isCollapsed)
-            return '<selection-caret>';
+            return Markup._SELECTION_CARET;
         else
-            return '<selection-anchor>';
+            return Markup._SELECTION_ANCHOR;
     } else if (index == sel.focusOffset && node == sel.focusNode)
-        return '<selection-focus>';
+        return Markup._SELECTION_FOCUS;
 
     return '';
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list