[evolution/gnome-3-16] Bug 747055 - Line full of equals signs halts selection of quoted text with shift + page down
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-16] Bug 747055 - Line full of equals signs halts selection of quoted text with shift + page down
- Date: Thu, 2 Apr 2015 12:21:46 +0000 (UTC)
commit d92220a2b761d46362fdf2842ddbf8b48346285c
Author: Tomas Popela <tpopela redhat com>
Date: Thu Apr 2 14:06:49 2015 +0200
Bug 747055 - Line full of equals signs halts selection of quoted text with shift + page down
The problem was that we were not splitting the long sequences of text (in this
case equals signs or even the long links) without a space that can't fit into
Normal block. If a long link is wrapped, the link will be removed and replaced
with the inner text of ANCHOR that will be wrapped later.
e-util/e-html-editor-selection.c | 59 ++++++++++++++++++++++++++-----------
e-util/e-html-editor-view.c | 1 -
2 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index b0a044a..fc143c7 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -5707,8 +5707,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 {
@@ -5952,6 +5953,37 @@ wrap_lines (EHTMLEditorSelection *selection,
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) {
if (webkit_dom_node_get_previous_sibling (node)) {
element = webkit_dom_document_create_element (
@@ -5967,19 +5999,6 @@ wrap_lines (EHTMLEditorSelection *selection,
} 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;
@@ -6098,14 +6117,18 @@ wrap_lines (EHTMLEditorSelection *selection,
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/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 2ffbbf4..0a4f0f4 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -2966,7 +2966,6 @@ body_input_event_cb (WebKitDOMElement *element,
EHTMLEditorViewHistoryEvent *ev;
remove_quoting_from_element (block);
- remove_wrapping_from_element (block);
block = e_html_editor_selection_wrap_paragraph_length (
selection, block, length);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]