[evolution] EHTMLEditorSelection - Correctly save the selection markers in quoted content



commit c169cd882c86a7af1cb0dacd6242b49fab0d0125
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Oct 30 15:15:26 2014 +0100

    EHTMLEditorSelection - Correctly save the selection markers in quoted content
    
    Before this change the selection markers could be saved next to the
    quote character and this could later prevent the selection to be
    restored correctly. If the selection could be saved next to the quote
    quote character we will save it before the first child of the block
    that is quoted.

 e-util/e-html-editor-selection.c |   49 ++++++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 10 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index b2f81ae..c45f476 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -5827,9 +5827,6 @@ in_empty_block_in_quoted_content (WebKitDOMNode *element)
 {
        WebKitDOMNode *first_child, *next_sibling;
 
-       if (!WEBKIT_DOM_IS_HTML_DIV_ELEMENT (element))
-               return NULL;
-
        first_child = webkit_dom_node_get_first_child (element);
        if (!WEBKIT_DOM_IS_ELEMENT (first_child))
                return NULL;
@@ -5919,6 +5916,23 @@ e_html_editor_selection_save (EHTMLEditorSelection *selection)
 
        container = webkit_dom_range_get_start_container (range, NULL);
        offset = webkit_dom_range_get_start_offset (range, NULL);
+       parent_node = webkit_dom_node_get_parent_node (container);
+
+       if (element_has_class (WEBKIT_DOM_ELEMENT (parent_node), "-x-evo-quote-character")) {
+               WebKitDOMNode *node;
+
+               node = webkit_dom_node_get_parent_node (
+                       webkit_dom_node_get_parent_node (parent_node));
+
+               if ((next_sibling = in_empty_block_in_quoted_content (node))) {
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (next_sibling),
+                               WEBKIT_DOM_NODE (marker),
+                               next_sibling,
+                               NULL);
+                       goto end_marker;
+               }
+       }
 
        if (WEBKIT_DOM_IS_TEXT (container)) {
                if (offset != 0) {
@@ -5929,7 +5943,7 @@ e_html_editor_selection_save (EHTMLEditorSelection *selection)
                        split_node = WEBKIT_DOM_NODE (split_text);
                } else {
                        marker_node = webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (container),
+                               parent_node,
                                WEBKIT_DOM_NODE (marker),
                                container,
                                NULL);
@@ -6014,6 +6028,24 @@ e_html_editor_selection_save (EHTMLEditorSelection *selection)
 
        container = webkit_dom_range_get_end_container (range, NULL);
        offset = webkit_dom_range_get_end_offset (range, NULL);
+       parent_node = webkit_dom_node_get_parent_node (container);
+
+       if (element_has_class (WEBKIT_DOM_ELEMENT (parent_node), "-x-evo-quote-character")) {
+               WebKitDOMNode *node;
+
+               node = webkit_dom_node_get_parent_node (
+                       webkit_dom_node_get_parent_node (parent_node));
+
+               printf ("%s\n", webkit_dom_html_element_get_outer_html (WEBKIT_DOM_HTML_ELEMENT (node)));
+               if ((next_sibling = in_empty_block_in_quoted_content (node))) {
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (next_sibling),
+                               WEBKIT_DOM_NODE (marker),
+                               next_sibling,
+                               NULL);
+                       return;
+               }
+       }
 
        if (WEBKIT_DOM_IS_TEXT (container)) {
                if (offset != 0) {
@@ -6024,10 +6056,7 @@ e_html_editor_selection_save (EHTMLEditorSelection *selection)
                        split_node = WEBKIT_DOM_NODE (split_text);
                } else {
                        marker_node = webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (container),
-                               WEBKIT_DOM_NODE (marker),
-                               container,
-                               NULL);
+                               parent_node, WEBKIT_DOM_NODE (marker), container, NULL);
                        goto check;
 
                }
@@ -6047,9 +6076,9 @@ e_html_editor_selection_save (EHTMLEditorSelection *selection)
                        return;
                }
                if (!webkit_dom_node_get_previous_sibling (container)) {
-                       split_node = webkit_dom_node_get_parent_node (container);
+                       split_node = parent_node;
                } else if (!webkit_dom_node_get_next_sibling (container)) {
-                       split_node = webkit_dom_node_get_parent_node (container);
+                       split_node = parent_node;
                        split_node = webkit_dom_node_get_next_sibling (split_node);
                } else
                        split_node = container;


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