[evolution] EHTMLEditorView - When switching from HTML mode to the Plain text mode remove all image backgrounds
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - When switching from HTML mode to the Plain text mode remove all image backgrounds
- Date: Thu, 2 Oct 2014 08:55:57 +0000 (UTC)
commit 0040f39bb2023dc7e6d829568d13a52437af177f
Author: Tomas Popela <tpopela redhat com>
Date: Thu Oct 2 10:30:12 2014 +0200
EHTMLEditorView - When switching from HTML mode to the Plain text mode remove all image backgrounds that
are set
e-util/e-html-editor-view.c | 42 ++++++++++++++++++++++++++++++++++++------
e-util/e-html-editor-view.h | 2 ++
2 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 83358f1..166f345 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -6160,10 +6160,38 @@ remove_wrapping_from_view (EHTMLEditorView *view)
g_object_unref (list);
}
+void
+remove_image_attributes_from_element (WebKitDOMElement *element)
+{
+ webkit_dom_element_remove_attribute (element, "background");
+ webkit_dom_element_remove_attribute (element, "data-uri");
+ webkit_dom_element_remove_attribute (element, "data-inline");
+ webkit_dom_element_remove_attribute (element, "data-name");
+}
+
+static void
+remove_background_images_in_document (WebKitDOMDocument *document)
+{
+ gint length, ii;
+ WebKitDOMNodeList *elements;
+
+ elements = webkit_dom_document_query_selector_all (
+ document, "[background][data-inline]", NULL);
+
+ length = webkit_dom_node_list_get_length (elements);
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMElement *element = WEBKIT_DOM_ELEMENT (
+ webkit_dom_node_list_item (elements, ii));
+
+ remove_image_attributes_from_element (element);
+ }
+
+ g_object_unref (elements);
+}
+
static void
remove_images_in_element (EHTMLEditorView *view,
- WebKitDOMElement *element,
- gboolean html_mode)
+ WebKitDOMElement *element)
{
gint length, ii;
WebKitDOMNodeList *images;
@@ -6186,9 +6214,7 @@ remove_images (EHTMLEditorView *view)
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
remove_images_in_element (
- view,
- WEBKIT_DOM_ELEMENT (webkit_dom_document_get_body (document)),
- view->priv->html_mode);
+ view, WEBKIT_DOM_ELEMENT (webkit_dom_document_get_body (document)));
}
static void
@@ -6521,7 +6547,9 @@ process_content_for_plain_text (EHTMLEditorView *view)
toggle_paragraphs_style_in_element (
view, WEBKIT_DOM_ELEMENT (source), FALSE);
remove_images_in_element (
- view, WEBKIT_DOM_ELEMENT (source), FALSE);
+ view, WEBKIT_DOM_ELEMENT (source));
+ remove_background_images_in_document (
+ document);
} else {
gchar *inner_html;
WebKitDOMElement *div;
@@ -6761,6 +6789,7 @@ convert_when_changing_composer_mode (EHTMLEditorView *view)
toggle_paragraphs_style (view);
toggle_smileys (view);
remove_images (view);
+ remove_background_images_in_document (document);
clear_attributes (document);
@@ -6882,6 +6911,7 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
toggle_paragraphs_style (view);
toggle_smileys (view);
remove_images (view);
+ remove_background_images_in_document (document);
plain = process_content_for_mode_change (view);
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index 2f27fb8..8801d76 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -165,6 +165,8 @@ void e_html_editor_view_add_inline_image_from_mime_part
GList * e_html_editor_view_get_parts_for_inline_images
(EHTMLEditorView *view,
const gchar *uid_domain);
+void remove_image_attributes_from_element
+ (WebKitDOMElement *element);
G_END_DECLS
#endif /* E_HTML_EDITOR_VIEW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]