diff options
author | Milan Crha <mcrha@redhat.com> | 2014-06-27 16:17:31 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-06-27 16:17:31 +0800 |
commit | 586ab6e32a64e18b78607b3300e82181ee3b11ff (patch) | |
tree | 7e386382dbd122abc57a21bfff7c1d838f61ccfa | |
parent | c3be15b038334c5a212384e8e3289879c72eef7d (diff) | |
download | gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar.gz gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar.bz2 gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar.lz gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar.xz gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.tar.zst gsoc2013-evolution-586ab6e32a64e18b78607b3300e82181ee3b11ff.zip |
Reply to selection in text-highlight part loses white-spaces
text-highlight module encloses the generated text into <pre/> tags,
thus the preview panel shows white-spaces correctly, but once
a reply is done to a selected text the returned HTML portion had
missing <pre/> tags, which led to lose of the white-spaces in
the generated content (in UI), while the white-spaces were there
in the raw HTML code. Enclosing selected HTML portion into <pre/>
tags in case the original text is also enclosed it them fixes it.
-rw-r--r-- | e-util/e-web-view.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index abe33b99e8..e17a18080e 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -2620,6 +2620,27 @@ e_web_view_update_actions (EWebView *web_view) g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0); } +static gboolean +element_is_in_pre_tag (WebKitDOMNode *node) +{ + WebKitDOMElement *element; + + if (!node) + return FALSE; + + while (element = webkit_dom_node_get_parent_element (node), element) { + node = WEBKIT_DOM_NODE (element); + + if (WEBKIT_DOM_IS_HTML_PRE_ELEMENT (element)) { + return TRUE; + } else if (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (element)) { + break; + } + } + + return FALSE; +} + static gchar * web_view_get_frame_selection_html (WebKitDOMElement *iframe) { @@ -2640,6 +2661,9 @@ web_view_get_frame_selection_html (WebKitDOMElement *iframe) range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL); if (range != NULL) { + gchar *inner_html; + WebKitDOMNode *node; + fragment = webkit_dom_range_clone_contents ( range, NULL); @@ -2649,8 +2673,16 @@ web_view_get_frame_selection_html (WebKitDOMElement *iframe) WEBKIT_DOM_NODE (element), WEBKIT_DOM_NODE (fragment), NULL); - return webkit_dom_html_element_get_inner_html ( + inner_html = webkit_dom_html_element_get_inner_html ( WEBKIT_DOM_HTML_ELEMENT (element)); + node = webkit_dom_range_get_start_container (range, NULL); + if (element_is_in_pre_tag (node)) { + gchar *tmp = inner_html; + inner_html = g_strconcat ("<pre>", tmp, "</pre>", NULL); + g_free (tmp); + } + + return inner_html; } } |