[evolution] Deleting a quoted content could leave paragraph that cannot be focused



commit 1f8a053e65b0fcacaf45c6020deb5ef64f510d9e
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Oct 7 12:22:21 2016 +0200

    Deleting a quoted content could leave paragraph that cannot be focused
    
    Insert a BR element to the right node.

 e-util/test-html-editor-units.c                    |   33 ++++++++++++++++++++
 .../web-extension/e-editor-dom-functions.c         |   18 +++++------
 2 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/e-util/test-html-editor-units.c b/e-util/test-html-editor-units.c
index f6e60c6..44fe89d 100644
--- a/e-util/test-html-editor-units.c
+++ b/e-util/test-html-editor-units.c
@@ -2571,6 +2571,38 @@ test_undo_link_paste_plain (TestFixture *fixture)
                g_test_fail ();
 }
 
+static void
+test_delete_quoted (TestFixture *fixture)
+{
+       if (!test_utils_process_commands (fixture,
+               "mode:plain\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><pre>a\n"
+               "b\n"
+               "c\n"
+               "<span class=\"-x-evo-to-body\" data-credits=\"On Thu, 2016-09-15 at 08:08 -0400, user 
wrote:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:ddddSusDdd\n"
+               "type:b",
+               HTML_PREFIX_PLAIN "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user 
wrote:</div>"
+               "<blockquote type=\"cite\">"
+               "<div style=\"width: 71ch;\">&gt; a</div>"
+               "<div style=\"width: 71ch;\">&gt; b</div>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
+               "> a\n"
+               "> b"))
+               g_test_fail ();
+}
+
 gint
 main (gint argc,
       gchar *argv[])
@@ -2730,6 +2762,7 @@ main (gint argc,
        test_utils_add_test ("/undo/indent", test_undo_indent);
        test_utils_add_test ("/undo/link-paste/html", test_undo_link_paste_html);
        test_utils_add_test ("/undo/link-paste/plain", test_undo_link_paste_plain);
+       test_utils_add_test ("/delete/quoted", test_delete_quoted);
 
        test_add_html_editor_bug_tests ();
 
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 a3425d5..9d2effc 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -3818,19 +3818,16 @@ e_editor_dom_body_key_up_event_process_backspace_or_delete (EEditorPage *editor_
        /* If we deleted a selection the caret will be inside the quote marks, fix it. */
        parent = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (selection_start_marker));
        if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-quote-character")) {
+               parent = webkit_dom_node_get_parent_node (parent);
                webkit_dom_node_insert_before (
-                       webkit_dom_node_get_parent_node (
-                               webkit_dom_node_get_parent_node (parent)),
+                       webkit_dom_node_get_parent_node (parent),
                        WEBKIT_DOM_NODE (selection_end_marker),
-                       webkit_dom_node_get_next_sibling (
-                               webkit_dom_node_get_parent_node (parent)),
+                       webkit_dom_node_get_next_sibling (parent),
                        NULL);
                webkit_dom_node_insert_before (
-                       webkit_dom_node_get_parent_node (
-                               webkit_dom_node_get_parent_node (parent)),
+                       webkit_dom_node_get_parent_node (parent),
                        WEBKIT_DOM_NODE (selection_start_marker),
-                       webkit_dom_node_get_next_sibling (
-                               webkit_dom_node_get_parent_node (parent)),
+                       webkit_dom_node_get_next_sibling (parent),
                        NULL);
        }
 
@@ -3861,11 +3858,12 @@ e_editor_dom_body_key_up_event_process_backspace_or_delete (EEditorPage *editor_
                        WEBKIT_DOM_NODE (selection_start_marker));
                if (WEBKIT_DOM_IS_ELEMENT (prev_sibling) &&
                    element_has_class (WEBKIT_DOM_ELEMENT (prev_sibling), "-x-evo-quoted") &&
-                   !webkit_dom_node_get_previous_sibling (prev_sibling))
+                   !webkit_dom_node_get_previous_sibling (prev_sibling)) {
                        webkit_dom_node_append_child (
-                               parent,
+                               webkit_dom_node_get_parent_node (parent),
                                WEBKIT_DOM_NODE (webkit_dom_document_create_element (document, "br", NULL)),
                                NULL);
+               }
        }
 
        e_editor_dom_merge_siblings_if_necessary (editor_page, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]