[evolution/gnome-3-26] Indentation in plain text adds unwanted spaces around links



commit 2826313b9cad80b5a93670ddd85f427783a0d6a1
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jan 26 09:59:22 2018 +0100

    Indentation in plain text adds unwanted spaces around links
    
    Indentation gap had been added in front of every text in the indented block,
    which can be wrong in cases where the text is "split" by an anchor, for example
    when added by magic-links. There was used wrong indentation gap in the plain
    text version too (3 in UI versus 4 spaces in plain text per level).
    
    This had been reported downstream at:
    https://bugzilla.redhat.com/show_bug.cgi?id=1538775

 .../web-extension/e-editor-dom-functions.c         |   24 +++++++++++++------
 1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index e820238..1af337c 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -6871,39 +6871,47 @@ process_indented_element (WebKitDOMElement *element)
 {
        gchar *spaces;
        WebKitDOMNode *child;
+       gboolean needs_indent = TRUE;
 
        if (!element)
                return;
 
-       spaces = g_strnfill (4 * get_indentation_level (element), ' ');
+       spaces = g_strnfill (SPACES_PER_INDENTATION * get_indentation_level (element), ' ');
 
        child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (element));
        while (child) {
                /* If next sibling is indented blockqoute skip it,
                 * it will be processed afterwards */
                if (WEBKIT_DOM_IS_ELEMENT (child) &&
-                   element_has_class (WEBKIT_DOM_ELEMENT (child), "-x-evo-indented"))
+                   element_has_class (WEBKIT_DOM_ELEMENT (child), "-x-evo-indented")) {
                        child = webkit_dom_node_get_next_sibling (child);
+                       if (!child)
+                               break;
+               }
 
                if (WEBKIT_DOM_IS_TEXT (child)) {
                        gchar *text_content;
-                       gchar *indented_text;
+                       gchar *indented_text = NULL;
 
                        text_content = webkit_dom_character_data_get_data (WEBKIT_DOM_CHARACTER_DATA (child));
-                       indented_text = g_strconcat (spaces, text_content, NULL);
+                       if (needs_indent) {
+                               indented_text = g_strconcat (spaces, text_content, NULL);
+                               needs_indent = FALSE;
+                       }
 
                        webkit_dom_character_data_set_data (
                                WEBKIT_DOM_CHARACTER_DATA (child),
-                               indented_text,
+                               indented_text ? indented_text : text_content,
                                NULL);
 
                        g_free (text_content);
                        g_free (indented_text);
+               } else if (WEBKIT_DOM_IS_HTML_BR_ELEMENT (child) ||
+                          WEBKIT_DOM_IS_HTML_DIV_ELEMENT (child) ||
+                          WEBKIT_DOM_IS_HTML_PRE_ELEMENT (child)) {
+                       needs_indent = TRUE;
                }
 
-               if (!child)
-                       break;
-
                /* Move to next node */
                if (webkit_dom_node_has_child_nodes (child))
                        child = webkit_dom_node_get_first_child (child);


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