[evolution/wip/webkit2] Some HTML signatures lost line breaks when inserted to the composer



commit 67c33ce4b508396a649fdff0beaa4798816b3fdf
Author: Tomas Popela <tpopela redhat com>
Date:   Tue May 31 09:49:44 2016 +0200

    Some HTML signatures lost line breaks when inserted to the composer
    
    Usually this applies for HTML signatures that were created in the GtkHTML based
    editor.
    
    Also don't try to convert the signatures that were created after the signature
    editor changed the way how they are saved.

 .../e-html-editor-view-dom-functions.c             |   21 +++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c 
b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
index 1359942..14c4d2c 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
@@ -6517,10 +6517,11 @@ convert_element_from_html_to_plain_text (WebKitDOMDocument *document,
                                          gboolean *wrap,
                                          gboolean *quote)
 {
-       gint blockquotes_count;
+       gint blockquotes_count, ii, length;
        gchar *inner_text, *inner_html;
        WebKitDOMElement *top_signature, *signature, *blockquote, *main_blockquote;
        WebKitDOMNode *signature_clone, *from;
+       WebKitDOMNodeList *list;
 
        top_signature = webkit_dom_element_query_selector (
                element, ".-x-evo-top-signature", NULL);
@@ -6546,6 +6547,24 @@ convert_element_from_html_to_plain_text (WebKitDOMDocument *document,
                from = WEBKIT_DOM_NODE (element);
        }
 
+       /* Add the missing BR elements on the end of all DIV elements to correctly
+        * preserve the line breaks. */
+       list = webkit_dom_element_query_selector_all (WEBKIT_DOM_ELEMENT (from), "div", NULL);
+       length = webkit_dom_node_list_get_length (list);
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *node;
+
+               node = webkit_dom_node_list_item (list, ii);
+               if (!WEBKIT_DOM_IS_HTML_BR_ELEMENT (webkit_dom_node_get_last_child (node))) {
+                       webkit_dom_node_append_child (
+                               node,
+                               WEBKIT_DOM_NODE (webkit_dom_document_create_element (document, "br", NULL)),
+                               NULL);
+               }
+               g_object_unref (node);
+       }
+       g_object_unref (list);
+
        blockquotes_count = create_text_markers_for_citations_in_element (WEBKIT_DOM_ELEMENT (from));
        create_text_markers_for_selection_in_element (WEBKIT_DOM_ELEMENT (from));
 


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