InsertHTML fails to insert h6 if the insertion point is before some text.
authoryi.4.shen@nokia.com <yi.4.shen@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 14:28:45 +0000 (14:28 +0000)
committeryi.4.shen@nokia.com <yi.4.shen@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 14:28:45 +0000 (14:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82689

Reviewed by Ryosuke Niwa.

Added the missing h6 tag for the isHeaderElement.

Source/WebCore:

No new tests: updated existing test (editing/execCommand/4128080-1.html)

* editing/ReplaceSelectionCommand.cpp:
(WebCore::isHeaderElement):

LayoutTests:

* editing/execCommand/4128080-1-expected.txt:
* editing/execCommand/4128080-1.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114131 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/4128080-1-expected.txt
LayoutTests/editing/execCommand/4128080-1.html
Source/WebCore/ChangeLog
Source/WebCore/editing/ReplaceSelectionCommand.cpp

index 2672f01..9cfb885 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-13  Yi Shen  <yi.4.shen@nokia.com>
+
+        InsertHTML fails to insert h6 if the insertion point is before some text.
+        https://bugs.webkit.org/show_bug.cgi?id=82689
+
+        Reviewed by Ryosuke Niwa.
+
+        Added the missing h6 tag for the isHeaderElement.
+
+        * editing/execCommand/4128080-1-expected.txt:
+        * editing/execCommand/4128080-1.html:
+
 2012-04-13  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, GTK test_expectations update.
index cad2f76..9794601 100644 (file)
@@ -1,3 +1,15 @@
-Success
-Success
+Test 1: Verify that a header at the beginning of inserted content is preserved.
+Success. <h1>bar</h1><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h1>bar</h1>bazfoo
+Success. <h2>bar</h2><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h2>bar</h2>bazfoo
+Success. <h3>bar</h3><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h3>bar</h3>bazfoo
+Success. <h4>bar</h4><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h4>bar</h4>bazfoo
+Success. <h5>bar</h5><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h5>bar</h5>bazfoo
+Success. <h6>bar</h6><div>baz</div> was inserted into <div>foo^foo<div> and the result was:foo<h6>bar</h6>bazfoo
+Test 2: Verify that a header at the end of inserted content is preserved.
+Success. <div>bar</div><h1>baz</h1> was inserted into <div>foo^foo<div> and the result was:foobar<h1>baz</h1>foo
+Success. <div>bar</div><h2>baz</h2> was inserted into <div>foo^foo<div> and the result was:foobar<h2>baz</h2>foo
+Success. <div>bar</div><h3>baz</h3> was inserted into <div>foo^foo<div> and the result was:foobar<h3>baz</h3>foo
+Success. <div>bar</div><h4>baz</h4> was inserted into <div>foo^foo<div> and the result was:foobar<h4>baz</h4>foo
+Success. <div>bar</div><h5>baz</h5> was inserted into <div>foo^foo<div> and the result was:foobar<h5>baz</h5>foo
+Success. <div>bar</div><h6>baz</h6> was inserted into <div>foo^foo<div> and the result was:foobar<h6>baz</h6>foo
 
index f6dc49f..b9625d3 100644 (file)
@@ -1,35 +1,42 @@
-<div id="div1" contentEditable="true">foofoo</div>
-<div id="div2" contentEditable="true">foofoo</div>
-
+<!DOCTYPE html>
+<html>
+<body>
+</body>
 <script>
+function insertHeaderForTest(testContent, expected)
+{
+    document.body.innerHTML = "<div id='testDiv' contentEditable='true'>foofoo</div>";
+    var targetDiv = document.getElementById("testDiv");
+    var targetText = targetDiv.firstChild;
+    window.getSelection().setPosition(targetText, 3);
+    document.execCommand("InsertHTML", false, testContent);
+    var actual = targetDiv.innerHTML;
+    if (actual == expected)
+        return "Success. " + testContent +" was inserted into <div>foo^foo<div> and the result was:" + actual + "\n";
+    return "Failure. Result was: " + actual + ", should have been: " + expected + "\n";
+}
+
 if (window.layoutTestController)
     window.layoutTestController.dumpAsText();
-    
-output = "";
 
 // Test 1: Verify that a header at the beginning of inserted content is preserved.
-div = document.getElementById("div1");
-text = div.firstChild;
-window.getSelection().setPosition(text, 3);
-document.execCommand("InsertHTML", false, "<h1>bar</h1><div>baz</div>");
-expected = "foo<h1>bar</h1>bazfoo";
-actual = div.innerHTML;
-if (actual == expected)
-    output += "Success\n";
-else
-    output += "Failure. Result was: " + actual + ", should have been: " + expected + "\n";
-    
+output = "Test 1: Verify that a header at the beginning of inserted content is preserved.\n";
+output += insertHeaderForTest("<h1>bar</h1><div>baz</div>", "foo<h1>bar</h1>bazfoo");
+output += insertHeaderForTest("<h2>bar</h2><div>baz</div>", "foo<h2>bar</h2>bazfoo");
+output += insertHeaderForTest("<h3>bar</h3><div>baz</div>", "foo<h3>bar</h3>bazfoo");
+output += insertHeaderForTest("<h4>bar</h4><div>baz</div>", "foo<h4>bar</h4>bazfoo");
+output += insertHeaderForTest("<h5>bar</h5><div>baz</div>", "foo<h5>bar</h5>bazfoo");
+output += insertHeaderForTest("<h6>bar</h6><div>baz</div>", "foo<h6>bar</h6>bazfoo");
+
 // Test 2: Verify that a header at the end of inserted content is preserved.
-div = document.getElementById("div2");
-text = div.firstChild;
-window.getSelection().setPosition(text, 3);
-document.execCommand("InsertHTML", false, "<div>bar</div><h1>baz</h1>");
-expected = "foobar<h1>baz</h1>foo";
-actual = div.innerHTML;
-if (actual == expected)
-    output += "Success\n";
-else
-    output += "Failure. Result was: " + actual + ", should have been: " + expected + "\n";
+output += "Test 2: Verify that a header at the end of inserted content is preserved.\n";
+output += insertHeaderForTest("<div>bar</div><h1>baz</h1>", "foobar<h1>baz</h1>foo");
+output += insertHeaderForTest("<div>bar</div><h2>baz</h2>", "foobar<h2>baz</h2>foo");
+output += insertHeaderForTest("<div>bar</div><h3>baz</h3>", "foobar<h3>baz</h3>foo");
+output += insertHeaderForTest("<div>bar</div><h4>baz</h4>", "foobar<h4>baz</h4>foo");
+output += insertHeaderForTest("<div>bar</div><h5>baz</h5>", "foobar<h5>baz</h5>foo");
+output += insertHeaderForTest("<div>bar</div><h6>baz</h6>", "foobar<h6>baz</h6>foo");
 
 document.body.innerText = output;
 </script>
+</html>
index 49c721a..80fb4ec 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-13  Yi Shen  <yi.4.shen@nokia.com>
+
+        InsertHTML fails to insert h6 if the insertion point is before some text.
+        https://bugs.webkit.org/show_bug.cgi?id=82689
+
+        Reviewed by Ryosuke Niwa.
+
+        Added the missing h6 tag for the isHeaderElement.
+
+        No new tests: updated existing test (editing/execCommand/4128080-1.html)
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::isHeaderElement):
+
 2012-04-13  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: exception in heap profiler when expanding a class in summary view
index 8c7b2c4..796d221 100644 (file)
@@ -444,11 +444,12 @@ static bool isHeaderElement(Node* a)
     if (!a)
         return false;
         
-    return a->hasTagName(h1Tag) ||
-           a->hasTagName(h2Tag) ||
-           a->hasTagName(h3Tag) ||
-           a->hasTagName(h4Tag) ||
-           a->hasTagName(h5Tag);
+    return a->hasTagName(h1Tag)
+        || a->hasTagName(h2Tag)
+        || a->hasTagName(h3Tag)
+        || a->hasTagName(h4Tag)
+        || a->hasTagName(h5Tag)
+        || a->hasTagName(h6Tag);
 }
 
 static bool haveSameTagName(Node* a, Node* b)