contentEditable deleting lists when list items are block level

https://bugs.webkit.org/show_bug.cgi?id=122602

Patch by Santosh Mahto <santosh.ma@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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 35432f07
2013-10-30 Santosh Mahto <santosh.ma@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 <rniwa@webkit.org>
Add a failing test expectation on media/media-can-play-mpeg4-video.html after r158288.
......
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."
| "
"
<!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="../../resources/dump-as-markup.js"></script>
<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>
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."
| "
"
<!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="../../resources/dump-as-markup.js"></script>
<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>
2013-10-30 Santosh Mahto <santosh.ma@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.noble@apple.com>
Unreviewed EFL build fix; give MediaEngineSupportParameters struct a default constructor.
......
......@@ -542,7 +542,7 @@ bool isListElement(Node *n)
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment