Bug 316447 - execCommand("insertHorizontalRule") should not set height/width; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Wed, 04 Apr 2012 13:47:36 +0300
changeset 94461 ad9d219c1855f3fe2deecae858ba5b17fa41c343
parent 94460 fba572626884ec5981b894c19dd48aaddb65d779
child 94462 b62e0012748bd588f3ae54ae5aa87d1d1e665b81
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs316447
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 316447 - execCommand("insertHorizontalRule") should not set height/width; r=ehsan
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/tests/Makefile.in
editor/libeditor/html/tests/test_bug316447.html
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -2932,26 +2932,17 @@ nsHTMLEditor::CreateElementWithDefaults(
   newElement = do_QueryInterface(newContent);
   if (NS_FAILED(res) || !newElement)
     return NS_ERROR_FAILURE;
 
   // Mark the new element dirty, so it will be formatted
   newElement->SetAttribute(NS_LITERAL_STRING("_moz_dirty"), EmptyString());
 
   // Set default values for new elements
-  if (TagName.EqualsLiteral("hr"))
-  {
-    // Note that we read the user's attributes for these from prefs (in InsertHLine JS)
-    res = SetAttributeOrEquivalent(newElement, NS_LITERAL_STRING("width"),
-                                   NS_LITERAL_STRING("100%"), true);
-    NS_ENSURE_SUCCESS(res, res);
-    res = SetAttributeOrEquivalent(newElement, NS_LITERAL_STRING("size"),
-                                   NS_LITERAL_STRING("2"), true);
-  } else if (TagName.EqualsLiteral("table"))
-  {
+  if (TagName.EqualsLiteral("table")) {
     res = newElement->SetAttribute(NS_LITERAL_STRING("cellpadding"),NS_LITERAL_STRING("2"));
     NS_ENSURE_SUCCESS(res, res);
     res = newElement->SetAttribute(NS_LITERAL_STRING("cellspacing"),NS_LITERAL_STRING("2"));
     NS_ENSURE_SUCCESS(res, res);
     res = newElement->SetAttribute(NS_LITERAL_STRING("border"),NS_LITERAL_STRING("1"));
   } else if (TagName.EqualsLiteral("td"))
   {
     res = SetAttributeOrEquivalent(newElement, NS_LITERAL_STRING("valign"),
--- a/editor/libeditor/html/tests/Makefile.in
+++ b/editor/libeditor/html/tests/Makefile.in
@@ -43,16 +43,17 @@ relativesrcdir  = editor/libeditor/html/
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = \
 		green.png \
 		test_bug290026.html \
 		test_bug291780.html \
+		test_bug316447.html \
 		test_bug332636.html \
 		test_bug332636.html^headers^ \
 		test_bug372345.html \
 		test_bug410986.html \
 		test_bug414526.html \
 		test_bug417418.html \
 		test_bug432225.html \
 		test_bug439808.html \
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/test_bug316447.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=316447
+-->
+<title>Test for Bug 316447</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=316447">Mozilla Bug 316447</a>
+<div contenteditable><br></div>
+<script>
+/** Test for Bug 316447 **/
+
+getSelection().selectAllChildren(document.querySelector("div"));
+document.execCommand("inserthorizontalrule");
+is(document.querySelector("div").innerHTML, "<hr>", "Wrong innerHTML");
+</script>