[evolution] EHTMLEditorView - Correct the logic to get if the body is empty to avoid the unnecessary processing



commit 46427d48d089f97f5ff7efad9bc12e207325407b
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Oct 23 15:58:11 2014 +0200

    EHTMLEditorView - Correct the logic to get if the body is empty to avoid the unnecessary processing of it

 e-util/e-html-editor-view.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 2504421..130e8cc 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4316,7 +4316,7 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
                                                   WebKitDOMDocument *document_convertor)
 {
        EHTMLEditorSelection *selection = e_html_editor_view_get_selection (view);
-       gboolean start_bottom, empty;
+       gboolean start_bottom, empty = FALSE;
        gchar *inner_text, *inner_html;
        gint ii, length;
        GSettings *settings;
@@ -4452,10 +4452,16 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
        inner_html = webkit_dom_html_element_get_inner_html (
                WEBKIT_DOM_HTML_ELEMENT (wrapper));
 
-       empty = (webkit_dom_element_get_child_element_count (
-               WEBKIT_DOM_ELEMENT (body_convertor)) == 1);
-       empty &= WEBKIT_DOM_IS_HTMLBR_ELEMENT (
-               webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body_convertor)));
+       length = webkit_dom_element_get_child_element_count (WEBKIT_DOM_ELEMENT (body_convertor));
+       if (length <= 1) {
+               empty = TRUE;
+               if (length == 1) {
+                       WebKitDOMNode *child;
+
+                       child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body_convertor));
+                       empty = child && WEBKIT_DOM_IS_HTMLBR_ELEMENT (child);
+               }
+       }
 
        if (!empty)
                parse_html_into_paragraphs (view, document, wrapper, inner_html, FALSE);


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