Don't special-case blockquote class for WebKit
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Wed, 21 Sep 2011 11:53:03 -0600
changeset 613 d91d1ebb3394
parent 612 d31b94d6e801
child 614 ee2791b98b92
Don't special-case blockquote class for WebKit

Previously, WebKit would generate blockquotes with
class="webkit-indent-blockquote", so we had to treat those as simple
indentation elements for compatibility. Annoyingly, this meant also
treating all indentation elements with classes as simple, so we'd just
remove them along with their class. Now having a class will make an
indentation element non-simple, so we'll refuse to remove it.
<blockquote class=foo> will become <div class=foo> if outdented. WebKit
no longer generates these classes, so this seems safe enough for the
future.

Also, I don't think I ever special-cased <span class=Apple-style-span>,
which was far more prevalent before these classes were removed. Props
to rniwa for removing them.

This was more complicated to fix than I expected. Of course, it creates
nastier markup when these extra classes are present in the input, but
it's better to avoid the special case in the long term. The idea is we
shouldn't have such markup in the input. (The visual results are
unchanged in any event.)

Fixes: http://www.w3.org/Bugs/Public/show_bug.cgi?id=13957
Reported-By: Ryosuke Niwa
conformancetest/data.js
editing.html
implementation.js
source.html
--- a/conformancetest/data.js	Wed Sep 21 12:12:57 2011 -0600
+++ b/conformancetest/data.js	Wed Sep 21 11:53:03 2011 -0600
@@ -10761,11 +10761,11 @@
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<p>[foo]<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>bar</blockquote><p>extra",
 	[["stylewithcss","false"],["indent",""]],
-	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>[foo]</p><p>bar</p></blockquote><p>extra</p>",
+	"<blockquote><p>[foo]</p></blockquote><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"indent":[false,false,"",false,false,""]}],
 ["<p>[foo]<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>bar</blockquote><p>extra",
 	[["stylewithcss","true"],["indent",""]],
-	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>[foo]</p><p>bar</p></blockquote><p>extra</p>",
+	"<blockquote><p>[foo]</p></blockquote><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<p>[foo<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>b]ar</blockquote><p>extra",
 	[["stylewithcss","false"],["indent",""]],
@@ -10777,11 +10777,11 @@
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<p>foo<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>bar</blockquote><p>[baz]<p>extra",
 	[["stylewithcss","false"],["indent",""]],
-	"<p>foo</p><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p><p>[baz]</p></blockquote><p>extra</p>",
+	"<p>foo</p><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p></blockquote><blockquote><p>[baz]</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"indent":[false,false,"",false,false,""]}],
 ["<p>foo<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>bar</blockquote><p>[baz]<p>extra",
 	[["stylewithcss","true"],["indent",""]],
-	"<p>foo</p><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p><p>[baz]</p></blockquote><p>extra</p>",
+	"<p>foo</p><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>bar</p></blockquote><blockquote><p>[baz]</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<p>foo<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>[bar</blockquote><p>baz]<p>extra",
 	[["stylewithcss","false"],["indent",""]],
@@ -10801,11 +10801,11 @@
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>foo</blockquote><p>[bar]<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>baz</blockquote><p>extra",
 	[["stylewithcss","false"],["indent",""]],
-	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>foo</p><p>[bar]</p><p>baz</p></blockquote><p>extra</p>",
+	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>foo</p></blockquote><blockquote><p>[bar]</p></blockquote><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>baz</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"indent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>foo</blockquote><p>[bar]<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px\"><p>baz</blockquote><p>extra",
 	[["stylewithcss","true"],["indent",""]],
-	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>foo</p><p>[bar]</p><p>baz</p></blockquote><p>extra</p>",
+	"<blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>foo</p></blockquote><blockquote><p>[bar]</p></blockquote><blockquote class=\"webkit-indent-blockquote\" style=\"margin:0 0 0 40px; border:none; padding:0px\"><p>baz</p></blockquote><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"indent":[false,false,"",false,false,""]}],
 ["<blockquote>f[oo<blockquote>b]ar</blockquote></blockquote><p>extra",
 	[["stylewithcss","false"],["indent",""]],
@@ -20929,35 +20929,35 @@
 	{"stylewithcss":[false,false,"",false,true,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar]</p><p>baz</p></blockquote><p>extra",
 	[["stylewithcss","false"],["outdent",""]],
-	"<p>foo[bar]</p><blockquote><p>baz</p></blockquote><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar]</p><blockquote><p>baz</p></blockquote></div><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar]</p><p>baz</p></blockquote><p>extra",
 	[["stylewithcss","true"],["outdent",""]],
-	"<p>foo[bar]</p><blockquote><p>baz</p></blockquote><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar]</p><blockquote><p>baz</p></blockquote></div><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar</p><p>b]az</p></blockquote><p>extra",
 	[["stylewithcss","false"],["outdent",""]],
-	"<p>foo[bar</p><p>b]az</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar</p><p>b]az</p></div><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar</p><p>b]az</p></blockquote><p>extra",
 	[["stylewithcss","true"],["outdent",""]],
-	"<p>foo[bar</p><p>b]az</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar</p><p>b]az</p></div><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar]</p></blockquote><p>baz</p><p>extra",
 	[["stylewithcss","false"],["outdent",""]],
-	"<p>foo[bar]</p><p>baz</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar]</p></div><p>baz</p><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar]</p></blockquote><p>baz</p><p>extra",
 	[["stylewithcss","true"],["outdent",""]],
-	"<p>foo[bar]</p><p>baz</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar]</p></div><p>baz</p><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar</p></blockquote><p>b]az</p><p>extra",
 	[["stylewithcss","false"],["outdent",""]],
-	"<p>foo[bar</p><p>b]az</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar</p></div><p>b]az</p><p>extra</p>",
 	{"stylewithcss":[false,true,"",false,false,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote class=\"webkit-indent-blockquote\" style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><p>foo[bar</p></blockquote><p>b]az</p><p>extra",
 	[["stylewithcss","true"],["outdent",""]],
-	"<p>foo[bar</p><p>b]az</p><p>extra</p>",
+	"<div class=\"webkit-indent-blockquote\"><p>foo[bar</p></div><p>b]az</p><p>extra</p>",
 	{"stylewithcss":[false,false,"",false,true,""],"outdent":[false,false,"",false,false,""]}],
 ["<blockquote><blockquote>foo[bar]baz</blockquote></blockquote>",
 	[["stylewithcss","false"],["outdent",""]],
--- a/editing.html	Wed Sep 21 12:12:57 2011 -0600
+++ b/editing.html	Wed Sep 21 11:53:03 2011 -0600
@@ -3962,13 +3962,11 @@
 positives, but it'll do for now.
 
 <p>A <dfn id=simple-indentation-element>simple indentation element</dfn> is an <a href=#indentation-element>indentation
-element</a> that has no attributes other than zero or more of
+element</a> that has no attributes except possibly
 
 <ul>
   <li>a <code class=external data-anolis-spec=html title="the style attribute"><a href=http://www.whatwg.org/html/#the-style-attribute>style</a></code> attribute that sets no properties other than "margin",
-  "border", "padding", or subproperties of those;
-
-  <li>a <code class=external data-anolis-spec=html title=classes><a href=http://www.whatwg.org/html/#classes>class</a></code> attribute;
+  "border", "padding", or subproperties of those; and/or
 
   <li>a <code class=external data-anolis-spec=html title="the dir attribute"><a href=http://www.whatwg.org/html/#the-dir-attribute>dir</a></code>
   attribute.
@@ -5722,9 +5720,8 @@
   <p>If <var title="">node</var> is an <a href=#indentation-element>indentation element</a>:
 
   <ol>
-    <li>Unset the <code class=external data-anolis-spec=html title=classes><a href=http://www.whatwg.org/html/#classes>class</a></code> and
-    <code class=external data-anolis-spec=html title="the dir attribute"><a href=http://www.whatwg.org/html/#the-dir-attribute>dir</a></code>
-    attributes of <var title="">node</var>, if any.
+    <li>Unset the <code class=external data-anolis-spec=html title="the dir
+    attribute"><a href=http://www.whatwg.org/html/#the-dir-attribute>dir</a></code> attribute of <var title="">node</var>, if any.
 
     <li>Unset the margin, padding, and border CSS properties of
     <var title="">node</var>.
--- a/implementation.js	Wed Sep 21 12:12:57 2011 -0600
+++ b/implementation.js	Wed Sep 21 11:53:03 2011 -0600
@@ -3668,24 +3668,19 @@
 }
 
 // "A simple indentation element is an indentation element that has no
-// attributes other than zero or more of
+// attributes except possibly
 //
-//   * "a style attribute that sets no properties other than "margin", "border",
-//     "padding", or subproperties of those;
-//   * "a class attribute;
+//   * "a style attribute that sets no properties other than "margin",
+//     "border", "padding", or subproperties of those; and/or
 //   * "a dir attribute."
 function isSimpleIndentationElement(node) {
 	if (!isIndentationElement(node)) {
 		return false;
 	}
 
-	if (node.tagName != "BLOCKQUOTE" && node.tagName != "DIV") {
-		return false;
-	}
-
 	for (var i = 0; i < node.attributes.length; i++) {
 		if (!isHtmlNamespace(node.attributes[i].namespaceURI)
-		|| ["style", "class", "dir"].indexOf(node.attributes[i].name) == -1) {
+		|| ["style", "dir"].indexOf(node.attributes[i].name) == -1) {
 			return false;
 		}
 	}
@@ -5300,15 +5295,16 @@
 
 	// "If node is an indentation element:"
 	if (isIndentationElement(node)) {
-		// "Unset the class and dir attributes of node, if any."
-		node.removeAttribute("class");
+		// "Unset the dir attribute of node, if any."
 		node.removeAttribute("dir");
 
 		// "Unset the margin, padding, and border CSS properties of node."
 		node.style.margin = "";
 		node.style.padding = "";
 		node.style.border = "";
-		if (node.getAttribute("style") == "") {
+		if (node.getAttribute("style") == ""
+		// Crazy WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=68551
+		|| node.getAttribute("style") == "border-width: initial; border-color: initial; ") {
 			node.removeAttribute("style");
 		}
 
--- a/source.html	Wed Sep 21 12:12:57 2011 -0600
+++ b/source.html	Wed Sep 21 11:53:03 2011 -0600
@@ -3983,13 +3983,11 @@
 positives, but it'll do for now.
 
 <p>A <dfn>simple indentation element</dfn> is an <span>indentation
-element</span> that has no attributes other than zero or more of
+element</span> that has no attributes except possibly
 
 <ul>
   <li>a [[style]] attribute that sets no properties other than "margin",
-  "border", "padding", or subproperties of those;
-
-  <li>a <code data-anolis-spec=html title=classes>class</code> attribute;
+  "border", "padding", or subproperties of those; and/or
 
   <li>a <code data-anolis-spec=html title="the dir attribute">dir</code>
   attribute.
@@ -5765,9 +5763,8 @@
   <p>If <var>node</var> is an <span>indentation element</span>:
 
   <ol>
-    <li>Unset the <code data-anolis-spec=html title=classes>class</code> and
-    <code data-anolis-spec=html title="the dir attribute">dir</code>
-    attributes of <var>node</var>, if any.
+    <li>Unset the <code data-anolis-spec=html title="the dir
+    attribute">dir</code> attribute of <var>node</var>, if any.
 
     <li>Unset the margin, padding, and border CSS properties of
     <var>node</var>.