[evolution] EHTMLEditorSelection - Turning off the bold formatting can leave unnecessary nodes in the DOM
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorSelection - Turning off the bold formatting can leave unnecessary nodes in the DOM
- Date: Fri, 26 Feb 2016 09:52:32 +0000 (UTC)
commit 922b882cbf7ea8da7e2f96a495d75943e35eca3d
Author: Tomas Popela <tpopela redhat com>
Date: Fri Feb 26 10:19:35 2016 +0100
EHTMLEditorSelection - Turning off the bold formatting can leave unnecessary nodes in the DOM
Correctly detect if the we are turning off the formatting in the middle of the
node and also remove the formatting element if empty.
e-util/e-html-editor-selection.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index de82b8a..cd45dea 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -3383,12 +3383,18 @@ set_font_style (WebKitDOMDocument *document,
return el;
} else {
- WebKitDOMNode *node;
+ gboolean no_sibling;
+ WebKitDOMNode *node, *sibling;
node = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (element));
/* Turning the formatting in the middle of element. */
- if (webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element))) {
+ sibling = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element));
+ no_sibling = sibling &&
+ !WEBKIT_DOM_IS_HTMLBR_ELEMENT (sibling) &&
+ !webkit_dom_node_get_next_sibling (sibling);
+
+ if (no_sibling) {
WebKitDOMNode *clone;
WebKitDOMNode *sibling;
@@ -3420,11 +3426,21 @@ set_font_style (WebKitDOMDocument *document,
webkit_dom_node_get_next_sibling (parent),
NULL);
+ if (WEBKIT_DOM_IS_HTMLBR_ELEMENT (sibling) && !no_sibling) {
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (parent),
+ node,
+ webkit_dom_node_get_next_sibling (parent),
+ NULL);
+ }
+
webkit_dom_html_element_insert_adjacent_text (
WEBKIT_DOM_HTML_ELEMENT (parent),
"afterend",
UNICODE_ZERO_WIDTH_SPACE,
NULL);
+
+ remove_node_if_empty (parent);
}
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]