Commit f9aef0a1 authored by Tomas Popela's avatar Tomas Popela

Bug 748178 - Eats CPU and memory when replying to calendar invite

The main cause was that composer went to busy loop when it was trying
to wrap a line with word that was longer that line length (usually 72
characters). Now we will force the split at line length to avoid this
situation.

Another thing was that when we wrapped the line it could happen that a
wrong text node will be chosen as a next node to split.
parent bfa1117b
......@@ -5901,11 +5901,8 @@ find_where_to_break_line (WebKitDOMNode *node,
do {
uc = g_utf8_get_char (str);
if (!uc) {
g_free (text_start);
if (pos <= max_len)
return pos;
else
return last_space > 0 ? last_space - 1 : 0;
ret_val = pos <= max_len ? pos : last_space > 0 ? last_space - 1 : 0;
goto out;
}
/* If last_space is zero then the word is longer than
......@@ -5913,16 +5910,15 @@ find_where_to_break_line (WebKitDOMNode *node,
* a space */
if ((pos > max_len) && (last_space > 0)) {
if (last_space > word_wrap_length) {
g_free (text_start);
return last_space > 0 ? last_space - 1 : 0;
ret_val = last_space > 0 ? last_space - 1 : 0;
goto out;
}
if (last_space > max_len) {
if (g_unichar_isspace (g_utf8_get_char (text_start)))
ret_val = 1;
g_free (text_start);
return ret_val;
goto out;
}
if (last_space == max_len - 1) {
......@@ -5931,8 +5927,8 @@ find_where_to_break_line (WebKitDOMNode *node,
last_space++;
}
g_free (text_start);
return last_space > 0 ? last_space - 1 : 0;
ret_val = last_space > 0 ? last_space - 1 : 0;
goto out;
}
if (g_unichar_isspace (uc) || str[0] == '-')
......@@ -5962,8 +5958,13 @@ find_where_to_break_line (WebKitDOMNode *node,
}
}
out:
g_free (text_start);
/* No space found, split at max_len. */
if (ret_val == 0)
ret_val = max_len;
return ret_val;
}
......@@ -6311,6 +6312,9 @@ wrap_lines (EHTMLEditorSelection *selection,
WEBKIT_DOM_NODE (element),
nd,
NULL);
node = webkit_dom_node_get_next_sibling (
WEBKIT_DOM_NODE (element));
} else {
webkit_dom_node_append_child (
webkit_dom_node_get_parent_node (node),
......@@ -6343,6 +6347,7 @@ wrap_lines (EHTMLEditorSelection *selection,
WEBKIT_DOM_NODE (element),
nd,
NULL);
line_length = 0;
break;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment