Title: [158314] trunk
Revision
158314
Author
commit-qu...@webkit.org
Date
2013-10-30 14:16:56 -0700 (Wed, 30 Oct 2013)

Log Message

contentEditable deleting lists when list items are block level
https://bugs.webkit.org/show_bug.cgi?id=122602

Patch by Santosh Mahto <santosh...@samsung.com> on 2013-10-30
Reviewed by Ryosuke Niwa.

Source/WebCore:

When listitems are styled with display:block/float then inserting paragraph
twice at end of listitem delete entire list. Generally when listitem is empty
then we delete the listitem on inserting paragraph. In this issue, on inserting
first paragraph one empty listitem is created, and on inserting second paragraph
we try to delete that empty listitem. but it misbehave becasue of incomplete
definition of htmlediting::isLisItem() and entire list is deleted.

htmlediting::isListItem() check only render object to decide whether it is
list or not, so if any LI element is block level then isListItem return false.
Now after this patch if parent of current node is list element then node is
treated as listItem.

Test: editing/execCommand/hit-enter-twice-atendof-block-styled-listitem.html

* editing/htmlediting.cpp:
(WebCore::isListItem): Modified condition to check if parent node is list;

LayoutTests:

Testcase: When listitem is styled with display:block then inserting
paragraph twice at the end of listitem should not remove entire list.

* editing/execCommand/hit-enter-twice-atendof-block-styled-listitem-expected.txt: Added.
* editing/execCommand/hit-enter-twice-atendof-block-styled-listitem.html: Added.

TestCase: When listitem is made of custom tag(<item>) and css(display:list-item)
then inserting paragraph twice at the end of listitem should not remove entire list.

* editing/execCommand/hit-enter-twice-atendof-custom-listitem-expected.txt: Added.
* editing/execCommand/hit-enter-twice-atendof-custom-listitem.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (158313 => 158314)


--- trunk/LayoutTests/ChangeLog	2013-10-30 20:59:18 UTC (rev 158313)
+++ trunk/LayoutTests/ChangeLog	2013-10-30 21:16:56 UTC (rev 158314)
@@ -1,3 +1,21 @@
+2013-10-30  Santosh Mahto  <santosh...@samsung.com>
+
+        contentEditable deleting lists when list items are block level
+        https://bugs.webkit.org/show_bug.cgi?id=122602
+
+        Reviewed by Ryosuke Niwa.
+
+        Testcase: When listitem is styled with display:block then inserting
+        paragraph twice at the end of listitem should not remove entire list.
+
+        * editing/execCommand/hit-enter-twice-atendof-block-styled-listitem-expected.txt: Added.
+        * editing/execCommand/hit-enter-twice-atendof-block-styled-listitem.html: Added.
+
+        TestCase: When listitem is made of custom tag(<item>) and css(display:list-item) 
+        then inserting paragraph twice at the end of listitem should not remove entire list.
+
+        * editing/execCommand/hit-enter-twice-atendof-custom-listitem-expected.txt: Added.
+        * editing/execCommand/hit-enter-twice-atendof-custom-listitem.html: Added.
 2013-10-30  Ryosuke Niwa  <rn...@webkit.org>
 
         Add a failing test expectation on media/media-can-play-mpeg4-video.html after r158288.

Added: trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem-expected.txt (0 => 158314)


--- trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem-expected.txt	2013-10-30 21:16:56 UTC (rev 158314)
@@ -0,0 +1,87 @@
+This test verifies that inserting paragraph twice at the end of last listitem styled with display:block/float does not remove entire list.
+Expected behavior is list should not be removed and one empty line should get added.
+
+Initial:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <li>
+|     "List item one"
+|   "
+            "
+|   <li>
+|     id="target"
+|     "List item two.<#selection-caret>"
+|   "
+        "
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "
+
+After inserting first paragraph:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <li>
+|     "List item one"
+|   "
+            "
+|   <li>
+|     id="target"
+|     "List item two."
+|   <li>
+|     id="target"
+|     <#selection-caret>
+|     <br>
+|   "
+        "
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "
+
+After inserting second paragraph:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <li>
+|     "List item one"
+|   "
+            "
+|   <li>
+|     id="target"
+|     "List item two."
+|   "
+        "
+| <div>
+|   <#selection-caret>
+|   <br>
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "

Added: trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem.html (0 => 158314)


--- trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-block-styled-listitem.html	2013-10-30 21:16:56 UTC (rev 158314)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    ul li {display:block; margin-left: 25px;}
+</style>
+</head>
+<body>
+    <div id="container" contenteditable="true">
+        <p>Paragraph before list.</p>
+        <ul>
+            <li>List item one</li>
+            <li id="target">List item two.</li>
+        </ul>
+        <p>Paragraph after list.</p>
+    </div>
+    <script src=""
+    <script>
+
+        Markup.description('This test verifies that inserting paragraph twice at the end of last listitem styled with display:block/float does not remove entire list.\nExpected behavior is list should not be removed and one empty line should get added.');
+
+        getSelection().collapse(document.getElementById('target'), 1);
+        Markup.dump('container', 'Initial');
+        document.execCommand("InsertParagraph");
+        Markup.dump('container', 'After inserting first paragraph');
+        document.execCommand("InsertParagraph");
+        Markup.dump('container', 'After inserting second paragraph');
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem-expected.txt (0 => 158314)


--- trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem-expected.txt	2013-10-30 21:16:56 UTC (rev 158314)
@@ -0,0 +1,87 @@
+This test verifies that inserting paragraph twice at the end of last listitem created with custom tag and display:list-item does not remove entire list.
+Expected behavior is list should not be removed and one empty line should get added.
+
+Initial:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <item>
+|     "First Item"
+|   "
+            "
+|   <item>
+|     id="target"
+|     "Second Item<#selection-caret>"
+|   "
+        "
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "
+
+After inserting first paragraph:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <item>
+|     "First Item"
+|   "
+            "
+|   <item>
+|     id="target"
+|     "Second Item"
+|   <item>
+|     id="target"
+|     <#selection-caret>
+|     <br>
+|   "
+        "
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "
+
+After inserting second paragraph:
+| "
+        "
+| <p>
+|   "Paragraph before list."
+| "
+        "
+| <ul>
+|   "
+            "
+|   <item>
+|     "First Item"
+|   "
+            "
+|   <item>
+|     id="target"
+|     "Second Item"
+|   "
+        "
+| <div>
+|   <#selection-caret>
+|   <br>
+| "
+        "
+| <p>
+|   "Paragraph after list."
+| "
+    "

Added: trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem.html (0 => 158314)


--- trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/insert-paragraph-twice-at-end-of-custom-listitem.html	2013-10-30 21:16:56 UTC (rev 158314)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    ul item {display:list-item; margin-left: 25px;}
+</style>
+</head>
+<body>
+    <div id="container" contenteditable="true">
+        <p>Paragraph before list.</p>
+        <ul>
+            <item>First Item</item>
+            <item id="target">Second Item</item>
+        </ul>
+        <p>Paragraph after list.</p>
+    </div>
+    <script src=""
+    <script>
+
+        Markup.description('This test verifies that inserting paragraph twice at the end of last listitem created with custom tag and display:list-item does not remove entire list.\nExpected behavior is list should not be removed and one empty line should get added.');
+
+        getSelection().collapse(document.getElementById('target'), 1);
+        Markup.dump('container', 'Initial');
+        document.execCommand("InsertParagraph");
+        Markup.dump('container', 'After inserting first paragraph');
+        document.execCommand("InsertParagraph");
+        Markup.dump('container', 'After inserting second paragraph');
+    </script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (158313 => 158314)


--- trunk/Source/WebCore/ChangeLog	2013-10-30 20:59:18 UTC (rev 158313)
+++ trunk/Source/WebCore/ChangeLog	2013-10-30 21:16:56 UTC (rev 158314)
@@ -1,3 +1,27 @@
+2013-10-30  Santosh Mahto  <santosh...@samsung.com>
+
+        contentEditable deleting lists when list items are block level
+        https://bugs.webkit.org/show_bug.cgi?id=122602
+
+        Reviewed by Ryosuke Niwa.
+
+        When listitems are styled with display:block/float then inserting paragraph
+        twice at end of listitem delete entire list. Generally when listitem is empty
+        then we delete the listitem on inserting paragraph. In this issue, on inserting
+        first paragraph one empty listitem is created, and on inserting second paragraph
+        we try to delete that empty listitem. but it misbehave becasue of incomplete 
+        definition of htmlediting::isLisItem() and entire list is deleted.
+
+        htmlediting::isListItem() check only render object to decide whether it is 
+        list or not, so if any LI element is block level then isListItem return false.
+        Now after this patch if parent of current node is list element then node is
+        treated as listItem.
+
+        Test: editing/execCommand/hit-enter-twice-atendof-block-styled-listitem.html
+
+        * editing/htmlediting.cpp:
+        (WebCore::isListItem): Modified condition to check if parent node is list;
+
 2013-10-30  Jer Noble  <jer.no...@apple.com>
 
         Unreviewed EFL build fix; give MediaEngineSupportParameters struct a default constructor.

Modified: trunk/Source/WebCore/editing/htmlediting.cpp (158313 => 158314)


--- trunk/Source/WebCore/editing/htmlediting.cpp	2013-10-30 20:59:18 UTC (rev 158313)
+++ trunk/Source/WebCore/editing/htmlediting.cpp	2013-10-30 21:16:56 UTC (rev 158314)
@@ -542,7 +542,7 @@
 
 bool isListItem(const Node *n)
 {
-    return n && n->renderer() && n->renderer()->isListItem();
+    return n && (isListElement(n->parentNode()) || (n->renderer() && n->renderer()->isListItem()));
 }
 
 Node* enclosingNodeWithTag(const Position& p, const QualifiedName& tagName)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to