Wrap non-text nodes too for inline formatting
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Tue, 08 Nov 2011 09:47:12 -0700
changeset 666 0e6c95119654
parent 665 d461532af710
child 667 fe389ca05561
Wrap non-text nodes too for inline formatting

This more closely matches WebKit, while the old behavior more closely
matched Gecko. The new behavior is better, because this way if the user
moves their cursor into the empty block, it will have the formatting
(bold or whatever).

Also fixed an unrelated bug in implementation.js, where value was not
getting computed quite correctly for standard inline value commands: I
forgot to update one place to use isFormattableNode when I added it.

Fixes: http://www.w3.org/Bugs/Public/show_bug.cgi?id=14729
conformancetest/data.js
editing.html
implementation.js
source.html
tests.js
--- a/conformancetest/data.js	Tue Nov 08 09:40:24 2011 -0700
+++ b/conformancetest/data.js	Tue Nov 08 09:47:12 2011 -0700
@@ -31,6 +31,14 @@
 	[["stylewithcss","true"],["backcolor","#00FFFF"]],
 	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p> <span style=\"background-color:rgb(0, 255, 255)\"><span>bar</span></span> </p><p><span style=\"background-color:rgb(0, 255, 255)\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["backcolor","#00FFFF"]],
+	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p><span style=\"background-color:rgb(0, 255, 255)\"><br></span></p><p><span style=\"background-color:rgb(0, 255, 255)\">bar]</span></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["backcolor","#00FFFF"]],
+	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p><span style=\"background-color:rgb(0, 255, 255)\"><br></span></p><p><span style=\"background-color:rgb(0, 255, 255)\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["backcolor","#00FFFF"]],
 	"<b>foo[]bar</b>",
@@ -90,11 +98,11 @@
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","false"],["backcolor","#00FFFF"]],
 	"{<p></p><p> </p><p><span style=\"background-color:rgb(0, 255, 255)\">foo</span></p>}",
-	{"stylewithcss":[false,true,"",false,false,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgba(0, 0, 0, 0)"]}],
+	{"stylewithcss":[false,true,"",false,false,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","true"],["backcolor","#00FFFF"]],
 	"{<p></p><p> </p><p><span style=\"background-color:rgb(0, 255, 255)\">foo</span></p>}",
-	{"stylewithcss":[false,false,"",false,true,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgba(0, 0, 0, 0)"]}],
+	{"stylewithcss":[false,false,"",false,true,""],"backcolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>",
 	[["stylewithcss","false"],["backcolor","#00FFFF"]],
 	"<table><tbody><tr><td>foo</td><td>b<span style=\"background-color:rgb(0, 255, 255)\">[a]</span>r</td><td>baz</td></tr></tbody></table>",
@@ -359,6 +367,14 @@
 	[["stylewithcss","true"],["bold",""]],
 	"<p><span style=\"font-weight:bold\">[foo</span></p><p> <span style=\"font-weight:bold\"><span>bar</span></span> </p><p><span style=\"font-weight:bold\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"bold":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["bold",""]],
+	"<p><b>[foo</b></p><p><b><br></b></p><p><b>bar]</b></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"bold":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["bold",""]],
+	"<p><span style=\"font-weight:bold\">[foo</span></p><p><span style=\"font-weight:bold\"><br></span></p><p><span style=\"font-weight:bold\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"bold":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["bold",""]],
 	"<b>foo[]bar</b>",
@@ -1335,6 +1351,14 @@
 	[["stylewithcss","true"],["createlink","http://www.google.com/"]],
 	"<p><a href=\"http://www.google.com/\">[foo</a></p><p> <a href=\"http://www.google.com/\"><span>bar</span></a> </p><p><a href=\"http://www.google.com/\">baz]</a></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"createlink":[false,false,"",false,false,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["createlink","http://www.google.com/"]],
+	"<p><a href=\"http://www.google.com/\">[foo</a></p><p><a href=\"http://www.google.com/\"><br></a></p><p><a href=\"http://www.google.com/\">bar]</a></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"createlink":[false,false,"",false,false,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["createlink","http://www.google.com/"]],
+	"<p><a href=\"http://www.google.com/\">[foo</a></p><p><a href=\"http://www.google.com/\"><br></a></p><p><a href=\"http://www.google.com/\">bar]</a></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"createlink":[false,false,"",false,false,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["createlink","http://www.google.com/"]],
 	"<b>foo[]bar</b>",
@@ -4463,6 +4487,14 @@
 	[["stylewithcss","true"],["fontname","sans-serif"]],
 	"<p><span style=\"font-family:sans-serif\">[foo</span></p><p> <span style=\"font-family:sans-serif\"><span>bar</span></span> </p><p><span style=\"font-family:sans-serif\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["fontname","sans-serif"]],
+	"<p><font face=\"sans-serif\">[foo</font></p><p><font face=\"sans-serif\"><br></font></p><p><font face=\"sans-serif\">bar]</font></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["fontname","sans-serif"]],
+	"<p><span style=\"font-family:sans-serif\">[foo</span></p><p><span style=\"font-family:sans-serif\"><br></span></p><p><span style=\"font-family:sans-serif\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
 	"<b>foo[]bar</b>",
@@ -4522,11 +4554,11 @@
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
 	"{<p></p><p> </p><p><font face=\"sans-serif\">foo</font></p>}",
-	{"stylewithcss":[false,true,"",false,false,""],"fontname":[false,false,"serif",false,false,"serif"]}],
+	{"stylewithcss":[false,true,"",false,false,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","true"],["fontname","sans-serif"]],
 	"{<p></p><p> </p><p><span style=\"font-family:sans-serif\">foo</span></p>}",
-	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"serif",false,false,"serif"]}],
+	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
 ["<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
 	"<table><tbody><tr><td>foo</td><td>b<font face=\"sans-serif\">[a]</font>r</td><td>baz</td></tr></tbody></table>",
@@ -4873,20 +4905,20 @@
 	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"monospace",false,false,"sans-serif"]}],
 ["foo<tt>{<br></tt>}bar",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
-	"foo<tt>{<br></tt>}bar",
+	"foo<tt>{<font face=\"sans-serif\"><br></font></tt>}bar",
 	{"stylewithcss":[false,true,"",false,false,""],"fontname":[false,false,"monospace",false,false,"sans-serif"]}],
 ["foo<tt>{<br></tt>}bar",
 	[["stylewithcss","true"],["fontname","sans-serif"]],
-	"foo<tt>{<br></tt>}bar",
+	"foo<tt>{<span style=\"font-family:sans-serif\"><br></span></tt>}bar",
 	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"monospace",false,false,"sans-serif"]}],
 ["foo<tt>{<br></tt>b]ar",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
 	"foo<tt>{<font face=\"sans-serif\"><br></font></tt><font face=\"sans-serif\">b]</font>ar",
-	{"stylewithcss":[false,true,"",false,false,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
+	{"stylewithcss":[false,true,"",false,false,""],"fontname":[true,false,"monospace",false,false,"sans-serif"]}],
 ["foo<tt>{<br></tt>b]ar",
 	[["stylewithcss","true"],["fontname","sans-serif"]],
 	"foo<tt>{<span style=\"font-family:sans-serif\"><br></span></tt><span style=\"font-family:sans-serif\">b]</span>ar",
-	{"stylewithcss":[false,false,"",false,true,""],"fontname":[false,false,"serif",false,false,"sans-serif"]}],
+	{"stylewithcss":[false,false,"",false,true,""],"fontname":[true,false,"monospace",false,false,"sans-serif"]}],
 ["fo[o<span style=font-family:monospace>b]ar</span>baz",
 	[["stylewithcss","false"],["fontname","sans-serif"]],
 	"fo<font face=\"sans-serif\">[o</font><span style=\"font-family:monospace\"><font face=\"sans-serif\">b]</font>ar</span>baz",
@@ -5055,6 +5087,14 @@
 	[["stylewithcss","true"],["fontsize","4"]],
 	"<p><span style=\"font-size:large\">[foo</span></p><p> <span style=\"font-size:large\"><span>bar</span></span> </p><p><span style=\"font-size:large\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"fontsize":[false,false,"3",false,false,"4"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["fontsize","4"]],
+	"<p><font size=\"4\">[foo</font></p><p><br></p><p><font size=\"4\">bar]</font></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"fontsize":[false,false,"3",true,false,"4"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["fontsize","4"]],
+	"<p><span style=\"font-size:large\">[foo</span></p><p><br></p><p><span style=\"font-size:large\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"fontsize":[false,false,"3",true,false,"4"]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["fontsize","4"]],
 	"<b>foo[]bar</b>",
@@ -5743,6 +5783,14 @@
 	[["stylewithcss","true"],["forecolor","#0000FF"]],
 	"<p><span style=\"color:rgb(0, 0, 255)\">[foo</span></p><p> <span style=\"color:rgb(0, 0, 255)\"><span>bar</span></span> </p><p><span style=\"color:rgb(0, 0, 255)\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["forecolor","#0000FF"]],
+	"<p><font color=\"#0000ff\">[foo</font></p><p><font color=\"#0000ff\"><br></font></p><p><font color=\"#0000ff\">bar]</font></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["forecolor","#0000FF"]],
+	"<p><span style=\"color:rgb(0, 0, 255)\">[foo</span></p><p><span style=\"color:rgb(0, 0, 255)\"><br></span></p><p><span style=\"color:rgb(0, 0, 255)\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 255)"]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["forecolor","#0000FF"]],
 	"<b>foo[]bar</b>",
@@ -5802,11 +5850,11 @@
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","false"],["forecolor","#0000FF"]],
 	"{<p></p><p> </p><p><font color=\"#0000ff\">foo</font></p>}",
-	{"stylewithcss":[false,true,"",false,false,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 0)"]}],
+	{"stylewithcss":[false,true,"",false,false,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 255)"]}],
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","true"],["forecolor","#0000FF"]],
 	"{<p></p><p> </p><p><span style=\"color:rgb(0, 0, 255)\">foo</span></p>}",
-	{"stylewithcss":[false,false,"",false,true,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 0)"]}],
+	{"stylewithcss":[false,false,"",false,true,""],"forecolor":[false,false,"rgb(0, 0, 0)",false,false,"rgb(0, 0, 255)"]}],
 ["foo[bar]baz",
 	[["stylewithcss","false"],["forecolor","blue"]],
 	"foo<font color=\"#0000ff\">[bar]</font>baz",
@@ -10879,6 +10927,14 @@
 	[["stylewithcss","true"],["hilitecolor","#00FFFF"]],
 	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p> <span style=\"background-color:rgb(0, 255, 255)\"><span>bar</span></span> </p><p><span style=\"background-color:rgb(0, 255, 255)\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["hilitecolor","#00FFFF"]],
+	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p><span style=\"background-color:rgb(0, 255, 255)\"><br></span></p><p><span style=\"background-color:rgb(0, 255, 255)\">bar]</span></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["hilitecolor","#00FFFF"]],
+	"<p><span style=\"background-color:rgb(0, 255, 255)\">[foo</span></p><p><span style=\"background-color:rgb(0, 255, 255)\"><br></span></p><p><span style=\"background-color:rgb(0, 255, 255)\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["hilitecolor","#00FFFF"]],
 	"<b>foo[]bar</b>",
@@ -10938,11 +10994,11 @@
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","false"],["hilitecolor","#00FFFF"]],
 	"{<p></p><p> </p><p><span style=\"background-color:rgb(0, 255, 255)\">foo</span></p>}",
-	{"stylewithcss":[false,true,"",false,false,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgba(0, 0, 0, 0)"]}],
+	{"stylewithcss":[false,true,"",false,false,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["{<p><p> <p>foo</p>}",
 	[["stylewithcss","true"],["hilitecolor","#00FFFF"]],
 	"{<p></p><p> </p><p><span style=\"background-color:rgb(0, 255, 255)\">foo</span></p>}",
-	{"stylewithcss":[false,false,"",false,true,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgba(0, 0, 0, 0)"]}],
+	{"stylewithcss":[false,false,"",false,true,""],"hilitecolor":[false,false,"rgba(0, 0, 0, 0)",false,false,"rgb(0, 255, 255)"]}],
 ["<table><tbody><tr><td>foo<td>b[a]r<td>baz</table>",
 	[["stylewithcss","false"],["hilitecolor","#00FFFF"]],
 	"<table><tbody><tr><td>foo</td><td>b<span style=\"background-color:rgb(0, 255, 255)\">[a]</span>r</td><td>baz</td></tr></tbody></table>",
@@ -19823,6 +19879,14 @@
 	[["stylewithcss","true"],["italic",""]],
 	"<p><span style=\"font-style:italic\">[foo</span></p><p> <span style=\"font-style:italic\"><span>bar</span></span> </p><p><span style=\"font-style:italic\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"italic":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["italic",""]],
+	"<p><i>[foo</i></p><p><i><br></i></p><p><i>bar]</i></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"italic":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["italic",""]],
+	"<p><span style=\"font-style:italic\">[foo</span></p><p><span style=\"font-style:italic\"><br></span></p><p><span style=\"font-style:italic\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"italic":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["italic",""]],
 	"<b>foo[]bar</b>",
@@ -25095,6 +25159,14 @@
 	[["stylewithcss","true"],["strikethrough",""]],
 	"<p><span style=\"text-decoration:line-through\">[foo</span></p><p> <span style=\"text-decoration:line-through\"><span>bar</span></span> </p><p><span style=\"text-decoration:line-through\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"strikethrough":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["strikethrough",""]],
+	"<p><s>[foo</s></p><p><s><br></s></p><p><s>bar]</s></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"strikethrough":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["strikethrough",""]],
+	"<p><span style=\"text-decoration:line-through\">[foo</span></p><p><span style=\"text-decoration:line-through\"><br></span></p><p><span style=\"text-decoration:line-through\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"strikethrough":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["strikethrough",""]],
 	"<b>foo[]bar</b>",
@@ -25743,6 +25815,14 @@
 	[["stylewithcss","true"],["subscript",""]],
 	"<p><sub>[foo</sub></p><p> <sub><span>bar</span></sub> </p><p><sub>baz]</sub></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"subscript":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["subscript",""]],
+	"<p><sub>[foo</sub></p><p><sub><br></sub></p><p><sub>bar]</sub></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"subscript":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["subscript",""]],
+	"<p><sub>[foo</sub></p><p><sub><br></sub></p><p><sub>bar]</sub></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"subscript":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["subscript",""]],
 	"<b>foo[]bar</b>",
@@ -26127,6 +26207,14 @@
 	[["stylewithcss","true"],["superscript",""]],
 	"<p><sup>[foo</sup></p><p> <sup><span>bar</span></sup> </p><p><sup>baz]</sup></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"superscript":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["superscript",""]],
+	"<p><sup>[foo</sup></p><p><sup><br></sup></p><p><sup>bar]</sup></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"superscript":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["superscript",""]],
+	"<p><sup>[foo</sup></p><p><sup><br></sup></p><p><sup>bar]</sup></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"superscript":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["superscript",""]],
 	"<b>foo[]bar</b>",
@@ -26519,6 +26607,14 @@
 	[["stylewithcss","true"],["underline",""]],
 	"<p><span style=\"text-decoration:underline\">[foo</span></p><p> <span style=\"text-decoration:underline\"><span>bar</span></span> </p><p><span style=\"text-decoration:underline\">baz]</span></p>",
 	{"stylewithcss":[false,false,"",false,true,""],"underline":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","false"],["underline",""]],
+	"<p><u>[foo</u></p><p><u><br></u></p><p><u>bar]</u></p>",
+	{"stylewithcss":[false,true,"",false,false,""],"underline":[false,false,"",false,true,""]}],
+["<p>[foo<p><br><p>bar]",
+	[["stylewithcss","true"],["underline",""]],
+	"<p><span style=\"text-decoration:underline\">[foo</span></p><p><span style=\"text-decoration:underline\"><br></span></p><p><span style=\"text-decoration:underline\">bar]</span></p>",
+	{"stylewithcss":[false,false,"",false,true,""],"underline":[false,false,"",false,true,""]}],
 ["<b>foo[]bar</b>",
 	[["stylewithcss","false"],["underline",""]],
 	"<b>foo[]bar</b>",
--- a/editing.html	Tue Nov 08 09:40:24 2011 -0700
+++ b/editing.html	Tue Nov 08 09:47:12 2011 -0700
@@ -2490,7 +2490,8 @@
 style="font-style: normal"&gt;</code> inside.
 
 <p>A <dfn id=formattable-node>formattable node</dfn> is an <a href=#editable>editable</a>
-<a href=#visible>visible</a> <code class=external data-anolis-spec=dom><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code> node.
+<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-node title=concept-node>node</a> that is either a <code class=external data-anolis-spec=dom><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#text>Text</a></code> node, an <code class=external data-anolis-spec=html title="the img element"><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#the-img-element>img</a></code>, or 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>.
 
 <p>Two quantities are <dfn id=equivalent-values>equivalent values</dfn> for a <a href=#command>command</a>
 if either both are null, or both are strings and they're equal and the
--- a/implementation.js	Tue Nov 08 09:40:24 2011 -0700
+++ b/implementation.js	Tue Nov 08 09:47:12 2011 -0700
@@ -1972,11 +1972,13 @@
 	return false;
 }
 
-// "A formattable node is an editable visible Text node."
+// "A formattable node is an editable visible node that is either a Text node,
+// an img, or a br."
 function isFormattableNode(node) {
 	return isEditable(node)
 		&& isVisible(node)
-		&& node.nodeType == Node.TEXT_NODE;
+		&& (node.nodeType == Node.TEXT_NODE
+		|| isHtmlElement(node, ["img", "br"]));
 }
 
 // "Two quantities are equivalent values for a command if either both are null,
@@ -8180,10 +8182,7 @@
 		};
 
 		commands[command].value = function() {
-			var refNode = getAllEffectivelyContainedNodes(getActiveRange(), function(node) {
-				return isEditable(node)
-					&& node.nodeType == Node.TEXT_NODE;
-			})[0];
+			var refNode = getAllEffectivelyContainedNodes(getActiveRange(), isFormattableNode)[0];
 
 			if (typeof refNode == "undefined") {
 				refNode = getActiveRange().startContainer;
--- a/source.html	Tue Nov 08 09:40:24 2011 -0700
+++ b/source.html	Tue Nov 08 09:47:12 2011 -0700
@@ -2487,7 +2487,8 @@
 style="font-style: normal"></code> inside.
 
 <p>A <dfn>formattable node</dfn> is an <span>editable</span>
-<span>visible</span> [[text]] node.
+<span>visible</span> [[node]] that is either a [[text]] node, an [[img]], or a
+[[br]].
 
 <p>Two quantities are <dfn>equivalent values</dfn> for a <span>command</span>
 if either both are null, or both are strings and they're equal and the
--- a/tests.js	Tue Nov 08 09:40:24 2011 -0700
+++ b/tests.js	Tue Nov 08 09:47:12 2011 -0700
@@ -84,6 +84,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -227,6 +228,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -707,6 +709,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -795,6 +798,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -903,6 +907,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -1645,6 +1650,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -2828,6 +2834,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -3627,6 +3634,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -3723,6 +3731,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -3781,6 +3790,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',
@@ -3842,6 +3852,7 @@
 		'<p>[foo</p> <p>bar]</p>',
 		'<span>[foo</span> <span>bar]</span>',
 		'<p>[foo</p><p> <span>bar</span> </p><p>baz]</p>',
+		'<p>[foo<p><br><p>bar]',
 		'<b>foo[]bar</b>',
 		'<i>foo[]bar</i>',
 		'<span>foo</span>{}<span>bar</span>',