Improve linebreak handling for nested containers
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Wed, 26 Oct 2011 13:15:38 -0600
changeset 655 8578618a74e6
parent 654 66e8fd53ba39
child 656 727d13f81c29
Improve linebreak handling for nested containers

Previously, hitting Enter (running insertParagraph) for markup such as
<ol><li><p>foo[]bar</ol>
would produce
<ol><li><p>foo<p>[]bar</ol>
This matches browsers, but it means that hitting Enter won't break out
of the list item, which is unexpected. This changes the markup to
<ol><li><p>foo<li><p>[]bar</ol>
which is more likely to match user expectations.

Fixes: http://www.w3.org/Bugs/Public/show_bug.cgi?id=13841
conformancetest/data.js
editing.html
implementation.js
source.html
tests.js
--- a/conformancetest/data.js	Wed Oct 26 14:17:07 2011 -0600
+++ b/conformancetest/data.js	Wed Oct 26 13:15:38 2011 -0600
@@ -14495,6 +14495,366 @@
 	[["stylewithcss","true"],["insertlinebreak",""]],
 	"<div contenteditable=\"false\"><ul contenteditable=\"\"><li>foo<br>{}<br></li></ul></div>",
 	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>foo[]</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><p>foo<br>{}<br></p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>foo[]</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><p>foo<br>{}<br></p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><p>foo<br>{}<br></p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><p>foo<br>{}<br></p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><p>foo<br>{}<br></p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><p>foo<br>{}<br></p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><p>foo<br>{}<br></p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><p>foo<br>{}<br></p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><p>foo<br>{}<br></p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><p>foo<br>{}<br></p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>foo[]</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><div>foo<br>{}<br></div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>foo[]</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><div>foo<br>{}<br></div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><div>foo<br>{}<br></div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><div>foo<br>{}<br></div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><div>foo<br>{}<br></div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><div>foo<br>{}<br></div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><div>foo<br>{}<br></div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><div>foo<br>{}<br></div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><div>foo<br>{}<br></div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><div>foo<br>{}<br></div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>foo[]</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><p>foo<br>{}<br></p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>foo[]</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><p>foo<br>{}<br></p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>foo[]</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><div>foo<br>{}<br></div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>foo[]</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><div>foo<br>{}<br></div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>[]foo</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><p><br>{}foo</p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>[]foo</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><p><br>{}foo</p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>[]foo</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><p><br>{}foo</p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>[]foo</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><p><br>{}foo</p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>[]foo</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><p><br>{}foo</p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>[]foo</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><p><br>{}foo</p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>[]foo</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><p><br>{}foo</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>[]foo</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><p><br>{}foo</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>[]foo</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><p><br>{}foo</p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>[]foo</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><p><br>{}foo</p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>[]foo</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><div><br>{}foo</div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>[]foo</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><div><br>{}foo</div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>[]foo</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><div><br>{}foo</div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>[]foo</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><div><br>{}foo</div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>[]foo</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><div><br>{}foo</div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>[]foo</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><div><br>{}foo</div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>[]foo</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><div><br>{}foo</div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>[]foo</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><div><br>{}foo</div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>[]foo</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><div><br>{}foo</div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>[]foo</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><div><br>{}foo</div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>[]foo</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><p><br>{}foo</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>[]foo</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><p><br>{}foo</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>[]foo</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><div><br>{}foo</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>[]foo</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><div><br>{}foo</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>foo[]bar</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><p>foo<br>{}bar</p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><p>foo[]bar</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><p>foo<br>{}bar</p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><p>foo<br>{}bar</p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><p>foo<br>{}bar</p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><p>foo<br>{}bar</p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><p>foo<br>{}bar</p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><p>foo<br>{}bar</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><p>foo<br>{}bar</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]bar</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><p>foo<br>{}bar</p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]bar</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><p>foo<br>{}bar</p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>foo[]bar</address>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<address><div>foo<br>{}bar</div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<address><div>foo[]bar</address>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<address><div>foo<br>{}bar</div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dt><div>foo<br>{}bar</div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dt><div>foo<br>{}bar</div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<dl><dd><div>foo<br>{}bar</div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<dl><dd><div>foo<br>{}bar</div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li><div>foo<br>{}bar</div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li><div>foo<br>{}bar</div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]bar</ul>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ul><li><div>foo<br>{}bar</div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]bar</ul>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ul><li><div>foo<br>{}bar</div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>foo[]bar</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><p>foo<br>{}bar</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><p>foo[]bar</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><p>foo<br>{}bar</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>foo[]bar</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div><div>foo<br>{}bar</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div><div>foo[]bar</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div><div>foo<br>{}bar</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}<br></p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}<br></p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]</div></div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo<br>{}<br></div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]</div></div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo<br>{}<br></div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}<br></p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}<br></p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>[]foo</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br>{}foo</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>[]foo</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br>{}foo</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>[]foo</div></div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\"><br>{}foo</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>[]foo</div></div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\"><br>{}foo</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>[]foo</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br>{}foo</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>[]foo</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br>{}foo</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}bar</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}bar</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]bar</div></div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo<br>{}bar</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]bar</div></div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo<br>{}bar</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]bar</div>",
+	[["stylewithcss","false"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}bar</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertlinebreak":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]bar</div>",
+	[["stylewithcss","true"],["insertlinebreak",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo<br>{}bar</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertlinebreak":[false,false,"",false,false,""]}],
 ["foo[]bar",
 	[["stylewithcss","false"],["insertorderedlist",""]],
 	"<ol><li>foo[]bar</li></ol>",
@@ -16263,6 +16623,366 @@
 	[["stylewithcss","true"],["insertparagraph",""]],
 	"<div contenteditable=\"false\"><ul contenteditable=\"\"><li>foo</li><li>{}<br></li></ul></div>",
 	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>foo[]</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><p>foo</p><p>{}<br></p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>foo[]</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><p>foo</p><p>{}<br></p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><p>foo</p></dt><dd><p>{}<br></p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><p>foo</p></dt><dd><p>{}<br></p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><p>foo</p></dd><dt><p>{}<br></p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><p>foo</p></dd><dt><p>{}<br></p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><p>foo</p></li><li><p>{}<br></p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><p>foo</p></li><li><p>{}<br></p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><p>foo</p></li><li><p>{}<br></p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><p>foo</p></li><li><p>{}<br></p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>foo[]</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><div>foo</div><div>{}<br></div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>foo[]</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><div>foo</div><div>{}<br></div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><div>foo</div></dt><dd><div>{}<br></div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><div>foo</div></dt><dd><div>{}<br></div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><div>foo</div></dd><dt><div>{}<br></div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><div>foo</div></dd><dt><div>{}<br></div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><div>foo</div></li><li><div>{}<br></div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><div>foo</div></li><li><div>{}<br></div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><div>foo</div></li><li><div>{}<br></div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><div>foo</div></li><li><div>{}<br></div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>foo[]</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><p>foo</p><p>{}<br></p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>foo[]</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><p>foo</p><p>{}<br></p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>foo[]</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><div>foo</div><div>{}<br></div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>foo[]</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><div>foo</div><div>{}<br></div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>[]foo</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><p><br></p><p>{}foo</p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>[]foo</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><p><br></p><p>{}foo</p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>[]foo</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><p><br></p></dt><dt><p>{}foo</p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>[]foo</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><p><br></p></dt><dt><p>{}foo</p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>[]foo</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><p><br></p></dd><dd><p>{}foo</p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>[]foo</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><p><br></p></dd><dd><p>{}foo</p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>[]foo</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><p><br></p></li><li><p>{}foo</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>[]foo</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><p><br></p></li><li><p>{}foo</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>[]foo</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><p><br></p></li><li><p>{}foo</p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>[]foo</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><p><br></p></li><li><p>{}foo</p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>[]foo</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><div><br></div><div>{}foo</div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>[]foo</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><div><br></div><div>{}foo</div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>[]foo</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><div><br></div></dt><dt><div>{}foo</div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>[]foo</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><div><br></div></dt><dt><div>{}foo</div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>[]foo</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><div><br></div></dd><dd><div>{}foo</div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>[]foo</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><div><br></div></dd><dd><div>{}foo</div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>[]foo</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><div><br></div></li><li><div>{}foo</div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>[]foo</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><div><br></div></li><li><div>{}foo</div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>[]foo</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><div><br></div></li><li><div>{}foo</div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>[]foo</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><div><br></div></li><li><div>{}foo</div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>[]foo</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><p><br></p><p>{}foo</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>[]foo</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><p><br></p><p>{}foo</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>[]foo</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><div><br></div><div>{}foo</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>[]foo</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><div><br></div><div>{}foo</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>foo[]bar</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><p>foo</p><p>{}bar</p></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><p>foo[]bar</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><p>foo</p><p>{}bar</p></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><p>foo</p></dt><dt><p>{}bar</p></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><p>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><p>foo</p></dt><dt><p>{}bar</p></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><p>foo</p></dd><dd><p>{}bar</p></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><p>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><p>foo</p></dd><dd><p>{}bar</p></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><p>foo</p></li><li><p>{}bar</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><p>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><p>foo</p></li><li><p>{}bar</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]bar</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><p>foo</p></li><li><p>{}bar</p></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><p>foo[]bar</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><p>foo</p></li><li><p>{}bar</p></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>foo[]bar</address>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<address><div>foo</div><div>{}bar</div></address>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<address><div>foo[]bar</address>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<address><div>foo</div><div>{}bar</div></address>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dt><div>foo</div></dt><dt><div>{}bar</div></dt></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dt><div>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dt><div>foo</div></dt><dt><div>{}bar</div></dt></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]bar</dl>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<dl><dd><div>foo</div></dd><dd><div>{}bar</div></dd></dl>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<dl><dd><div>foo[]bar</dl>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<dl><dd><div>foo</div></dd><dd><div>{}bar</div></dd></dl>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li><div>foo</div></li><li><div>{}bar</div></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li><div>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li><div>foo</div></li><li><div>{}bar</div></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]bar</ul>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ul><li><div>foo</div></li><li><div>{}bar</div></li></ul>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ul><li><div>foo[]bar</ul>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ul><li><div>foo</div></li><li><div>{}bar</div></li></ul>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>foo[]bar</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><p>foo</p><p>{}bar</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><p>foo[]bar</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><p>foo</p><p>{}bar</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>foo[]bar</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div><div>foo</div><div>{}bar</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div><div>foo[]bar</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div><div>foo</div><div>{}bar</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p></li><li class=\"a\"><p class=\"b\">{}<br></p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p></li><li class=\"a\"><p class=\"b\">{}<br></p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]</div></div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo</div><div class=\"b\">{}<br></div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]</div></div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo</div><div class=\"b\">{}<br></div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p><p class=\"b\">{}<br></p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p><p class=\"b\">{}<br></p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>[]foo</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br></p></li><li class=\"a\"><p class=\"b\">{}foo</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>[]foo</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br></p></li><li class=\"a\"><p class=\"b\">{}foo</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>[]foo</div></div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\"><br></div><div class=\"b\">{}foo</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>[]foo</div></div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\"><br></div><div class=\"b\">{}foo</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>[]foo</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br></p><p class=\"b\">{}foo</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>[]foo</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\"><br></p><p class=\"b\">{}foo</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]bar</ol>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p></li><li class=\"a\"><p class=\"b\">{}bar</p></li></ol>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<ol><li class=a id=x><p class=b id=y>foo[]bar</ol>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<ol><li class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p></li><li class=\"a\"><p class=\"b\">{}bar</p></li></ol>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]bar</div></div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo</div><div class=\"b\">{}bar</div></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><div class=b id=y>foo[]bar</div></div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><div class=\"b\" id=\"y\">foo</div><div class=\"b\">{}bar</div></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]bar</div>",
+	[["stylewithcss","false"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p><p class=\"b\">{}bar</p></div>",
+	{"stylewithcss":[false,true,"",false,false,""],"insertparagraph":[false,false,"",false,false,""]}],
+["<div class=a id=x><p class=b id=y>foo[]bar</div>",
+	[["stylewithcss","true"],["insertparagraph",""]],
+	"<div class=\"a\" id=\"x\"><p class=\"b\" id=\"y\">foo</p><p class=\"b\">{}bar</p></div>",
+	{"stylewithcss":[false,false,"",false,true,""],"insertparagraph":[false,false,"",false,false,""]}],
 ["foo[bar]baz",
 	[["stylewithcss","false"],["inserttext","a"]],
 	"fooa[]baz",
--- a/editing.html	Wed Oct 26 14:17:07 2011 -0600
+++ b/editing.html	Wed Oct 26 13:15:38 2011 -0600
@@ -65,7 +65,7 @@
 <body class=draft>
 <div class=head id=head>
 <h1>HTML Editing APIs</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-24-october-2011>Work in Progress &mdash; Last Update 24 October 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-26-october-2011>Work in Progress &mdash; Last Update 26 October 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;<a href=mailto:[email protected]>[email protected]</a>&gt;
@@ -8957,6 +8957,24 @@
   its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
 
   <li>
+  <p class=comments><a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=13841">Bug 13841</a>.
+
+  <p>If <var title="">container</var> is an <a href=#editable>editable</a> <a href=#single-line-container>single-line
+  container</a> <a href=#in-the-same-editing-host>in the same editing host</a> as <var title="">node</var>,
+  and its <a class=external data-anolis-spec=dom 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 "p" or "div":
+
+  <ol>
+    <li>Let <var title="">outer container</var> equal <var title="">container</var>.
+
+    <li>While <var title="">outer container</var> is not a <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-dd-element>dd</a></code> or <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-li-element>li</a></code>,
+    and <var title="">outer container</var>'s <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> is <a href=#editable>editable</a>, set
+    <var title="">outer container</var> to its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a>.
+
+    <li>If <var title="">outer container</var> is a <code class=external data-anolis-spec=html title="the dd element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-dd-element>dd</a></code> or <code class=external data-anolis-spec=html title="the dt element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-dt-element>dt</a></code> or <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-li-element>li</a></code>, set
+    <var title="">container</var> to <var title="">outer container</var>.
+  </ol>
+
+  <li>
   <p class=comments>We add the default wrapper in this case.
 
   <p>If <var title="">container</var> is not <a href=#editable>editable</a> or not <a href=#in-the-same-editing-host>in the
@@ -9106,17 +9124,17 @@
   <li>
   <p class=comments>We don't want the start to be just inside a node, because
   if it is, we'll leave behind an empty element either in the new or old
-  container.  Clearly we don't want the start point to get any higher than the
-  container itself, though.
+  container.  Empty block nodes are fine, and we'll add a <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-br-element>br</a></code> later, but
+  empty inline nodes are bad, since the user can't interact with them.
 
   <p>While <var title="">new line range</var>'s <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-offset title=concept-range-start-offset>start offset</a> is zero and its
-  <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> is not <var title="">container</var>, set its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start title=concept-range-start>start</a> to
-  (<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>, <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-index title=concept-tree-index>index</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>).
+  <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> is not a <a href=#prohibited-paragraph-child>prohibited paragraph child</a>, set its
+  <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start title=concept-range-start>start</a> to (<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>, <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-index title=concept-tree-index>index</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>).
 
   <li>While <var title="">new line range</var>'s <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-offset title=concept-range-start-offset>start offset</a> is the <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-length title=concept-node-length>length</a>
-  of its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> and its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> is not <var title="">container</var>, set
-  its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start title=concept-range-start>start</a> to (<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>, 1 + <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-index title=concept-tree-index>index</a> of
-  <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>).
+  of its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> and its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a> is not a <a href=#prohibited-paragraph-child>prohibited
+  paragraph child</a>, set its <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start title=concept-range-start>start</a> to (<a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-parent title=concept-tree-parent>parent</a> of
+  <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>, 1 + <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-index title=concept-tree-index>index</a> of <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-range-start-node title=concept-range-start-node>start node</a>).
 
   <li>Let <var title="">end of line</var> be true if <var title="">new line range</var>
   <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#contained title=contained>contains</a> either nothing or a single <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-br-element>br</a></code>, and false otherwise.
@@ -9174,6 +9192,18 @@
 
   <li>Call <code class=external data-anolis-spec=dom title=dom-Node-appendChild><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-appendchild>appendChild(<var title="">frag</var>)</a></code> on <var title="">new container</var>.
 
+  <li>
+  <p class=comments>Needed in case we have something like
+  <code title="">&lt;ol&gt;&lt;li&gt;&lt;p&gt;[]foo&lt;/ol&gt;</code>, which becomes
+  <code title="">&lt;ol&gt;&lt;li&gt;&lt;p&gt;&lt;li&gt;&lt;p&gt;foo&lt;/ol&gt;</code>.  In this case we want to add the <code class=external data-anolis-spec=html title="the br element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-br-element>br</a></code>
+  to the <code class=external data-anolis-spec=html title="the p element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-p-element>p</a></code>, not the <code class=external data-anolis-spec=html title="the li element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-li-element>li</a></code>.  Likewise for <code title="">&lt;ol&gt;&lt;li&gt;&lt;p&gt;foo[]&lt;/ol&gt;</code>.
+
+  <p>While <var title="">container</var>'s <code class=external data-anolis-spec=dom title=dom-Node-lastChild><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-lastchild>lastChild</a></code> is a <a href=#prohibited-paragraph-child>prohibited paragraph
+  child</a>, set <var title="">container</var> to its <code class=external data-anolis-spec=dom title=dom-Node-lastChild><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-lastchild>lastChild</a></code>.
+
+  <li>While <var title="">new container</var>'s <code class=external data-anolis-spec=dom title=dom-Node-lastChild><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-lastchild>lastChild</a></code> is a <a href=#prohibited-paragraph-child>prohibited
+  paragraph child</a>, set <var title="">new container</var> to its <code class=external data-anolis-spec=dom title=dom-Node-lastChild><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-node-lastchild>lastChild</a></code>.
+
   <li>If <var title="">container</var> has no <a href=#visible>visible</a> <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>children</a>, call
   <code class=external data-anolis-spec=dom title=dom-Document-createElement><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createelement>createElement("br")</a></code> on the <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#context-object>context object</a>, and append the result as the
   last <a class=external data-anolis-spec=dom href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-tree-child title=concept-tree-child>child</a> of <var title="">container</var>.
--- a/implementation.js	Wed Oct 26 14:17:07 2011 -0600
+++ b/implementation.js	Wed Oct 26 13:15:38 2011 -0600
@@ -7272,6 +7272,30 @@
 			container = container.parentNode;
 		}
 
+		// "If container is an editable single-line container in the same
+		// editing host as node, and its local name is "p" or "div":"
+		if (isEditable(container)
+		&& isSingleLineContainer(container)
+		&& inSameEditingHost(node, container.parentNode)
+		&& (container.tagName == "P" || container.tagName == "DIV")) {
+			// "Let outer container equal container."
+			var outerContainer = container;
+
+			// "While outer container is not a dd or dt or li, and outer
+			// container's parent is editable, set outer container to its
+			// parent."
+			while (!isHtmlElement(outerContainer, ["dd", "dt", "li"])
+			&& isEditable(outerContainer.parentNode)) {
+				outerContainer = outerContainer.parentNode;
+			}
+
+			// "If outer container is a dd or dt or li, set container to outer
+			// container."
+			if (isHtmlElement(outerContainer, ["dd", "dt", "li"])) {
+				container = outerContainer;
+			}
+		}
+
 		// "If container is not editable or not in the same editing host as
 		// node or is not a single-line container:"
 		if (!isEditable(container)
@@ -7413,18 +7437,18 @@
 		newLineRange.setEnd(container, getNodeLength(container));
 
 		// "While new line range's start offset is zero and its start node is
-		// not container, set its start to (parent of start node, index of
-		// start node)."
+		// not a prohibited paragraph child, set its start to (parent of start
+		// node, index of start node)."
 		while (newLineRange.startOffset == 0
-		&& newLineRange.startContainer != container) {
+		&& !isProhibitedParagraphChild(newLineRange.startContainer)) {
 			newLineRange.setStart(newLineRange.startContainer.parentNode, getNodeIndex(newLineRange.startContainer));
 		}
 
 		// "While new line range's start offset is the length of its start node
-		// and its start node is not container, set its start to (parent of
-		// start node, 1 + index of start node)."
+		// and its start node is not a prohibited paragraph child, set its
+		// start to (parent of start node, 1 + index of start node)."
 		while (newLineRange.startOffset == getNodeLength(newLineRange.startContainer)
-		&& newLineRange.startContainer != container) {
+		&& !isProhibitedParagraphChild(newLineRange.startContainer)) {
 			newLineRange.setStart(newLineRange.startContainer.parentNode, 1 + getNodeIndex(newLineRange.startContainer));
 		}
 
@@ -7496,6 +7520,18 @@
 		// "Call appendChild(frag) on new container."
 		newContainer.appendChild(frag);
 
+		// "While container's lastChild is a prohibited paragraph child, set
+		// container to its lastChild."
+		while (isProhibitedParagraphChild(container.lastChild)) {
+			container = container.lastChild;
+		}
+
+		// "While new container's lastChild is a prohibited paragraph child,
+		// set new container to its lastChild."
+		while (isProhibitedParagraphChild(newContainer.lastChild)) {
+			newContainer = newContainer.lastChild;
+		}
+
 		// "If container has no visible children, call createElement("br") on
 		// the context object, and append the result as the last child of
 		// container."
--- a/source.html	Wed Oct 26 14:17:07 2011 -0600
+++ b/source.html	Wed Oct 26 13:15:38 2011 -0600
@@ -9047,6 +9047,25 @@
   its [[parent]].
 
   <li>
+  <p class=comments><a
+  href=http://www.w3.org/Bugs/Public/show_bug.cgi?id=13841>Bug 13841</a>.
+
+  <p>If <var>container</var> is an <span>editable</span> <span>single-line
+  container</span> <span>in the same editing host</span> as <var>node</var>,
+  and its [[localname]] is "p" or "div":
+
+  <ol>
+    <li>Let <var>outer container</var> equal <var>container</var>.
+
+    <li>While <var>outer container</var> is not a [[dd]] or [[dt]] or [[li]],
+    and <var>outer container</var>'s [[parent]] is <span>editable</span>, set
+    <var>outer container</var> to its [[parent]].
+
+    <li>If <var>outer container</var> is a [[dd]] or [[dt]] or [[li]], set
+    <var>container</var> to <var>outer container</var>.
+  </ol>
+
+  <li>
   <p class=comments>We add the default wrapper in this case.
 
   <p>If <var>container</var> is not <span>editable</span> or not <span>in the
@@ -9196,17 +9215,17 @@
   <li>
   <p class=comments>We don't want the start to be just inside a node, because
   if it is, we'll leave behind an empty element either in the new or old
-  container.  Clearly we don't want the start point to get any higher than the
-  container itself, though.
+  container.  Empty block nodes are fine, and we'll add a [[br]] later, but
+  empty inline nodes are bad, since the user can't interact with them.
 
   <p>While <var>new line range</var>'s [[startoffset]] is zero and its
-  [[startnode]] is not <var>container</var>, set its [[rangestart]] to
-  ([[parent]] of [[startnode]], [[index]] of [[startnode]]).
+  [[startnode]] is not a <span>prohibited paragraph child</span>, set its
+  [[rangestart]] to ([[parent]] of [[startnode]], [[index]] of [[startnode]]).
 
   <li>While <var>new line range</var>'s [[startoffset]] is the [[length]]
-  of its [[startnode]] and its [[startnode]] is not <var>container</var>, set
-  its [[rangestart]] to ([[parent]] of [[startnode]], 1 + [[index]] of
-  [[startnode]]).
+  of its [[startnode]] and its [[startnode]] is not a <span>prohibited
+  paragraph child</span>, set its [[rangestart]] to ([[parent]] of
+  [[startnode]], 1 + [[index]] of [[startnode]]).
 
   <li>Let <var>end of line</var> be true if <var>new line range</var>
   [[contains]] either nothing or a single [[br]], and false otherwise.
@@ -9264,6 +9283,18 @@
 
   <li>Call [[appendchild|<var>frag</var>]] on <var>new container</var>.
 
+  <li>
+  <p class=comments>Needed in case we have something like
+  {{code|<ol><li><p>[]foo</ol>}}, which becomes
+  {{code|<ol><li><p><li><p>foo</ol>}}.  In this case we want to add the [[br]]
+  to the [[p]], not the [[li]].  Likewise for {{code|<ol><li><p>foo[]</ol>}}.
+
+  <p>While <var>container</var>'s [[lastchild]] is a <span>prohibited paragraph
+  child</span>, set <var>container</var> to its [[lastchild]].
+
+  <li>While <var>new container</var>'s [[lastchild]] is a <span>prohibited
+  paragraph child</span>, set <var>new container</var> to its [[lastchild]].
+
   <li>If <var>container</var> has no <span>visible</span> [[children]], call
   [[createelement|"br"]] on the [[contextobject]], and append the result as the
   last [[child]] of <var>container</var>.
--- a/tests.js	Wed Oct 26 14:17:07 2011 -0600
+++ b/tests.js	Wed Oct 26 13:15:38 2011 -0600
@@ -2336,6 +2336,57 @@
 		'<ul contenteditable><li>foo[]</ul>',
 		'<div contenteditable=false><ul contenteditable><li>{}<br></ul></div>',
 		'<div contenteditable=false><ul contenteditable><li>foo[]</ul></div>',
+
+		// http://www.w3.org/Bugs/Public/show_bug.cgi?id=13841
+		// https://bugs.webkit.org/show_bug.cgi?id=23507
+		'<address><p>foo[]</address>',
+		'<dl><dt><p>foo[]</dl>',
+		'<dl><dd><p>foo[]</dl>',
+		'<ol><li><p>foo[]</ol>',
+		'<ul><li><p>foo[]</ul>',
+		'<address><div>foo[]</address>',
+		'<dl><dt><div>foo[]</dl>',
+		'<dl><dd><div>foo[]</dl>',
+		'<ol><li><div>foo[]</ol>',
+		'<ul><li><div>foo[]</ul>',
+		'<div><p>foo[]</div>',
+		'<div><div>foo[]</div>',
+
+		'<address><p>[]foo</address>',
+		'<dl><dt><p>[]foo</dl>',
+		'<dl><dd><p>[]foo</dl>',
+		'<ol><li><p>[]foo</ol>',
+		'<ul><li><p>[]foo</ul>',
+		'<address><div>[]foo</address>',
+		'<dl><dt><div>[]foo</dl>',
+		'<dl><dd><div>[]foo</dl>',
+		'<ol><li><div>[]foo</ol>',
+		'<ul><li><div>[]foo</ul>',
+		'<div><p>[]foo</div>',
+		'<div><div>[]foo</div>',
+
+		'<address><p>foo[]bar</address>',
+		'<dl><dt><p>foo[]bar</dl>',
+		'<dl><dd><p>foo[]bar</dl>',
+		'<ol><li><p>foo[]bar</ol>',
+		'<ul><li><p>foo[]bar</ul>',
+		'<address><div>foo[]bar</address>',
+		'<dl><dt><div>foo[]bar</dl>',
+		'<dl><dd><div>foo[]bar</dl>',
+		'<ol><li><div>foo[]bar</ol>',
+		'<ul><li><div>foo[]bar</ul>',
+		'<div><p>foo[]bar</div>',
+		'<div><div>foo[]bar</div>',
+
+		'<ol><li class=a id=x><p class=b id=y>foo[]</ol>',
+		'<div class=a id=x><div class=b id=y>foo[]</div></div>',
+		'<div class=a id=x><p class=b id=y>foo[]</div>',
+		'<ol><li class=a id=x><p class=b id=y>[]foo</ol>',
+		'<div class=a id=x><div class=b id=y>[]foo</div></div>',
+		'<div class=a id=x><p class=b id=y>[]foo</div>',
+		'<ol><li class=a id=x><p class=b id=y>foo[]bar</ol>',
+		'<div class=a id=x><div class=b id=y>foo[]bar</div></div>',
+		'<div class=a id=x><p class=b id=y>foo[]bar</div>',
 	],
 	//@}
 	inserttext: [