Avoid more unserializable DOMs with xmp
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Thu, 23 Jun 2011 11:40:23 -0600
changeset 312 99fc7f229637
parent 311 9495a6858c2f
child 313 b05a3a530044
Avoid more unserializable DOMs with xmp

Also fix up listing a bit while I'm at it.
editcommands.html
implementation.js
source.html
tests.js
--- a/editcommands.html	Thu Jun 23 11:01:19 2011 -0600
+++ b/editcommands.html	Thu Jun 23 11:40:23 2011 -0600
@@ -2596,7 +2596,7 @@
 <h3 id=block-formatting-command-definitions><span class=secno>7.1 </span>Block formatting command definitions</h3>
 
 <p>A <dfn id=prohibited-paragraph-child-name>prohibited paragraph child name</dfn> is "address", "article",
-"aside", "blockquote", "caption", "center", "col", "colgroup", "details", "dd",
+"aside", "blockquote", "caption", "center", "col", "colgroup", "dd", "details",
 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form",
 "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "li", "listing",
 "menu", "nav", "ol", "p", "plaintext", "pre", "section", "summary", "table",
@@ -2652,8 +2652,10 @@
 </ul>
 
 <p>A <dfn id=non-list-single-line-container>non-list single-line container</dfn> is an <a href=#html-element>HTML element</a>
-with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> "address", "div", "h1", "h2", "h3", "h4", "h5", "h6", "p",
-or "pre".
+with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> "address", "div", "h1", "h2", "h3", "h4", "h5", "h6",
+"listing", "p", "pre", or "xmp".
+<!-- listing and xmp are included because otherwise insertParagraph inside them
+won't work, since paragraphs aren't an allowed child. -->
 
 <p>A <dfn id=single-line-container>single-line container</dfn> is either a <a href=#non-list-single-line-container>non-list single-line
 container</a>, or an <a href=#html-element>HTML element</a> with <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> "li",
@@ -4806,7 +4808,7 @@
   Everyone: address, div, h*, p, pre
   Everyone but IE: blockquote
   Everyone but Opera: dd, dt
-  IE only: ol, ul
+  IE only: dir, menu, ol, ul
   Firefox and Chrome only: dl
   Chrome only: article, aside, footer, header, hgroup, nav, section
 
@@ -5546,7 +5548,8 @@
     <a class=external data-anolis-spec=domrange href=http://html5.org/specs/dom-range.html#context-object>context object</a>.  Set <var title="">container</var> to the result.
   </ol>
 
-  <li>If <var title="">container</var>'s <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> is "address" or "pre":
+  <li>If <var title="">container</var>'s <a class=external data-anolis-spec=domcore href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-local-name title=concept-element-local-name>local name</a> is "address", "listing", or
+  "pre":
   <!--
   IE9 and Chrome 13 dev just break <pre> up into multiple <pre>s.  Firefox
   5.0a2 and Opera 11.10 insert a <br> instead, treating it differently from
@@ -5558,6 +5561,10 @@
   Firefox 5.0a2 inserts <br> instead.  Opera 11.10 nests <p>s inside.  I don't
   like Opera's behavior, because it means we nest formatBlock candidates inside
   one another, so I'll go with Firefox.
+
+  listing and xmp work the same as pre in all browsers.  For Firefox and Opera,
+  this results in trying to put a br inside an xmp, so I go with IE/Chrome for
+  xmp.
   -->
 
   <p class=XXX>Why don't we just insert a newline character if it's a pre?  We
--- a/implementation.js	Thu Jun 23 11:01:19 2011 -0600
+++ b/implementation.js	Thu Jun 23 11:40:23 2011 -0600
@@ -3073,14 +3073,14 @@
 //@{
 
 // "A prohibited paragraph child name is "address", "article", "aside",
-// "blockquote", "caption", "center", "col", "colgroup", "details", "dd",
+// "blockquote", "caption", "center", "col", "colgroup", "dd", "details",
 // "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer",
 // "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "li",
 // "listing", "menu", "nav", "ol", "p", "plaintext", "pre", "section",
 // "summary", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul", or
 // "xmp"."
 var prohibitedParagraphChildNames = ["address", "article", "aside",
-	"blockquote", "caption", "center", "col", "colgroup", "details", "dd",
+	"blockquote", "caption", "center", "col", "colgroup", "dd", "details",
 	"dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer",
 	"form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "li",
 	"listing", "menu", "nav", "ol", "p", "plaintext", "pre", "section",
@@ -3169,10 +3169,11 @@
 }
 
 // "A non-list single-line container is an HTML element with local name
-// "address", "div", "h1", "h2", "h3", "h4", "h5", "h6", "p", or "pre"."
+// "address", "div", "h1", "h2", "h3", "h4", "h5", "h6", "listing", "p", "pre",
+// or "xmp"."
 function isNonListSingleLineContainer(node) {
 	return isHtmlElement(node, ["address", "div", "h1", "h2", "h3", "h4", "h5",
-		"h6", "p", "pre"]);
+		"h6", "listing", "p", "pre", "xmp"]);
 }
 
 // "A single-line container is either a non-list single-line container, or an
@@ -5828,8 +5829,9 @@
 			);
 		}
 
-		// "If container's local name is "address" or "pre":"
+		// "If container's local name is "address", "listing", or "pre":"
 		if (container.tagName == "ADDRESS"
+		|| container.tagName == "LISTING"
 		|| container.tagName == "PRE") {
 			// "Let br be the result of calling createElement("br") on the
 			// context object."
--- a/source.html	Thu Jun 23 11:01:19 2011 -0600
+++ b/source.html	Thu Jun 23 11:40:23 2011 -0600
@@ -2574,7 +2574,7 @@
 <h3>Block formatting command definitions</h3>
 <!-- @{ -->
 <p>A <dfn>prohibited paragraph child name</dfn> is "address", "article",
-"aside", "blockquote", "caption", "center", "col", "colgroup", "details", "dd",
+"aside", "blockquote", "caption", "center", "col", "colgroup", "dd", "details",
 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", "form",
 "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "li", "listing",
 "menu", "nav", "ol", "p", "plaintext", "pre", "section", "summary", "table",
@@ -2630,8 +2630,10 @@
 </ul>
 
 <p>A <dfn>non-list single-line container</dfn> is an <span>HTML element</span>
-with [[localname]] "address", "div", "h1", "h2", "h3", "h4", "h5", "h6", "p",
-or "pre".
+with [[localname]] "address", "div", "h1", "h2", "h3", "h4", "h5", "h6",
+"listing", "p", "pre", or "xmp".
+<!-- listing and xmp are included because otherwise insertParagraph inside them
+won't work, since paragraphs aren't an allowed child. -->
 
 <p>A <dfn>single-line container</dfn> is either a <span>non-list single-line
 container</span>, or an <span>HTML element</span> with [[localname]] "li",
@@ -4808,7 +4810,7 @@
   Everyone: address, div, h*, p, pre
   Everyone but IE: blockquote
   Everyone but Opera: dd, dt
-  IE only: ol, ul
+  IE only: dir, menu, ol, ul
   Firefox and Chrome only: dl
   Chrome only: article, aside, footer, header, hgroup, nav, section
 
@@ -5559,7 +5561,8 @@
     [[contextobject]].  Set <var>container</var> to the result.
   </ol>
 
-  <li>If <var>container</var>'s [[localname]] is "address" or "pre":
+  <li>If <var>container</var>'s [[localname]] is "address", "listing", or
+  "pre":
   <!--
   IE9 and Chrome 13 dev just break <pre> up into multiple <pre>s.  Firefox
   5.0a2 and Opera 11.10 insert a <br> instead, treating it differently from
@@ -5571,6 +5574,10 @@
   Firefox 5.0a2 inserts <br> instead.  Opera 11.10 nests <p>s inside.  I don't
   like Opera's behavior, because it means we nest formatBlock candidates inside
   one another, so I'll go with Firefox.
+
+  listing and xmp work the same as pre in all browsers.  For Firefox and Opera,
+  this results in trying to put a br inside an xmp, so I go with IE/Chrome for
+  xmp.
   -->
 
   <p class=XXX>Why don't we just insert a newline character if it's a pre?  We
--- a/tests.js	Thu Jun 23 11:01:19 2011 -0600
+++ b/tests.js	Thu Jun 23 11:40:23 2011 -0600
@@ -749,6 +749,8 @@
 		['<p>', '<ul><li>[foobar]</ul>'],
 		['<p>', '<address>[foobar]</address>'],
 		['<p>', '<pre>[foobar]</pre>'],
+		['<p>', '<listing>[foobar]</listing>'],
+		['<p>', '<xmp>[foobar]</xmp>'],
 		['<p>', '<article>[foobar]</article>'],
 		['<p>', '<ins>[foobar]</ins>'],
 		['<p>', '<del>[foobar]</del>'],
@@ -764,92 +766,110 @@
 		['<blockquote>', '<section><hgroup><h1>[foo]</h1><h2>bar</h2></hgroup><p>baz</section>'],
 		['<article>', '<section>[foo]</section>'],
 
-		['<p>', '<div>[foobar]</div>'],
+		['<address>', '<div>[foobar]</div>'],
+		['<article>', '<div>[foobar]</div>'],
 		['<blockquote>', '<div>[foobar]</div>'],
+		['<dd>', '<div>[foobar]</div>'],
+		['<del>', '<div>[foobar]</div>'],
+		['<dl>', '<div>[foobar]</div>'],
+		['<dt>', '<div>[foobar]</div>'],
 		['<h1>', '<div>[foobar]</div>'],
 		['<h2>', '<div>[foobar]</div>'],
 		['<h3>', '<div>[foobar]</div>'],
 		['<h4>', '<div>[foobar]</div>'],
 		['<h5>', '<div>[foobar]</div>'],
 		['<h6>', '<div>[foobar]</div>'],
-		['<dl>', '<div>[foobar]</div>'],
-		['<dt>', '<div>[foobar]</div>'],
-		['<dd>', '<div>[foobar]</div>'],
+		['<ins>', '<div>[foobar]</div>'],
+		['<li>', '<div>[foobar]</div>'],
 		['<ol>', '<div>[foobar]</div>'],
-		['<ul>', '<div>[foobar]</div>'],
-		['<li>', '<div>[foobar]</div>'],
-		['<address>', '<div>[foobar]</div>'],
+		['<p>', '<div>[foobar]</div>'],
 		['<pre>', '<div>[foobar]</div>'],
-		['<article>', '<div>[foobar]</div>'],
-		['<ins>', '<div>[foobar]</div>'],
-		['<del>', '<div>[foobar]</div>'],
+		['<ul>', '<div>[foobar]</div>'],
 		['<quasit>', '<div>[foobar]</div>'],
 
+		['<address>', '<p>[foobar]</p>'],
+		['<article>', '<p>[foobar]</p>'],
+		['<aside>', '<p>[foobar]</p>'],
+		['<blockquote>', '<p>[foobar]</p>'],
+		['<body>', '<p>[foobar]</p>'],
+		['<dd>', '<p>[foobar]</p>'],
+		['<del>', '<p>[foobar]</p>'],
+		['<details>', '<p>[foobar]</p>'],
+		['<dir>', '<p>[foobar]</p>'],
 		['<div>', '<p>[foobar]</p>'],
-		['<p>', '<p>[foobar]</p>'],
-		['<blockquote>', '<p>[foobar]</p>'],
+		['<dl>', '<p>[foobar]</p>'],
+		['<dt>', '<p>[foobar]</p>'],
+		['<fieldset>', '<p>[foobar]</p>'],
+		['<figcaption>', '<p>[foobar]</p>'],
+		['<figure>', '<p>[foobar]</p>'],
+		['<footer>', '<p>[foobar]</p>'],
+		['<form>', '<p>[foobar]</p>'],
 		['<h1>', '<p>[foobar]</p>'],
 		['<h2>', '<p>[foobar]</p>'],
 		['<h3>', '<p>[foobar]</p>'],
 		['<h4>', '<p>[foobar]</p>'],
 		['<h5>', '<p>[foobar]</p>'],
 		['<h6>', '<p>[foobar]</p>'],
-		['<dl>', '<p>[foobar]</p>'],
-		['<dt>', '<p>[foobar]</p>'],
-		['<dd>', '<p>[foobar]</p>'],
-		['<ol>', '<p>[foobar]</p>'],
-		['<ul>', '<p>[foobar]</p>'],
-		['<li>', '<p>[foobar]</p>'],
-		['<address>', '<p>[foobar]</p>'],
-		['<pre>', '<p>[foobar]</p>'],
-		['<ins>', '<p>[foobar]</p>'],
-		['<del>', '<p>[foobar]</p>'],
-		['<quasit>', '<p>[foobar]</p>'],
-		['<article>', '<p>[foobar]</p>'],
-		['<aside>', '<p>[foobar]</p>'],
-		['<body>', '<p>[foobar]</p>'],
-		['<figcaption>', '<p>[foobar]</p>'],
-		['<figure>', '<p>[foobar]</p>'],
-		['<footer>', '<p>[foobar]</p>'],
 		['<header>', '<p>[foobar]</p>'],
 		['<head>', '<p>[foobar]</p>'],
 		['<hgroup>', '<p>[foobar]</p>'],
+		['<hr>', '<p>[foobar]</p>'],
 		['<html>', '<p>[foobar]</p>'],
+		['<ins>', '<p>[foobar]</p>'],
+		['<li>', '<p>[foobar]</p>'],
+		['<listing>', '<p>[foobar]</p>'],
+		['<menu>', '<p>[foobar]</p>'],
 		['<nav>', '<p>[foobar]</p>'],
+		['<ol>', '<p>[foobar]</p>'],
+		['<p>', '<p>[foobar]</p>'],
+		['<plaintext>', '<p>[foobar]</p>'],
+		['<pre>', '<p>[foobar]</p>'],
 		['<section>', '<p>[foobar]</p>'],
-
+		['<ul>', '<p>[foobar]</p>'],
+		['<xmp>', '<p>[foobar]</p>'],
+		['<quasit>', '<p>[foobar]</p>'],
+
+		['<address>', '<p>[foo<p>bar]'],
+		['<article>', '<p>[foo<p>bar]'],
+		['<aside>', '<p>[foo<p>bar]'],
+		['<blockquote>', '<p>[foo<p>bar]'],
+		['<body>', '<p>[foo<p>bar]'],
+		['<dd>', '<p>[foo<p>bar]'],
+		['<del>', '<p>[foo<p>bar]'],
+		['<details>', '<p>[foo<p>bar]'],
+		['<dir>', '<p>[foo<p>bar]'],
 		['<div>', '<p>[foo<p>bar]'],
-		['<p>', '<p>[foo<p>bar]'],
-		['<blockquote>', '<p>[foo<p>bar]'],
+		['<dl>', '<p>[foo<p>bar]'],
+		['<dt>', '<p>[foo<p>bar]'],
+		['<fieldset>', '<p>[foo<p>bar]'],
+		['<figcaption>', '<p>[foo<p>bar]'],
+		['<figure>', '<p>[foo<p>bar]'],
+		['<footer>', '<p>[foo<p>bar]'],
+		['<form>', '<p>[foo<p>bar]'],
 		['<h1>', '<p>[foo<p>bar]'],
 		['<h2>', '<p>[foo<p>bar]'],
 		['<h3>', '<p>[foo<p>bar]'],
 		['<h4>', '<p>[foo<p>bar]'],
 		['<h5>', '<p>[foo<p>bar]'],
 		['<h6>', '<p>[foo<p>bar]'],
-		['<dl>', '<p>[foo<p>bar]'],
-		['<dt>', '<p>[foo<p>bar]'],
-		['<dd>', '<p>[foo<p>bar]'],
-		['<ol>', '<p>[foo<p>bar]'],
-		['<ul>', '<p>[foo<p>bar]'],
-		['<li>', '<p>[foo<p>bar]'],
-		['<address>', '<p>[foo<p>bar]'],
-		['<pre>', '<p>[foo<p>bar]'],
-		['<ins>', '<p>[foo<p>bar]'],
-		['<del>', '<p>[foo<p>bar]'],
-		['<quasit>', '<p>[foo<p>bar]'],
-		['<article>', '<p>[foo<p>bar]'],
-		['<aside>', '<p>[foo<p>bar]'],
-		['<body>', '<p>[foo<p>bar]'],
-		['<figcaption>', '<p>[foo<p>bar]'],
-		['<figure>', '<p>[foo<p>bar]'],
-		['<footer>', '<p>[foo<p>bar]'],
 		['<header>', '<p>[foo<p>bar]'],
 		['<head>', '<p>[foo<p>bar]'],
 		['<hgroup>', '<p>[foo<p>bar]'],
+		['<hr>', '<p>[foo<p>bar]'],
 		['<html>', '<p>[foo<p>bar]'],
+		['<ins>', '<p>[foo<p>bar]'],
+		['<li>', '<p>[foo<p>bar]'],
+		['<listing>', '<p>[foo<p>bar]'],
+		['<menu>', '<p>[foo<p>bar]'],
 		['<nav>', '<p>[foo<p>bar]'],
+		['<ol>', '<p>[foo<p>bar]'],
+		['<p>', '<p>[foo<p>bar]'],
+		['<plaintext>', '<p>[foo<p>bar]'],
+		['<pre>', '<p>[foo<p>bar]'],
 		['<section>', '<p>[foo<p>bar]'],
+		['<ul>', '<p>[foo<p>bar]'],
+		['<xmp>', '<p>[foo<p>bar]'],
+		['<quasit>', '<p>[foo<p>bar]'],
 
 		['p', '<div>[foobar]</div>'],
 
@@ -1767,6 +1787,7 @@
 		'<xmp>foo[]bar</xmp>',
 		'<script>foo[]bar</script>baz',
 		'<div style=display:none>foo[]bar</div>baz',
+		'<listing>foo[]bar</listing>',
 
 		'<ol><li>{}<br></li></ol>',
 		'foo<ol><li>{}<br></li></ol>',