aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-06-19 20:42:24 +0800
committerTomas Popela <tpopela@redhat.com>2014-06-19 21:23:17 +0800
commit5524dbf7a2b66907cfa72181bfdeb44e268e5718 (patch)
tree6c448232e4869794a89e512d16f98d0e6298636a
parente88d5106a1d4e2e83a48d893c16eb1c15b4e54a5 (diff)
downloadgsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar.gz
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar.bz2
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar.lz
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar.xz
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.tar.zst
gsoc2013-evolution-5524dbf7a2b66907cfa72181bfdeb44e268e5718.zip
EHTMLEditor - Make functions that remove quote and wrap elements public
Use them whenever it's possible and remove their duplicates from EHTMLEditorView.
-rw-r--r--e-util/e-html-editor-selection.c32
-rw-r--r--e-util/e-html-editor-selection.h2
-rw-r--r--e-util/e-html-editor-view.c31
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 a9ba9a7d81..4565f76e32 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 104a1a43d7..1501687d49 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 f17c4446f3..85555147b5 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;