[evolution] Bug 771044 - [WK2] Composer deletes too much text
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 771044 - [WK2] Composer deletes too much text
- Date: Thu, 8 Sep 2016 22:22:19 +0000 (UTC)
commit 86dab2b755d70a9be296df5909c48ee97967609b
Author: Tomas Popela <tpopela redhat com>
Date: Fri Sep 9 00:07:11 2016 +0200
Bug 771044 - [WK2] Composer deletes too much text
When saving the selection, only append the selection end mark to the end of the
container if the following statements are met:
* container is not text
* the offset is not 0 (that would be when the selection starts/end in the
beginning of node)
* offset is bigger by one than the count of the container's children that are
elements
For more see https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset
In the next cycle we really need to simplify the logic inside the
e_editor_dom_selection_save()..
e-util/test-html-editor-units-bugs.c | 15 +++++++++++++++
.../web-extension/e-editor-dom-functions.c | 10 +++++++++-
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/e-util/test-html-editor-units-bugs.c b/e-util/test-html-editor-units-bugs.c
index e0deb7a..3fcb5cf 100644
--- a/e-util/test-html-editor-units-bugs.c
+++ b/e-util/test-html-editor-units-bugs.c
@@ -574,6 +574,20 @@ test_bug_770074 (TestFixture *fixture)
g_test_fail ();
}
+static void
+test_bug_771044 (TestFixture *fixture)
+{
+ if (!test_utils_run_simple_test (fixture,
+ "type:123 456\\n789 abc\\n\n"
+ "seq:uuhSdsD\n",
+ HTML_PREFIX
+ "<p>789 abc</p>"
+ "<p><br></p>"
+ HTML_SUFFIX,
+ "789 abc\n"))
+ g_test_fail ();
+}
+
void
test_add_html_editor_bug_tests (void)
{
@@ -586,4 +600,5 @@ test_add_html_editor_bug_tests (void)
test_utils_add_test ("/bug/769955", test_bug_769955);
test_utils_add_test ("/bug/770073", test_bug_770073);
test_utils_add_test ("/bug/770074", test_bug_770074);
+ test_utils_add_test ("/bug/771044", test_bug_771044);
}
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 2865d4b..3838f54 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -12802,6 +12802,11 @@ e_editor_dom_selection_save (EEditorPage *editor_page)
WEBKIT_DOM_NODE (start_marker),
NULL);
goto insert_end_marker;
+ } else if (offset != 0 && WEBKIT_DOM_IS_ELEMENT (container) &&
+ offset == webkit_dom_element_get_child_element_count (WEBKIT_DOM_ELEMENT
(container)) + 1) {
+ webkit_dom_node_append_child (
+ container, WEBKIT_DOM_NODE (start_marker), NULL);
+ goto insert_end_marker;
} else {
if (webkit_dom_node_get_first_child (container)) {
marker_node = webkit_dom_node_insert_before (
@@ -12915,10 +12920,13 @@ e_editor_dom_selection_save (EEditorPage *editor_page)
!WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent_node)) {
split_node = parent_node;
split_node = webkit_dom_node_get_next_sibling (split_node);
- } else {
+ } else if (offset != 0 && WEBKIT_DOM_IS_ELEMENT (container) &&
+ offset == webkit_dom_element_get_child_element_count (WEBKIT_DOM_ELEMENT
(container)) + 1) {
webkit_dom_node_append_child (
container, WEBKIT_DOM_NODE (end_marker), NULL);
goto out;
+ } else {
+ split_node = container;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]