Crashes in WebCore::InsertListCommand::unlistifyParagraph.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 05:57:30 +0000 (05:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Sep 2011 05:57:30 +0000 (05:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67918

Patch by Shinya Kawanaka <shinyak@google.com> on 2011-09-12
Reviewed by Ryosuke Niwa.

Source/WebCore:

execCommand("InsertUnorderedList") was crashing if the parent node of the target is
a kind of list element and it is not contenteditable.
This patch checks the parent node is contenteditable.

Test: editing/execCommand/insert-list-in-noneditable-list-parent.html

* editing/htmlediting.cpp:
(WebCore::enclosingListChild): Checks the parent node is contenteditable.

LayoutTests:

Added tests.

* editing/execCommand/insert-list-in-noneditable-list-parent-expected.txt: Added.
* editing/execCommand/insert-list-in-noneditable-list-parent.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/htmlediting.cpp

index 859ee51..dd7575c 100644 (file)
@@ -1,3 +1,15 @@
+2011-09-12  Shinya Kawanaka  <shinyak@google.com>
+
+        Crashes in WebCore::InsertListCommand::unlistifyParagraph.
+        https://bugs.webkit.org/show_bug.cgi?id=67918
+
+        Reviewed by Ryosuke Niwa.
+
+        Added tests.
+
+        * editing/execCommand/insert-list-in-noneditable-list-parent-expected.txt: Added.
+        * editing/execCommand/insert-list-in-noneditable-list-parent.html: Added.
+
 2011-09-12  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r94975.
diff --git a/LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent-expected.txt b/LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent-expected.txt
new file mode 100644 (file)
index 0000000..86cab0c
--- /dev/null
@@ -0,0 +1,32 @@
+execCommand("InsertUnorderedList") for contenteditable root element was crashing. The test has passed if it does not crash.
+PASS
+| "
+    "
+| <dl>
+|   <div>
+|     contenteditable="true"
+|     id="div1"
+|     <ul>
+|       <li>
+|         <br>
+| "
+    "
+| <ul>
+|   <div>
+|     contenteditable="true"
+|     id="div2"
+|     <ul>
+|       <li>
+|         <br>
+| "
+    "
+| <ol>
+|   <div>
+|     contenteditable="true"
+|     id="div3"
+|     <ul>
+|       <li>
+|         <#selection-caret>
+|         <br>
+| "
+"
diff --git a/LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent.html b/LayoutTests/editing/execCommand/insert-list-in-noneditable-list-parent.html
new file mode 100644 (file)
index 0000000..ab20178
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+
+<script src="../../resources/dump-as-markup.js"></script>
+<div id="div">
+    <dl><div id="div1" contenteditable="true"></div></dl>
+    <ul><div id="div2" contenteditable="true"></div></ul>
+    <ol><div id="div3" contenteditable="true"></div></ol>
+</div>
+
+<script>
+div1.focus();
+document.execCommand("InsertUnorderedList");
+
+div2.focus();
+document.execCommand("InsertUnorderedList");
+
+div3.focus();
+document.execCommand("InsertUnorderedList");
+
+Markup.description('execCommand("InsertUnorderedList") for contenteditable root element was crashing. The test has passed if it does not crash.\nPASS');
+Markup.dump(div);
+</script>
index c9f883f..022ba2f 100644 (file)
@@ -1,3 +1,19 @@
+2011-09-12  Shinya Kawanaka  <shinyak@google.com>
+
+        Crashes in WebCore::InsertListCommand::unlistifyParagraph.
+        https://bugs.webkit.org/show_bug.cgi?id=67918
+
+        Reviewed by Ryosuke Niwa.
+
+        execCommand("InsertUnorderedList") was crashing if the parent node of the target is
+        a kind of list element and it is not contenteditable.
+        This patch checks the parent node is contenteditable.
+
+        Test: editing/execCommand/insert-list-in-noneditable-list-parent.html
+
+        * editing/htmlediting.cpp:
+        (WebCore::enclosingListChild): Checks the parent node is contenteditable.
+
 2011-09-12  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r94975.
index 15cd799..3e25b20 100644 (file)
@@ -666,7 +666,7 @@ Node* enclosingListChild(Node *node)
     
     // FIXME: This function is inappropriately named if it starts with node instead of node->parentNode()
     for (Node* n = node; n && n->parentNode(); n = n->parentNode()) {
-        if (n->hasTagName(liTag) || isListElement(n->parentNode()))
+        if (n->hasTagName(liTag) || (isListElement(n->parentNode()) && n != root))
             return n;
         if (n == root || isTableCell(n))
             return 0;