[evolution] EHTMLEditorSelection - Normalize nodes after restoring selection
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorSelection - Normalize nodes after restoring selection
- Date: Fri, 13 Mar 2015 07:52:17 +0000 (UTC)
commit 751099767ebdbfc1cdca159c7edc01d9bad73dc6
Author: Tomas Popela <tpopela redhat com>
Date: Fri Mar 13 08:38:12 2015 +0100
EHTMLEditorSelection - Normalize nodes after restoring selection
Otherwise it could happen that if we try to save the selection on the
same point it will be saved wrongly (to different position).
e-util/e-html-editor-selection.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 9554b5e..c5ad239 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -6899,6 +6899,7 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection)
WebKitDOMDocument *document;
WebKitDOMElement *marker;
WebKitDOMNode *selection_start_marker, *selection_end_marker;
+ WebKitDOMNode *parent_start, *parent_end;
WebKitDOMRange *range;
WebKitDOMDOMSelection *dom_selection;
WebKitDOMDOMWindow *window;
@@ -6936,9 +6937,12 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection)
ok = is_selection_position_node (selection_end_marker);
if (ok) {
+ parent_start = webkit_dom_node_get_parent_node (selection_end_marker);
+
remove_node (selection_start_marker);
remove_node (selection_end_marker);
+ webkit_dom_node_normalize (parent_start);
return;
}
}
@@ -6959,6 +6963,8 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection)
return;
}
+ parent_start = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker));
+
webkit_dom_range_set_start_after (range, WEBKIT_DOM_NODE (marker), NULL);
remove_node (WEBKIT_DOM_NODE (marker));
@@ -6972,10 +6978,17 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection)
return;
}
+ parent_end = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker));
webkit_dom_range_set_end_before (range, WEBKIT_DOM_NODE (marker), NULL);
remove_node (WEBKIT_DOM_NODE (marker));
webkit_dom_dom_selection_remove_all_ranges (dom_selection);
+ if (webkit_dom_node_is_same_node (parent_start, parent_end))
+ webkit_dom_node_normalize (parent_start);
+ else {
+ webkit_dom_node_normalize (parent_start);
+ webkit_dom_node_normalize (parent_end);
+ }
webkit_dom_dom_selection_add_range (dom_selection, range);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]