[evolution/wip/webkit2] EHTMLEditorSelection - Correctly wrap after link that does not fit on the line
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorSelection - Correctly wrap after link that does not fit on the line
- Date: Wed, 22 Apr 2015 12:53:38 +0000 (UTC)
commit dcc99c26b5efc70e57df2ff3c81f2d39292656cf
Author: Tomas Popela <tpopela redhat com>
Date: Tue Mar 24 11:28:35 2015 +0100
EHTMLEditorSelection - Correctly wrap after link that does not fit on the line
.../e-html-editor-selection-dom-functions.c | 33 +++++++++++++++++--
1 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/web-extensions/e-html-editor-selection-dom-functions.c
b/web-extensions/e-html-editor-selection-dom-functions.c
index 178307b..6ec84b2 100644
--- a/web-extensions/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/e-html-editor-selection-dom-functions.c
@@ -2143,6 +2143,7 @@ wrap_lines (WebKitDOMDocument *document,
text_content = webkit_dom_node_get_text_content (node);
anchor_length = g_utf8_strlen (text_content, -1);
+ g_free (text_content);
if (len + anchor_length > word_wrap_length) {
element = webkit_dom_document_create_element (
document, "BR", NULL);
@@ -2156,15 +2157,39 @@ wrap_lines (WebKitDOMDocument *document,
} else
len += anchor_length;
- g_free (text_content);
+ /* If the anchor doesn't fit on the line wrap after it */
+ if (anchor_length > word_wrap_length) {
+ element = webkit_dom_document_create_element (
+ document, "BR", NULL);
+ element_add_class (element, "-x-evo-wrap-br");
+ node = webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (node),
+ WEBKIT_DOM_NODE (element),
+ webkit_dom_node_get_next_sibling (node),
+ NULL);
+ len = 0;
+ }
/* If there is space after the anchor don't try to
* wrap before it */
node = webkit_dom_node_get_next_sibling (node);
if (WEBKIT_DOM_IS_TEXT (node)) {
text_content = webkit_dom_node_get_text_content (node);
- if (g_strcmp0 (text_content, " ") == 0) {
- node = webkit_dom_node_get_next_sibling (node);
- len++;
+ if (g_str_has_prefix (text_content, " ")) {
+ if (g_strcmp0 (text_content, " ") == 0) {
+ node = webkit_dom_node_get_next_sibling (node);
+ len++;
+ } else {
+ WebKitDOMText *text_node;
+
+ text_node = webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (node), 1, NULL);
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (node),
+ node,
+ webkit_dom_node_get_previous_sibling (node),
+ NULL);
+ node = WEBKIT_DOM_NODE (text_node);
+ }
}
g_free (text_content);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]