[evolution] EHTMLEditor - Make functions that remove quote and wrap elements public



commit 5524dbf7a2b66907cfa72181bfdeb44e268e5718
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jun 19 14:42:24 2014 +0200

    EHTMLEditor - Make functions that remove quote and wrap elements public
    
    Use them whenever it's possible and remove their duplicates from EHTMLEditorView.

 e-util/e-html-editor-selection.c |   32 ++++++++++++++++----------------
 e-util/e-html-editor-selection.h |    2 ++
 e-util/e-html-editor-view.c      |   31 +++----------------------------
 3 files changed, 21 insertions(+), 44 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index a9ba9a7..4565f76 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -1571,8 +1571,8 @@ merge_lists_if_possible (WebKitDOMNode *list)
                merge_list_into_list (next_sibling, list, FALSE);
 }
 
-static void
-remove_wrapping (WebKitDOMElement *element)
+void
+remove_wrapping_from_element (WebKitDOMElement *element)
 {
        WebKitDOMNodeList *list;
        gint ii, length;
@@ -1586,11 +1586,11 @@ remove_wrapping (WebKitDOMElement *element)
        webkit_dom_node_normalize (WEBKIT_DOM_NODE (element));
 }
 
-static void
-remove_quoting (WebKitDOMElement *element)
+void
+remove_quoting_from_element (WebKitDOMElement *element)
 {
-       WebKitDOMNodeList *list;
        gint ii, length;
+       WebKitDOMNodeList *list;
 
        list = webkit_dom_element_query_selector_all (
                element, "span.-x-evo-quoted", NULL);
@@ -1602,17 +1602,17 @@ remove_quoting (WebKitDOMElement *element)
                element, "span.-x-evo-temp-text-wrapper", NULL);
        length = webkit_dom_node_list_get_length (list);
        for (ii = 0; ii < length; ii++) {
-               WebKitDOMNode *nd = webkit_dom_node_list_item (list, ii);
+               WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
+               WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
 
-               while (webkit_dom_node_has_child_nodes (nd)) {
+               while (webkit_dom_node_get_first_child (node))
                        webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (nd),
-                               webkit_dom_node_get_first_child (nd),
-                               nd,
+                               parent,
+                               webkit_dom_node_get_first_child (node),
+                               node,
                                NULL);
-               }
 
-               remove_node (nd);
+               remove_node (node);
        }
 
        webkit_dom_node_normalize (WEBKIT_DOM_NODE (element));
@@ -1706,11 +1706,11 @@ format_change_block_to_block (EHTMLEditorSelection *selection,
                if (webkit_dom_element_query_selector (
                        WEBKIT_DOM_ELEMENT (block), "span.-x-evo-quoted", NULL)) {
                        quoted = TRUE;
-                       remove_quoting (WEBKIT_DOM_ELEMENT (block));
+                       remove_quoting_from_element (WEBKIT_DOM_ELEMENT (block));
                }
 
                if (!html_mode)
-                       remove_wrapping (WEBKIT_DOM_ELEMENT (block));
+                       remove_wrapping_from_element (WEBKIT_DOM_ELEMENT (block));
 
                after_selection_end = webkit_dom_node_contains (
                        block, WEBKIT_DOM_NODE (selection_end_marker));
@@ -1872,8 +1872,8 @@ format_change_block_to_list (EHTMLEditorSelection *selection,
                next_block = webkit_dom_node_get_next_sibling (
                        WEBKIT_DOM_NODE (block));
 
-               remove_wrapping (WEBKIT_DOM_ELEMENT (block));
-               remove_quoting (WEBKIT_DOM_ELEMENT (block));
+               remove_wrapping_from_element (WEBKIT_DOM_ELEMENT (block));
+               remove_quoting_from_element (WEBKIT_DOM_ELEMENT (block));
 
                item = webkit_dom_document_create_element (document, "LI", NULL);
                content = webkit_dom_node_get_text_content (block);
diff --git a/e-util/e-html-editor-selection.h b/e-util/e-html-editor-selection.h
index 104a1a4..1501687 100644
--- a/e-util/e-html-editor-selection.h
+++ b/e-util/e-html-editor-selection.h
@@ -245,6 +245,8 @@ EHTMLEditorSelectionBlockFormat
 EHTMLEditorSelectionAlignment
                e_html_editor_selection_get_list_alignment_from_node
                                                (WebKitDOMNode *node);
+void           remove_wrapping_from_element    (WebKitDOMElement *element);
+void           remove_quoting_from_element     (WebKitDOMElement *element);
 G_END_DECLS
 
 #endif /* E_HTML_EDITOR_SELECTION_H */
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index f17c444..8555514 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -3703,38 +3703,13 @@ e_html_editor_view_dequote_plain_text (EHTMLEditorView *view)
                document, "blockquote.-x-evo-plaintext-quoted", NULL);
        length = webkit_dom_node_list_get_length (paragraphs);
        for (ii = 0; ii < length; ii++) {
-               WebKitDOMNodeList *list;
                WebKitDOMElement *element;
-               gint jj, list_length;
 
                element = WEBKIT_DOM_ELEMENT (webkit_dom_node_list_item (paragraphs, ii));
 
                if (is_citation_node (WEBKIT_DOM_NODE (element))) {
                        element_remove_class (element, "-x-evo-plaintext-quoted");
-
-                       list = webkit_dom_element_query_selector_all (
-                               element, "span.-x-evo-quoted", NULL);
-                       list_length = webkit_dom_node_list_get_length (list);
-                       for (jj = 0; jj < list_length; jj++) {
-                               WebKitDOMNode *node = webkit_dom_node_list_item (list, jj);
-
-                               webkit_dom_node_remove_child (
-                                       webkit_dom_node_get_parent_node (node),
-                                       node,
-                                       NULL);
-                       }
-                       list = webkit_dom_element_query_selector_all (
-                               element, "span.-x-evo-temp-text-wrapper", NULL);
-                       list_length = webkit_dom_node_list_get_length (list);
-                       for (jj = 0; jj < list_length; jj++) {
-                               WebKitDOMNode *node = webkit_dom_node_list_item (list, jj);
-
-                               webkit_dom_node_replace_child (
-                                       webkit_dom_node_get_parent_node (node),
-                                       webkit_dom_node_get_first_child (node),
-                                       node,
-                                       NULL);
-                       }
+                       remove_quoting_from_element (element);
                }
        }
 }
@@ -4588,7 +4563,7 @@ process_elements (EHTMLEditorView *view,
 }
 
 static void
-remove_wrapping (EHTMLEditorView *view)
+remove_wrapping_from_view (EHTMLEditorView *view)
 {
        gint length;
        gint ii;
@@ -5271,7 +5246,7 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
 
                toggle_paragraphs_style (view);
                toggle_smileys (view);
-               remove_wrapping (view);
+               remove_wrapping_from_view (view);
        } else {
                gchar *plain;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]