[evolution] EHTMLEditorSelection - Fix text wrapping
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorSelection - Fix text wrapping
- Date: Wed, 6 May 2015 13:04:29 +0000 (UTC)
commit ae1d204a1e080dfe89bf71e4af39066935b2d3b6
Author: Tomas Popela <tpopela redhat com>
Date: Wed May 6 14:38:03 2015 +0200
EHTMLEditorSelection - Fix text wrapping
In find_where_to_break_line we need to look at the current character
before we will try to break the line, otherwise when the last character
is space we would use the previous space as we didn't checked the current
one.
Also fix runtime critical warnings when we are on the end of the current
paragraph and we don't have any node to continue with.
e-util/e-html-editor-selection.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 6fcccee..0752180 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -5886,7 +5886,7 @@ find_where_to_break_line (WebKitDOMNode *node,
{
gchar *str, *text_start;
gunichar uc;
- gint pos;
+ gint pos = 1;
gint last_space = 0;
gint length;
gint ret_val = 0;
@@ -5895,8 +5895,6 @@ find_where_to_break_line (WebKitDOMNode *node,
text_start = webkit_dom_character_data_get_data (WEBKIT_DOM_CHARACTER_DATA (node));
length = g_utf8_strlen (text_start, -1);
- pos = 1;
- last_space = 0;
str = text_start;
do {
uc = g_utf8_get_char (str);
@@ -5905,6 +5903,9 @@ find_where_to_break_line (WebKitDOMNode *node,
goto out;
}
+ if (g_unichar_isspace (uc) || str[0] == '-')
+ last_space = pos;
+
/* If last_space is zero then the word is longer than
* word_wrap_length characters, so continue until we find
* a space */
@@ -5931,9 +5932,6 @@ find_where_to_break_line (WebKitDOMNode *node,
goto out;
}
- if (g_unichar_isspace (uc) || str[0] == '-')
- last_space = pos;
-
pos += 1;
str = g_utf8_next_char (str);
} while (*str);
@@ -6265,7 +6263,7 @@ wrap_lines (EHTMLEditorSelection *selection,
length_left = webkit_dom_character_data_get_length (
WEBKIT_DOM_CHARACTER_DATA (node));
- if ((length_left + line_length) < word_wrap_length) {
+ if ((length_left + line_length) <= word_wrap_length) {
line_length += length_left;
goto next_node;
}
@@ -6367,13 +6365,17 @@ wrap_lines (EHTMLEditorSelection *selection,
node,
NULL);
}
- length_left = webkit_dom_character_data_get_length (
- WEBKIT_DOM_CHARACTER_DATA (node));
+ if (node)
+ length_left = webkit_dom_character_data_get_length (
+ WEBKIT_DOM_CHARACTER_DATA (node));
line_length = 0;
}
line_length += length_left - offset;
next_node:
+ if (!node)
+ break;
+
if (WEBKIT_DOM_IS_HTMLLI_ELEMENT (node))
line_length = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]