[evolution/evolution-3-12] Reply to selection in text-highlight part loses white-spaces
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/evolution-3-12] Reply to selection in text-highlight part loses white-spaces
- Date: Fri, 27 Jun 2014 08:25:42 +0000 (UTC)
commit cde22464f72ab39956e14fb6bc7cadeb865fc712
Author: Milan Crha <mcrha redhat com>
Date: Fri Jun 27 10:17:31 2014 +0200
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.
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 7615db4..52699ba 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2574,6 +2574,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)
{
@@ -2594,6 +2615,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);
@@ -2603,8 +2627,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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]