[evolution] EHTMLEditorView - Busy loop after pasting two links after each other in the quoted content



commit aff6c2024c060f53888a13857fe67d3e6d045486
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Apr 8 08:51:48 2016 +0200

    EHTMLEditorView - Busy loop after pasting two links after each other in the quoted content

 e-util/e-html-editor-view.c |   56 +++++++++++++++++++++++++++++++++----------
 1 files changed, 43 insertions(+), 13 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 634e906..72d2409 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -8551,27 +8551,57 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
 
                /* Pasting text that was parsed just into one paragraph */
                if (webkit_dom_node_is_same_node (first_paragraph, last_paragraph)) {
-                       WebKitDOMNode *child, *parent;
+                       WebKitDOMNode *child, *parent_block;
+                       WebKitDOMNode *parent;
 
-                       parent = e_html_editor_get_parent_block_node_from_child (
+                       parent_block = e_html_editor_get_parent_block_node_from_child (
                                WEBKIT_DOM_NODE (selection_start_marker));
 
-                       remove_quoting_from_element (WEBKIT_DOM_ELEMENT (parent));
-                       remove_wrapping_from_element (WEBKIT_DOM_ELEMENT (parent));
+                       remove_quoting_from_element (WEBKIT_DOM_ELEMENT (parent_block));
+                       remove_wrapping_from_element (WEBKIT_DOM_ELEMENT (parent_block));
 
-                       while ((child = webkit_dom_node_get_first_child (first_paragraph)))
-                               webkit_dom_node_insert_before (
-                                       parent,
-                                       child,
-                                       WEBKIT_DOM_NODE (selection_start_marker),
+                       parent = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (selection_start_marker));
+                       while ((child = webkit_dom_node_get_first_child (first_paragraph))) {
+                               if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent) &&
+                                   WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (child)) {
+                                       WebKitDOMNode *anchor_child;
+
+                                       while ((anchor_child = webkit_dom_node_get_first_child (child)))
+                                               webkit_dom_node_insert_before (
+                                                       webkit_dom_node_get_parent_node (
+                                                               WEBKIT_DOM_NODE (selection_start_marker)),
+                                                       anchor_child,
+                                                       WEBKIT_DOM_NODE (selection_start_marker),
+                                                       NULL);
+                                       remove_node (child);
+                               } else
+                                       webkit_dom_node_insert_before (
+                                               webkit_dom_node_get_parent_node (
+                                                       WEBKIT_DOM_NODE (selection_start_marker)),
+                                               child,
+                                               WEBKIT_DOM_NODE (selection_start_marker),
+                                               NULL);
+                       }
+
+                       if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent)) {
+                               gchar *text_content;
+
+                               text_content = webkit_dom_node_get_text_content (parent);
+
+                               webkit_dom_element_set_attribute (
+                                       WEBKIT_DOM_ELEMENT (parent),
+                                       "href",
+                                       text_content,
                                        NULL);
+                               g_free (text_content);
+                       }
 
-                       parent = WEBKIT_DOM_NODE (
+                       parent_block = WEBKIT_DOM_NODE (
                                e_html_editor_selection_wrap_paragraph_length (
-                                       selection, WEBKIT_DOM_ELEMENT (parent), length));
-                       webkit_dom_node_normalize (parent);
+                                       selection, WEBKIT_DOM_ELEMENT (parent_block), length));
+                       webkit_dom_node_normalize (parent_block);
                        e_html_editor_view_quote_plain_text_element_after_wrapping (
-                               document, WEBKIT_DOM_ELEMENT (parent), citation_level);
+                               document, WEBKIT_DOM_ELEMENT (parent_block), citation_level);
 
                        e_html_editor_selection_restore (selection);
 


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