[evolution/wip/webkit2] Bug 747055 - Line full of equals signs halts selection of quoted text with shift + page down



commit b06ac05effdd80fbf4fc69bdc8c5b9a5ebad2155
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Feb 24 11:05:13 2016 +0100

    Bug 747055 - Line full of equals signs halts selection of quoted text with shift + page down

 .../e-html-editor-selection-dom-functions.c        |   59 ++++++++++++++------
 .../composer/e-html-editor-view-dom-functions.c    |    1 -
 2 files changed, 41 insertions(+), 19 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 6c2533e..7d8529c 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -1942,8 +1942,9 @@ find_where_to_break_line (WebKitDOMNode *node,
                ret_val = max_len + 1;
        } else {
                if (last_space == 0) {
-                       /* If word is longer than word_wrap_length, we cannot wrap it */
-                       ret_val = length;
+                       /* If word is longer than word_wrap_length, we have to
+                        * split at maximal given length. */
+                       ret_val = max_len;
                } else if (last_space < max_len) {
                        ret_val = last_space;
                } else {
@@ -2241,6 +2242,37 @@ 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);
+
+                               next_sibling = webkit_dom_node_get_next_sibling (node);
+                               /* If the anchor doesn't fit on the line wrap after it */
+                               if (anchor_length > word_wrap_length) {
+                                       WebKitDOMElement *removed_link;
+                                       WebKitDOMNode *inner_node;
+
+                                       while ((inner_node = webkit_dom_node_get_first_child (node))) {
+                                               webkit_dom_node_insert_before (
+                                                       webkit_dom_node_get_parent_node (node),
+                                                       inner_node,
+                                                       next_sibling,
+                                                       NULL);
+                                       }
+                                       next_sibling = webkit_dom_node_get_next_sibling (node);
+
+                                       removed_link =
+                                               webkit_dom_document_create_element (
+                                                       document, "SPAN", NULL);
+                                       webkit_dom_element_set_attribute (
+                                               removed_link, "data-removed-link", "", NULL);
+                                       webkit_dom_node_insert_before (
+                                               webkit_dom_node_get_parent_node (node),
+                                               WEBKIT_DOM_NODE (removed_link),
+                                               node,
+                                               NULL);
+                                       remove_node (node);
+                                       node = next_sibling;
+                                       continue;
+                               }
+
                                if (len + anchor_length > word_wrap_length) {
                                        element = webkit_dom_document_create_element (
                                                document, "BR", NULL);
@@ -2254,19 +2286,6 @@ wrap_lines (WebKitDOMDocument *document,
                                } else
                                        len += anchor_length;
 
-                               next_sibling = webkit_dom_node_get_next_sibling (node);
-                               /* If the anchor doesn't fit on the line wrap after it */
-                               if (anchor_length > word_wrap_length && next_sibling) {
-                                       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),
-                                               next_sibling,
-                                               NULL);
-                                       len = 0;
-                               }
                                /* If there is space after the anchor don't try to
                                 * wrap before it */
                                node = next_sibling;
@@ -2385,14 +2404,18 @@ wrap_lines (WebKitDOMDocument *document,
                                                WEBKIT_DOM_NODE (element),
                                                nd,
                                                NULL);
+                                       len = 0;
+                                       break;
                                } else {
-                                       webkit_dom_node_append_child (
+                                       node = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
+                                               WEBKIT_DOM_TEXT (node), word_wrap_length - len, NULL));
+
+                                       webkit_dom_node_insert_before (
                                                webkit_dom_node_get_parent_node (node),
                                                WEBKIT_DOM_NODE (element),
+                                               node,
                                                NULL);
                                }
-                               len = 0;
-                               break;
                        } else {
                                webkit_dom_node_insert_before (
                                        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 731b200..c4cee66 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -2382,7 +2382,6 @@ body_input_event_cb (WebKitDOMElement *element,
                                EHTMLEditorHistoryEvent *ev;
 
                                dom_remove_quoting_from_element (block);
-                               dom_remove_wrapping_from_element (block);
 
                                block = dom_wrap_paragraph_length (document, extension, block, length);
                                webkit_dom_node_normalize (WEBKIT_DOM_NODE (block));


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