[evolution] EHTMLEditorView, EHTMLEditorSelection - Use webkit_dom_html_element_insert_adjacent_html



commit fa66952d411a47918c28fb37f5fb6d4259c8598a
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Feb 11 11:14:08 2015 +0100

    EHTMLEditorView, EHTMLEditorSelection - Use webkit_dom_html_element_insert_adjacent_html
    
    To avoid some unnecessary string allocation/manipulation.

 e-util/e-html-editor-selection.c |   14 ++++----------
 e-util/e-html-editor-view.c      |   20 ++++++--------------
 2 files changed, 10 insertions(+), 24 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index fc3721f..4d77ed2 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -3865,17 +3865,14 @@ e_html_editor_selection_set_monospaced (EHTMLEditorSelection *selection,
                        g_free (end);
                } else {
                        WebKitDOMRange *new_range;
-                       gchar *outer_html;
-                       gchar *tmp;
 
                        webkit_dom_element_set_id (tt_element, "ev-tt");
 
-                       outer_html = webkit_dom_html_element_get_outer_html (
-                               WEBKIT_DOM_HTML_ELEMENT (tt_element));
-                       tmp = g_strconcat (outer_html, UNICODE_ZERO_WIDTH_SPACE, NULL);
-                       webkit_dom_html_element_set_outer_html (
+                       webkit_dom_html_element_insert_adjacent_html (
                                WEBKIT_DOM_HTML_ELEMENT (tt_element),
-                               tmp, NULL);
+                               "beforeend",
+                               UNICODE_ZERO_WIDTH_SPACE,
+                               NULL);
 
                        /* We need to get that element again */
                        tt_element = webkit_dom_document_get_element_by_id (
@@ -3897,9 +3894,6 @@ e_html_editor_selection_set_monospaced (EHTMLEditorSelection *selection,
                        webkit_dom_dom_selection_modify (
                                window_selection, "move", "right", "character");
 
-                       g_free (outer_html);
-                       g_free (tmp);
-
                        e_html_editor_view_force_spell_check_for_current_paragraph (
                                view);
                }
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 9a7c984..02e5323 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1334,17 +1334,13 @@ html_editor_view_check_magic_links (EHTMLEditorView *view,
                                        new_href);
 
                                if (appending_to_link) {
-                                       gchar *tmp;
-
-                                       tmp = g_strconcat (inner_html, text_to_append, NULL);
-                                       webkit_dom_html_element_set_inner_html (
+                                       webkit_dom_html_element_insert_adjacent_html (
                                                WEBKIT_DOM_HTML_ELEMENT (parent),
-                                               tmp,
+                                               "beforeend",
+                                               text_to_append,
                                                NULL);
 
                                        remove_node (node);
-
-                                       g_free (tmp);
                                }
 
                                g_free (new_href);
@@ -1372,17 +1368,13 @@ html_editor_view_check_magic_links (EHTMLEditorView *view,
                                        new_href);
 
                                if (appending_to_link) {
-                                       gchar *tmp;
-
-                                       tmp = g_strconcat (inner_html, text_to_append, NULL);
-                                       webkit_dom_html_element_set_inner_html (
+                                       webkit_dom_html_element_insert_adjacent_html (
                                                WEBKIT_DOM_HTML_ELEMENT (parent),
-                                               tmp,
+                                               "beforeend",
+                                               text_to_append,
                                                NULL);
 
                                        remove_node (node);
-
-                                       g_free (tmp);
                                }
 
                                g_free (new_href);


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