[evolution/wip/webkit2] EHTMLEditorSelection - Avoid wrong wrapping in some cases



commit c0c6c8048c1154acfcf9a017dc87815f11b90d2f
Author: Tomas Popela <tpopela redhat com>
Date:   Tue Mar 1 13:15:20 2016 +0100

    EHTMLEditorSelection - Avoid wrong wrapping in some cases

 .../e-html-editor-selection-dom-functions.c        |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 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 f9ba962..9a4fbce 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -2439,9 +2439,22 @@ wrap_lines (WebKitDOMDocument *document,
                while (node && (length_left + line_length) > length_to_wrap) {
                        gint max_length;
 
+                       element = webkit_dom_document_create_element (document, "BR", NULL);
+                       element_add_class (element, "-x-evo-wrap-br");
+
                        max_length = length_to_wrap - line_length;
                        if (max_length < 0)
                                max_length = length_to_wrap;
+                       else if (max_length == 0) {
+                               /* Break before the current node and continue. */
+                               webkit_dom_node_insert_before (
+                                       webkit_dom_node_get_parent_node (node),
+                                       WEBKIT_DOM_NODE (element),
+                                       node,
+                                       NULL);
+                               line_length = 0;
+                               continue;
+                       }
 
                        /* Allow anchors to break on any character. */
                        if (g_object_get_data (G_OBJECT (node), "-x-evo-anchor-text"))
@@ -2453,9 +2466,6 @@ wrap_lines (WebKitDOMDocument *document,
                                        WEBKIT_DOM_CHARACTER_DATA (node), max_length);
                        }
 
-                       element = webkit_dom_document_create_element (document, "BR", NULL);
-                       element_add_class (element, "-x-evo-wrap-br");
-
                        if (offset > 0) {
                                WebKitDOMNode *nd;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]