[evolution/wip/webkit2] New test for creating a list from various blocks
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] New test for creating a list from various blocks
- Date: Tue, 19 Jul 2016 14:17:43 +0000 (UTC)
commit 306731f63b9f5d5779856633d355ea7af4e98f3a
Author: Tomas Popela <tpopela redhat com>
Date: Tue Jul 19 16:15:57 2016 +0200
New test for creating a list from various blocks
Fix the issue when we were inserting a LI element inside another LI element.
e-util/test-html-editor-units.c | 29 ++++++++++++++++++++
.../web-extension/e-editor-dom-functions.c | 26 ++++++++++-------
2 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
index 5820393..313fd1b 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -393,6 +393,34 @@ test_list_bullet_html (TestFixture *fixture)
}
static void
+test_list_bullet_html_from_block (TestFixture *fixture)
+{
+ if (!test_utils_run_simple_test (fixture,
+ "mode:html\n"
+ "type:item 1\\n\n"
+ "type:item 2\n"
+ "action:style-list-roman\n"
+ "type:\\n\n"
+ "action:style-preformat\n"
+ "type:item 3\\n\n"
+ "action:select-all\n"
+ "action:style-list-bullet\n",
+ HTML_PREFIX
+ "<ul>"
+ "<li>item 1</li>"
+ "<li>item 2</li>"
+ "<li>item 3</li>"
+ "<li><br></li>"
+ "</ul>"
+ HTML_SUFFIX,
+ " * item 1\n"
+ " * item 2\n"
+ " * item 3\n"
+ " * "))
+ g_test_fail ();
+}
+
+static void
test_list_alpha_html (TestFixture *fixture)
{
if (!test_utils_run_simple_test (fixture,
@@ -667,6 +695,7 @@ main (gint argc,
add_test ("/font/size/typed", test_font_size_typed);
add_test ("/list/bullet/plain", test_list_bullet_plain);
add_test ("/list/bullet/html", test_list_bullet_html);
+ add_test ("/list/bullet/html/from-block", test_list_bullet_html_from_block);
add_test ("/list/alpha/html", test_list_alpha_html);
add_test ("/list/roman/plain", test_list_roman_plain);
add_test ("/list/multi/html", test_list_multi_html);
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 0df5914..2ee99b0 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -16341,7 +16341,7 @@ format_change_block_to_list (EEditorPage *editor_page,
/* Process all blocks that are in the selection one by one */
while (block && !after_selection_end) {
- gboolean empty = FALSE;
+ gboolean empty = FALSE, block_is_list;
gchar *content;
WebKitDOMNode *child, *parent;
@@ -16363,27 +16363,31 @@ format_change_block_to_list (EEditorPage *editor_page,
change_leading_space_to_nbsp (block);
change_trailing_space_in_block_to_nbsp (block);
+ block_is_list = node_is_list_or_item (block);
+
while ((child = webkit_dom_node_get_first_child (block))) {
if (WEBKIT_DOM_IS_HTML_BR_ELEMENT (child))
empty = FALSE;
webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (item), child, NULL);
+ WEBKIT_DOM_NODE (block_is_list ? list : item), child, NULL);
}
- /* We have to use again the hidden space to move caret into newly inserted list */
- if (empty) {
- WebKitDOMElement *br;
+ if (!block_is_list) {
+ /* We have to use again the hidden space to move caret into newly inserted list */
+ if (empty) {
+ WebKitDOMElement *br;
+
+ br = webkit_dom_document_create_element (
+ document, "BR", NULL);
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (item), WEBKIT_DOM_NODE (br), NULL);
+ }
- br = webkit_dom_document_create_element (
- document, "BR", NULL);
webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (item), WEBKIT_DOM_NODE (br), NULL);
+ WEBKIT_DOM_NODE (list), WEBKIT_DOM_NODE (item), NULL);
}
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (list), WEBKIT_DOM_NODE (item), NULL);
-
parent = webkit_dom_node_get_parent_node (block);
remove_node (block);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]