[evolution/wip/webkit2] EHTMLEditorSelection - Turning off the bold formatting can leave unnecessary nodes in the DOM



commit 159c48bde3ee50d33decf117fa2ae4575b5ac7a7
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Mar 3 16:33:16 2016 +0100

    EHTMLEditorSelection - Turning off the bold formatting can leave unnecessary nodes in the DOM

 .../e-html-editor-selection-dom-functions.c        |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-selection-dom-functions.c 
b/web-extensions/composer/e-html-editor-selection-dom-functions.c
index 290c8c6..331d516 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -3529,12 +3529,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_HTML_BR_ELEMENT (sibling) &&
+                       !webkit_dom_node_get_next_sibling (sibling);
+
+               if (no_sibling) {
                        WebKitDOMNode *clone;
                        WebKitDOMNode *sibling;
 
@@ -3566,11 +3572,21 @@ set_font_style (WebKitDOMDocument *document,
                        webkit_dom_node_get_next_sibling (parent),
                        NULL);
 
+               if (WEBKIT_DOM_IS_HTML_BR_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]