diff options
author | Tomas Popela <tpopela@redhat.com> | 2014-07-28 19:20:30 +0800 |
---|---|---|
committer | Tomas Popela <tpopela@redhat.com> | 2014-07-29 00:37:16 +0800 |
commit | 7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9 (patch) | |
tree | 58db092076ab99c477c63a68628be2f0ab5cda40 | |
parent | 2d9a406dc8d6d8a1a01d2670b5ae6e1641a38915 (diff) | |
download | gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar.gz gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar.bz2 gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar.lz gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar.xz gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.tar.zst gsoc2013-evolution-7270148caecc4bbaf2ed3cb9101f6bcd2b37beb9.zip |
Bug 733725 - Runtime critical when pasting test from the same composer instance
Fix the warnings and also fix the wrong structure of the composer
content when we were pasting multiline content into the composer.
-rw-r--r-- | e-util/e-html-editor-view.c | 72 |
1 files changed, 51 insertions, 21 deletions
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index bac4e0ed47..d8fadac1a5 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -4415,13 +4415,15 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view, WEBKIT_DOM_NODE (element)); node = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (parent)); - node = webkit_dom_node_get_first_child (node); if (node) { - inner_html = webkit_dom_node_get_text_content (node); - if (g_str_has_prefix (inner_html, UNICODE_NBSP)) - webkit_dom_character_data_replace_data ( - WEBKIT_DOM_CHARACTER_DATA (node), 0, 1, "", NULL); - g_free (inner_html); + node = webkit_dom_node_get_first_child (node); + if (node) { + inner_html = webkit_dom_node_get_text_content (node); + if (g_str_has_prefix (inner_html, UNICODE_NBSP)) + webkit_dom_character_data_replace_data ( + WEBKIT_DOM_CHARACTER_DATA (node), 0, 1, "", NULL); + g_free (inner_html); + } } selection_marker = webkit_dom_document_get_element_by_id ( @@ -4454,25 +4456,53 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view, WEBKIT_DOM_NODE (selection_marker))), NULL); node = parent; - } else + } else { node = webkit_dom_node_get_next_sibling (parent); + if (!node) { + WebKitDOMNode *first_child, *tmp; + + /* When pasting content that does not contain just the + * one line text WebKit inserts all the content after the + * first line into one element. So we have to take it out + * of this element and insert it after that element. */ + tmp = webkit_dom_node_get_parent_node (parent); + first_child = webkit_dom_node_get_first_child (tmp); + while (first_child) { + WebKitDOMNode *next_child = + webkit_dom_node_get_next_sibling (first_child); + if (webkit_dom_node_has_child_nodes (first_child)) + webkit_dom_node_insert_before ( + webkit_dom_node_get_parent_node (tmp), + first_child, + tmp, + NULL); + first_child = next_child; + } + remove_node (tmp); + } + } - /* Restore caret on the end of pasted text */ - webkit_dom_node_insert_before ( - node, - WEBKIT_DOM_NODE (selection_marker), - webkit_dom_node_get_first_child (node), - NULL); + if (node) { + /* Restore caret on the end of pasted text */ + webkit_dom_node_insert_before ( + node, + WEBKIT_DOM_NODE (selection_marker), + webkit_dom_node_get_first_child (node), + NULL); - selection_marker = webkit_dom_document_get_element_by_id ( - document, "-x-evo-selection-start-marker"); - webkit_dom_node_insert_before ( - node, - WEBKIT_DOM_NODE (selection_marker), - webkit_dom_node_get_first_child (node), - NULL); + selection_marker = webkit_dom_document_get_element_by_id ( + document, "-x-evo-selection-start-marker"); + webkit_dom_node_insert_before ( + node, + WEBKIT_DOM_NODE (selection_marker), + webkit_dom_node_get_first_child (node), + NULL); + } + + if (element) + webkit_dom_element_remove_attribute (element, "class"); - if (!has_selection) + if (webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (parent)) && !has_selection) remove_node (parent); } else { /* When pasting the content that was copied from the composer, WebKit |