[evolution] EHTMLEditorSelection - Correct wrapping when deleting characters in quoted content
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorSelection - Correct wrapping when deleting characters in quoted content
- Date: Fri, 4 Sep 2015 11:47:37 +0000 (UTC)
commit 9a9f1f436812b98bcb17dc3ec94ce6b4d5249cb7
Author: Tomas Popela <tpopela redhat com>
Date: Fri Sep 4 11:48:30 2015 +0200
EHTMLEditorSelection - Correct wrapping when deleting characters in quoted content
When deleting a character from the first word in the line in the quoted content
and that word could fit on the previous line after deleting that character we
need to remove the BR element (used for wrapping) from the end of the previous
line and start the wrapping from the first node in that line.
e-util/e-html-editor-selection.c | 44 +++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 8dada4b..be11aaf 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -6195,7 +6195,6 @@ wrap_lines (EHTMLEditorSelection *selection,
gint word_wrap_length)
{
WebKitDOMNode *node, *start_node, *block_clone;
- WebKitDOMElement *element;
guint line_length;
gulong length_left;
gchar *text_content;
@@ -6243,6 +6242,9 @@ wrap_lines (EHTMLEditorSelection *selection,
node = WEBKIT_DOM_NODE (fragment);
start_node = node;
} else {
+ WebKitDOMElement *selection_start_marker, *selection_end_marker;
+ WebKitDOMNode *start_point;
+
if (!webkit_dom_node_has_child_nodes (block))
return WEBKIT_DOM_ELEMENT (block);
@@ -6250,13 +6252,13 @@ wrap_lines (EHTMLEditorSelection *selection,
/* When we wrap, we are wrapping just the text after caret, text
* before the caret is already wrapped, so unwrap the text after
* the caret position */
- element = webkit_dom_element_query_selector (
+ selection_end_marker = webkit_dom_element_query_selector (
WEBKIT_DOM_ELEMENT (block_clone),
"span#-x-evo-selection-end-marker",
NULL);
- if (element) {
- WebKitDOMNode *nd = WEBKIT_DOM_NODE (element);
+ if (selection_end_marker) {
+ WebKitDOMNode *nd = WEBKIT_DOM_NODE (selection_end_marker);
while (nd) {
WebKitDOMNode *next_nd = webkit_dom_node_get_next_sibling (nd);
@@ -6304,15 +6306,17 @@ wrap_lines (EHTMLEditorSelection *selection,
}
/* We have to start from the end of the last wrapped line */
- element = webkit_dom_element_query_selector (
+ selection_start_marker = webkit_dom_element_query_selector (
WEBKIT_DOM_ELEMENT (block_clone),
"span#-x-evo-selection-start-marker",
NULL);
- if (element) {
- WebKitDOMNode *nd = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (element));
+ if (selection_start_marker) {
+ gboolean first_removed = FALSE;
+ WebKitDOMNode *nd;
- element = NULL;
+ nd = webkit_dom_node_get_previous_sibling (
+ WEBKIT_DOM_NODE (selection_start_marker));
while (nd) {
WebKitDOMNode *prev_nd = webkit_dom_node_get_previous_sibling (nd);
@@ -6320,16 +6324,30 @@ wrap_lines (EHTMLEditorSelection *selection,
prev_nd = webkit_dom_node_get_previous_sibling
(webkit_dom_node_get_parent_node (nd));
if (WEBKIT_DOM_IS_HTMLBR_ELEMENT (nd)) {
- element = WEBKIT_DOM_ELEMENT (nd);
- break;
+ if (first_removed) {
+ start_point = nd;
+ break;
+ } else {
+ remove_node (nd);
+ first_removed = TRUE;
+ }
+ } else if (WEBKIT_DOM_IS_ELEMENT (nd) &&
+ webkit_dom_element_has_attribute (WEBKIT_DOM_ELEMENT (nd),
"data-hidden-space")) {
+ webkit_dom_html_element_set_outer_text (
+ WEBKIT_DOM_HTML_ELEMENT (nd), " ", NULL);
+ } else if (!prev_nd) {
+ start_point = nd;
}
nd = prev_nd;
}
}
- if (element) {
- node = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element));
+ if (start_point) {
+ if (WEBKIT_DOM_IS_HTMLBR_ELEMENT (start_point))
+ node = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (start_point));
+ else
+ node = start_point;
start_node = block_clone;
} else
start_node = node;
@@ -6338,6 +6356,7 @@ wrap_lines (EHTMLEditorSelection *selection,
line_length = 0;
while (node) {
gint offset = 0;
+ WebKitDOMElement *element;
if (WEBKIT_DOM_IS_TEXT (node)) {
const gchar *newline;
@@ -6629,6 +6648,7 @@ wrap_lines (EHTMLEditorSelection *selection,
if (selection) {
gchar *html;
+ WebKitDOMElement *element;
/* Create a wrapper DIV and put the processed content into it */
element = webkit_dom_document_create_element (document, "DIV", NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]