[evolution/wip/webkit2] Bug 759337 - Busy loop after sending a message with a space on the end of paragraph
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Bug 759337 - Busy loop after sending a message with a space on the end of paragraph
- Date: Thu, 3 Mar 2016 13:41:27 +0000 (UTC)
commit 46146444be75efbdb1b38f13062ac1b80f4e4d02
Author: Tomas Popela <tpopela redhat com>
Date: Thu Mar 3 13:32:48 2016 +0100
Bug 759337 - Busy loop after sending a message with a space on the end of paragraph
.../e-html-editor-selection-dom-functions.c | 53 +++++++++++++++++---
.../composer/e-html-editor-view-dom-functions.c | 2 +-
2 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-selection-dom-functions.c
b/web-extensions/composer/e-html-editor-selection-dom-functions.c
index 5a6b847..d395214 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -2138,6 +2138,27 @@ dom_scroll_to_caret (WebKitDOMDocument *document)
}
static void
+mark_and_remove_trailing_space (WebKitDOMDocument *document,
+ WebKitDOMNode *node)
+{
+ WebKitDOMElement *element;
+
+ element = webkit_dom_document_create_element (document, "SPAN", NULL);
+ webkit_dom_element_set_attribute (element, "data-hidden-space", "", NULL);
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (node),
+ WEBKIT_DOM_NODE (element),
+ webkit_dom_node_get_next_sibling (node),
+ NULL);
+ webkit_dom_character_data_replace_data (
+ WEBKIT_DOM_CHARACTER_DATA (node),
+ webkit_dom_character_data_get_length (WEBKIT_DOM_CHARACTER_DATA (node)),
+ 1,
+ "",
+ NULL);
+}
+
+static void
mark_and_remove_leading_space (WebKitDOMDocument *document,
WebKitDOMNode *node)
{
@@ -2636,6 +2657,11 @@ wrap_lines (WebKitDOMDocument *document,
if (nd_content && *nd_content) {
if (*nd_content == ' ')
mark_and_remove_leading_space (document, nd);
+
+ if
(!webkit_dom_node_get_next_sibling (nd) &&
+ g_str_has_suffix
(nd_content, " "))
+
mark_and_remove_trailing_space (document, nd);
+
g_free (nd_content);
}
@@ -2685,20 +2711,29 @@ wrap_lines (WebKitDOMDocument *document,
nd = node;
if (nd) {
+ gboolean no_sibling = FALSE;
gchar *nd_content;
nd_content = webkit_dom_node_get_text_content (nd);
if (nd_content && *nd_content) {
if (*nd_content == ' ')
mark_and_remove_leading_space (document, nd);
+
+ if (!webkit_dom_node_get_next_sibling (nd) &&
+ g_str_has_suffix (nd_content, " ")) {
+ mark_and_remove_trailing_space (document, nd);
+ no_sibling = TRUE;
+ }
+
g_free (nd_content);
}
- webkit_dom_node_insert_before (
- webkit_dom_node_get_parent_node (node),
- WEBKIT_DOM_NODE (element),
- nd,
- NULL);
+ if (!no_sibling)
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (node),
+ WEBKIT_DOM_NODE (element),
+ nd,
+ NULL);
offset = 0;
@@ -2706,8 +2741,12 @@ wrap_lines (WebKitDOMDocument *document,
if (!*nd_content)
remove_node (nd);
g_free (nd_content);
- node = webkit_dom_node_get_next_sibling (
- WEBKIT_DOM_NODE (element));
+
+ if (no_sibling)
+ node = NULL;
+ else
+ node = webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (element));
} else {
webkit_dom_node_append_child (
webkit_dom_node_get_parent_node (node),
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.c
b/web-extensions/composer/e-html-editor-view-dom-functions.c
index 76826a6..d7b1367 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -4255,7 +4255,7 @@ parse_html_into_blocks (WebKitDOMDocument *document,
/* Replace single spaces on the beginning of line, 2+ spaces and
* tabulators with non breaking spaces */
- regex_nbsp = g_regex_new ("^\\s{1}|\\s{2,}|\x9", 0, 0, NULL);
+ regex_nbsp = g_regex_new ("^\\s{1}|\\s{2,}|\x9|\\s$", 0, 0, NULL);
while (next_br) {
gboolean local_ignore_next_br = ignore_next_br;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]