[evolution/gnome-3-24] Undoing the HISTORY_IMAGE event won't remove the image



commit 4347ea9671464d1d74b6d799258935c5af6d02bf
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Mar 23 11:30:48 2017 +0100

    Undoing the HISTORY_IMAGE event won't remove the image
    
    The selection could be inside the resizable wrapper as well and not only
    before it.
    
    Extend the /image/insert unit test to cover undo and redo as well.

 src/e-util/test-html-editor-units.c                |    6 ++++++
 .../web-extension/e-editor-undo-redo-manager.c     |   11 ++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index a2845c3..fc24a94 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -976,6 +976,8 @@ test_image_insert (TestFixture *fixture)
        /* Mimic what the action:insert-image does, without invoking the image chooser dialog */
        cnt_editor = e_html_editor_get_content_editor (fixture->editor);
        e_content_editor_insert_image (cnt_editor, uri);
+       /* Wait some time until the operation is finished */
+       test_utils_wait_milliseconds (500);
 
        g_free (uri);
 
@@ -989,6 +991,10 @@ test_image_insert (TestFixture *fixture)
        g_free (image_data);
 
        if (!test_utils_run_simple_test (fixture,
+               "undo:save\n" /* 1 */
+               "undo:undo\n"
+               "undo:redo\n"
+               "undo:test:1\n"
                "type:+after\n",
                expected_html,
                "before*+after"))
diff --git a/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c 
b/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
index 9c8205b..4aa8dc5 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-undo-redo-manager.c
@@ -1589,10 +1589,19 @@ undo_redo_image (EEditorPage *editor_page,
 
                node = webkit_dom_node_get_next_sibling  (WEBKIT_DOM_NODE (element));
 
-               if (WEBKIT_DOM_IS_ELEMENT (node))
+               if (WEBKIT_DOM_IS_ELEMENT (node)) {
                        if (element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-resizable-wrapper") ||
                            element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-smiley-wrapper"))
                                remove_node (node);
+                       else if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (node)) {
+                               WebKitDOMNode *parent;
+
+                               parent = webkit_dom_node_get_parent_node (node);
+                               if (element_has_class (WEBKIT_DOM_ELEMENT (parent), 
"-x-evo-resizable-wrapper") ||
+                                   element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-smiley-wrapper"))
+                                       remove_node (parent);
+                       }
+               }
                e_editor_dom_selection_restore (editor_page);
        } else {
                WebKitDOMElement *element;


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