[evolution/wip/webkit2] EHTMLEditorView - Redoing a citation split removes an extra text
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorView - Redoing a citation split removes an extra text
- Date: Tue, 31 May 2016 12:07:46 +0000 (UTC)
commit 432a9e9f1b852a8bd737fdc7df4c9ab42a75f439
Author: Tomas Popela <tpopela redhat com>
Date: Tue May 31 12:06:48 2016 +0200
EHTMLEditorView - Redoing a citation split removes an extra text
Redoing the following action: 'When we have a selected text in the quoted
content and we press the return key to split the citation' will remove the text
that is after the selection.
.../e-html-editor-undo-redo-manager.c | 4 +-
.../e-html-editor-view-dom-functions.c | 55 ++++++++------------
2 files changed, 23 insertions(+), 36 deletions(-)
---
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
b/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
index b59e4fd..9f1ada4 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
@@ -1904,8 +1904,8 @@ undo_redo_citation_split (WebKitDOMDocument *document,
if (event->before.start.x == event->after.start.x &&
event->before.start.y == event->after.start.y &&
- event->after.end.x == event->after.end.x &&
- event->after.end.y == event->after.end.y)
+ event->before.end.x == event->after.end.x &&
+ event->before.end.y == event->after.end.y)
in_situ = TRUE;
if (undo) {
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
index b2a236b..8c45ed6 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
@@ -8916,56 +8916,43 @@ split_citation (WebKitDOMDocument *document,
manager = e_html_editor_web_extension_get_undo_redo_manager (extension);
if (!e_html_editor_undo_redo_manager_is_operation_in_progress (manager)) {
+ WebKitDOMElement *selection_end;
+ WebKitDOMNode *sibling;
+
ev = g_new0 (EHTMLEditorHistoryEvent, 1);
ev->type = HISTORY_CITATION_SPLIT;
+ dom_selection_save (document);
+
dom_selection_get_coordinates (
document, &ev->before.start.x, &ev->before.start.y, &ev->before.end.x,
&ev->before.end.y);
if (!dom_selection_is_collapsed (document)) {
- WebKitDOMDocumentFragment *fragment;
- WebKitDOMDOMWindow *dom_window;
- WebKitDOMDOMSelection *dom_selection;
WebKitDOMRange *range;
- dom_window = webkit_dom_document_get_default_view (document);
- dom_selection = webkit_dom_dom_window_get_selection (dom_window);
- g_object_unref (dom_window);
-
- if (!webkit_dom_dom_selection_get_range_count (dom_selection)) {
- g_object_unref (dom_selection);
- return FALSE;
- }
-
- range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
- fragment = webkit_dom_range_clone_contents (range, NULL);
+ range = dom_get_current_range (document);
+ insert_delete_event (document, extension, range);
g_object_unref (range);
- g_object_unref (dom_selection);
-
- ev->data.fragment = fragment;
- } else {
- WebKitDOMElement *selection_end;
- WebKitDOMNode *sibling;
- dom_selection_save (document);
+ ev->before.end.x = ev->before.start.x;
+ ev->before.end.y = ev->before.start.y;
+ }
- selection_end = webkit_dom_document_get_element_by_id (
- document, "-x-evo-selection-end-marker");
+ selection_end = webkit_dom_document_get_element_by_id (
+ document, "-x-evo-selection-end-marker");
- sibling = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (selection_end));
- if (!sibling || (WEBKIT_DOM_IS_HTML_BR_ELEMENT (sibling) &&
- !element_has_class (WEBKIT_DOM_ELEMENT (sibling), "-x-evo-wrap-br"))) {
- WebKitDOMDocumentFragment *fragment;
+ sibling = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (selection_end));
+ if (!sibling || (WEBKIT_DOM_IS_HTML_BR_ELEMENT (sibling) &&
+ !element_has_class (WEBKIT_DOM_ELEMENT (sibling), "-x-evo-wrap-br"))) {
+ WebKitDOMDocumentFragment *fragment;
- fragment = webkit_dom_document_create_document_fragment (document);
- ev->data.fragment = fragment;
- } else {
- ev->data.fragment = NULL;
- }
+ fragment = webkit_dom_document_create_document_fragment (document);
+ ev->data.fragment = fragment;
+ } else
+ ev->data.fragment = NULL;
- dom_selection_restore (document);
- }
+ dom_selection_restore (document);
}
element = dom_insert_new_line_into_citation (document, extension, "");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]