[evolution/wip/webkit2: 62/62] Commit already done work before rebase



commit ef4b219272107827576687627114747f4ddae780
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Oct 3 10:35:33 2014 +0200

    Commit already done work before rebase

 e-util/Makefile.am                                 |   12 +
 e-util/e-dom-utils.c                               |  160 ++
 e-util/e-dom-utils.h                               |   12 +
 e-util/e-html-editor-actions-dom-functions.c       |  282 ++++
 e-util/e-html-editor-actions-dom-functions.h       |   52 +
 e-util/e-html-editor-actions.c                     |  252 +---
 e-util/e-html-editor-cell-dialog-dom-functions.c   |  361 ++++
 e-util/e-html-editor-cell-dialog-dom-functions.h   |   72 +
 e-util/e-html-editor-cell-dialog.c                 |  879 ++++++----
 e-util/e-html-editor-cell-dialog.h                 |    3 +-
 e-util/e-html-editor-defines.h                     |   30 +
 e-util/e-html-editor-dom-functions.c               |   80 +
 e-util/e-html-editor-find-dialog.c                 |  119 +-
 e-util/e-html-editor-hrule-dialog-dom-functions.c  |   71 +
 e-util/e-html-editor-hrule-dialog-dom-functions.h  |   31 +
 e-util/e-html-editor-hrule-dialog.c                |  431 ++++--
 e-util/e-html-editor-image-dialog-dom-functions.c  |   93 ++
 e-util/e-html-editor-image-dialog-dom-functions.h  |   35 +
 e-util/e-html-editor-image-dialog.c                |  695 ++++++--
 e-util/e-html-editor-image-dialog.h                |    3 +-
 e-util/e-html-editor-link-dialog-dom-functions.c   |  170 ++
 e-util/e-html-editor-link-dialog-dom-functions.h   |   34 +
 e-util/e-html-editor-link-dialog.c                 |  193 +--
 e-util/e-html-editor-page-dialog.c                 |  272 +++-
 e-util/e-html-editor-private.h                     |    3 -
 e-util/e-html-editor-replace-dialog.c              |  217 ++-
 e-util/e-html-editor-selection-dom-functions.c     | 1164 +++++++++++++
 e-util/e-html-editor-selection-dom-functions.h     |   65 +
 e-util/e-html-editor-selection.c                   |  992 +-----------
 e-util/e-html-editor-selection.h                   |    6 +-
 e-util/e-html-editor-table-dialog-dom-functions.c  |  334 ++++
 e-util/e-html-editor-table-dialog-dom-functions.h  |   72 +
 e-util/e-html-editor-table-dialog.c                |  594 +++++---
 e-util/e-html-editor-view-dom-functions.c          |  103 ++
 e-util/e-html-editor-view-dom-functions.h          |   35 +
 e-util/e-html-editor-view.c                        |  257 ++--
 e-util/e-html-editor-view.h                        |   10 +-
 e-util/e-html-editor.c                             |   68 +-
 e-util/e-mail-signature-preview.c                  |   41 +-
 e-util/e-search-bar.c                              |   15 +-
 e-util/e-web-view.c                                |  196 +--
 e-util/e-web-view.h                                |   16 -
 e-util/web-extensions/Makefile.am                  |   23 +
 .../web-extensions/e-html-editor-web-extension.c   | 1724 ++++++++++++++++++++
 .../web-extensions/e-html-editor-web-extension.h   |   26 +
 em-format/e-mail-formatter.c                       |   11 +
 modules/itip-formatter/itip-view.c                 |   14 +-
 47 files changed, 7619 insertions(+), 2709 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 18b4b24..ca267ec 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -200,16 +200,22 @@ evolution_util_include_HEADERS =  \
        e-filter-rule.h \
        e-focus-tracker.h \
        e-html-editor-actions.h \
+       e-html-editor-actions-dom-functions.h \
        e-html-editor-cell-dialog.h \
+       e-html-editor-cell-dialog-dom-functions.h \
        e-html-editor-dialog.h \
        e-html-editor-find-dialog.h \
        e-html-editor-hrule-dialog.h \
+       e-html-editor-hrule-dialog-dom-functions.h \
        e-html-editor-image-dialog.h \
+       e-html-editor-image-dialog-dom-functions.h \
        e-html-editor-link-dialog.h \
+       e-html-editor-link-dialog-dom-functions.h \
        e-html-editor-page-dialog.h \
        e-html-editor-paragraph-dialog.h \
        e-html-editor-replace-dialog.h \
        e-html-editor-selection.h \
+       e-html-editor-selection-dom-functions.h \
        e-html-editor-spell-check-dialog.h \
        e-html-editor-table-dialog.h \
        e-html-editor-text-dialog.h \
@@ -472,17 +478,23 @@ libevolution_util_la_SOURCES = \
        e-filter-rule.c \
        e-focus-tracker.c \
        e-html-editor-actions.c \
+       e-html-editor-actions-dom-functions.c \
        e-html-editor-cell-dialog.c \
+       e-html-editor-cell-dialog-dom-functions.c \
        e-html-editor-dialog.c \
        e-html-editor-find-dialog.c \
        e-html-editor-hrule-dialog.c \
+       e-html-editor-hrule-dialog-dom-functions.c \
        e-html-editor-image-dialog.c \
+       e-html-editor-image-dialog-dom-functions.c \
        e-html-editor-link-dialog.c \
+       e-html-editor-link-dialog-dom-functions.c \
        e-html-editor-page-dialog.c \
        e-html-editor-paragraph-dialog.c \
        e-html-editor-private.h \
        e-html-editor-replace-dialog.c \
        e-html-editor-selection.c \
+       e-html-editor-selection-dom-functions.c \
        e-html-editor-spell-check-dialog.c \
        e-html-editor-table-dialog.c \
        e-html-editor-text-dialog.c \
diff --git a/e-util/e-dom-utils.c b/e-util/e-dom-utils.c
index f8f4176..9d8db7d 100644
--- a/e-util/e-dom-utils.c
+++ b/e-util/e-dom-utils.c
@@ -25,6 +25,8 @@
 
 #include "../web-extensions/evolution-web-extension.h"
 
+#include "e-misc-utils.h"
+
 #include <config.h>
 
 #include <string.h>
@@ -1370,3 +1372,161 @@ e_html_editor_dom_node_find_child_element (WebKitDOMNode *node,
 
        return NULL;
 }
+
+gboolean
+element_has_id (WebKitDOMElement *element,
+                const gchar* id)
+{
+       gchar *element_id;
+
+       if (!element)
+               return FALSE;
+
+       if (!WEBKIT_DOM_IS_ELEMENT (element))
+               return FALSE;
+
+       element_id = webkit_dom_element_get_id (element);
+
+       if (g_ascii_strcasecmp (element_id, id) != 0) {
+               g_free (element_id);
+               return FALSE;
+       }
+       g_free (element_id);
+
+       return TRUE;
+}
+
+gboolean
+element_has_tag (WebKitDOMElement *element,
+                 const gchar* tag)
+{
+       gchar *element_tag;
+
+       if (!WEBKIT_DOM_IS_ELEMENT (element))
+               return FALSE;
+
+       element_tag = webkit_dom_node_get_local_name (WEBKIT_DOM_NODE (element));
+
+       if (g_ascii_strcasecmp (element_tag, tag) != 0) {
+               g_free (element_tag);
+               return FALSE;
+       }
+       g_free (element_tag);
+
+       return TRUE;
+}
+
+gboolean
+element_has_class (WebKitDOMElement *element,
+                const gchar* class)
+{
+       gchar *element_class;
+
+       if (!element)
+               return FALSE;
+
+       if (!WEBKIT_DOM_IS_ELEMENT (element))
+               return FALSE;
+
+       element_class = webkit_dom_element_get_class_name (element);
+
+       if (g_strstr_len (element_class, -1, class)) {
+               g_free (element_class);
+               return TRUE;
+       }
+       g_free (element_class);
+
+       return FALSE;
+}
+
+void
+element_add_class (WebKitDOMElement *element,
+                   const gchar* class)
+{
+       gchar *element_class;
+       gchar *new_class;
+
+       if (!WEBKIT_DOM_IS_ELEMENT (element))
+               return;
+
+       if (element_has_class (element, class))
+               return;
+
+       element_class = webkit_dom_element_get_class_name (element);
+
+       if (g_strcmp0 (element_class, "") == 0)
+               new_class = g_strdup (class);
+       else
+               new_class = g_strconcat (element_class, " ", class, NULL);
+
+       webkit_dom_element_set_class_name (element, new_class);
+
+       g_free (element_class);
+       g_free (new_class);
+}
+
+void
+element_remove_class (WebKitDOMElement *element,
+                      const gchar* class)
+{
+       gchar *element_class;
+       GString *result;
+
+       if (!WEBKIT_DOM_IS_ELEMENT (element))
+               return;
+
+       if (!element_has_class (element, class))
+               return;
+
+       element_class = webkit_dom_element_get_class_name (element);
+
+       if (g_strcmp0 (element_class, class) == 0) {
+               webkit_dom_element_remove_attribute (element, "class");
+               g_free (element_class);
+               return;
+       }
+
+       result = e_str_replace_string (element_class, class, "");
+       if (result) {
+               webkit_dom_element_set_class_name (element, result->str);
+               g_string_free (result, TRUE);
+       }
+
+       g_free (element_class);
+}
+
+void
+remove_node (WebKitDOMNode *node)
+{
+       WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
+
+       /* Check if the parent exists, if so it means that the node is still
+        * in the DOM or at least the parent is. If it doesn't exists it is not
+        * in the DOM and we can free it. */
+       if (parent)
+               webkit_dom_node_remove_child (parent, node, NULL);
+       else
+               g_object_unref (node);
+}
+
+void
+remove_node_if_empty (WebKitDOMNode *node)
+{
+       if (!WEBKIT_DOM_IS_NODE (node))
+               return;
+
+       if (!webkit_dom_node_get_first_child (node)) {
+               remove_node (node);
+       } else {
+               gchar *text_content;
+
+               text_content = webkit_dom_node_get_text_content (node);
+               if (!text_content)
+                       remove_node (node);
+
+               if (text_content && !*text_content)
+                       remove_node (node);
+
+               g_free (text_content);
+       }
+}
diff --git a/e-util/e-dom-utils.h b/e-util/e-dom-utils.h
index ae29176..168d259 100644
--- a/e-util/e-dom-utils.h
+++ b/e-util/e-dom-utils.h
@@ -110,6 +110,18 @@ WebKitDOMElement *
                e_html_editor_dom_node_find_child_element (
                                                WebKitDOMNode *node,
                                                const gchar *tagname);
+gboolean       element_has_id                  (WebKitDOMElement *element,
+                                                const gchar* id);
+gboolean       element_has_tag                 (WebKitDOMElement *element,
+                                                const gchar* tag);
+gboolean       element_has_class               (WebKitDOMElement *element,
+                                                const gchar* class);
+void           element_add_class               (WebKitDOMElement *element,
+                                                const gchar* class);
+void           element_remove_class            (WebKitDOMElement *element,
+                                                const gchar* class);
+void           remove_node                     (WebKitDOMNode *node);
+void           remove_node_if_empty            (WebKitDOMNode *node);
 G_END_DECLS
 
 #endif /* E_DOM_UTILS_H */
diff --git a/e-util/e-html-editor-actions-dom-functions.c b/e-util/e-html-editor-actions-dom-functions.c
new file mode 100644
index 0000000..6a4d87a
--- /dev/null
+++ b/e-util/e-html-editor-actions-dom-functions.c
@@ -0,0 +1,282 @@
+/*
+ * e-html-editor-actions-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-actions-dom-functions.h"
+
+#include "e-dom-utils.h"
+
+static WebKitDOMElement *
+get_table_cell_element (WebKitDOMDocument *document)
+{
+       return webkit_dom_document_get_element_by_id (document, "-x-evo-table-cell");
+}
+
+void
+e_html_editor_dialog_delete_cell (WebKitDOMDocument *document)
+{
+       WebKitDOMNode *sibling;
+       WebKitDOMElement *cell, *table_cell;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       cell = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TD");
+       if (!cell)
+               cell = e_html_editor_dom_node_find_parent_element (
+                       WEBKIT_DOM_NODE (table_cell), "TH");
+       g_return_if_fail (cell != NULL);
+
+       sibling = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (cell));
+       if (!sibling) {
+               sibling = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (cell));
+       }
+
+       webkit_dom_node_remove_child (
+               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (cell)),
+               WEBKIT_DOM_NODE (cell), NULL);
+
+       if (sibling) {
+               webkit_dom_html_table_cell_element_set_col_span (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (sibling),
+                       webkit_dom_html_table_cell_element_get_col_span (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (sibling)) + 1);
+       }
+}
+
+void
+e_html_editor_dialog_delete_column (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *cell, *table, *table_cell;
+       WebKitDOMHTMLCollection *rows;
+       gulong index, length, ii;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       /* Find TD in which the selection starts */
+       cell = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TD");
+       if (!cell)
+               cell = e_html_editor_dom_node_find_parent_element (
+                       WEBKIT_DOM_NODE (table_cell), "TH");
+       g_return_if_fail (cell != NULL);
+
+       table = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (cell), "TABLE");
+       g_return_if_fail (table != NULL);
+
+       rows = webkit_dom_html_table_element_get_rows (
+                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
+       length = webkit_dom_html_collection_get_length (rows);
+
+       index = webkit_dom_html_table_cell_element_get_cell_index (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
+
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *row;
+
+               row = webkit_dom_html_collection_item (rows, ii);
+
+               webkit_dom_html_table_row_element_delete_cell (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index, NULL);
+       }
+
+       g_object_unref (rows);
+}
+
+void
+e_html_editor_dialog_delete_row (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *row, *table_cell;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       row = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TR");
+       g_return_if_fail (row != NULL);
+
+       webkit_dom_node_remove_child (
+               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row)),
+               WEBKIT_DOM_NODE (row), NULL);
+}
+
+void
+e_html_editor_dialog_delete_table (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table, *table_cell;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       table = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TABLE");
+       g_return_if_fail (table != NULL);
+
+       webkit_dom_node_remove_child (
+               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (table)),
+               WEBKIT_DOM_NODE (table), NULL);
+}
+
+void
+e_html_editor_dialog_insert_column_after (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *cell, *row, *table_cell;
+       gulong index;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       cell = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TD");
+       if (!cell)
+               cell = e_html_editor_dom_node_find_parent_element (
+                       WEBKIT_DOM_NODE (table_cell), "TH");
+       g_return_if_fail (cell != NULL);
+
+       row = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (cell), "TR");
+       g_return_if_fail (row != NULL);
+
+       /* Get the first row in the table */
+       row = WEBKIT_DOM_ELEMENT (
+               webkit_dom_node_get_first_child (
+                       webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row))));
+
+       index = webkit_dom_html_table_cell_element_get_cell_index (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
+
+       while (row) {
+               webkit_dom_html_table_row_element_insert_cell (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index + 1, NULL);
+
+               row = WEBKIT_DOM_ELEMENT (
+                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (row)));
+       }
+}
+
+void
+e_html_editor_dialog_insert_column_before (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *cell, *row, *table_cell;
+       gulong index;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       cell = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TD");
+       if (!cell) {
+               cell = e_html_editor_dom_node_find_parent_element (
+                       WEBKIT_DOM_NODE (table_cell), "TH");
+       }
+       g_return_if_fail (cell != NULL);
+
+       row = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TR");
+       g_return_if_fail (row != NULL);
+
+       /* Get the first row in the table */
+       row = WEBKIT_DOM_ELEMENT (
+               webkit_dom_node_get_first_child (
+                       webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row))));
+
+       index = webkit_dom_html_table_cell_element_get_cell_index (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
+
+       while (row) {
+               webkit_dom_html_table_row_element_insert_cell (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index - 1, NULL);
+
+               row = WEBKIT_DOM_ELEMENT (
+                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (row)));
+       }
+}
+
+void
+e_html_editor_dialog_insert_row_above (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *row, *table, *table_cell;
+       WebKitDOMHTMLCollection *cells;
+       WebKitDOMHTMLElement *new_row;
+       gulong index, cell_count, ii;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       row = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TR");
+       g_return_if_fail (row != NULL);
+
+       table = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (row), "TABLE");
+       g_return_if_fail (table != NULL);
+
+       index = webkit_dom_html_table_row_element_get_row_index (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+
+       new_row = webkit_dom_html_table_element_insert_row (
+                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), index, NULL);
+
+       cells = webkit_dom_html_table_row_element_get_cells (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+       cell_count = webkit_dom_html_collection_get_length (cells);
+       for (ii = 0; ii < cell_count; ii++) {
+               webkit_dom_html_table_row_element_insert_cell (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (new_row), -1, NULL);
+       }
+
+       g_object_unref (cells);
+}
+
+void
+e_html_editor_dialog_insert_row_below (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *row, *table, *table_cell;
+       WebKitDOMHTMLCollection *cells;
+       WebKitDOMHTMLElement *new_row;
+       gulong index, cell_count, ii;
+
+       table_cell = get_table_cell_element (document);
+       g_return_if_fail (table_cell != NULL);
+
+       row = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (table_cell), "TR");
+       g_return_if_fail (row != NULL);
+
+       table = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (row), "TABLE");
+       g_return_if_fail (table != NULL);
+
+       index = webkit_dom_html_table_row_element_get_row_index (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+
+       new_row = webkit_dom_html_table_element_insert_row (
+                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), index + 1, NULL);
+
+       cells = webkit_dom_html_table_row_element_get_cells (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+       cell_count = webkit_dom_html_collection_get_length (cells);
+       for (ii = 0; ii < cell_count; ii++) {
+               webkit_dom_html_table_row_element_insert_cell (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (new_row), -1, NULL);
+       }
+
+       g_object_unref (cells);
+}
diff --git a/e-util/e-html-editor-actions-dom-functions.h b/e-util/e-html-editor-actions-dom-functions.h
new file mode 100644
index 0000000..0489929
--- /dev/null
+++ b/e-util/e-html-editor-actions-dom-functions.h
@@ -0,0 +1,52 @@
+/*
+ * e-html-editor-actions-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_dialog_delete_cell
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_delete_column
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_delete_row
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_delete_table
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_insert_column_after
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_insert_column_before
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_insert_row_above
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_dialog_insert_row_below
+                                               (WebKitDOMDocument *document);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-actions.c b/e-util/e-html-editor-actions.c
index 8aa9733..e4524ad 100644
--- a/e-util/e-html-editor-actions.c
+++ b/e-util/e-html-editor-actions.c
@@ -132,256 +132,100 @@ editor_update_static_spell_actions (EHTMLEditor *editor)
  *****************************************************************************/
 
 static void
-action_context_delete_cell_cb (GtkAction *action,
-                               EHTMLEditor *editor)
+html_editor_call_simple_proxy_function (EHTMLEditor *editor,
+                                        const gchar *function)
 {
-       WebKitDOMNode *sibling;
-       WebKitDOMElement *cell;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       cell = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TD");
-       if (!cell) {
-               cell = e_html_editor_dom_node_find_parent_element (
-                                       editor->priv->table_cell, "TH");
-       }
-       g_return_if_fail (cell != NULL);
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       sibling = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (cell));
-       if (!sibling) {
-               sibling = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (cell));
-       }
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       webkit_dom_node_remove_child (
-               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (cell)),
-               WEBKIT_DOM_NODE (cell), NULL);
+       g_dbus_proxy_call (
+               web_extension,
+               function,
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
+}
 
-       if (sibling) {
-               webkit_dom_html_table_cell_element_set_col_span (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (sibling),
-                       webkit_dom_html_table_cell_element_get_col_span (
-                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (sibling)) + 1);
-       }
+static void
+action_context_delete_cell_cb (GtkAction *action,
+                               EHTMLEditor *editor)
+{
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogDeleteCell");
 }
 
 static void
 action_context_delete_column_cb (GtkAction *action,
                                  EHTMLEditor *editor)
 {
-       WebKitDOMElement *cell, *table;
-       WebKitDOMHTMLCollection *rows;
-       gulong index, length, ii;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       /* Find TD in which the selection starts */
-       cell = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TD");
-       if (!cell) {
-               cell = e_html_editor_dom_node_find_parent_element (
-                                       editor->priv->table_cell, "TH");
-       }
-       g_return_if_fail (cell != NULL);
-
-       table = e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (cell), "TABLE");
-       g_return_if_fail (table != NULL);
-
-       rows = webkit_dom_html_table_element_get_rows (
-                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
-       length = webkit_dom_html_collection_get_length (rows);
-
-       index = webkit_dom_html_table_cell_element_get_cell_index (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
-
-       for (ii = 0; ii < length; ii++) {
-               WebKitDOMNode *row;
-
-               row = webkit_dom_html_collection_item (rows, ii);
-
-               webkit_dom_html_table_row_element_delete_cell (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index, NULL);
-       }
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogDeleteColumn");
 }
 
 static void
 action_context_delete_row_cb (GtkAction *action,
                               EHTMLEditor *editor)
 {
-       WebKitDOMElement *row;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       row = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TR");
-       g_return_if_fail (row != NULL);
-
-       webkit_dom_node_remove_child (
-               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row)),
-               WEBKIT_DOM_NODE (row), NULL);
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogDeleteRow");
 }
 
 static void
 action_context_delete_table_cb (GtkAction *action,
                                 EHTMLEditor *editor)
 {
-       WebKitDOMElement *table;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       table = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TABLE");
-       g_return_if_fail (table != NULL);
-
-       webkit_dom_node_remove_child (
-               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (table)),
-               WEBKIT_DOM_NODE (table), NULL);
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogDeleteTable");
 }
 
 static void
 action_context_insert_column_after_cb (GtkAction *action,
                                        EHTMLEditor *editor)
 {
-       WebKitDOMElement *cell, *row;
-       gulong index;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       cell = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TD");
-       if (!cell) {
-               cell = e_html_editor_dom_node_find_parent_element (
-                                       editor->priv->table_cell, "TH");
-       }
-       g_return_if_fail (cell != NULL);
-
-       row = e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (cell), "TR");
-       g_return_if_fail (row != NULL);
-
-       /* Get the first row in the table */
-       row = WEBKIT_DOM_ELEMENT (
-               webkit_dom_node_get_first_child (
-                       webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row))));
-
-       index = webkit_dom_html_table_cell_element_get_cell_index (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
-
-       while (row) {
-               webkit_dom_html_table_row_element_insert_cell (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index + 1, NULL);
-
-               row = WEBKIT_DOM_ELEMENT (
-                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (row)));
-       }
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogInsertColumnAfter");
 }
 
 static void
 action_context_insert_column_before_cb (GtkAction *action,
                                         EHTMLEditor *editor)
 {
-       WebKitDOMElement *cell, *row;
-       gulong index;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       cell = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TD");
-       if (!cell) {
-               cell = e_html_editor_dom_node_find_parent_element (
-                               editor->priv->table_cell, "TH");
-       }
-       g_return_if_fail (cell != NULL);
-
-       row = e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (cell), "TR");
-       g_return_if_fail (row != NULL);
-
-       /* Get the first row in the table */
-       row = WEBKIT_DOM_ELEMENT (
-               webkit_dom_node_get_first_child (
-                       webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (row))));
-
-       index = webkit_dom_html_table_cell_element_get_cell_index (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
-
-       while (row) {
-               webkit_dom_html_table_row_element_insert_cell (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), index - 1, NULL);
-
-               row = WEBKIT_DOM_ELEMENT (
-                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (row)));
-       }
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogInsertColumnBefore");
 }
 
 static void
 action_context_insert_row_above_cb (GtkAction *action,
                                     EHTMLEditor *editor)
 {
-       WebKitDOMElement *row, *table;
-       WebKitDOMHTMLCollection *cells;
-       WebKitDOMHTMLElement *new_row;
-       gulong index, cell_count, ii;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       row = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TR");
-       g_return_if_fail (row != NULL);
-
-       table = e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (row), "TABLE");
-       g_return_if_fail (table != NULL);
-
-       index = webkit_dom_html_table_row_element_get_row_index (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-
-       new_row = webkit_dom_html_table_element_insert_row (
-                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), index, NULL);
-
-       cells = webkit_dom_html_table_row_element_get_cells (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-       cell_count = webkit_dom_html_collection_get_length (cells);
-       for (ii = 0; ii < cell_count; ii++) {
-               webkit_dom_html_table_row_element_insert_cell (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (new_row), -1, NULL);
-       }
-
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogInsertRowAbove");
 }
 
 static void
 action_context_insert_row_below_cb (GtkAction *action,
                                     EHTMLEditor *editor)
 {
-       WebKitDOMElement *row, *table;
-       WebKitDOMHTMLCollection *cells;
-       WebKitDOMHTMLElement *new_row;
-       gulong index, cell_count, ii;
-
-       g_return_if_fail (editor->priv->table_cell != NULL);
-
-       row = e_html_editor_dom_node_find_parent_element (editor->priv->table_cell, "TR");
-       g_return_if_fail (row != NULL);
-
-       table = e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (row), "TABLE");
-       g_return_if_fail (table != NULL);
-
-       index = webkit_dom_html_table_row_element_get_row_index (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-
-       new_row = webkit_dom_html_table_element_insert_row (
-                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), index + 1, NULL);
-
-       cells = webkit_dom_html_table_row_element_get_cells (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-       cell_count = webkit_dom_html_collection_get_length (cells);
-       for (ii = 0; ii < cell_count; ii++) {
-               webkit_dom_html_table_row_element_insert_cell (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (new_row), -1, NULL);
-       }
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorDialogInsertRowBelow");
 }
 
 static void
 action_context_remove_link_cb (GtkAction *action,
                                EHTMLEditor *editor)
 {
-       EHTMLEditorView *view;
-       EHTMLEditorSelection *selection;
-
-       view = e_html_editor_get_view (editor);
-       selection = e_html_editor_view_get_selection (view);
-
-       e_html_editor_selection_unlink (selection);
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorSelectionDOMUnlink");
 }
 
 static void
@@ -737,8 +581,7 @@ action_properties_cell_cb (GtkAction *action,
        }
 
        e_html_editor_cell_dialog_show (
-               E_HTML_EDITOR_CELL_DIALOG (editor->priv->cell_dialog),
-               editor->priv->table_cell);
+               E_HTML_EDITOR_CELL_DIALOG (editor->priv->cell_dialog));
 }
 
 static void
@@ -751,8 +594,7 @@ action_properties_image_cb (GtkAction *action,
        }
 
        e_html_editor_image_dialog_show (
-               E_HTML_EDITOR_IMAGE_DIALOG (editor->priv->image_dialog),
-               editor->priv->image);
+               E_HTML_EDITOR_IMAGE_DIALOG (editor->priv->image_dialog));
 }
 
 static void
@@ -906,14 +748,16 @@ static void
 action_unindent_cb (GtkAction *action,
                     EHTMLEditor *editor)
 {
-       e_html_editor_selection_unindent (editor->priv->selection);
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorSelectionDOMUnindent");
 }
 
 static void
 action_wrap_lines_cb (GtkAction *action,
                       EHTMLEditor *editor)
 {
-       e_html_editor_selection_wrap_lines (editor->priv->selection);
+       html_editor_call_simple_proxy_function (
+               editor, "EHTMLEditorSelectionDOMWrapLines");
 }
 
 static void
diff --git a/e-util/e-html-editor-cell-dialog-dom-functions.c 
b/e-util/e-html-editor-cell-dialog-dom-functions.c
new file mode 100644
index 0000000..d116e74
--- /dev/null
+++ b/e-util/e-html-editor-cell-dialog-dom-functions.c
@@ -0,0 +1,361 @@
+/*
+ * e-html-editor-cell-dialog-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-cell-dialog-dom-functions.h"
+
+#include "e-dom-utils.h"
+
+enum {
+       SCOPE_CELL,
+       SCOPE_ROW,
+       SCOPE_COLUMN,
+       SCOPE_TABLE
+};
+
+typedef void (*DOMStrFunc) (WebKitDOMHTMLTableCellElement *cell, const gchar *val, gpointer user_data);
+typedef void (*DOMUlongFunc) (WebKitDOMHTMLTableCellElement *cell, gulong val, gpointer user_data);
+typedef void (*DOMBoolFunc) (WebKitDOMHTMLTableCellElement *cell, gboolean val, gpointer user_data);
+
+static WebKitDOMElement *
+get_current_cell_element (WebKitDOMDocument *document)
+{
+       return webkit_dom_document_get_element_by_id (document, "-x-evo-current-cell");
+}
+
+static void
+call_cell_dom_func (WebKitDOMHTMLTableCellElement *cell,
+                    gpointer func,
+                    GValue *value,
+                    gpointer user_data)
+{
+       if (G_VALUE_HOLDS_STRING (value)) {
+               DOMStrFunc f = func;
+               f (cell, g_value_get_string (value), user_data);
+       } else if (G_VALUE_HOLDS_LONG (value)) {
+               DOMUlongFunc f = func;
+               f (cell, g_value_get_ulong (value), user_data);
+       } else if (G_VALUE_HOLDS_BOOLEAN (value)) {
+               DOMBoolFunc f = func;
+               f (cell, g_value_get_boolean (value), user_data);
+       }
+}
+
+static void
+for_each_cell_do (WebKitDOMElement *row,
+                  gpointer func,
+                  GValue *value,
+                  gpointer user_data)
+{
+       WebKitDOMHTMLCollection *cells;
+       gulong ii, length;
+       cells = webkit_dom_html_table_row_element_get_cells (
+                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+       length = webkit_dom_html_collection_get_length (cells);
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *cell;
+               cell = webkit_dom_html_collection_item (cells, ii);
+               if (!cell) {
+                       continue;
+               }
+
+               call_cell_dom_func (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell), func, value, user_data);
+       }
+}
+
+static void
+html_editor_cell_dialog_set_attribute (WebKitDOMDocument *document,
+                                       guint scope,
+                                       gpointer func,
+                                       GValue *value,
+                                       gpointer user_data)
+{
+       WebKitDOMElement *cell = get_current_cell_element (document);
+
+       if (scope == SCOPE_CELL) {
+
+               call_cell_dom_func (
+                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell),
+                       func, value, user_data);
+
+       } else if (scope == SCOPE_COLUMN) {
+               gulong index, ii, length;
+               WebKitDOMElement *table;
+               WebKitDOMHTMLCollection *rows;
+
+               index = webkit_dom_html_table_cell_element_get_cell_index (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell));
+               table = e_html_editor_dom_node_find_parent_element (
+                               WEBKIT_DOM_NODE (cell), "TABLE");
+               if (!table) {
+                       return;
+               }
+
+               rows = webkit_dom_html_table_element_get_rows (
+                               WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
+               length = webkit_dom_html_collection_get_length (rows);
+               for (ii = 0; ii < length; ii++) {
+                       WebKitDOMNode *row, *cell;
+                       WebKitDOMHTMLCollection *cells;
+
+                       row = webkit_dom_html_collection_item (rows, ii);
+                       cells = webkit_dom_html_table_row_element_get_cells (
+                                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+                       cell = webkit_dom_html_collection_item (cells, index);
+                       if (!cell) {
+                               continue;
+                       }
+
+                       call_cell_dom_func (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell),
+                               func, value, user_data);
+               }
+
+       } else if (scope == SCOPE_ROW) {
+               WebKitDOMElement *row;
+
+               row = e_html_editor_dom_node_find_parent_element (
+                               WEBKIT_DOM_NODE (cell), "TR");
+               if (!row) {
+                       return;
+               }
+
+               for_each_cell_do (row, func, value, user_data);
+
+       } else if (scope == SCOPE_TABLE) {
+               gulong ii, length;
+               WebKitDOMElement *table;
+               WebKitDOMHTMLCollection *rows;
+
+               table = e_html_editor_dom_node_find_parent_element (
+                               WEBKIT_DOM_NODE (cell), "TABLE");
+               if (!table) {
+                       return;
+               }
+
+               rows = webkit_dom_html_table_element_get_rows (
+                               WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
+               length = webkit_dom_html_collection_get_length (rows);
+               for (ii = 0; ii < length; ii++) {
+                       WebKitDOMNode *row;
+
+                       row = webkit_dom_html_collection_item (rows, ii);
+                       if (!row) {
+                               continue;
+                       }
+
+                       for_each_cell_do (
+                               WEBKIT_DOM_ELEMENT (row), func, value, user_data);
+               }
+       }
+}
+
+static void
+cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
+                       gboolean header_style,
+                      gpointer user_data)
+{
+       WebKitDOMDocument *document;
+       WebKitDOMNodeList *nodes;
+       WebKitDOMElement *new_cell;
+       gulong length, ii;
+       gchar *tagname;
+
+       document = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (cell));
+       tagname = webkit_dom_element_get_tag_name (WEBKIT_DOM_ELEMENT (cell));
+
+       if (header_style && (g_ascii_strncasecmp (tagname, "TD", 2) == 0)) {
+
+               new_cell = webkit_dom_document_create_element (document, "TH", NULL);
+
+       } else if (!header_style && (g_ascii_strncasecmp (tagname, "TH", 2) == 0)) {
+
+               new_cell = webkit_dom_document_create_element (document, "TD", NULL);
+
+       } else {
+               g_free (tagname);
+               return;
+       }
+
+       webkit_dom_element_set_id (new_cell, "-x-evo-current-cell");
+
+       /* Move all child nodes from cell to new_cell */
+       nodes = webkit_dom_node_get_child_nodes (WEBKIT_DOM_NODE (cell));
+       length = webkit_dom_node_list_get_length (nodes);
+       for (ii = 0; ii < length; ii++) {
+               WebKitDOMNode *node;
+
+               node = webkit_dom_node_list_item (nodes, ii);
+               webkit_dom_node_append_child (
+                       WEBKIT_DOM_NODE (new_cell), node, NULL);
+       }
+
+       /* Insert new_cell before cell and remove cell */
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (
+                       WEBKIT_DOM_NODE (cell)),
+               WEBKIT_DOM_NODE (new_cell),
+               WEBKIT_DOM_NODE (cell), NULL);
+
+       webkit_dom_node_remove_child (
+               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (cell)),
+               WEBKIT_DOM_NODE (cell), NULL);
+
+       g_object_unref (nodes);
+
+       g_free (tagname);
+}
+
+void
+e_html_editor_cell_dialog_mark_current_cell_element (WebKitDOMDocument *document,
+                                                     const gchar *id)
+{
+       WebKitDOMElement *element, *parent = NULL;
+
+       element = webkit_dom_document_get_element_by_id (document, id);
+
+       parent = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (element), "TD");
+       if (!parent)
+               parent = e_html_editor_dom_node_find_parent_element (
+                       WEBKIT_DOM_NODE (element), "TH");
+
+       element = webkit_dom_document_get_element_by_id (document, "-x-evo-current-cell");
+       if (element)
+               webkit_dom_element_remove_attribute (element, "id");
+
+       webkit_dom_element_set_id (parent, "-x-evo-current-cell");
+}
+
+void
+e_html_editor_cell_dialog_set_element_v_align (WebKitDOMDocument *document,
+                                               const gchar *v_align,
+                                               guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_STRING);
+       g_value_set_string (&val, v_align);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_v_align, &val, NULL);
+
+       g_value_unset (&val);
+}
+
+void
+e_html_editor_cell_dialog_set_element_align (WebKitDOMDocument *document,
+                                             const gchar *align,
+                                             guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_STRING);
+       g_value_set_string (&val, align);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_align, &val, NULL);
+
+       g_value_unset (&val);
+}
+
+void
+e_html_editor_cell_dialog_set_element_no_wrap (WebKitDOMDocument *document,
+                                               gboolean wrap_text,
+                                               guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_BOOLEAN);
+       g_value_set_boolean (&val, wrap_text);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_no_wrap, &val, NULL);
+}
+
+void
+e_html_editor_cell_dialog_set_element_header_style (WebKitDOMDocument *document,
+                                                    gboolean header_style,
+                                                    guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_BOOLEAN);
+       g_value_set_boolean (&val, header_style);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, cell_set_header_style, &val, NULL);
+}
+
+void
+e_html_editor_cell_dialog_set_element_width (WebKitDOMDocument *document,
+                                             const gchar *width,
+                                             guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_STRING);
+       g_value_set_string (&val, width);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_width, &val, NULL);
+
+       g_value_unset (&val);
+}
+
+void
+e_html_editor_cell_dialog_set_element_col_span (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_LONG);
+       g_value_set_long (&val, span);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_col_span, &val, NULL);
+}
+
+void
+e_html_editor_cell_dialog_set_element_row_span (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_LONG);
+       g_value_set_long (&val, span);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_row_span, &val, NULL);
+}
+
+void
+e_html_editor_cell_dialog_set_element_bg_color (WebKitDOMDocument *document,
+                                                const gchar *color,
+                                                guint scope)
+{
+       GValue val = { 0 };
+
+       g_value_init (&val, G_TYPE_STRING);
+       g_value_set_string (&val, color);
+
+       html_editor_cell_dialog_set_attribute (
+               document, scope, webkit_dom_html_table_cell_element_set_bg_color, &val, NULL);
+}
diff --git a/e-util/e-html-editor-cell-dialog-dom-functions.h 
b/e-util/e-html-editor-cell-dialog-dom-functions.h
new file mode 100644
index 0000000..c27e506
--- /dev/null
+++ b/e-util/e-html-editor-cell-dialog-dom-functions.h
@@ -0,0 +1,72 @@
+/*
+ * e-html-editor-actions-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_cell_dialog_mark_current_cell_element
+                                               (WebKitDOMDocument *document,
+                                                const gchar *id);
+
+void           e_html_editor_cell_dialog_set_element_v_align
+                                               (WebKitDOMDocument *document,
+                                                const gchar *v_align,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_align
+                                               (WebKitDOMDocument *document,
+                                                const gchar *align,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_no_wrap
+                                               (WebKitDOMDocument *document,
+                                                gboolean wrap_text,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_header_style
+                                               (WebKitDOMDocument *document,
+                                                gboolean header_style,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_width
+                                               (WebKitDOMDocument *document,
+                                                const gchar *width,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_col_span
+                                               (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_row_span
+                                               (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_bg_color
+                                               (WebKitDOMDocument *document,
+                                                const gchar *color,
+                                                guint scope);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-cell-dialog.c b/e-util/e-html-editor-cell-dialog.c
index 2c9680b..61e2746 100644
--- a/e-util/e-html-editor-cell-dialog.c
+++ b/e-util/e-html-editor-cell-dialog.c
@@ -62,7 +62,6 @@ struct _EHTMLEditorCellDialogPrivate {
 
        GtkWidget *remove_image_button;
 
-       WebKitDOMElement *cell;
        guint scope;
 };
 
@@ -75,141 +74,12 @@ enum {
 
 static GdkRGBA transparent = { 0, 0, 0, 0 };
 
-typedef void (*DOMStrFunc) (WebKitDOMHTMLTableCellElement *cell, const gchar *val, gpointer user_data);
-typedef void (*DOMUlongFunc) (WebKitDOMHTMLTableCellElement *cell, gulong val, gpointer user_data);
-typedef void (*DOMBoolFunc) (WebKitDOMHTMLTableCellElement *cell, gboolean val, gpointer user_data);
-
 G_DEFINE_TYPE (
        EHTMLEditorCellDialog,
        e_html_editor_cell_dialog,
        E_TYPE_HTML_EDITOR_DIALOG);
 
 static void
-call_cell_dom_func (WebKitDOMHTMLTableCellElement *cell,
-                    gpointer func,
-                    GValue *value,
-                    gpointer user_data)
-{
-       if (G_VALUE_HOLDS_STRING (value)) {
-               DOMStrFunc f = func;
-               f (cell, g_value_get_string (value), user_data);
-       } else if (G_VALUE_HOLDS_ULONG (value)) {
-               DOMUlongFunc f = func;
-               f (cell, g_value_get_ulong (value), user_data);
-       } else if (G_VALUE_HOLDS_BOOLEAN (value)) {
-               DOMBoolFunc f = func;
-               f (cell, g_value_get_boolean (value), user_data);
-       }
-}
-
-static void
-for_each_cell_do (WebKitDOMElement *row,
-                  gpointer func,
-                  GValue *value,
-                  gpointer user_data)
-{
-       WebKitDOMHTMLCollection *cells;
-       gulong ii, length;
-       cells = webkit_dom_html_table_row_element_get_cells (
-                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-       length = webkit_dom_html_collection_get_length (cells);
-       for (ii = 0; ii < length; ii++) {
-               WebKitDOMNode *cell;
-               cell = webkit_dom_html_collection_item (cells, ii);
-               if (!cell) {
-                       continue;
-               }
-
-               call_cell_dom_func (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell), func, value, user_data);
-       }
-}
-
-static void
-html_editor_cell_dialog_set_attribute (EHTMLEditorCellDialog *dialog,
-                                       gpointer func,
-                                       GValue *value,
-                                       gpointer user_data)
-{
-       if (dialog->priv->scope == SCOPE_CELL) {
-
-               call_cell_dom_func (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell),
-                       func, value, user_data);
-
-       } else if (dialog->priv->scope == SCOPE_COLUMN) {
-               gulong index, ii, length;
-               WebKitDOMElement *table;
-               WebKitDOMHTMLCollection *rows;
-
-               index = webkit_dom_html_table_cell_element_get_cell_index (
-                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell));
-               table = e_html_editor_dom_node_find_parent_element (
-                               WEBKIT_DOM_NODE (dialog->priv->cell), "TABLE");
-               if (!table) {
-                       return;
-               }
-
-               rows = webkit_dom_html_table_element_get_rows (
-                               WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
-               length = webkit_dom_html_collection_get_length (rows);
-               for (ii = 0; ii < length; ii++) {
-                       WebKitDOMNode *row, *cell;
-                       WebKitDOMHTMLCollection *cells;
-
-                       row = webkit_dom_html_collection_item (rows, ii);
-                       cells = webkit_dom_html_table_row_element_get_cells (
-                                       WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
-                       cell = webkit_dom_html_collection_item (cells, index);
-                       if (!cell) {
-                               continue;
-                       }
-
-                       call_cell_dom_func (
-                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (cell),
-                               func, value, user_data);
-               }
-
-       } else if (dialog->priv->scope == SCOPE_ROW) {
-               WebKitDOMElement *row;
-
-               row = e_html_editor_dom_node_find_parent_element (
-                               WEBKIT_DOM_NODE (dialog->priv->cell), "TR");
-               if (!row) {
-                       return;
-               }
-
-               for_each_cell_do (row, func, value, user_data);
-
-       } else if (dialog->priv->scope == SCOPE_TABLE) {
-               gulong ii, length;
-               WebKitDOMElement *table;
-               WebKitDOMHTMLCollection *rows;
-
-               table = e_html_editor_dom_node_find_parent_element (
-                               WEBKIT_DOM_NODE (dialog->priv->cell), "TABLE");
-               if (!table) {
-                       return;
-               }
-
-               rows = webkit_dom_html_table_element_get_rows (
-                               WEBKIT_DOM_HTML_TABLE_ELEMENT (table));
-               length = webkit_dom_html_collection_get_length (rows);
-               for (ii = 0; ii < length; ii++) {
-                       WebKitDOMNode *row;
-
-                       row = webkit_dom_html_collection_item (rows, ii);
-                       if (!row) {
-                               continue;
-                       }
-
-                       for_each_cell_do (
-                               WEBKIT_DOM_ELEMENT (row), func, value, user_data);
-               }
-       }
-}
-
-static void
 html_editor_cell_dialog_set_scope (EHTMLEditorCellDialog *dialog)
 {
        if (gtk_toggle_button_get_active (
@@ -238,130 +108,134 @@ html_editor_cell_dialog_set_scope (EHTMLEditorCellDialog *dialog)
 static  void
 html_editor_cell_dialog_set_valign (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
-
-       g_value_init (&val, G_TYPE_STRING);
-       g_value_set_string (
-               &val,
-               gtk_combo_box_get_active_id (
-                       GTK_COMBO_BOX (dialog->priv->valign_combo)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_v_align, &val, NULL);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       g_value_unset (&val);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementVAlign",
+               g_variant_new (
+                       "(tsu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_combo_box_get_active_id (
+                               GTK_COMBO_BOX (dialog->priv->valign_combo)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_halign (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
-
-       g_value_init (&val, G_TYPE_STRING);
-       g_value_set_string (
-               &val,
-               gtk_combo_box_get_active_id (
-                       GTK_COMBO_BOX (dialog->priv->halign_combo)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_align, &val, NULL);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       g_value_unset (&val);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementAlign",
+               g_variant_new (
+                       "(tsu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_combo_box_get_active_id (
+                               GTK_COMBO_BOX (dialog->priv->halign_combo)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_wrap_text (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
-
-       g_value_init (&val, G_TYPE_BOOLEAN);
-       g_value_set_boolean (
-               &val,
-               !gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->wrap_text_check)));
-
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_no_wrap, &val, NULL);
-}
-
-static void
-cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
-                       gboolean header_style,
-                       gpointer user_data)
-{
-       EHTMLEditorCellDialog *dialog = user_data;
-       WebKitDOMDocument *document;
-       WebKitDOMNodeList *nodes;
-       WebKitDOMElement *new_cell;
-       gulong length, ii;
-       gchar *tagname;
-
-       document = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (cell));
-       tagname = webkit_dom_element_get_tag_name (WEBKIT_DOM_ELEMENT (cell));
-
-       if (header_style && (g_ascii_strncasecmp (tagname, "TD", 2) == 0)) {
-
-               new_cell = webkit_dom_document_create_element (document, "TH", NULL);
-
-       } else if (!header_style && (g_ascii_strncasecmp (tagname, "TH", 2) == 0)) {
-
-               new_cell = webkit_dom_document_create_element (document, "TD", NULL);
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       } else {
-               g_free (tagname);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
                return;
-       }
 
-       /* Move all child nodes from cell to new_cell */
-       nodes = webkit_dom_node_get_child_nodes (WEBKIT_DOM_NODE (cell));
-       length = webkit_dom_node_list_get_length (nodes);
-       for (ii = 0; ii < length; ii++) {
-               WebKitDOMNode *node;
-
-               node = webkit_dom_node_list_item (nodes, ii);
-               webkit_dom_node_append_child (
-                       WEBKIT_DOM_NODE (new_cell), node, NULL);
-       }
-
-       /* Insert new_cell before cell and remove cell */
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (
-                       WEBKIT_DOM_NODE (cell)),
-               WEBKIT_DOM_NODE (new_cell),
-               WEBKIT_DOM_NODE (cell), NULL);
-
-       webkit_dom_node_remove_child (
-               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (cell)),
-               WEBKIT_DOM_NODE (cell), NULL);
-
-       dialog->priv->cell = new_cell;
-
-       g_object_unref (nodes);
-
-       g_free (tagname);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementNoWrap",
+               g_variant_new (
+                       "(tbu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       !gtk_combo_box_get_active (
+                               GTK_COMBO_BOX (dialog->priv->wrap_text_check)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_header_style (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       g_value_init (&val, G_TYPE_BOOLEAN);
-       g_value_set_boolean (
-               &val,
-               gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->header_style_check)));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, cell_set_header_style, &val, dialog);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementHeaderStyle",
+               g_variant_new (
+                       "(tbu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_toggle_button_get_active (
+                               GTK_TOGGLE_BUTTON (
+                                       dialog->priv->header_style_check)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_width (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
        gchar *width;
 
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
        if (!gtk_toggle_button_get_active (
                GTK_TOGGLE_BUTTON (dialog->priv->width_check))) {
 
@@ -377,10 +251,19 @@ html_editor_cell_dialog_set_width (EHTMLEditorCellDialog *dialog)
                                        "px" : "%"));
        }
 
-       g_value_init (&val, G_TYPE_STRING);
-       g_value_take_string (&val, width);
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_width, &val, NULL);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementWidth",
+               g_variant_new (
+                       "(tsu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       width,
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (width);
 }
@@ -388,39 +271,75 @@ html_editor_cell_dialog_set_width (EHTMLEditorCellDialog *dialog)
 static void
 html_editor_cell_dialog_set_column_span (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       g_value_init (&val, G_TYPE_ULONG);
-       g_value_set_ulong (
-               &val,
-               gtk_spin_button_get_value_as_int (
-                       GTK_SPIN_BUTTON (dialog->priv->col_span_edit)));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_col_span, &val, NULL);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementColSpan",
+               g_variant_new (
+                       "(tiu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_spin_button_get_value_as_int (
+                               GTK_SPIN_BUTTON (dialog->priv->col_span_edit)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_row_span (EHTMLEditorCellDialog *dialog)
 {
-       GValue val = { 0 };
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       g_value_init (&val, G_TYPE_ULONG);
-       g_value_set_ulong (
-               &val,
-               gtk_spin_button_get_value_as_int (
-                       GTK_SPIN_BUTTON (dialog->priv->row_span_edit)));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_row_span, &val, NULL);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementRowSpan",
+               g_variant_new (
+                       "(tiu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_spin_button_get_value_as_int (
+                               GTK_SPIN_BUTTON (dialog->priv->row_span_edit)),
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_cell_dialog_set_background_color (EHTMLEditorCellDialog *dialog)
 {
-       gchar *color = NULL;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       gchar *color;
        GdkRGBA rgba;
-       GValue val = { 0 };
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        e_color_combo_get_current_color (
                E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
@@ -429,58 +348,89 @@ html_editor_cell_dialog_set_background_color (EHTMLEditorCellDialog *dialog)
        else
                color = g_strdup ("");
 
-       g_value_init (&val, G_TYPE_STRING);
-       g_value_take_string (&val, color);
-
-       html_editor_cell_dialog_set_attribute (
-               dialog, webkit_dom_html_table_cell_element_set_bg_color, &val, NULL);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetElementBgColor",
+               g_variant_new (
+                       "(tsu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       color,
+                       dialog->priv->scope),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (color);
 }
 
 static void
-cell_set_background_image (WebKitDOMHTMLTableCellElement *cell,
-                           const gchar *uri,
-                           EHTMLEditorCellDialog *dialog)
+html_editor_cell_dialog_set_background_image (EHTMLEditorCellDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       const gchar *uri;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       if (uri && *uri) {
+       uri = gtk_file_chooser_get_uri (
+               GTK_FILE_CHOOSER (dialog->priv->background_image_chooser));
+
+       if (!uri || !*uri) {
                e_html_editor_selection_replace_image_src (
                        e_html_editor_view_get_selection (view),
-                       WEBKIT_DOM_ELEMENT (cell),
+                       "#-x-evo-current-cell",
                        uri);
-       } else
-               remove_image_attributes_from_element (WEBKIT_DOM_ELEMENT (cell));
+       } else {
+               g_dbus_proxy_call (
+                       web_extension,
+                       "RemoveImageAttributesFromElement",
+                       g_variant_new (
+                               "(ts)",
+                               webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                               "#-x-evo-current-cell"),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       NULL,
+                       NULL);
+       }
 
        gtk_widget_set_sensitive (dialog->priv->remove_image_button, uri && *uri);
 }
 
 static void
-html_editor_cell_dialog_set_background_image (EHTMLEditorCellDialog *dialog)
+html_editor_cell_dialog_remove_image (EHTMLEditorCellDialog *dialog)
 {
-       gchar *uri;
-       GValue val = { 0 };
-
-       uri = gtk_file_chooser_get_uri (
-               GTK_FILE_CHOOSER (dialog->priv->background_image_chooser));
-
-       g_value_init (&val, G_TYPE_STRING);
-       g_value_take_string (&val, uri);
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       const gchar *uri;
 
-       html_editor_cell_dialog_set_attribute (
-               dialog, cell_set_background_image, &val, dialog);
-}
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-static void
-html_editor_cell_dialog_remove_image (EHTMLEditorCellDialog *dialog)
-{
-       remove_image_attributes_from_element (
-               WEBKIT_DOM_ELEMENT (dialog->priv->cell));
+       g_dbus_proxy_call (
+               web_extension,
+               "RemoveImageAttributesFromElement",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "#-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        gtk_file_chooser_unselect_all (
                GTK_FILE_CHOOSER (dialog->priv->background_image_chooser));
@@ -491,106 +441,308 @@ html_editor_cell_dialog_remove_image (EHTMLEditorCellDialog *dialog)
 static void
 html_editor_cell_dialog_show (GtkWidget *widget)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        EHTMLEditorCellDialog *dialog;
-       gchar *tmp;
+       GDBusProxy *web_extension;
+       GVariant *result;
        GdkRGBA color;
 
-       dialog = E_HTML_EDITOR_CELL_DIALOG (widget);
+       dialog = E_HTML_EDITOR_CELL_DIALOG (dialog);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        gtk_toggle_button_set_active (
                GTK_TOGGLE_BUTTON (dialog->priv->scope_cell_button), TRUE);
 
-       tmp = webkit_dom_html_table_cell_element_get_align (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell));
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->halign_combo),
-               (tmp && *tmp) ? tmp : "left");
-       g_free (tmp);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetAlign",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *align;
+
+               g_variant_get (result, "(&s)", &align);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->halign_combo),
+                       (align && *align) ? align : "left");
+               g_variant_unref (result);
+       }
 
-       tmp = webkit_dom_html_table_cell_element_get_v_align (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell));
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->valign_combo),
-               (tmp && *tmp) ? tmp : "middle");
-       g_free (tmp);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetVAlign",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *v_align;
+
+               g_variant_get (result, "(&s)", &v_align);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->valign_combo),
+                       (v_align && *v_align) ? v_align : "middle");
+               g_variant_unref (result);
+       }
 
-       gtk_toggle_button_set_active (
-               GTK_TOGGLE_BUTTON (dialog->priv->wrap_text_check),
-               !webkit_dom_html_table_cell_element_get_no_wrap (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell)));
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetNoWrap",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               gboolean no_wrap;
+
+               g_variant_get (result, "(b)", &no_wrap);
+               gtk_toggle_button_set_active (
+                       GTK_TOGGLE_BUTTON (dialog->priv->wrap_text_check), !no_wrap);
+               g_variant_unref (result);
+       }
 
-       tmp = webkit_dom_element_get_tag_name (
-               WEBKIT_DOM_ELEMENT (dialog->priv->cell));
-       gtk_toggle_button_set_active (
-               GTK_TOGGLE_BUTTON (dialog->priv->header_style_check),
-               (g_ascii_strncasecmp (tmp, "TH", 2) == 0));
-       g_free (tmp);
-
-       tmp = webkit_dom_html_table_cell_element_get_width (
-               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell));
-       if (tmp && *tmp) {
-               gint val = atoi (tmp);
-               gtk_spin_button_set_value (
-                       GTK_SPIN_BUTTON (dialog->priv->width_edit), val);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ElementGetTagName",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *tag_name;
+
+               g_variant_get (result, "(&s)", &tag_name);
                gtk_toggle_button_set_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->width_check), TRUE);
-       } else {
+                       GTK_TOGGLE_BUTTON (dialog->priv->header_style_check),
+                       (g_ascii_strncasecmp (tag_name, "TH", 2) == 0));
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *width;
+
+               g_variant_get (result, "(&s)", &width);
+               if (width && *width) {
+                       gint val = atoi (width);
+                       gtk_spin_button_set_value (
+                               GTK_SPIN_BUTTON (dialog->priv->width_edit), val);
+                       gtk_toggle_button_set_active (
+                               GTK_TOGGLE_BUTTON (dialog->priv->width_check), TRUE);
+               } else {
+                       gtk_spin_button_set_value (
+                               GTK_SPIN_BUTTON (dialog->priv->width_edit), 0);
+                       gtk_toggle_button_set_active (
+                               GTK_TOGGLE_BUTTON (dialog->priv->width_check), FALSE);
+               }
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->width_units), "units-px");
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetRowSpan",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong row_span;
+
+               g_variant_get (result, "(i)", &row_span);
                gtk_spin_button_set_value (
-                       GTK_SPIN_BUTTON (dialog->priv->width_edit), 0);
-               gtk_toggle_button_set_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->width_check), FALSE);
+                       GTK_SPIN_BUTTON (dialog->priv->row_span_edit), row_span);
+               g_variant_unref (result);
        }
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->width_units), "units-px");
-       g_free (tmp);
-
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->row_span_edit),
-               webkit_dom_html_table_cell_element_get_row_span (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell)));
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->col_span_edit),
-               webkit_dom_html_table_cell_element_get_col_span (
-                       WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell)));
-
-       if (webkit_dom_element_has_attribute (
-               WEBKIT_DOM_ELEMENT (dialog->priv->cell), "background")) {
-               tmp = webkit_dom_element_get_attribute (
-                       WEBKIT_DOM_ELEMENT (dialog->priv->cell), "data-uri");
-
-               gtk_file_chooser_set_uri (
-                       GTK_FILE_CHOOSER (dialog->priv->background_image_chooser),
-                       tmp);
-
-               g_free (tmp);
-       } else {
-               gtk_file_chooser_unselect_all (
-                       GTK_FILE_CHOOSER (dialog->priv->background_image_chooser));
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetColSpan",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong col_span;
+
+               g_variant_get (result, "(i)", &col_span);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->col_span_edit), col_span);
+               g_variant_unref (result);
        }
 
-       tmp = webkit_dom_html_table_cell_element_get_bg_color (
-               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (dialog->priv->cell));
-       if (tmp && *tmp) {
-               if (gdk_rgba_parse (&color, tmp)) {
-                       e_color_combo_set_current_color (
-                               E_COLOR_COMBO (dialog->priv->background_color_picker),
-                               &color);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ElementHasAttribute",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (
+                               WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell",
+                       "background"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               gboolean has_background;
+
+               g_variant_get (result, "(b)", &has_background);
+               if (has_background) {
+                       g_variant_unref (result);
+                       result = g_dbus_proxy_call_sync (
+                               web_extension,
+                               "ElementGetAttribute",
+                               g_variant_new (
+                                       "(tss)",
+                                       webkit_web_view_get_page_id (
+                                               WEBKIT_WEB_VIEW (view)),
+                                       "-x-evo-current-cell",
+                                       "data-uri"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL);
+
+                       if (result) {
+                               const gchar *value;
+
+                               g_variant_get (result, "(&s)", &value);
+
+                               gtk_file_chooser_set_uri (
+                                       GTK_FILE_CHOOSER (dialog->priv->background_image_chooser),
+                                       value);
+
+                               g_variant_unref (result);
+                       }
                } else {
-                       e_color_combo_set_current_color (
-                               E_COLOR_COMBO (dialog->priv->background_color_picker),
-                               &transparent);
+                       gtk_file_chooser_unselect_all (
+                               GTK_FILE_CHOOSER (dialog->priv->background_image_chooser));
+                       g_variant_unref (result);
+               }
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "TableCellElementGetBgColor",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *bg_color;
+
+               g_variant_get (result, "(&s)", &bg_color);
+
+               if (bg_color && *bg_color) {
+                       if (gdk_rgba_parse (&color, bg_color)) {
+                               e_color_combo_set_current_color (
+                                       E_COLOR_COMBO (dialog->priv->background_color_picker),
+                                       &color);
+                       } else {
+                               e_color_combo_set_current_color (
+                                       E_COLOR_COMBO (dialog->priv->background_color_picker),
+                                       &transparent);
+                       }
                }
-       } else {
                e_color_combo_set_current_color (
                        E_COLOR_COMBO (dialog->priv->background_color_picker),
                        &transparent);
+
+               g_variant_unref (result);
        }
-       g_free (tmp);
 
        GTK_WIDGET_CLASS (e_html_editor_cell_dialog_parent_class)->show (widget);
 }
 
 static void
+html_editor_cell_dialog_hide (GtkWidget *widget)
+{
+       EHTMLEditor *editor;
+       EHTMLEditorCellDialog *dialog;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       dialog = E_HTML_EDITOR_CELL_DIALOG (widget);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ElementRemoveAttribute",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-cell",
+                       "id"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
+
+       GTK_WIDGET_CLASS (e_html_editor_cell_dialog_parent_class)->hide (widget);
+}
+
+static void
 e_html_editor_cell_dialog_class_init (EHTMLEditorCellDialogClass *class)
 {
        GtkWidgetClass *widget_class;
@@ -599,6 +751,7 @@ e_html_editor_cell_dialog_class_init (EHTMLEditorCellDialogClass *class)
 
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->show = html_editor_cell_dialog_show;
+       widget_class->hide = html_editor_cell_dialog_hide;
 }
 
 static void
@@ -897,19 +1050,33 @@ e_html_editor_cell_dialog_new (EHTMLEditor *editor)
 }
 
 void
-e_html_editor_cell_dialog_show (EHTMLEditorCellDialog *dialog,
-                                WebKitDOMNode *cell)
+e_html_editor_cell_dialog_show (EHTMLEditorCellDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        EHTMLEditorCellDialogClass *class;
+       GDBusProxy *web_extension;
 
        g_return_if_fail (E_IS_HTML_EDITOR_CELL_DIALOG (dialog));
-       g_return_if_fail (cell != NULL);
 
-       dialog->priv->cell = e_html_editor_dom_node_find_parent_element (cell, "TD");
-       if (dialog->priv->cell == NULL) {
-               dialog->priv->cell =
-                       e_html_editor_dom_node_find_parent_element (cell, "TH");
-       }
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogMarkCurrentCellElement",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-table-cell"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        class = E_HTML_EDITOR_CELL_DIALOG_GET_CLASS (dialog);
        GTK_WIDGET_CLASS (class)->show (GTK_WIDGET (dialog));
diff --git a/e-util/e-html-editor-cell-dialog.h b/e-util/e-html-editor-cell-dialog.h
index 3a7f608..963e12b 100644
--- a/e-util/e-html-editor-cell-dialog.h
+++ b/e-util/e-html-editor-cell-dialog.h
@@ -64,8 +64,7 @@ struct _EHTMLEditorCellDialogClass {
 GType          e_html_editor_cell_dialog_get_type
                                                (void) G_GNUC_CONST;
 GtkWidget *    e_html_editor_cell_dialog_new   (EHTMLEditor *editor);
-void           e_html_editor_cell_dialog_show  (EHTMLEditorCellDialog *dialog,
-                                                WebKitDOMNode *cell);
+void           e_html_editor_cell_dialog_show  (EHTMLEditorCellDialog *dialog);
 
 G_END_DECLS
 
diff --git a/e-util/e-html-editor-defines.h b/e-util/e-html-editor-defines.h
new file mode 100644
index 0000000..e1537d2
--- /dev/null
+++ b/e-util/e-html-editor-defines.h
@@ -0,0 +1,30 @@
+/*
+ * e-html-editor-defines.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_DEFINES_H
+#define E_HTML_EDITOR_DEFINES_H
+
+#define E_HTML_EDITOR_NODE_IS_HR         (1 << 0)
+#define E_HTML_EDITOR_NODE_IS_TEXT       (1 << 1)
+#define E_HTML_EDITOR_NODE_IS_ANCHOR     (1 << 2)
+#define E_HTML_EDITOR_NODE_IS_IMAGE      (1 << 3)
+#define E_HTML_EDITOR_NODE_IS_TABLE_CELL (1 << 4)
+#define E_HTML_EDITOR_NODE_IS_TABLE      (1 << 5)
+#define E_HTML_EDITOR_LAST_FLAG          (1 << 6)
+
+#endif /* E_HTML_EDITOR_DEFINES_H */
diff --git a/e-util/e-html-editor-dom-functions.c b/e-util/e-html-editor-dom-functions.c
new file mode 100644
index 0000000..216d7e1
--- /dev/null
+++ b/e-util/e-html-editor-dom-functions.c
@@ -0,0 +1,80 @@
+/*
+ * e-html-editor-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-dom-functions.h"
+#include "e-html-editor-defines.h"
+
+#include "e-dom-utils.h"
+
+guint
+get_e_html_editor_flags_for_element_on_coordinates (WebKitDOMDocument *document,
+                                                    gint32 x,
+                                                    gint32 y)
+{
+       guint flags = 0;
+       WebKitDOMElement *element, *tmp;
+
+       tmp = webkit_dom_document_get_element_by_id (document, "-x-evo-current-image");
+       if (tmp)
+               webkit_dom_element_remove_attribute (tmp, "id");
+       tmp = webkit_dom_document_get_element_by_id (document, "-x-evo-table-cell");
+       if (tmp)
+               webkit_dom_element_remove_attribute (tmp, "id");
+
+       element = e_dom_utils_get_element_from_point (document, x, y);
+       if (!element) {
+               flags |= E_HTML_EDITOR_NODE_IS_TEXT;
+               return flags;
+       }
+
+       if (WEBKIT_DOM_IS_HTML_HR_ELEMENT (element))
+               flags |= E_HTML_EDITOR_NODE_IS_HR;
+
+       if (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (element) ||
+           (e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (element), "A") != NULL))
+               flags |= E_HTML_EDITOR_NODE_IS_ANCHOR;
+
+       if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (element) ||
+           (e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (element), "IMG") != NULL)) {
+
+               flags |= E_HTML_EDITOR_NODE_IS_IMAGE;
+
+               webkit_dom_element_set_id (element, "-x-evo-current-image");
+       }
+
+       if (WEBKIT_DOM_IS_HTML_TABLE_CELL_ELEMENT (element) ||
+           (e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (element), "TD") != NULL) ||
+           (e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (element), "TH") != NULL)) {
+
+               flags |= E_HTML_EDITOR_NODE_IS_TABLE_CELL;
+
+               webkit_dom_element_set_id (element, "-x-evo-table-cell");
+       }
+
+       if (flags && E_HTML_EDITOR_NODE_IS_TABLE_CELL &&
+           (WEBKIT_DOM_IS_HTML_TABLE_ELEMENT (element) ||
+           (e_html_editor_dom_node_find_parent_element (WEBKIT_DOM_NODE (element), "TABLE") != NULL));
+
+               flags |= E_HTML_EDITOR_NODE_IS_TABLE;
+       }
+
+       if (flags == 0)
+               flags |= E_HTML_EDITOR_NODE_IS_TEXT;
+
+       return flags;
+}
diff --git a/e-util/e-html-editor-find-dialog.c b/e-util/e-html-editor-find-dialog.c
index 2a19d01..e82bb1a 100644
--- a/e-util/e-html-editor-find-dialog.c
+++ b/e-util/e-html-editor-find-dialog.c
@@ -25,6 +25,7 @@
 #include "e-html-editor-find-dialog.h"
 #include "e-dialog-widgets.h"
 
+#include <webkit2/webkit2.h>
 #include <glib/gi18n-lib.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -41,6 +42,10 @@ struct _EHTMLEditorFindDialogPrivate {
        GtkWidget *find_button;
 
        GtkWidget *result_label;
+
+       WebKitFindController *find_controller;
+       gulong found_text_handler_id;
+       gulong failed_to_find_text_handler_id;
 };
 
 G_DEFINE_TYPE (
@@ -68,43 +73,49 @@ html_editor_find_dialog_show (GtkWidget *widget)
 }
 
 static void
-html_editor_find_dialog_find_cb (EHTMLEditorFindDialog *dialog)
+webkit_find_controller_found_text_cb (WebKitFindController *find_controller,
+                                      guint match_count,
+                                      EHTMLEditorFindDialog *dialog)
 {
-       gboolean found;
-       EHTMLEditor *editor;
-       EHTMLEditorView *view;
-
-       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
-       view = e_html_editor_get_view (editor);
-       found = webkit_web_view_search_text (
-                       WEBKIT_WEB_VIEW (view),
-                       gtk_entry_get_text (
-                               GTK_ENTRY (dialog->priv->entry)),
-                       gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (
-                                       dialog->priv->case_sensitive)),
-                       !gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (
-                                       dialog->priv->backwards)),
-                       gtk_toggle_button_get_active (
-                               GTK_TOGGLE_BUTTON (
-                                       dialog->priv->wrap_search)));
-
-       gtk_widget_set_sensitive (dialog->priv->find_button, found);
+       gtk_widget_set_sensitive (dialog->priv->find_button, TRUE);
 
        /* We give focus to WebKit so that the selection is highlited.
         * Without focus selection is not visible (at least with my default
         * color scheme). The focus in fact is not given to WebKit, because
         * this dialog is modal, but it satisfies it in a way that it paints
         * the selection :) */
-       gtk_widget_grab_focus (GTK_WIDGET (view));
+       /* FIXME WK2 - still needed ?
+       gtk_widget_grab_focus (GTK_WIDGET (view)); */
+}
 
-       if (!found) {
-               gtk_label_set_label (
-                       GTK_LABEL (dialog->priv->result_label),
-                       N_("No match found"));
-               gtk_widget_show (dialog->priv->result_label);
-       }
+static void
+webkit_find_controller_failed_to_found_text_cb (WebKitFindController *find_controller,
+                                                EHTMLEditorFindDialog *dialog)
+{
+       gtk_label_set_label (
+               GTK_LABEL (dialog->priv->result_label), N_("No match found"));
+       gtk_widget_show (dialog->priv->result_label);
+}
+
+static void
+html_editor_find_dialog_find_cb (EHTMLEditorFindDialog *dialog)
+{
+       guint32 flags = 0;
+
+       if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_sensitive)))
+               flags |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
+
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards)))
+               flags |= WEBKIT_FIND_OPTIONS_BACKWARDS;
+
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap_search)))
+               flags |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
+
+       webkit_find_controller_search (
+               dialog->priv->find_controller,
+               gtk_entry_get_text (GTK_ENTRY (dialog->priv->entry)),
+               flags,
+               G_MAXUINT);
 }
 
 static gboolean
@@ -125,12 +136,41 @@ entry_key_release_event (GtkWidget *widget,
 }
 
 static void
+html_editor_find_dialog_dispose (GObject *object)
+{
+       EHTMLEditorFindDialogPrivate *priv;
+
+       priv = E_HTML_EDITOR_FIND_DIALOG_GET_PRIVATE (object);
+
+       if (priv->found_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->found_text_handler_id);
+               priv->found_text_handler_id = 0;
+       }
+
+       if (priv->failed_to_find_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->failed_to_find_text_handler_id);
+               priv->failed_to_find_text_handler_id = 0;
+       }
+
+       /* Chain up to parent's dispose() method. */
+       G_OBJECT_CLASS (e_html_editor_find_dialog_parent_class)->dispose (object);
+}
+
+static void
 e_html_editor_find_dialog_class_init (EHTMLEditorFindDialogClass *class)
 {
+       GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
        g_type_class_add_private (class, sizeof (EHTMLEditorFindDialogPrivate));
 
+       object_class = G_OBJECT_CLASS (class);
+       object_class->dispose = html_editor_find_dialog_dispose;
+
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->show = html_editor_find_dialog_show;
 }
@@ -138,12 +178,30 @@ e_html_editor_find_dialog_class_init (EHTMLEditorFindDialogClass *class)
 static void
 e_html_editor_find_dialog_init (EHTMLEditorFindDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        GtkGrid *main_layout;
        GtkBox *box;
        GtkWidget *widget;
+       WebKitFindController *find_controller;
 
        dialog->priv = E_HTML_EDITOR_FIND_DIALOG_GET_PRIVATE (dialog);
 
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       find_controller =
+               webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
+
+       dialog->priv->found_text_handler_id = g_signal_connect (
+               find_controller, "found-text",
+               G_CALLBACK (webkit_find_controller_found_text_cb), dialog);
+
+       dialog->priv->failed_to_find_text_handler_id = g_signal_connect (
+               find_controller, "failed-to-find-text",
+               G_CALLBACK (webkit_find_controller_failed_to_found_text_cb), dialog);
+
+       dialog->priv->find_controller = find_controller;
+
        main_layout = e_html_editor_dialog_get_container (E_HTML_EDITOR_DIALOG (dialog));
 
        widget = gtk_entry_new ();
@@ -217,9 +275,8 @@ e_html_editor_find_dialog_new (EHTMLEditor *editor)
 void
 e_html_editor_find_dialog_find_next (EHTMLEditorFindDialog *dialog)
 {
-       if (gtk_entry_get_text_length (GTK_ENTRY (dialog->priv->entry)) == 0) {
+       if (gtk_entry_get_text_length (GTK_ENTRY (dialog->priv->entry)) == 0)
                return;
-       }
 
        html_editor_find_dialog_find_cb (dialog);
 }
diff --git a/e-util/e-html-editor-hrule-dialog-dom-functions.c 
b/e-util/e-html-editor-hrule-dialog-dom-functions.c
new file mode 100644
index 0000000..7d538c1
--- /dev/null
+++ b/e-util/e-html-editor-hrule-dialog-dom-functions.c
@@ -0,0 +1,71 @@
+/*
+ * e-html-editor-hrule-dialog-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-hrule-dialog-dom-functions.h"
+
+#include "e-html-editor-selection-dom-functions.h"
+
+#define WEBKIT_DOM_USE_UNSTABLE_API
+#include <webkitdom/WebKitDOMDOMSelection.h>
+#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
+
+gboolean
+e_html_editor_hrule_dialog_find_hrule (WebKitDOMDocument *document)
+{
+       gboolean found = TRUE;
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *selection;
+       WebKitDOMElement *rule = NULL;
+
+       window = webkit_dom_document_get_default_view (document);
+       selection = webkit_dom_dom_window_get_selection (window);
+       if (webkit_dom_dom_selection_get_range_count (selection) < 1)
+               return FALSE;
+/* FIXME WK2
+       rule = e_html_editor_view_get_element_under_mouse_click (view); */
+       if (!rule) {
+               WebKitDOMElement *caret, *parent, *element;
+
+               caret = e_html_editor_selection_dom_save_caret_position (document);
+               parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (caret));
+               element = caret;
+
+               while (!WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
+                       element = parent;
+                       parent = webkit_dom_node_get_parent_element (
+                               WEBKIT_DOM_NODE (parent));
+               }
+
+               rule = webkit_dom_document_create_element (document, "HR", NULL);
+
+               /* Insert horizontal rule into body below the caret */
+               webkit_dom_node_insert_before (
+                       WEBKIT_DOM_NODE (parent),
+                       WEBKIT_DOM_NODE (rule),
+                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
+                       NULL);
+
+               e_html_editor_selection_dom_clear_caret_position_marker (document);
+
+               found = FALSE;
+       }
+
+       webkit_dom_element_set_id (rule, "-x-evo-current-hr");
+
+       return found;
+}
diff --git a/e-util/e-html-editor-hrule-dialog-dom-functions.h 
b/e-util/e-html-editor-hrule-dialog-dom-functions.h
new file mode 100644
index 0000000..4f6e57c
--- /dev/null
+++ b/e-util/e-html-editor-hrule-dialog-dom-functions.h
@@ -0,0 +1,31 @@
+/*
+ * e-html-editor-hrule-dialog-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_HRULE_DIALOG_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_HRULE_DIALOG_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+gboolean       e_html_editor_hrule_dialog_find_hrule
+                                               (WebKitDOMDocument *document);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_HRULE_DIALOG_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-hrule-dialog.c b/e-util/e-html-editor-hrule-dialog.c
index 528f084..a5162c4 100644
--- a/e-util/e-html-editor-hrule-dialog.c
+++ b/e-util/e-html-editor-hrule-dialog.c
@@ -26,7 +26,6 @@
 #include "e-html-editor-view.h"
 
 #include <glib/gi18n-lib.h>
-#include <webkit/webkitdom.h>
 #include <stdlib.h>
 
 #define E_HTML_EDITOR_HRULE_DIALOG_GET_PRIVATE(obj) \
@@ -40,8 +39,6 @@ struct _EHTMLEditorHRuleDialogPrivate {
 
        GtkWidget *alignment_combo;
        GtkWidget *shaded_check;
-
-       WebKitDOMHTMLHRElement *hr_element;
 };
 
 G_DEFINE_TYPE (
@@ -52,43 +49,100 @@ G_DEFINE_TYPE (
 static void
 html_editor_hrule_dialog_set_alignment (EHTMLEditorHRuleDialog *dialog)
 {
-       const gchar *alignment;
-
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       alignment = gtk_combo_box_get_active_id (
-                       GTK_COMBO_BOX (dialog->priv->alignment_combo));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       webkit_dom_htmlhr_element_set_align (dialog->priv->hr_element, alignment);
+       g_dbus_proxy_call (
+               web_extension,
+               "HRElementSetAlign",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr",
+                       gtk_combo_box_get_active_id (
+                               GTK_COMBO_BOX (dialog->priv->alignment_combo))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_hrule_dialog_get_alignment (EHTMLEditorHRuleDialog *dialog)
 {
-       gchar *alignment;
-
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       alignment = webkit_dom_htmlhr_element_get_align (dialog->priv->hr_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->alignment_combo), alignment);
-       g_free (alignment);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "HRElementGetAlign",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->alignment_combo), value);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_hrule_dialog_set_size (EHTMLEditorHRuleDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        gchar *size;
+       GDBusProxy *web_extension;
 
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        size = g_strdup_printf (
                "%d",
                (gint) gtk_spin_button_get_value (
                        GTK_SPIN_BUTTON (dialog->priv->size_edit)));
 
-       webkit_dom_htmlhr_element_set_size (dialog->priv->hr_element, size);
+       g_dbus_proxy_call (
+               web_extension,
+               "HRElementGetAlign",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr",
+                       size),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (size);
 }
@@ -96,32 +150,61 @@ html_editor_hrule_dialog_set_size (EHTMLEditorHRuleDialog *dialog)
 static void
 html_editor_hrule_dialog_get_size (EHTMLEditorHRuleDialog *dialog)
 {
-       gchar *size;
-       gint size_int = 0;
-
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GVariant *result;
+       GDBusProxy *web_extension;
 
-       size = webkit_dom_htmlhr_element_get_size (dialog->priv->hr_element);
-       if (size && *size) {
-               size_int = atoi (size);
-       }
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       if (size_int == 0) {
-               size_int = 2;
-       }
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "HRElementGetSize",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+               gint value_int = 0;
+
+               g_variant_get (result, "(&s)", &value);
+               if (value && *value)
+                       value_int = atoi (value);
+
+               if (value_int == 0)
+                       value_int = 2;
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->size_edit), (gdouble) size_int);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->size_edit),
+                       (gdouble) value_int);
 
-       g_free (size);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_hrule_dialog_set_width (EHTMLEditorHRuleDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        gchar *width, *units;
+       GDBusProxy *web_extension;
 
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        units = gtk_combo_box_text_get_active_text (
                        GTK_COMBO_BOX_TEXT (dialog->priv->unit_combo));
@@ -131,7 +214,19 @@ html_editor_hrule_dialog_set_width (EHTMLEditorHRuleDialog *dialog)
                        GTK_SPIN_BUTTON (dialog->priv->width_edit)),
                units);
 
-       webkit_dom_htmlhr_element_set_width (dialog->priv->hr_element, width);
+       g_dbus_proxy_call (
+               web_extension,
+               "HRElementSetWidth",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr",
+                       width),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (units);
        g_free (width);
@@ -140,67 +235,150 @@ html_editor_hrule_dialog_set_width (EHTMLEditorHRuleDialog *dialog)
 static void
 html_editor_hrule_dialog_get_width (EHTMLEditorHRuleDialog *dialog)
 {
-       gchar *width;
-       const gchar *units;
-       gint width_int = 0;
-
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GVariant *result;
+       GDBusProxy *web_extension;
 
-       width = webkit_dom_htmlhr_element_get_width (dialog->priv->hr_element);
-       if (width && *width) {
-               width_int = atoi (width);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-               if (strstr (width, "%") != NULL) {
-                       units = "units-percent";
-               } else {
-                       units = "units-px";
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "HRElementGetWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value, *units;
+               gint value_int = 0;
+
+               g_variant_get (result, "(&s)", &value);
+               if (value && *value) {
+                       value_int = atoi (value);
+
+                       if (strstr (value, "%") != NULL)
+                               units = "units-percent";
+                       else
+                               units = "units-px";
+
+                       if (value_int == 0) {
+                               value_int = 100;
+                               units = "units-percent";
+                       }
+
+                       gtk_spin_button_set_value (
+                               GTK_SPIN_BUTTON (dialog->priv->width_edit),
+                               (gdouble) value_int);
+                       gtk_combo_box_set_active_id (
+                               GTK_COMBO_BOX (dialog->priv->unit_combo), units);
                }
+               g_variant_unref (result);
        }
-
-       if (width_int == 0) {
-               width_int = 100;
-               units = "units-percent";
-       }
-
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->width_edit), (gdouble) width_int);
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->unit_combo), units);
-
-       g_free (width);
 }
 
 static void
 html_editor_hrule_dialog_set_shading (EHTMLEditorHRuleDialog *dialog)
 {
-       gboolean no_shade;
-
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       no_shade = !gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->shaded_check));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       webkit_dom_htmlhr_element_set_no_shade (dialog->priv->hr_element, no_shade);
+       g_dbus_proxy_call (
+               web_extension,
+               "HRElementSetNoShade",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr",
+                       !gtk_toggle_button_get_active (
+                               GTK_TOGGLE_BUTTON (dialog->priv->shaded_check))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_hrule_dialog_get_shading (EHTMLEditorHRuleDialog *dialog)
 {
-       g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GVariant *result;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       gtk_toggle_button_set_active (
-               GTK_TOGGLE_BUTTON (dialog->priv->shaded_check),
-               !webkit_dom_htmlhr_element_get_no_shade (dialog->priv->hr_element));
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "HRElementGetNoShade",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               gboolean value;
+
+               g_variant_get (result, "(&b)", &value);
+               gtk_toggle_button_set_active (
+                       GTK_TOGGLE_BUTTON (dialog->priv->shaded_check), !value);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_hrule_dialog_hide (GtkWidget *widget)
 {
-       EHTMLEditorHRuleDialogPrivate *priv;
+       EHTMLEditor *editor;
+       EHTMLEditorHRuleDialog *dialog;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       priv = E_HTML_EDITOR_HRULE_DIALOG_GET_PRIVATE (widget);
+       dialog = E_HTML_EDITOR_HRULE_DIALOG (widget);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       priv->hr_element = NULL;
+       g_dbus_proxy_call (
+               web_extension,
+               "ElementRemoveAttribute",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-hr",
+                       "id"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        GTK_WIDGET_CLASS (e_html_editor_hrule_dialog_parent_class)->hide (widget);
 }
@@ -210,81 +388,58 @@ html_editor_hrule_dialog_show (GtkWidget *widget)
 {
        EHTMLEditorHRuleDialog *dialog;
        EHTMLEditor *editor;
-       EHTMLEditorSelection *editor_selection;
        EHTMLEditorView *view;
-
-       WebKitDOMDocument *document;
-       WebKitDOMDOMWindow *window;
-       WebKitDOMDOMSelection *selection;
-       WebKitDOMElement *rule;
+       GVariant *result;
+       GDBusProxy *web_extension;
 
        dialog = E_HTML_EDITOR_HRULE_DIALOG (widget);
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       editor_selection = e_html_editor_view_get_selection (view);
-
-       document = webkit_web_view_get_dom_document (
-                       WEBKIT_WEB_VIEW (view));
-       window = webkit_dom_document_get_default_view (document);
-       selection = webkit_dom_dom_window_get_selection (window);
-       if (webkit_dom_dom_selection_get_range_count (selection) < 1) {
-               GTK_WIDGET_CLASS (e_html_editor_hrule_dialog_parent_class)->show (widget);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
                return;
-       }
-
-       rule = e_html_editor_view_get_element_under_mouse_click (view);
-       if (!rule) {
-               WebKitDOMElement *caret, *parent, *element;
 
-               caret = e_html_editor_selection_save_caret_position (editor_selection);
-
-               parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (caret));
-               element = caret;
-
-               while (!WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
-                       element = parent;
-                       parent = webkit_dom_node_get_parent_element (
-                               WEBKIT_DOM_NODE (parent));
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorHRuleDialogFindHRule",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               gboolean found = FALSE;
+
+               g_variant_get (result, "(b)", found);
+               if (found) {
+                       html_editor_hrule_dialog_get_alignment (dialog);
+                       html_editor_hrule_dialog_get_size (dialog);
+                       html_editor_hrule_dialog_get_width (dialog);
+                       html_editor_hrule_dialog_get_shading (dialog);
+               } else {
+                       /* For new rule reset the values to default */
+                       gtk_spin_button_set_value (
+                               GTK_SPIN_BUTTON (dialog->priv->width_edit), 100.0);
+                       gtk_combo_box_set_active_id (
+                               GTK_COMBO_BOX (dialog->priv->unit_combo), "units-percent");
+                       gtk_spin_button_set_value (
+                               GTK_SPIN_BUTTON (dialog->priv->size_edit), 2.0);
+                       gtk_combo_box_set_active_id (
+                               GTK_COMBO_BOX (dialog->priv->alignment_combo), "left");
+                       gtk_toggle_button_set_active (
+                               GTK_TOGGLE_BUTTON (dialog->priv->shaded_check), FALSE);
+
+                       html_editor_hrule_dialog_set_alignment (dialog);
+                       html_editor_hrule_dialog_set_size (dialog);
+                       html_editor_hrule_dialog_set_alignment (dialog);
+                       html_editor_hrule_dialog_set_shading (dialog);
+
+                       e_html_editor_view_set_changed (view, TRUE);
                }
-
-               rule = webkit_dom_document_create_element (document, "HR", NULL);
-
-               /* Insert horizontal rule into body below the caret */
-               webkit_dom_node_insert_before (
-                       WEBKIT_DOM_NODE (parent),
-                       WEBKIT_DOM_NODE (rule),
-                       webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
-                       NULL);
-
-               e_html_editor_selection_clear_caret_position_marker (editor_selection);
-
-               dialog->priv->hr_element = WEBKIT_DOM_HTMLHR_ELEMENT (rule);
-
-               /* For new rule reset the values to default */
-               gtk_spin_button_set_value (
-                       GTK_SPIN_BUTTON (dialog->priv->width_edit), 100.0);
-               gtk_combo_box_set_active_id (
-                       GTK_COMBO_BOX (dialog->priv->unit_combo), "units-percent");
-               gtk_spin_button_set_value (
-                       GTK_SPIN_BUTTON (dialog->priv->size_edit), 2.0);
-               gtk_combo_box_set_active_id (
-                       GTK_COMBO_BOX (dialog->priv->alignment_combo), "left");
-               gtk_toggle_button_set_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->shaded_check), FALSE);
-
-               html_editor_hrule_dialog_set_alignment (dialog);
-               html_editor_hrule_dialog_set_size (dialog);
-               html_editor_hrule_dialog_set_alignment (dialog);
-               html_editor_hrule_dialog_set_shading (dialog);
-
-               e_html_editor_view_set_changed (view, TRUE);
-       } else {
-               dialog->priv->hr_element = WEBKIT_DOM_HTMLHR_ELEMENT (rule);
-
-               html_editor_hrule_dialog_get_alignment (dialog);
-               html_editor_hrule_dialog_get_size (dialog);
-               html_editor_hrule_dialog_get_width (dialog);
-               html_editor_hrule_dialog_get_shading (dialog);
+               g_variant_unref (result);
        }
 
        /* Chain up to parent implementation */
diff --git a/e-util/e-html-editor-image-dialog-dom-functions.c 
b/e-util/e-html-editor-image-dialog-dom-functions.c
new file mode 100644
index 0000000..bae465b
--- /dev/null
+++ b/e-util/e-html-editor-image-dialog-dom-functions.c
@@ -0,0 +1,93 @@
+/*
+ * e-html-editor-image-dialog-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-image-dialog-dom-functions.h"
+
+#include "e-dom-utils.h"
+
+static WebKitDOMElement *
+get_current_image_element (WebKitDOMDocument *document)
+{
+       return webkit_dom_document_get_element_by_id (document, "-x-evo-current-img");
+}
+
+void
+e_html_editor_image_dialog_set_element_url (WebKitDOMDocument *document,
+                                            const gchar *url)
+{
+       WebKitDOMElement *image, *link;
+
+       image = get_current_image_element (document);
+       link = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (image), "A");
+
+       if (link) {
+               if (!url || !*url) {
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (
+                                       WEBKIT_DOM_NODE (link)),
+                               WEBKIT_DOM_NODE (image),
+                               WEBKIT_DOM_NODE (link), NULL);
+                       webkit_dom_node_remove_child (
+                               webkit_dom_node_get_parent_node (
+                                       WEBKIT_DOM_NODE (link)),
+                               WEBKIT_DOM_NODE (link), NULL);
+               } else {
+                       webkit_dom_html_anchor_element_set_href (
+                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link), url);
+               }
+       } else {
+               if (url && *url) {
+                       WebKitDOMDocument *document;
+
+                       document = webkit_dom_node_get_owner_document (
+                                       WEBKIT_DOM_NODE (image));
+                       link = webkit_dom_document_create_element (
+                                       document, "A", NULL);
+
+                       webkit_dom_html_anchor_element_set_href (
+                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link), url);
+
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (
+                                       WEBKIT_DOM_NODE (image)),
+                               WEBKIT_DOM_NODE (link),
+                               WEBKIT_DOM_NODE (image), NULL);
+
+                       webkit_dom_node_append_child (
+                               WEBKIT_DOM_NODE (link),
+                               WEBKIT_DOM_NODE (image), NULL);
+               }
+       }
+}
+
+gchar *
+e_html_editor_image_dialog_get_element_url (WebKitDOMDocument *document)
+{
+       gchar *value;
+       WebKitDOMElement *image, *link;
+
+       image = get_current_image_element (document);
+       link = e_html_editor_dom_node_find_parent_element (
+               WEBKIT_DOM_NODE (image), "A");
+
+       value = webkit_dom_html_anchor_element_get_href (
+               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link));
+
+       return value;
+}
diff --git a/e-util/e-html-editor-image-dialog-dom-functions.h 
b/e-util/e-html-editor-image-dialog-dom-functions.h
new file mode 100644
index 0000000..63d4b31
--- /dev/null
+++ b/e-util/e-html-editor-image-dialog-dom-functions.h
@@ -0,0 +1,35 @@
+/*
+ * e-html-editor-image-dialog-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_IMAGE_DIALOG_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_IMAGE_DIALOG_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_image_dialog_set_element_url
+                                               (WebKitDOMDocument *document,
+                                                const gchar *url);
+
+gchar *                e_html_editor_image_dialog_get_element_url
+                                               (WebKitDOMDocument *document);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_IMAGE_DIALOG_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-image-dialog.c b/e-util/e-html-editor-image-dialog.c
index 7c12550..79382ff 100644
--- a/e-util/e-html-editor-image-dialog.c
+++ b/e-util/e-html-editor-image-dialog.c
@@ -49,8 +49,6 @@ struct _EHTMLEditorImageDialogPrivate {
 
        GtkWidget *url_edit;
        GtkWidget *test_url_button;
-
-       WebKitDOMHTMLImageElement *image;
 };
 
 G_DEFINE_TYPE (
@@ -74,7 +72,7 @@ html_editor_image_dialog_set_src (EHTMLEditorImageDialog *dialog)
                GTK_FILE_CHOOSER (dialog->priv->file_chooser));
 
        e_html_editor_selection_replace_image_src (
-               editor_selection, WEBKIT_DOM_ELEMENT (dialog->priv->image), uri);
+               editor_selection, "img#-x-evo-current-img", uri);
 
        g_free (uri);
 }
@@ -82,20 +80,66 @@ html_editor_image_dialog_set_src (EHTMLEditorImageDialog *dialog)
 static void
 html_editor_image_dialog_set_alt (EHTMLEditorImageDialog *dialog)
 {
-       webkit_dom_html_image_element_set_alt (
-               dialog->priv->image,
-               gtk_entry_get_text (GTK_ENTRY (dialog->priv->description_edit)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetAlt",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       gtk_entry_get_text (GTK_ENTRY (
+                               dialog->priv->description_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_width (EHTMLEditorImageDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
        gint requested;
-       gulong natural;
+       gulong natural = 0;
        gint width;
 
-       natural = webkit_dom_html_image_element_get_natural_width (
-                       dialog->priv->image);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetNaturalWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               g_variant_get (result, "(i)", &natural);
+               g_variant_unref (result);
+       }
+
        requested = gtk_spin_button_get_value_as_int (
                        GTK_SPIN_BUTTON (dialog->priv->width_edit));
 
@@ -116,18 +160,78 @@ html_editor_image_dialog_set_width (EHTMLEditorImageDialog *dialog)
 
        }
 
-       webkit_dom_html_image_element_set_width (dialog->priv->image, width);
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetWidth",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       width),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
+}
+
+static void
+remove_attribute (EHTMLEditorView *view,
+                  GDBusProxy *web_extension,
+                  const gchar *attribute)
+{
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ElementRemoveAttribute",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       attribute),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_width_units (EHTMLEditorImageDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
        gint requested;
-       gulong natural;
+       gulong natural = 0;
        gint width = 0;
 
-       natural = webkit_dom_html_image_element_get_natural_width (
-                       dialog->priv->image);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetNaturalWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               g_variant_get (result, "(i)", &natural);
+               g_variant_unref (result);
+       }
+
        requested = gtk_spin_button_get_value_as_int (
                        GTK_SPIN_BUTTON (dialog->priv->width_edit));
 
@@ -140,8 +244,7 @@ html_editor_image_dialog_set_width_units (EHTMLEditorImageDialog *dialog)
                        } else {
                                width = natural;
                        }
-                       webkit_dom_element_remove_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image), "style");
+                       remove_attribute (view, web_extension, "style");
                        gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
                        break;
 
@@ -151,16 +254,24 @@ html_editor_image_dialog_set_width_units (EHTMLEditorImageDialog *dialog)
                        } else {
                                width = 100;
                        }
-                       webkit_dom_element_remove_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image), "style");
+                       remove_attribute (view, web_extension, "style");
                        gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
                        break;
 
                case 2: /* follow */
-                       webkit_dom_element_set_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image),
-                               "style",
-                               "width: auto;",
+                       g_dbus_proxy_call (
+                               web_extension,
+                               "ElementSetAttribute",
+                               g_variant_new (
+                                       "(tsi)",
+                                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                                       "-x-evo-current-img",
+                                       "style",
+                                       "width: auto;"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL,
                                NULL);
                        gtk_widget_set_sensitive (dialog->priv->width_edit, FALSE);
                        break;
@@ -175,12 +286,37 @@ html_editor_image_dialog_set_width_units (EHTMLEditorImageDialog *dialog)
 static void
 html_editor_image_dialog_set_height (EHTMLEditorImageDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
        gint requested;
-       gulong natural;
+       gulong natural = 0;
        gint height;
 
-       natural = webkit_dom_html_image_element_get_natural_height (
-                       dialog->priv->image);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetNaturalHeight",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               g_variant_get (result, "(i)", &natural);
+               g_variant_unref (result);
+       }
+
        requested = gtk_spin_button_get_value_as_int (
                        GTK_SPIN_BUTTON (dialog->priv->height_edit));
 
@@ -201,18 +337,55 @@ html_editor_image_dialog_set_height (EHTMLEditorImageDialog *dialog)
 
        }
 
-       webkit_dom_html_image_element_set_height (dialog->priv->image, height);
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetHeight",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       height),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_height_units (EHTMLEditorImageDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
        gint requested;
-       gulong natural;
+       gulong natural = 0;
        gint height = -1;
 
-       natural = webkit_dom_html_image_element_get_natural_height (
-                       dialog->priv->image);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetNaturalHeight",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               g_variant_get (result, "(i)", &natural);
+               g_variant_unref (result);
+       }
+
        requested = gtk_spin_button_get_value_as_int (
                        GTK_SPIN_BUTTON (dialog->priv->height_edit));
 
@@ -225,8 +398,7 @@ html_editor_image_dialog_set_height_units (EHTMLEditorImageDialog *dialog)
                        } else {
                                height = natural;
                        }
-                       webkit_dom_element_remove_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image), "style");
+                       remove_attribute (view, web_extension, "style");
                        gtk_widget_set_sensitive (dialog->priv->height_edit, TRUE);
                        break;
 
@@ -236,16 +408,24 @@ html_editor_image_dialog_set_height_units (EHTMLEditorImageDialog *dialog)
                        } else {
                                height = 100;
                        }
-                       webkit_dom_element_remove_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image), "style");
+                       remove_attribute (view, web_extension, "style");
                        gtk_widget_set_sensitive (dialog->priv->height_edit, TRUE);
                        break;
 
                case 2: /* follow */
-                       webkit_dom_element_set_attribute (
-                               WEBKIT_DOM_ELEMENT (dialog->priv->image),
-                               "style",
-                               "height: auto;",
+                       g_dbus_proxy_call (
+                               web_extension,
+                               "ElementSetAttribute",
+                               g_variant_new (
+                                       "(tsi)",
+                                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                                       "-x-evo-current-img",
+                                       "style",
+                                       "height: auto;"),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1,
+                               NULL,
+                               NULL,
                                NULL);
                        gtk_widget_set_sensitive (dialog->priv->height_edit, FALSE);
                        break;
@@ -260,92 +440,150 @@ html_editor_image_dialog_set_height_units (EHTMLEditorImageDialog *dialog)
 static void
 html_editor_image_dialog_set_alignment (EHTMLEditorImageDialog *dialog)
 {
-       webkit_dom_html_image_element_set_align (
-               dialog->priv->image,
-               gtk_combo_box_get_active_id (
-                       GTK_COMBO_BOX (dialog->priv->alignment)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetAlign",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       gtk_combo_box_get_active_id (
+                               GTK_COMBO_BOX (dialog->priv->alignment))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_x_padding (EHTMLEditorImageDialog *dialog)
 {
-       webkit_dom_html_image_element_set_hspace (
-               dialog->priv->image,
-               gtk_spin_button_get_value_as_int (
-                       GTK_SPIN_BUTTON (dialog->priv->x_padding_edit)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetHSpace",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       gtk_spin_button_get_value_as_int (
+                               GTK_SPIN_BUTTON (dialog->priv->x_padding_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_y_padding (EHTMLEditorImageDialog *dialog)
 {
-       webkit_dom_html_image_element_set_vspace (
-               dialog->priv->image,
-               gtk_spin_button_get_value_as_int (
-                       GTK_SPIN_BUTTON (dialog->priv->y_padding_edit)));
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetVSpace",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       gtk_spin_button_get_value_as_int (
+                               GTK_SPIN_BUTTON (dialog->priv->y_padding_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_image_dialog_set_border (EHTMLEditorImageDialog *dialog)
 {
-       gchar *val;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       gchar *value;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       val = g_strdup_printf (
+       value = g_strdup_printf (
                "%d", gtk_spin_button_get_value_as_int (
                        GTK_SPIN_BUTTON (dialog->priv->border_edit)));
 
-       webkit_dom_html_image_element_set_border (dialog->priv->image, val);
+       g_dbus_proxy_call (
+               web_extension,
+               "ImageElementSetVSpace",
+               g_variant_new (
+                       "(tsi)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       value),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
-       g_free (val);
+       g_free (value);
 }
 
 static void
 html_editor_image_dialog_set_url (EHTMLEditorImageDialog *dialog)
 {
-       WebKitDOMElement *link;
-       const gchar *url;
-
-       url = gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit));
-       link = e_html_editor_dom_node_find_parent_element (
-               WEBKIT_DOM_NODE (dialog->priv->image), "A");
-
-       if (link) {
-               if (!url || !*url) {
-                       webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (
-                                       WEBKIT_DOM_NODE (link)),
-                               WEBKIT_DOM_NODE (dialog->priv->image),
-                               WEBKIT_DOM_NODE (link), NULL);
-                       webkit_dom_node_remove_child (
-                               webkit_dom_node_get_parent_node (
-                                       WEBKIT_DOM_NODE (link)),
-                               WEBKIT_DOM_NODE (link), NULL);
-               } else {
-                       webkit_dom_html_anchor_element_set_href (
-                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link), url);
-               }
-       } else {
-               if (url && *url) {
-                       WebKitDOMDocument *document;
-
-                       document = webkit_dom_node_get_owner_document (
-                                       WEBKIT_DOM_NODE (dialog->priv->image));
-                       link = webkit_dom_document_create_element (
-                                       document, "A", NULL);
-
-                       webkit_dom_html_anchor_element_set_href (
-                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link), url);
-
-                       webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (
-                                       WEBKIT_DOM_NODE (dialog->priv->image)),
-                               WEBKIT_DOM_NODE (link),
-                               WEBKIT_DOM_NODE (dialog->priv->image), NULL);
-
-                       webkit_dom_node_append_child (
-                               WEBKIT_DOM_NODE (link),
-                               WEBKIT_DOM_NODE (dialog->priv->image), NULL);
-               }
-       }
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorImageDialogSetElementUrl",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
@@ -361,69 +599,199 @@ html_editor_image_dialog_test_url (EHTMLEditorImageDialog *dialog)
 static void
 html_editor_image_dialog_show (GtkWidget *widget)
 {
+       EHTMLEditor *editor;
        EHTMLEditorImageDialog *dialog;
-       WebKitDOMElement *link;
-       gchar *tmp;
-       glong val;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
        dialog = E_HTML_EDITOR_IMAGE_DIALOG (widget);
-
-       if (!dialog->priv->image) {
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
                return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ElementGetAttribute",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img",
+                       "data-uri"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               if (value && *value) {
+                       gtk_file_chooser_set_uri (
+                               GTK_FILE_CHOOSER (dialog->priv->file_chooser), value);
+                       gtk_widget_set_sensitive (
+                               GTK_WIDGET (dialog->priv->file_chooser), TRUE);
+               } else {
+                       gtk_file_chooser_set_uri (
+                               GTK_FILE_CHOOSER (dialog->priv->file_chooser), "");
+                       gtk_widget_set_sensitive (
+                               GTK_WIDGET (dialog->priv->file_chooser), FALSE);
+               }
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetAlt",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               gtk_entry_set_text (
+                       GTK_ENTRY (dialog->priv->description_edit),
+                       value ? value : "");
+               g_variant_unref (result);
        }
 
-       tmp = webkit_dom_element_get_attribute (
-               WEBKIT_DOM_ELEMENT (dialog->priv->image), "data-uri");
-       if (tmp && *tmp) {
-               gtk_file_chooser_set_uri (
-                       GTK_FILE_CHOOSER (dialog->priv->file_chooser), tmp);
-               gtk_widget_set_sensitive (
-                       GTK_WIDGET (dialog->priv->file_chooser), TRUE);
-               g_free (tmp);
-       } else {
-               gtk_file_chooser_set_uri (
-                       GTK_FILE_CHOOSER (dialog->priv->file_chooser), "");
-               gtk_widget_set_sensitive (
-                       GTK_WIDGET (dialog->priv->file_chooser), FALSE);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong value = 0;
+
+               g_variant_get (result, "(&i)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->width_edit), value);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->width_units), "units-px");
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetHeight",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong value;
+
+               g_variant_get (result, "(i)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->height_edit), value);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->height_units), "units-px");
+               g_variant_unref (result);
        }
 
-       tmp = webkit_dom_html_image_element_get_alt (dialog->priv->image);
-       gtk_entry_set_text (GTK_ENTRY (dialog->priv->description_edit), tmp ? tmp : "");
-       g_free (tmp);
-
-       val = webkit_dom_html_image_element_get_width (dialog->priv->image);
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->width_edit), val);
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->width_units), "units-px");
-
-       val = webkit_dom_html_image_element_get_height (dialog->priv->image);
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->height_edit), val);
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->height_units), "units-px");
-
-       tmp = webkit_dom_html_image_element_get_border (dialog->priv->image);
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->alignment),
-               (tmp && *tmp) ? tmp : "bottom");
-       g_free (tmp);
-
-       val = webkit_dom_html_image_element_get_hspace (dialog->priv->image);
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->x_padding_edit), val);
-
-       val = webkit_dom_html_image_element_get_vspace (dialog->priv->image);
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->y_padding_edit), val);
-
-       link = e_html_editor_dom_node_find_parent_element (
-                       WEBKIT_DOM_NODE (dialog->priv->image), "A");
-       if (link) {
-               tmp = webkit_dom_html_anchor_element_get_href (
-                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link));
-               gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), tmp);
-               g_free (tmp);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetBorder",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->alignment),
+                       (value && *value) ? value : "bottom");
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetHSpace",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong value = 0;
+
+               g_variant_get (result, "(&i)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->x_padding_edit), value);
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ImageElementGetVSpace",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       "-x-evo-current-img"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               glong value = 0;
+
+               g_variant_get (result, "(&i)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->y_padding_edit), value);
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorImageDialogGetElementUrl",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), value);
+               g_variant_unref (result);
        }
 
        /* Chain up to parent implementation */
@@ -433,11 +801,19 @@ html_editor_image_dialog_show (GtkWidget *widget)
 static void
 html_editor_image_dialog_hide (GtkWidget *widget)
 {
-       EHTMLEditorImageDialogPrivate *priv;
+       EHTMLEditor *editor;
+       EHTMLEditorImageDialog *dialog;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       priv = E_HTML_EDITOR_IMAGE_DIALOG_GET_PRIVATE (widget);
+       dialog = E_HTML_EDITOR_IMAGE_DIALOG (widget);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       priv->image = NULL;
+       remove_attribute (view, web_extension, "id");
 
        GTK_WIDGET_CLASS (e_html_editor_image_dialog_parent_class)->hide (widget);
 }
@@ -687,19 +1063,12 @@ e_html_editor_image_dialog_new (EHTMLEditor *editor)
 }
 
 void
-e_html_editor_image_dialog_show (EHTMLEditorImageDialog *dialog,
-                                 WebKitDOMNode *image)
+e_html_editor_image_dialog_show (EHTMLEditorImageDialog *dialog)
 {
        EHTMLEditorImageDialogClass *class;
 
        g_return_if_fail (E_IS_HTML_EDITOR_IMAGE_DIALOG (dialog));
 
-       if (image) {
-               dialog->priv->image = WEBKIT_DOM_HTML_IMAGE_ELEMENT (image);
-       } else {
-               dialog->priv->image = NULL;
-       }
-
        class = E_HTML_EDITOR_IMAGE_DIALOG_GET_CLASS (dialog);
        GTK_WIDGET_CLASS (class)->show (GTK_WIDGET (dialog));
 }
diff --git a/e-util/e-html-editor-image-dialog.h b/e-util/e-html-editor-image-dialog.h
index efdbaf9..a4d0304 100644
--- a/e-util/e-html-editor-image-dialog.h
+++ b/e-util/e-html-editor-image-dialog.h
@@ -64,8 +64,7 @@ struct _EHTMLEditorImageDialogClass {
 GType          e_html_editor_image_dialog_get_type
                                                (void) G_GNUC_CONST;
 GtkWidget *    e_html_editor_image_dialog_new  (EHTMLEditor *editor);
-void           e_html_editor_image_dialog_show (EHTMLEditorImageDialog *dialog,
-                                                WebKitDOMNode *image);
+void           e_html_editor_image_dialog_show (EHTMLEditorImageDialog *dialog);
 
 G_END_DECLS
 
diff --git a/e-util/e-html-editor-link-dialog-dom-functions.c 
b/e-util/e-html-editor-link-dialog-dom-functions.c
new file mode 100644
index 0000000..8695b21
--- /dev/null
+++ b/e-util/e-html-editor-link-dialog-dom-functions.c
@@ -0,0 +1,170 @@
+/*
+ * e-html-editor-link-dialog-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-link-dialog-dom-functions.h"
+
+#include "e-util-enums.h"
+
+#include "e-dom-utils.h"
+#include "e-html-editor-view-dom-functions.h"
+#include "e-html-editor-selection-dom-functions.h"
+
+#define WEBKIT_DOM_USE_UNSTABLE_API
+#include <webkitdom/WebKitDOMDOMSelection.h>
+#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
+
+void
+e_html_editor_link_dialog_ok (WebKitDOMDocument *document,
+                              const gchar *url,
+                              const gchar *inner_text)
+{
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *dom_selection;
+       WebKitDOMRange *range;
+       WebKitDOMElement *link;
+
+       window = webkit_dom_document_get_default_view (document);
+       dom_selection = webkit_dom_dom_window_get_selection (window);
+
+       if (!dom_selection ||
+           (webkit_dom_dom_selection_get_range_count (dom_selection) == 0)) {
+               return;
+       }
+
+       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+       link = e_html_editor_dom_node_find_parent_element (
+                       webkit_dom_range_get_start_container (range, NULL), "A");
+       if (!link) {
+               if ((webkit_dom_range_get_start_container (range, NULL) !=
+                       webkit_dom_range_get_end_container (range, NULL)) ||
+                   (webkit_dom_range_get_start_offset (range, NULL) !=
+                       webkit_dom_range_get_end_offset (range, NULL))) {
+
+                       WebKitDOMDocumentFragment *fragment;
+                       fragment = webkit_dom_range_extract_contents (range, NULL);
+                       link = e_html_editor_dom_node_find_child_element (
+                               WEBKIT_DOM_NODE (fragment), "A");
+                       webkit_dom_range_insert_node (
+                               range, WEBKIT_DOM_NODE (fragment), NULL);
+
+                       webkit_dom_dom_selection_set_base_and_extent (
+                               dom_selection,
+                               webkit_dom_range_get_start_container (range, NULL),
+                               webkit_dom_range_get_start_offset (range, NULL),
+                               webkit_dom_range_get_end_container (range, NULL),
+                               webkit_dom_range_get_end_offset (range, NULL),
+                               NULL);
+               } else {
+                       /* get element that was clicked on */
+                       /* FIXME WK2
+                       link = e_html_editor_view_get_element_under_mouse_click (view); */
+                       if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
+                               link = NULL;
+               }
+       }
+
+       if (link) {
+               webkit_dom_html_anchor_element_set_href (
+                       WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link), url);
+               webkit_dom_html_element_set_inner_html (
+                       WEBKIT_DOM_HTML_ELEMENT (link), inner_text, NULL);
+       } else {
+               gchar *text;
+
+               /* Check whether a text is selected or not */
+               text = webkit_dom_range_get_text (range);
+               if (text && *text) {
+                       e_html_editor_selection_dom_create_link (document, url);
+               } else {
+                       gchar *html = g_strdup_printf (
+                               "<a href=\"%s\">%s</a>", url, inner_text);
+
+                       e_html_editor_view_dom_exec_command (
+                               document, E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, html);
+                       g_free (html);
+
+               }
+
+               g_free (text);
+       }
+}
+
+GVariant *
+e_html_editor_link_dialog_show (WebKitDOMDocument *document)
+{
+       GVariant *result = NULL;
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *dom_selection;
+       WebKitDOMRange *range;
+       WebKitDOMElement *link;
+
+       window = webkit_dom_document_get_default_view (document);
+       dom_selection = webkit_dom_dom_window_get_selection (window);
+
+       /* No selection at all */
+       if (!dom_selection ||
+           webkit_dom_dom_selection_get_range_count (dom_selection) < 1) {
+               return;
+       }
+
+       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+       link = e_html_editor_dom_node_find_parent_element (
+               webkit_dom_range_get_start_container (range, NULL), "A");
+       if (!link) {
+               if ((webkit_dom_range_get_start_container (range, NULL) !=
+                       webkit_dom_range_get_end_container (range, NULL)) ||
+                   (webkit_dom_range_get_start_offset (range, NULL) !=
+                       webkit_dom_range_get_end_offset (range, NULL))) {
+
+                       WebKitDOMDocumentFragment *fragment;
+                       fragment = webkit_dom_range_clone_contents (range, NULL);
+                       link = e_html_editor_dom_node_find_child_element (
+                                       WEBKIT_DOM_NODE (fragment), "A");
+               } else {
+                       /* get element that was clicked on */
+                       /* FIXME WK2
+                       link = e_html_editor_view_get_element_under_mouse_click (view); */
+                       if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
+                               link = NULL;
+               }
+       }
+
+       if (link) {
+               gchar *href, *text;
+
+               href = webkit_dom_html_anchor_element_get_href (
+                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link));
+               text = webkit_dom_html_element_get_inner_text (
+                               WEBKIT_DOM_HTML_ELEMENT (link));
+
+               result = g_variant_new ("(ss)", href, text);
+
+               g_free (text);
+               g_free (href);
+       } else {
+               gchar *text;
+
+               text = webkit_dom_range_get_text (range);
+               if (text && *text)
+                       result = g_variant_new ("(ss)", "", text);
+
+               g_free (text);
+       }
+
+       return result;
+}
diff --git a/e-util/e-html-editor-link-dialog-dom-functions.h 
b/e-util/e-html-editor-link-dialog-dom-functions.h
new file mode 100644
index 0000000..89cbd6e
--- /dev/null
+++ b/e-util/e-html-editor-link-dialog-dom-functions.h
@@ -0,0 +1,34 @@
+/*
+ * e-html-editor-link-dialog-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_LINK_DIALOG_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_LINK_DIALOG_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_link_dialog_ok    (WebKitDOMDocument *document,
+                                                const gchar *url,
+                                                const gchar *inner_text);
+
+GVariant *     e_html_editor_link_dialog_show  (WebKitDOMDocument *document);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_LINK_DIALOG_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-link-dialog.c b/e-util/e-html-editor-link-dialog.c
index 1cfddfe..0bde260 100644
--- a/e-util/e-html-editor-link-dialog.c
+++ b/e-util/e-html-editor-link-dialog.c
@@ -103,93 +103,27 @@ html_editor_link_dialog_ok (EHTMLEditorLinkDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
-       EHTMLEditorSelection *selection;
-       WebKitDOMDocument *document;
-       WebKitDOMDOMWindow *window;
-       WebKitDOMDOMSelection *dom_selection;
-       WebKitDOMRange *range;
-       WebKitDOMElement *link;
+       GDBusProxy *web_extension;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       selection = e_html_editor_view_get_selection (view);
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       window = webkit_dom_document_get_default_view (document);
-       dom_selection = webkit_dom_dom_window_get_selection (window);
-
-       if (!dom_selection ||
-           (webkit_dom_dom_selection_get_range_count (dom_selection) == 0)) {
-               gtk_widget_hide (GTK_WIDGET (dialog));
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
                return;
-       }
-
-       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
-       link = e_html_editor_dom_node_find_parent_element (
-                       webkit_dom_range_get_start_container (range, NULL), "A");
-       if (!link) {
-               if ((webkit_dom_range_get_start_container (range, NULL) !=
-                       webkit_dom_range_get_end_container (range, NULL)) ||
-                   (webkit_dom_range_get_start_offset (range, NULL) !=
-                       webkit_dom_range_get_end_offset (range, NULL))) {
-
-                       WebKitDOMDocumentFragment *fragment;
-                       fragment = webkit_dom_range_extract_contents (range, NULL);
-                       link = e_html_editor_dom_node_find_child_element (
-                               WEBKIT_DOM_NODE (fragment), "A");
-                       webkit_dom_range_insert_node (
-                               range, WEBKIT_DOM_NODE (fragment), NULL);
-
-                       webkit_dom_dom_selection_set_base_and_extent (
-                               dom_selection,
-                               webkit_dom_range_get_start_container (range, NULL),
-                               webkit_dom_range_get_start_offset (range, NULL),
-                               webkit_dom_range_get_end_container (range, NULL),
-                               webkit_dom_range_get_end_offset (range, NULL),
-                               NULL);
-               } else {
-                       /* get element that was clicked on */
-                       link = e_html_editor_view_get_element_under_mouse_click (view);
-                       if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
-                               link = NULL;
-               }
-       }
 
-       if (link) {
-               webkit_dom_html_anchor_element_set_href (
-                       WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link),
-                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit)));
-               webkit_dom_html_element_set_inner_html (
-                       WEBKIT_DOM_HTML_ELEMENT (link),
-                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->label_edit)),
-                       NULL);
-       } else {
-               gchar *text;
-
-               /* Check whether a text is selected or not */
-               text = webkit_dom_range_get_text (range);
-               if (text && *text) {
-                       e_html_editor_selection_create_link (
-                               selection,
-                               gtk_entry_get_text (
-                                       GTK_ENTRY (dialog->priv->url_edit)));
-               } else {
-                       gchar *html = g_strdup_printf (
-                               "<a href=\"%s\">%s</a>",
-                               gtk_entry_get_text (
-                                       GTK_ENTRY (dialog->priv->url_edit)),
-                               gtk_entry_get_text (
-                                       GTK_ENTRY (dialog->priv->label_edit)));
-
-                       e_html_editor_view_exec_command (
-                               view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, html);
-
-                       g_free (html);
-
-               }
-
-               g_free (text);
-       }
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorLinkDialogOk",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit)),
+                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->label_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        gtk_widget_hide (GTK_WIDGET (dialog));
 }
@@ -212,88 +146,59 @@ static void
 html_editor_link_dialog_show (GtkWidget *widget)
 {
        EHTMLEditor *editor;
-       EHTMLEditorView *view;
        EHTMLEditorLinkDialog *dialog;
-       WebKitDOMDocument *document;
-       WebKitDOMDOMWindow *window;
-       WebKitDOMDOMSelection *dom_selection;
-       WebKitDOMRange *range;
-       WebKitDOMElement *link;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
        dialog = E_HTML_EDITOR_LINK_DIALOG (widget);
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       window = webkit_dom_document_get_default_view (document);
-       dom_selection = webkit_dom_dom_window_get_selection (window);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        /* Reset to default values */
        gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), "http://";);
        gtk_entry_set_text (GTK_ENTRY (dialog->priv->label_edit), "");
        gtk_widget_set_sensitive (dialog->priv->label_edit, TRUE);
        gtk_widget_set_sensitive (dialog->priv->remove_link_button, TRUE);
-       dialog->priv->label_autofill = TRUE;
-
-       /* No selection at all */
-       if (!dom_selection ||
-           webkit_dom_dom_selection_get_range_count (dom_selection) < 1) {
-               gtk_widget_set_sensitive (dialog->priv->remove_link_button, FALSE);
-               goto chainup;
-       }
-
-       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
-       link = e_html_editor_dom_node_find_parent_element (
-               webkit_dom_range_get_start_container (range, NULL), "A");
-       if (!link) {
-               if ((webkit_dom_range_get_start_container (range, NULL) !=
-                       webkit_dom_range_get_end_container (range, NULL)) ||
-                   (webkit_dom_range_get_start_offset (range, NULL) !=
-                       webkit_dom_range_get_end_offset (range, NULL))) {
-
-                       WebKitDOMDocumentFragment *fragment;
-                       fragment = webkit_dom_range_clone_contents (range, NULL);
-                       link = e_html_editor_dom_node_find_child_element (
-                                       WEBKIT_DOM_NODE (fragment), "A");
-               } else {
-                       /* get element that was clicked on */
-                       link = e_html_editor_view_get_element_under_mouse_click (view);
-                       if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
-                               link = NULL;
-               }
-       }
-
-       if (link) {
-               gchar *href, *text;
 
-               href = webkit_dom_html_anchor_element_get_href (
-                               WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link));
-               text = webkit_dom_html_element_get_inner_text (
-                               WEBKIT_DOM_HTML_ELEMENT (link));
+       dialog->priv->label_autofill = TRUE;
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorLinkDialogShow",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-               gtk_entry_set_text (
-                       GTK_ENTRY (dialog->priv->url_edit), href);
-               gtk_entry_set_text (
-                       GTK_ENTRY (dialog->priv->label_edit), text);
+       if (result) {
+               const gchar *href, *inner_text;
 
-               g_free (text);
-               g_free (href);
-       } else {
-               gchar *text;
+               g_variant_get (result, "(&s&s)", &href, &inner_text);
 
-               text = webkit_dom_range_get_text (range);
-               if (text && *text) {
+               if (href && *href) {
                        gtk_entry_set_text (
-                               GTK_ENTRY (dialog->priv->label_edit), text);
-                       gtk_widget_set_sensitive (
-                               dialog->priv->label_edit, FALSE);
+                               GTK_ENTRY (dialog->priv->url_edit), href);
+               }
+
+               if (inner_text && *inner_text) {
                        gtk_widget_set_sensitive (
-                               dialog->priv->remove_link_button, FALSE);
+                               dialog->priv->label_edit, TRUE);
+                       if (!href || !*href) {
+                               gtk_widget_set_sensitive (
+                                       dialog->priv->label_edit, FALSE);
+                               gtk_widget_set_sensitive (
+                                       dialog->priv->remove_link_button, FALSE);
+                       }
                }
-               g_free (text);
+               g_variant_unref (result);
        }
 
- chainup:
        /* Chain up to parent implementation */
        GTK_WIDGET_CLASS (e_html_editor_link_dialog_parent_class)->show (widget);
 }
diff --git a/e-util/e-html-editor-page-dialog.c b/e-util/e-html-editor-page-dialog.c
index 0f9897f..c1c1f69 100644
--- a/e-util/e-html-editor-page-dialog.c
+++ b/e-util/e-html-editor-page-dialog.c
@@ -148,22 +148,33 @@ html_editor_page_dialog_set_text_color (EHTMLEditorPageDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMHTMLElement *body;
+       GDBusProxy *web_extension;
        GdkRGBA rgba;
        gchar *color;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       body = webkit_dom_document_get_body (document);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        e_color_combo_get_current_color (
                E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
 
        color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
-       webkit_dom_html_body_element_set_text (
-               WEBKIT_DOM_HTML_BODY_ELEMENT (body), color);
+
+       g_dbus_proxy_call (
+               web_extension,
+               "BodySetTextColor",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       color),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (color);
 }
@@ -173,22 +184,33 @@ html_editor_page_dialog_set_link_color (EHTMLEditorPageDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMHTMLElement *body;
+       GDBusProxy *web_extension;
        GdkRGBA rgba;
        gchar *color;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       body = webkit_dom_document_get_body (document);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        e_color_combo_get_current_color (
                E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
 
        color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
-       webkit_dom_html_body_element_set_link (
-               WEBKIT_DOM_HTML_BODY_ELEMENT (body), color);
+
+       g_dbus_proxy_call (
+               web_extension,
+               "BodySetLinkColor",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       color),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (color);
 }
@@ -198,15 +220,15 @@ html_editor_page_dialog_set_background_color (EHTMLEditorPageDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMHTMLElement *body;
+       GDBusProxy *web_extension;
        GdkRGBA rgba;
        gchar *color;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       body = webkit_dom_document_get_body (document);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        e_color_combo_get_current_color (
                E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
@@ -215,8 +237,18 @@ html_editor_page_dialog_set_background_color (EHTMLEditorPageDialog *dialog)
        else
                color = g_strdup ("");
 
-       webkit_dom_html_body_element_set_bg_color (
-               WEBKIT_DOM_HTML_BODY_ELEMENT (body), color);
+       g_dbus_proxy_call (
+               web_extension,
+               "BodySetBgColor",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       color),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (color);
 }
@@ -262,27 +294,34 @@ html_editor_page_dialog_set_background_image (EHTMLEditorPageDialog *dialog)
 {
        EHTMLEditor *editor;
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMHTMLElement *body;
+       GDBusProxy *web_extension;
        gchar *uri;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       body = webkit_dom_document_get_body (document);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        uri = gtk_file_chooser_get_uri (
-                       GTK_FILE_CHOOSER (
-                               dialog->priv->background_image_filechooser));
+               GTK_FILE_CHOOSER (dialog->priv->background_image_filechooser));
 
        if (uri && *uri)
                e_html_editor_selection_replace_image_src (
-                       e_html_editor_view_get_selection (view),
-                       WEBKIT_DOM_ELEMENT (body),
-                       uri);
+                       e_html_editor_view_get_selection (view), "body", uri);
        else
-               remove_image_attributes_from_element (
-                       WEBKIT_DOM_ELEMENT (body));
+               g_dbus_proxy_call (
+                       web_extension,
+                       "RemoveImageAttributesFromElement",
+                       g_variant_new (
+                               "(ts)",
+                               webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                               "body"),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       NULL,
+                       NULL);
 
        gtk_widget_set_sensitive (dialog->priv->remove_image_button, uri && *uri);
 
@@ -316,73 +355,140 @@ html_editor_page_dialog_show (GtkWidget *widget)
        EHTMLEditor *editor;
        EHTMLEditorView *view;
        EHTMLEditorPageDialog *dialog;
-       WebKitDOMDocument *document;
-       WebKitDOMHTMLElement *body;
-       gchar *tmp;
+       GDBusProxy *web_extension;
        GdkRGBA rgba;
+       GVariant *result;
 
        dialog = E_HTML_EDITOR_PAGE_DIALOG (widget);
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "ElementGetAttributeBySelector",
+               g_variant_new (
+                       "(tss)",
+                       webkit_web_view_get_page_id (
+                               WEBKIT_WEB_VIEW (view)),
+                       "body",
+                       "data-uri"),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       body = webkit_dom_document_get_body (document);
+       if (result) {
+               const gchar *value;
 
-       tmp = webkit_dom_element_get_attribute (
-               WEBKIT_DOM_ELEMENT (body), "data-uri");
-       if (tmp && *tmp) {
-               gint ii;
-               gchar *fname = g_filename_from_uri (tmp, NULL, NULL);
-               for (ii = 0; ii < G_N_ELEMENTS (templates); ii++) {
-                       const Template *tmplt = &templates[ii];
-
-                       if (g_strcmp0 (tmplt->filename, fname) == 0) {
-                               gtk_combo_box_set_active (
-                                       GTK_COMBO_BOX (dialog->priv->background_template_combo),
-                                       ii);
-                               break;
+               g_variant_get (result, "(&s)", &value);
+
+               if (value && *value) {
+                       gint ii;
+                       gchar *fname = g_filename_from_uri (value, NULL, NULL);
+                       for (ii = 0; ii < G_N_ELEMENTS (templates); ii++) {
+                               const Template *tmplt = &templates[ii];
+
+                               if (g_strcmp0 (tmplt->filename, fname) == 0) {
+                                       gtk_combo_box_set_active (
+                                               GTK_COMBO_BOX (dialog->priv->background_template_combo),
+                                               ii);
+                                       break;
+                               }
                        }
+                       g_free (fname);
+               } else {
+                       gtk_combo_box_set_active (
+                               GTK_COMBO_BOX (dialog->priv->background_template_combo), 0);
                }
-               g_free (fname);
-       } else {
-               gtk_combo_box_set_active (
-                       GTK_COMBO_BOX (dialog->priv->background_template_combo), 0);
+               g_variant_unref (result);
        }
-       g_free (tmp);
-
-       tmp = webkit_dom_html_body_element_get_text (
-                       WEBKIT_DOM_HTML_BODY_ELEMENT (body));
-       if (!tmp || !*tmp || !gdk_rgba_parse (&rgba, tmp))
-               e_utils_get_theme_color (widget, "theme_text_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &rgba);
-       g_free (tmp);
-       e_color_combo_set_current_color (
-               E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
 
-       tmp = webkit_dom_html_body_element_get_link (
-                       WEBKIT_DOM_HTML_BODY_ELEMENT (body));
-       if (!tmp || !*tmp) {
-               GdkColor color;
-               gtk_widget_style_get (
-                       GTK_WIDGET (view), "link-color", &color, NULL);
-
-               rgba.alpha = 1;
-               rgba.red = ((gdouble) color.red) / G_MAXUINT16;
-               rgba.green = ((gdouble) color.green) / G_MAXUINT16;
-               rgba.blue = ((gdouble) color.blue) / G_MAXUINT16;
-       } else {
-               gdk_rgba_parse (&rgba, tmp);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "BodyGetTextColor",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value || !gdk_rgba_parse (&rgba, value))
+                       e_utils_get_theme_color (
+                               widget,
+                               "theme_text_color",
+                               E_UTILS_DEFAULT_THEME_TEXT_COLOR,
+                               &rgba);
+               e_color_combo_set_current_color (
+                       E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
+               g_variant_unref (result);
        }
-       g_free (tmp);
-       e_color_combo_set_current_color (
-               E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
 
-       tmp = webkit_dom_html_body_element_get_bg_color (
-                       WEBKIT_DOM_HTML_BODY_ELEMENT (body));
-       if (!tmp || !*tmp || !gdk_rgba_parse (&rgba, tmp))
-               e_utils_get_theme_color (widget, "theme_base_color", E_UTILS_DEFAULT_THEME_BASE_COLOR, &rgba);
-       g_free (tmp);
-       e_color_combo_set_current_color (
-               E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "BodyGetLinkColor",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value) {
+                       GdkColor color;
+                       gtk_widget_style_get (
+                               GTK_WIDGET (view), "link-color", &color, NULL);
+
+                       rgba.alpha = 1;
+                       rgba.red = ((gdouble) color.red) / G_MAXUINT16;
+                       rgba.green = ((gdouble) color.green) / G_MAXUINT16;
+                       rgba.blue = ((gdouble) color.blue) / G_MAXUINT16;
+               } else {
+                       gdk_rgba_parse (&rgba, value);
+               }
+               e_color_combo_set_current_color (
+                       E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
+               g_variant_unref (result);
+       }
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "BodyGetBgColor",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (result) {
+               const gchar *value;
+
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value || !gdk_rgba_parse (&rgba, value))
+                       e_utils_get_theme_color (
+                       widget,
+                       "theme_base_color",
+                       E_UTILS_DEFAULT_THEME_BASE_COLOR,
+                       &rgba);
+               e_color_combo_set_current_color (
+                       E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
+               g_variant_unref (result);
+       }
 
        GTK_WIDGET_CLASS (e_html_editor_page_dialog_parent_class)->show (widget);
 }
diff --git a/e-util/e-html-editor-private.h b/e-util/e-html-editor-private.h
index dc4658b..6872721 100644
--- a/e-util/e-html-editor-private.h
+++ b/e-util/e-html-editor-private.h
@@ -90,9 +90,6 @@ struct _EHTMLEditorPrivate {
 
        guint spell_suggestions_merge_id;
 
-       WebKitDOMNode *image;
-       WebKitDOMNode *table_cell;
-
        gint editor_layout_row;
 };
 
diff --git a/e-util/e-html-editor-replace-dialog.c b/e-util/e-html-editor-replace-dialog.c
index 2b43690..936d13e 100644
--- a/e-util/e-html-editor-replace-dialog.c
+++ b/e-util/e-html-editor-replace-dialog.c
@@ -24,6 +24,7 @@
 
 #include "e-html-editor-replace-dialog.h"
 
+#include <webkit2/webkit2.h>
 #include <glib/gi18n-lib.h>
 
 #define E_HTML_EDITOR_REPLACE_DIALOG_GET_PRIVATE(obj) \
@@ -50,6 +51,13 @@ struct _EHTMLEditorReplaceDialogPrivate {
        GtkWidget *replace_all_button;
 
        EHTMLEditor *editor;
+
+       gboolean skip;
+
+       WebKitFindController *find_controller;
+       gulong found_text_handler_id;
+       gulong failed_to_find_text_handler_id;
+       gulong counted_matches_handler_id;
 };
 
 enum {
@@ -57,98 +65,110 @@ enum {
        PROP_EDITOR
 };
 
-static gboolean
-jump (EHTMLEditorReplaceDialog *dialog)
+static void
+webkit_find_controller_found_text_cb (WebKitFindController *find_controller,
+                                      guint match_count,
+                                      EHTMLEditorReplaceDialog *dialog)
 {
-       EHTMLEditor *editor;
-       WebKitWebView *webview;
-       gboolean found;
+       gtk_widget_hide (dialog->priv->result_label);
 
-       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
-       webview = WEBKIT_WEB_VIEW (
-                       e_html_editor_get_view (editor));
+       if (!dialog->priv->skip) {
+               /* FIXME WK2
+               e_html_editor_selection_replace (
+                       selection,
+                       gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_entry)));*/
+       }
 
-       found = webkit_web_view_search_text (
-               webview,
-               gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_entry)),
-               gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->case_sensitive)),
-               !gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->backwards)),
-               gtk_toggle_button_get_active (
-                       GTK_TOGGLE_BUTTON (dialog->priv->wrap)));
-
-       return found;
+       dialog->priv->skip = FALSE;
 }
 
 static void
-html_editor_replace_dialog_skip_cb (EHTMLEditorReplaceDialog *dialog)
+webkit_find_controller_failed_to_found_text_cb (WebKitFindController *find_controller,
+                                                EHTMLEditorReplaceDialog *dialog)
 {
-       if (!jump (dialog)) {
-               gtk_label_set_label (
-                       GTK_LABEL (dialog->priv->result_label),
-                       N_("No match found"));
-               gtk_widget_show (dialog->priv->result_label);
-       } else {
-               gtk_widget_hide (dialog->priv->result_label);
-       }
+       gtk_label_set_label (
+               GTK_LABEL (dialog->priv->result_label), N_("No match found"));
+       gtk_widget_show (dialog->priv->result_label);
 }
 
 static void
-html_editor_replace_dialog_replace_cb (EHTMLEditorReplaceDialog *dialog)
+webkit_find_controller_counted_matches_cb (WebKitFindController *find_controller,
+                                           guint match_count,
+                                           EHTMLEditorReplaceDialog *dialog)
 {
-       EHTMLEditor *editor;
-       EHTMLEditorView *view;
-       EHTMLEditorSelection *selection;
+       gchar *result;
+       guint ii = 0;
 
-       /* Jump to next matching word */
-       if (!jump (dialog)) {
-               gtk_label_set_label (
-                       GTK_LABEL (dialog->priv->result_label),
-                       N_("No match found"));
-               gtk_widget_show (dialog->priv->result_label);
-               return;
-       } else {
-               gtk_widget_hide (dialog->priv->result_label);
+       for (ii = 0; ii < match_count; ii++) {
+               webkit_find_controller_search_next (dialog->priv->find_controller);
+               /* Jump behind the word */
+               /* FIXME WK2 is it needed ?
+               e_html_editor_selection_move (
+                       selection, TRUE, E_HTML_EDITOR_SELECTION_GRANULARITY_WORD);*/
        }
 
-       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
-       view = e_html_editor_get_view (editor);
-       selection = e_html_editor_view_get_selection (view);
+       result = g_strdup_printf (_("%d occurences replaced"), match_count);
+       gtk_label_set_label (GTK_LABEL (dialog->priv->result_label), result);
+       gtk_widget_show (dialog->priv->result_label);
+       g_free (result);
+
+}
+
+static void
+search (EHTMLEditorReplaceDialog *dialog)
+{
+       guint32 flags = 0;
+
+       if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_sensitive)))
+               flags |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
+
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards)))
+               flags |= WEBKIT_FIND_OPTIONS_BACKWARDS;
+
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap)))
+               flags |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
+
+       webkit_find_controller_search (
+               dialog->priv->find_controller,
+               gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_entry)),
+               flags,
+               G_MAXUINT);
+}
+
+static void
+html_editor_replace_dialog_skip_cb (EHTMLEditorReplaceDialog *dialog)
+{
+       dialog->priv->skip = TRUE;
+       webkit_find_controller_search_next (dialog->priv->find_controller);
+}
 
-       e_html_editor_selection_replace (
-               selection,
-               gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_entry)));
+static void
+html_editor_replace_dialog_replace_cb (EHTMLEditorReplaceDialog *dialog)
+{
+       dialog->priv->skip = FALSE;
+       /* Jump to next matching word */
+       webkit_find_controller_search_next (dialog->priv->find_controller);
 }
 
 static void
 html_editor_replace_dialog_replace_all_cb (EHTMLEditorReplaceDialog *dialog)
 {
-       gint i = 0;
-       gchar *result;
-       EHTMLEditor *editor;
-       EHTMLEditorView *view;
-       EHTMLEditorSelection *selection;
-       const gchar *replacement;
+       guint32 flags = 0;
 
-       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
-       view = e_html_editor_get_view (editor);
-       selection = e_html_editor_view_get_selection (view);
-       replacement = gtk_entry_get_text (GTK_ENTRY (dialog->priv->replace_entry));
+       if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_sensitive)))
+               flags |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
 
-       while (jump (dialog)) {
-               e_html_editor_selection_replace (selection, replacement);
-               i++;
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->backwards)))
+               flags |= WEBKIT_FIND_OPTIONS_BACKWARDS;
 
-               /* Jump behind the word */
-               e_html_editor_selection_move (
-                       selection, TRUE, E_HTML_EDITOR_SELECTION_GRANULARITY_WORD);
-       }
+       if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->wrap)))
+               flags |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
 
-       result = g_strdup_printf (_("%d occurences replaced"), i);
-       gtk_label_set_label (GTK_LABEL (dialog->priv->result_label), result);
-       gtk_widget_show (dialog->priv->result_label);
-       g_free (result);
+       webkit_find_controller_count_matches (
+               dialog->priv->find_controller,
+               gtk_entry_get_text (GTK_ENTRY (dialog->priv->search_entry)),
+               flags,
+               G_MAXUINT);
 }
 
 static void
@@ -163,6 +183,9 @@ html_editor_replace_dialog_entry_changed (EHTMLEditorReplaceDialog *dialog)
        gtk_widget_set_sensitive (dialog->priv->skip_button, ready);
        gtk_widget_set_sensitive (dialog->priv->replace_button, ready);
        gtk_widget_set_sensitive (dialog->priv->replace_all_button, ready);
+
+       if (ready)
+               search (dialog);
 }
 
 static void
@@ -178,12 +201,48 @@ html_editor_replace_dialog_show (GtkWidget *widget)
 }
 
 static void
+html_editor_replace_dialog_dispose (GObject *object)
+{
+       EHTMLEditorReplaceDialogPrivate *priv;
+
+       priv = E_HTML_EDITOR_REPLACE_DIALOG_GET_PRIVATE (object);
+
+       if (priv->found_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->found_text_handler_id);
+               priv->found_text_handler_id = 0;
+       }
+
+       if (priv->failed_to_find_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->failed_to_find_text_handler_id);
+               priv->failed_to_find_text_handler_id = 0;
+       }
+
+       if (priv->counted_matches_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->counted_matches_handler_id);
+               priv->counted_matches_handler_id = 0;
+       }
+
+       /* Chain up to parent's dispose() method. */
+       G_OBJECT_CLASS (e_html_editor_replace_dialog_parent_class)->dispose (object);
+}
+
+static void
 e_html_editor_replace_dialog_class_init (EHTMLEditorReplaceDialogClass *class)
 {
+       GObjectClass *object_class;
        GtkWidgetClass *widget_class;
 
        g_type_class_add_private (class, sizeof (EHTMLEditorReplaceDialogPrivate));
 
+       object_class = G_OBJECT_CLASS (class);
+       object_class->dispose = html_editor_replace_dialog_dispose;
+
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->show = html_editor_replace_dialog_show;
 }
@@ -191,12 +250,34 @@ e_html_editor_replace_dialog_class_init (EHTMLEditorReplaceDialogClass *class)
 static void
 e_html_editor_replace_dialog_init (EHTMLEditorReplaceDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
        GtkGrid *main_layout;
        GtkWidget *widget, *layout;
        GtkBox *button_box;
+       WebKitFindController *find_controller;
 
        dialog->priv = E_HTML_EDITOR_REPLACE_DIALOG_GET_PRIVATE (dialog);
 
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       find_controller =
+               webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (view));
+
+       dialog->priv->found_text_handler_id = g_signal_connect (
+               find_controller, "found-text",
+               G_CALLBACK (webkit_find_controller_found_text_cb), dialog);
+
+       dialog->priv->failed_to_find_text_handler_id = g_signal_connect (
+               find_controller, "failed-to-find-text",
+               G_CALLBACK (webkit_find_controller_failed_to_found_text_cb), dialog);
+
+       dialog->priv->counted_matches_handler_id = g_signal_connect (
+               find_controller, "failed-to-find-text",
+               G_CALLBACK (webkit_find_controller_counted_matches_cb), dialog);
+
+       dialog->priv->find_controller = find_controller;
+
        main_layout = e_html_editor_dialog_get_container (E_HTML_EDITOR_DIALOG (dialog));
 
        widget = gtk_entry_new ();
diff --git a/e-util/e-html-editor-selection-dom-functions.c b/e-util/e-html-editor-selection-dom-functions.c
new file mode 100644
index 0000000..5730bc2
--- /dev/null
+++ b/e-util/e-html-editor-selection-dom-functions.c
@@ -0,0 +1,1164 @@
+/*
+ * e-html-editor-selection-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-selection-dom-functions.h"
+
+#include "e-util-enums.h"
+
+#include "e-dom-utils.h"
+
+#include "e-html-editor-view-dom-functions.h"
+
+#define WEBKIT_DOM_USE_UNSTABLE_API
+#include <webkitdom/WebKitDOMDOMSelection.h>
+#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
+
+#define UNICODE_ZERO_WIDTH_SPACE "\xe2\x80\x8b"
+#define UNICODE_NBSP "\xc2\xa0"
+
+#define SPACES_PER_INDENTATION 4
+#define SPACES_PER_LIST_LEVEL 8
+#define MINIMAL_PARAGRAPH_WIDTH 5
+#define WORD_WRAP_LENGTH 71
+
+void
+e_html_editor_selection_dom_replace_base64_image_src (WebKitDOMDocument *document,
+                                                      const gchar *selector,
+                                                      const gchar *base64_content,
+                                                      const gchar *filename,
+                                                      const gchar *uri)
+{
+       WebKitDOMElement *element;
+
+       element = webkit_dom_document_query_selector (document, selector, NULL);
+
+       if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (element))
+               webkit_dom_html_image_element_set_src (
+                       WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
+                       base64_content);
+       else
+               webkit_dom_element_set_attribute (
+                       element, "background", base64_content, NULL);
+
+       webkit_dom_element_set_attribute (element, "data-uri", uri, NULL);
+       webkit_dom_element_set_attribute (element, "data-inline", "", NULL);
+       webkit_dom_element_set_attribute (
+               element, "data-name", filename ? filename : "", NULL);
+}
+
+/**
+ * e_html_editor_selection_dom_clear_caret_position_marker:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Removes previously set caret position marker from composer.
+ */
+void
+e_html_editor_selection_dom_clear_caret_position_marker (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *element;
+
+       element = webkit_dom_document_get_element_by_id (document, "-x-evo-caret-position");
+
+       if (element)
+               remove_node (WEBKIT_DOM_NODE (element));
+}
+/* FIXME WK2 Rename to _create_caret_position_node */
+static WebKitDOMNode *
+e_html_editor_selection_dom_get_caret_position_node (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *element;
+
+       element = webkit_dom_document_create_element (document, "SPAN", NULL);
+       webkit_dom_element_set_id (element, "-x-evo-caret-position");
+       webkit_dom_element_set_attribute (
+               element, "style", "color: red", NULL);
+       webkit_dom_html_element_set_inner_html (
+               WEBKIT_DOM_HTML_ELEMENT (element), "*", NULL);
+
+       return WEBKIT_DOM_NODE (element);
+}
+
+static WebKitDOMRange *
+html_editor_selection_dom_get_current_range (WebKitDOMDocument *document)
+{
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *selection_dom;
+       WebKitDOMRange *range = NULL;
+
+       window = webkit_dom_document_get_default_view (document);
+       if (!window)
+               return NULL;
+
+       selection_dom = webkit_dom_dom_window_get_selection (window);
+       if (!WEBKIT_DOM_IS_DOM_SELECTION (selection_dom))
+               return NULL;
+
+       if (webkit_dom_dom_selection_get_range_count (selection_dom) < 1)
+               return NULL;
+
+       range = webkit_dom_dom_selection_get_range_at (selection_dom, 0, NULL);
+
+       return range;
+}
+/**
+ * e_html_editor_selection_dom_save_caret_position:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Saves current caret position in composer.
+ *
+ * Returns: #WebKitDOMElement that was created on caret position
+ */
+WebKitDOMElement *
+e_html_editor_selection_dom_save_caret_position (WebKitDOMDocument *document)
+{
+       WebKitDOMNode *split_node;
+       WebKitDOMNode *start_offset_node;
+       WebKitDOMNode *caret_node;
+       WebKitDOMRange *range;
+       gulong start_offset;
+
+       e_html_editor_selection_dom_clear_caret_position_marker (document);
+
+       range = html_editor_selection_dom_get_current_range (document);
+       if (!range)
+               return NULL;
+
+       start_offset = webkit_dom_range_get_start_offset (range, NULL);
+       start_offset_node = webkit_dom_range_get_end_container (range, NULL);
+
+       caret_node = e_html_editor_selection_dom_get_caret_position_node (document);
+
+       if (WEBKIT_DOM_IS_TEXT (start_offset_node) && start_offset != 0) {
+               WebKitDOMText *split_text;
+
+               split_text = webkit_dom_text_split_text (
+                               WEBKIT_DOM_TEXT (start_offset_node),
+                               start_offset, NULL);
+               split_node = WEBKIT_DOM_NODE (split_text);
+       } else {
+               split_node = start_offset_node;
+       }
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (start_offset_node),
+               caret_node,
+               split_node,
+               NULL);
+
+       return WEBKIT_DOM_ELEMENT (caret_node);
+}
+
+static void
+fix_quoting_nodes_after_caret_restoration (WebKitDOMDOMSelection *window_selection,
+                                           WebKitDOMNode *prev_sibling,
+                                           WebKitDOMNode *next_sibling)
+{
+       WebKitDOMNode *tmp_node;
+
+       if (!element_has_class (WEBKIT_DOM_ELEMENT (prev_sibling), "-x-evo-temp-text-wrapper"))
+               return;
+
+       webkit_dom_dom_selection_modify (
+               window_selection, "move", "forward", "character");
+       tmp_node = webkit_dom_node_get_next_sibling (
+               webkit_dom_node_get_first_child (prev_sibling));
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (prev_sibling),
+               tmp_node,
+               next_sibling,
+               NULL);
+
+       tmp_node = webkit_dom_node_get_first_child (prev_sibling);
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (prev_sibling),
+               tmp_node,
+               webkit_dom_node_get_previous_sibling (next_sibling),
+               NULL);
+
+       remove_node (prev_sibling);
+
+       webkit_dom_dom_selection_modify (
+               window_selection, "move", "backward", "character");
+}
+
+static void
+e_html_editor_selection_dom_move_caret_into_element (WebKitDOMDocument *document,
+                                                     WebKitDOMElement *element)
+{
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *window_selection;
+       WebKitDOMRange *new_range;
+
+       if (!element)
+               return;
+
+       window = webkit_dom_document_get_default_view (document);
+       window_selection = webkit_dom_dom_window_get_selection (window);
+       new_range = webkit_dom_document_create_range (document);
+
+       webkit_dom_range_select_node_contents (
+               new_range, WEBKIT_DOM_NODE (element), NULL);
+       webkit_dom_range_collapse (new_range, FALSE, NULL);
+       webkit_dom_dom_selection_remove_all_ranges (window_selection);
+       webkit_dom_dom_selection_add_range (window_selection, new_range);
+}
+
+/**
+ * e_html_editor_selection_restore_caret_position:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Restores previously saved caret position in composer.
+ */
+void
+e_html_editor_selection_dom_restore_caret_position (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *element;
+       gboolean fix_after_quoting;
+       gboolean swap_direction = FALSE;
+
+       element = webkit_dom_document_get_element_by_id (
+               document, "-x-evo-caret-position");
+       fix_after_quoting = element_has_class (element, "-x-evo-caret-quoting");
+
+       if (element) {
+               WebKitDOMDOMWindow *window;
+               WebKitDOMNode *parent_node;
+               WebKitDOMDOMSelection *window_selection;
+               WebKitDOMNode *prev_sibling;
+               WebKitDOMNode *next_sibling;
+
+               if (!webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (element)))
+                       swap_direction = TRUE;
+
+               window = webkit_dom_document_get_default_view (document);
+               window_selection = webkit_dom_dom_window_get_selection (window);
+               parent_node = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element));
+               /* If parent is BODY element, we try to restore the position on the
+                * element that is next to us */
+               if (WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent_node)) {
+                       /* Look if we have DIV on right */
+                       next_sibling = webkit_dom_node_get_next_sibling (
+                               WEBKIT_DOM_NODE (element));
+                       if (!WEBKIT_DOM_IS_ELEMENT (next_sibling)) {
+                               e_html_editor_selection_dom_clear_caret_position_marker (document);
+                               return;
+                       }
+
+                       if (element_has_class (WEBKIT_DOM_ELEMENT (next_sibling), "-x-evo-paragraph")) {
+                               remove_node (WEBKIT_DOM_NODE (element));
+
+                               e_html_editor_selection_dom_move_caret_into_element (
+                                       document, WEBKIT_DOM_ELEMENT (next_sibling));
+
+                               goto out;
+                       }
+               }
+
+               e_html_editor_selection_dom_move_caret_into_element (document, element);
+
+               if (fix_after_quoting) {
+                       prev_sibling = webkit_dom_node_get_previous_sibling (
+                               WEBKIT_DOM_NODE (element));
+                       next_sibling = webkit_dom_node_get_next_sibling (
+                               WEBKIT_DOM_NODE (element));
+                       if (!next_sibling)
+                               fix_after_quoting = FALSE;
+               }
+
+               remove_node (WEBKIT_DOM_NODE (element));
+
+               if (fix_after_quoting)
+                       fix_quoting_nodes_after_caret_restoration (
+                               window_selection, prev_sibling, next_sibling);
+ out:
+               /* FIXME If caret position is restored and afterwards the
+                * position is saved it is not on the place where it supposed
+                * to be (it is in the beginning of parent's element. It can
+                * be avoided by moving with the caret. */
+               if (swap_direction) {
+                       webkit_dom_dom_selection_modify (
+                               window_selection, "move", "forward", "character");
+                       webkit_dom_dom_selection_modify (
+                               window_selection, "move", "backward", "character");
+               } else {
+                       webkit_dom_dom_selection_modify (
+                               window_selection, "move", "backward", "character");
+                       webkit_dom_dom_selection_modify (
+                               window_selection, "move", "forward", "character");
+               }
+       }
+}
+
+static void
+e_html_editor_selection_dom_insert_base64_image (WebKitDOMDocument *document,
+                                                 const gchar *base64_content,
+                                                 const gchar *filename,
+                                                 const gchar *uri)
+{
+       WebKitDOMElement *element, *caret_position, *resizable_wrapper;
+       WebKitDOMText *text;
+
+       caret_position = e_html_editor_selection_dom_save_caret_position (document);
+
+       resizable_wrapper =
+               webkit_dom_document_create_element (document, "span", NULL);
+       webkit_dom_element_set_attribute (
+               resizable_wrapper, "class", "-x-evo-resizable-wrapper", NULL);
+
+       element = webkit_dom_document_create_element (document, "img", NULL);
+       webkit_dom_html_image_element_set_src (
+               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
+               base64_content);
+       webkit_dom_element_set_attribute (
+               WEBKIT_DOM_ELEMENT (element), "data-uri", uri, NULL);
+       webkit_dom_element_set_attribute (
+               WEBKIT_DOM_ELEMENT (element), "data-inline", "", NULL);
+       webkit_dom_element_set_attribute (
+               WEBKIT_DOM_ELEMENT (element), "data-name",
+               filename ? filename : "", NULL);
+       webkit_dom_node_append_child (
+               WEBKIT_DOM_NODE (resizable_wrapper),
+               WEBKIT_DOM_NODE (element),
+               NULL);
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (
+                       WEBKIT_DOM_NODE (caret_position)),
+               WEBKIT_DOM_NODE (resizable_wrapper),
+               WEBKIT_DOM_NODE (caret_position),
+               NULL);
+
+       /* We have to again use UNICODE_ZERO_WIDTH_SPACE character to restore
+        * caret on right position */
+       text = webkit_dom_document_create_text_node (
+               document, UNICODE_ZERO_WIDTH_SPACE);
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (
+                       WEBKIT_DOM_NODE (caret_position)),
+               WEBKIT_DOM_NODE (text),
+               WEBKIT_DOM_NODE (caret_position),
+               NULL);
+
+       e_html_editor_selection_dom_restore_caret_position (document);
+}
+
+/**
+ * e_html_editor_selection_dom_unlink:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Removes any links (&lt;A&gt; elements) from current selection or at current
+ * cursor position.
+ */
+void
+e_html_editor_selection_dom_unlink (WebKitDOMDocument *document)
+{
+       EHTMLEditorViewCommand command;
+       WebKitDOMDOMWindow *window;
+       WebKitDOMDOMSelection *selection_dom;
+       WebKitDOMRange *range;
+       WebKitDOMElement *link;
+
+       window = webkit_dom_document_get_default_view (document);
+       selection_dom = webkit_dom_dom_window_get_selection (window);
+
+       range = webkit_dom_dom_selection_get_range_at (selection_dom, 0, NULL);
+       link = e_html_editor_dom_node_find_parent_element (
+                       webkit_dom_range_get_start_container (range, NULL), "A");
+
+       if (!link) {
+               gchar *text;
+               /* get element that was clicked on */
+               /* FIXME WK2
+               link = e_html_editor_view_get_element_under_mouse_click (view); */
+               if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
+                       link = NULL;
+
+               text = webkit_dom_html_element_get_inner_text (
+                       WEBKIT_DOM_HTML_ELEMENT (link));
+               webkit_dom_html_element_set_outer_html (
+                       WEBKIT_DOM_HTML_ELEMENT (link), text, NULL);
+               g_free (text);
+       } else {
+               command = E_HTML_EDITOR_VIEW_COMMAND_UNLINK;
+               e_html_editor_view_dom_exec_command (document, command, NULL);
+       }
+}
+
+/**
+ * e_html_editor_selection_dom_create_link:
+ * @document: a @WebKitDOMDocument
+ * @uri: destination of the new link
+ *
+ * Converts current selection into a link pointing to @url.
+ */
+void
+e_html_editor_selection_dom_create_link (WebKitDOMDocument *document,
+                                         const gchar *uri)
+{
+       EHTMLEditorViewCommand command;
+
+       g_return_if_fail (uri != NULL && *uri != '\0');
+
+       command = E_HTML_EDITOR_VIEW_COMMAND_CREATE_LINK;
+       e_html_editor_view_dom_exec_command (document, command, uri);
+}
+
+/**
+ * e_html_editor_selection_dom_get_list_format_from_node:
+ * @node: an #WebKitDOMNode
+ *
+ * Returns block format of given list.
+ *
+ * Returns: #EHTMLEditorSelectionBlockFormat
+ */
+static EHTMLEditorSelectionBlockFormat
+e_html_editor_selection_dom_get_list_format_from_node (WebKitDOMNode *node)
+{
+       EHTMLEditorSelectionBlockFormat format =
+               E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST;
+
+       if (WEBKIT_DOM_IS_HTML_LI_ELEMENT (node))
+               return -1;
+
+       if (WEBKIT_DOM_IS_HTML_U_LIST_ELEMENT (node))
+               return format;
+
+       if (WEBKIT_DOM_IS_HTML_O_LIST_ELEMENT (node)) {
+               gchar *type_value = webkit_dom_element_get_attribute (
+                       WEBKIT_DOM_ELEMENT (node), "type");
+
+               if (!type_value)
+                       return E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST;
+
+               if (!*type_value)
+                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST;
+               else if (g_ascii_strcasecmp (type_value, "A") == 0)
+                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA;
+               else if (g_ascii_strcasecmp (type_value, "I") == 0)
+                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN;
+               g_free (type_value);
+
+               return format;
+       }
+
+       return -1;
+}
+
+static gboolean
+is_in_html_mode (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *document_element;
+
+       document_element = webkit_dom_document_get_document_element (document);
+
+       return webkit_dom_element_has_attribute (document_element, "data-html-mode");
+
+       /* FIXME WK2 we have to probably add a body attribute that shows,
+        * whether the composer is in HTML mode */
+       /*
+       EHTMLEditorView *view = e_html_editor_selection_ref_html_editor_view (selection);
+       gboolean ret_val;
+
+       g_return_val_if_fail (view != NULL, FALSE);
+
+       ret_val = e_html_editor_view_get_html_mode (view);
+
+       g_object_unref (view);
+
+       return ret_val;
+       */
+       return FALSE;
+}
+
+static gboolean
+node_is_list_or_item (WebKitDOMNode *node)
+{
+       return node && (
+               WEBKIT_DOM_IS_HTML_O_LIST_ELEMENT (node) ||
+               WEBKIT_DOM_IS_HTML_U_LIST_ELEMENT (node) ||
+               WEBKIT_DOM_IS_HTML_LI_ELEMENT (node));
+}
+
+static gboolean
+node_is_list (WebKitDOMNode *node)
+{
+       return node && (
+               WEBKIT_DOM_IS_HTML_O_LIST_ELEMENT (node) ||
+               WEBKIT_DOM_IS_HTML_U_LIST_ELEMENT (node));
+}
+
+static gint
+get_list_level (WebKitDOMNode *node)
+{
+       gint level = 0;
+
+       while (node && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (node)) {
+               if (node_is_list (node))
+                       level++;
+               node = webkit_dom_node_get_parent_node (node);
+       }
+
+       return level;
+}
+
+static void
+set_ordered_list_type_to_element (WebKitDOMElement *list,
+                                  EHTMLEditorSelectionBlockFormat format)
+{
+       if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST)
+               webkit_dom_element_remove_attribute (list, "type");
+       else if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA)
+               webkit_dom_element_set_attribute (list, "type", "A", NULL);
+       else if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN)
+               webkit_dom_element_set_attribute (list, "type", "I", NULL);
+}
+
+static void
+e_html_editor_selection_dom_set_paragraph_style (WebKitDOMDocument *document,
+                                                 WebKitDOMElement *element,
+                                                 gint width,
+                                                 gint offset,
+                                                 const gchar *style_to_add)
+{
+       EHTMLEditorSelectionAlignment alignment;
+       char *style = NULL;
+       gint word_wrap_length = (width == -1) ? WORD_WRAP_LENGTH : width;
+
+       alignment = e_html_editor_selection_get_alignment (selection);
+
+       element_add_class (element, "-x-evo-paragraph");
+       element_add_class (element, get_css_alignment_value_class (alignment));
+       if (!is_in_html_mode (document)) {
+               style = g_strdup_printf (
+                       "width: %dch; word-wrap: normal; %s",
+                       (word_wrap_length + offset), style_to_add);
+       } else {
+               if (*style_to_add)
+                       style = g_strdup_printf ("%s", style_to_add);
+       }
+       if (style) {
+               webkit_dom_element_set_attribute (element, "style", style, NULL);
+               g_free (style);
+       }
+}
+
+static WebKitDOMElement *
+create_list_element (WebKitDOMDocument *document,
+                     EHTMLEditorSelectionBlockFormat format,
+                    gint level,
+                     gboolean html_mode)
+{
+       WebKitDOMElement *list;
+       gint offset = -SPACES_PER_LIST_LEVEL;
+       gboolean inserting_unordered_list =
+               format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST;
+
+       list = webkit_dom_document_create_element (
+               document, inserting_unordered_list  ? "UL" : "OL", NULL);
+
+       set_ordered_list_type_to_element (list, format);
+
+       if (level >= 0)
+               offset = (level + 1) * -SPACES_PER_LIST_LEVEL;
+
+       if (!html_mode)
+               e_html_editor_selection_dom_set_paragraph_style (
+                       document, list, -1, offset, "");
+
+       return list;
+}
+
+static void
+indent_list (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *selection_start_marker, *selection_end_marker;
+       WebKitDOMNode *item, *next_item;
+       gboolean after_selection_end = FALSE;
+
+       selection_start_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-start-marker", NULL);
+
+       selection_end_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-end-marker", NULL);
+
+       item = get_parent_block_node_from_child (
+               WEBKIT_DOM_NODE (selection_start_marker));
+
+       if (WEBKIT_DOM_IS_HTML_LI_ELEMENT (item)) {
+               gboolean html_mode = is_in_html_mode (document);
+               WebKitDOMElement *list;
+               WebKitDOMNode *source_list = webkit_dom_node_get_parent_node (item);
+               EHTMLEditorSelectionBlockFormat format;
+
+               format = e_html_editor_selection_dom_get_list_format_from_node (source_list);
+
+               list = create_list_element (
+                       selection, document, format, get_list_level (item), html_mode);
+
+               element_add_class (list, "-x-evo-indented");
+
+               webkit_dom_node_insert_before (
+                       source_list, WEBKIT_DOM_NODE (list), item, NULL);
+
+               while (item && !after_selection_end) {
+                       after_selection_end = webkit_dom_node_contains (
+                               item, WEBKIT_DOM_NODE (selection_end_marker));
+
+                       next_item = webkit_dom_node_get_next_sibling (item);
+
+                       webkit_dom_node_append_child (
+                               WEBKIT_DOM_NODE (list), item, NULL);
+
+                       item = next_item;
+               }
+
+               merge_lists_if_possible (WEBKIT_DOM_NODE (list));
+       }
+}
+
+static void
+e_html_editor_selection_set_indented_style (WebKitDOMElement *element,
+                                            gint width)
+{
+       gchar *style;
+       gint word_wrap_length = (width == -1) ? WORD_WRAP_LENGTH : width;
+
+       webkit_dom_element_set_class_name (element, "-x-evo-indented");
+
+       if (is_in_html_mode (document))
+               style = g_strdup_printf ("margin-left: %dch;", SPACES_PER_INDENTATION);
+       else
+               style = g_strdup_printf (
+                       "margin-left: %dch; word-wrap: normal; width: %dch;",
+                       SPACES_PER_INDENTATION, word_wrap_length);
+
+       webkit_dom_element_set_attribute (element, "style", style, NULL);
+       g_free (style);
+}
+
+static WebKitDOMElement *
+e_html_editor_selection_get_indented_element (WebKitDOMDocument *document,
+                                              gint width)
+{
+       WebKitDOMElement *element;
+
+       element = webkit_dom_document_create_element (document, "DIV", NULL);
+       e_html_editor_selection_set_indented_style (element, width);
+
+       return element;
+}
+
+static void
+indent_block (WebKitDOMDocument *document,
+              WebKitDOMNode *block,
+              gint width)
+{
+       WebKitDOMElement *element;
+
+       element = e_html_editor_selection_get_indented_element (document, width);
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (block),
+               WEBKIT_DOM_NODE (element),
+               block,
+               NULL);
+
+       /* Remove style and let the paragraph inherit it from parent */
+       if (element_has_class (WEBKIT_DOM_ELEMENT (block), "-x-evo-paragraph"))
+               webkit_dom_element_remove_attribute (
+                       WEBKIT_DOM_ELEMENT (block), "style");
+
+       webkit_dom_node_append_child (
+               WEBKIT_DOM_NODE (element),
+               block,
+               NULL);
+}
+
+static gint
+get_indentation_level (WebKitDOMElement *element)
+{
+       WebKitDOMElement *parent;
+       gint level = 0;
+
+       if (element_has_class (element, "-x-evo-indented"))
+               level++;
+
+       parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (element));
+       /* Count level of indentation */
+       while (parent && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
+               if (element_has_class (parent, "-x-evo-indented"))
+                       level++;
+
+               parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (parent));
+       }
+
+       return level;
+}
+
+/**
+ * e_html_editor_selection_indent:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Indents current paragraph by one level.
+ */
+static void
+e_html_editor_selection_indent (WebKitDOMDocument *document)
+{
+       gboolean after_selection_start = FALSE, after_selection_end = FALSE;
+       WebKitDOMElement *selection_start_marker, *selection_end_marker;
+       WebKitDOMNode *block;
+
+       e_html_editor_selection_dom_save (document);
+
+       selection_start_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-start-marker", NULL);
+
+       selection_end_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-end-marker", NULL);
+
+       /* If the selection was not saved, move it into the first child of body */
+       if (!selection_start_marker || !selection_end_marker) {
+               WebKitDOMHTMLElement *body;
+
+               body = webkit_dom_document_get_body (document);
+               selection_start_marker = webkit_dom_document_create_element (
+                       document, "SPAN", NULL);
+               webkit_dom_element_set_id (
+                       selection_start_marker, "-x-evo-selection-start-marker");
+               webkit_dom_node_insert_before (
+                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+                       WEBKIT_DOM_NODE (selection_start_marker),
+                       webkit_dom_node_get_first_child (
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (body))),
+                       NULL);
+               selection_end_marker = webkit_dom_document_create_element (
+                       document, "SPAN", NULL);
+               webkit_dom_element_set_id (
+                       selection_end_marker, "-x-evo-selection-end-marker");
+               webkit_dom_node_insert_before (
+                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+                       WEBKIT_DOM_NODE (selection_end_marker),
+                       webkit_dom_node_get_first_child (
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (body))),
+                       NULL);
+       }
+
+       block = get_parent_indented_block (
+               WEBKIT_DOM_NODE (selection_start_marker));
+       if (!block)
+               block = get_parent_block_node_from_child (
+                       WEBKIT_DOM_NODE (selection_start_marker));
+
+       while (block && !after_selection_end) {
+               gint ii, length, level, final_width = 0;
+               gint word_wrap_length = WORD_WRAP_LENGTH;
+               WebKitDOMNode *next_block;
+               WebKitDOMNodeList *list;
+
+               next_block = webkit_dom_node_get_next_sibling (block);
+
+               list = webkit_dom_element_query_selector_all (
+                       WEBKIT_DOM_ELEMENT (block),
+                       ".-x-evo-indented > *:not(.-x-evo-indented):not(li)",
+                       NULL);
+
+               after_selection_end = webkit_dom_node_contains (
+                       block, WEBKIT_DOM_NODE (selection_end_marker));
+
+               length = webkit_dom_node_list_get_length (list);
+               if (length == 0 && node_is_list_or_item (block)) {
+                       indent_list (document);
+                       goto next;
+               }
+
+               if (length == 0) {
+                       if (!after_selection_start) {
+                               after_selection_start = webkit_dom_node_contains (
+                                       block, WEBKIT_DOM_NODE (selection_start_marker));
+                               if (!after_selection_start)
+                                       goto next;
+                       }
+
+                       level = get_indentation_level (WEBKIT_DOM_ELEMENT (block));
+
+                       final_width = word_wrap_length - SPACES_PER_INDENTATION * (level + 1);
+                       if (final_width < MINIMAL_PARAGRAPH_WIDTH &&
+                           !is_in_html_mode (document))
+                               goto next;
+
+                       indent_block (document, block, final_width);
+
+                       if (after_selection_end)
+                               goto next;
+               }
+
+               for (ii = 0; ii < length; ii++) {
+                       WebKitDOMNode *block_to_process;
+
+                       block_to_process = webkit_dom_node_list_item (list, ii);
+
+                       after_selection_end = webkit_dom_node_contains (
+                               block_to_process, WEBKIT_DOM_NODE (selection_end_marker));
+
+                       if (!after_selection_start) {
+                               after_selection_start = webkit_dom_node_contains (
+                                       block_to_process,
+                                       WEBKIT_DOM_NODE (selection_start_marker));
+                               if (!after_selection_start)
+                                       continue;
+                       }
+
+                       level = get_indentation_level (
+                               WEBKIT_DOM_ELEMENT (block_to_process));
+
+                       final_width = word_wrap_length - SPACES_PER_INDENTATION * (level + 1);
+                       if (final_width < MINIMAL_PARAGRAPH_WIDTH &&
+                           !is_in_html_mode (document))
+                               continue;
+
+                       indent_block (document, block_to_process, final_width);
+
+                       if (after_selection_end)
+                               break;
+               }
+
+ next:
+               g_object_unref (list);
+
+               if (!after_selection_end)
+                       block = next_block;
+       }
+
+       e_html_editor_selection_dom_restore (document);
+       /* FIXME WK2
+       e_html_editor_view_force_spell_check_for_current_paragraph (view);
+
+       g_object_notify (G_OBJECT (selection), "indented"); */
+}
+
+static const gchar *
+get_css_alignment_value_class (EHTMLEditorSelectionAlignment alignment)
+{
+       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT)
+               return ""; /* Left is by default on ltr */
+
+       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_CENTER)
+               return "-x-evo-align-center";
+
+       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_RIGHT)
+               return "-x-evo-align-right";
+
+       return "";
+}
+
+static void
+unindent_list (WebKitDOMDocument *document)
+{
+       gboolean after = FALSE;
+       WebKitDOMElement *new_list;
+       WebKitDOMElement *selection_start_marker, *selection_end_marker;
+       WebKitDOMNode *source_list, *source_list_clone, *current_list, *item;
+       WebKitDOMNode *prev_item;
+
+       selection_start_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-start-marker", NULL);
+       selection_end_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-end-marker", NULL);
+
+       if (!selection_start_marker || !selection_end_marker)
+               return;
+
+       /* Copy elements from previous block to list */
+       item = get_parent_block_node_from_child (
+               WEBKIT_DOM_NODE (selection_start_marker));
+       source_list = webkit_dom_node_get_parent_node (item);
+       new_list = WEBKIT_DOM_ELEMENT (
+               webkit_dom_node_clone_node (source_list, FALSE));
+       current_list = source_list;
+       source_list_clone = webkit_dom_node_clone_node (source_list, FALSE);
+
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (source_list),
+               WEBKIT_DOM_NODE (source_list_clone),
+               webkit_dom_node_get_next_sibling (source_list),
+               NULL);
+
+       if (element_has_class (WEBKIT_DOM_ELEMENT (source_list), "-x-evo-indented"))
+               element_add_class (WEBKIT_DOM_ELEMENT (new_list), "-x-evo-indented");
+
+       prev_item = source_list;
+
+       while (item) {
+               WebKitDOMNode *next_item = webkit_dom_node_get_next_sibling (item);
+
+               if (WEBKIT_DOM_IS_HTML_LI_ELEMENT (item)) {
+                       if (after)
+                               prev_item = webkit_dom_node_append_child (
+                                       source_list_clone, WEBKIT_DOM_NODE (item), NULL);
+                       else
+                               prev_item = webkit_dom_node_insert_before (
+                                       webkit_dom_node_get_parent_node (prev_item),
+                                       item,
+                                       webkit_dom_node_get_next_sibling (prev_item),
+                                       NULL);
+               }
+
+               if (webkit_dom_node_contains (item, WEBKIT_DOM_NODE (selection_end_marker)))
+                       after = TRUE;
+
+               if (!next_item) {
+                       if (after)
+                               break;
+
+                       current_list = webkit_dom_node_get_next_sibling (current_list);
+                       next_item = webkit_dom_node_get_first_child (current_list);
+               }
+               item = next_item;
+       }
+
+       remove_node_if_empty (source_list_clone);
+       remove_node_if_empty (source_list);
+}
+
+static void
+unindent_block (WebKitDOMDocument *document,
+                WebKitDOMNode *block)
+{
+       gboolean before_node = TRUE;
+       gint word_wrap_length = WORD_WRAP_LENGTH;
+       gint level, width;
+       EHTMLEditorSelectionAlignment alignment;
+       WebKitDOMElement *element;
+       WebKitDOMElement *prev_blockquote = NULL, *next_blockquote = NULL;
+       WebKitDOMNode *block_to_process, *node_clone, *child;
+
+       block_to_process = block;
+
+       alignment = e_html_editor_selection_get_alignment_from_node (block_to_process);
+
+       element = webkit_dom_node_get_parent_element (block_to_process);
+
+       if (!WEBKIT_DOM_IS_HTML_DIV_ELEMENT (element) &&
+           !element_has_class (element, "-x-evo-indented"))
+               return;
+
+       element_add_class (WEBKIT_DOM_ELEMENT (block_to_process), "-x-evo-to-unindent");
+
+       level = get_indentation_level (element);
+       width = word_wrap_length - SPACES_PER_INDENTATION * level;
+
+       /* Look if we have previous siblings, if so, we have to
+        * create new blockquote that will include them */
+       if (webkit_dom_node_get_previous_sibling (block_to_process))
+               prev_blockquote = e_html_editor_selection_get_indented_element (
+                       selection, document, width);
+
+       /* Look if we have next siblings, if so, we have to
+        * create new blockquote that will include them */
+       if (webkit_dom_node_get_next_sibling (block_to_process))
+               next_blockquote = e_html_editor_selection_get_indented_element (
+                       selection, document, width);
+
+       /* Copy nodes that are before / after the element that we want to unindent */
+       while ((child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (element)))) {
+               if (webkit_dom_node_is_equal_node (child, block_to_process)) {
+                       before_node = FALSE;
+                       node_clone = webkit_dom_node_clone_node (child, TRUE);
+                       remove_node (child);
+                       continue;
+               }
+
+               webkit_dom_node_append_child (
+                       before_node ?
+                               WEBKIT_DOM_NODE (prev_blockquote) :
+                               WEBKIT_DOM_NODE (next_blockquote),
+                       child,
+                       NULL);
+       }
+
+       element_remove_class (WEBKIT_DOM_ELEMENT (node_clone), "-x-evo-to-unindent");
+
+       /* Insert blockqoute with nodes that were before the element that we want to unindent */
+       if (prev_blockquote) {
+               if (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (prev_blockquote))) {
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
+                               WEBKIT_DOM_NODE (prev_blockquote),
+                               WEBKIT_DOM_NODE (element),
+                               NULL);
+               }
+       }
+
+       if (level == 1 && element_has_class (WEBKIT_DOM_ELEMENT (node_clone), "-x-evo-paragraph")) {
+               e_html_editor_selection_dom_set_paragraph_style (
+                       document, WEBKIT_DOM_ELEMENT (node_clone), word_wrap_length, 0, "");
+               element_add_class (
+                       WEBKIT_DOM_ELEMENT (node_clone),
+                       get_css_alignment_value_class (alignment));
+       }
+
+       /* Insert the unindented element */
+       webkit_dom_node_insert_before (
+               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
+               node_clone,
+               WEBKIT_DOM_NODE (element),
+               NULL);
+
+       /* Insert blockqoute with nodes that were after the element that we want to unindent */
+       if (next_blockquote) {
+               if (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (next_blockquote))) {
+                       webkit_dom_node_insert_before (
+                               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
+                               WEBKIT_DOM_NODE (next_blockquote),
+                               WEBKIT_DOM_NODE (element),
+                               NULL);
+               }
+       }
+
+       /* Remove old blockquote */
+       remove_node (WEBKIT_DOM_NODE (element));
+}
+
+/**
+ * e_html_editor_selection_unindent:
+ * @selection: an #EHTMLEditorSelection
+ *
+ * Unindents current paragraph by one level.
+ */
+static void
+e_html_editor_selection_unindent (WebKitDOMDocument *document)
+{
+       gboolean after_selection_start = FALSE, after_selection_end = FALSE;
+       WebKitDOMElement *selection_start_marker, *selection_end_marker;
+       WebKitDOMNode *block;
+
+       e_html_editor_selection_dom_save (document);
+
+       selection_start_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-start-marker", NULL);
+       selection_end_marker = webkit_dom_document_query_selector (
+               document, "span#-x-evo-selection-end-marker", NULL);
+
+       /* If the selection was not saved, move it into the first child of body */
+       if (!selection_start_marker || !selection_end_marker) {
+               WebKitDOMHTMLElement *body;
+
+               body = webkit_dom_document_get_body (document);
+               selection_start_marker = webkit_dom_document_create_element (
+                       document, "SPAN", NULL);
+               webkit_dom_element_set_id (
+                       selection_start_marker, "-x-evo-selection-start-marker");
+               webkit_dom_node_insert_before (
+                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+                       WEBKIT_DOM_NODE (selection_start_marker),
+                       webkit_dom_node_get_first_child (
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (body))),
+                       NULL);
+               selection_end_marker = webkit_dom_document_create_element (
+                       document, "SPAN", NULL);
+               webkit_dom_element_set_id (
+                       selection_end_marker, "-x-evo-selection-end-marker");
+               webkit_dom_node_insert_before (
+                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+                       WEBKIT_DOM_NODE (selection_end_marker),
+                       webkit_dom_node_get_first_child (
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (body))),
+                       NULL);
+       }
+
+       block = get_parent_indented_block (
+               WEBKIT_DOM_NODE (selection_start_marker));
+       if (!block)
+               block = get_parent_block_node_from_child (
+                       WEBKIT_DOM_NODE (selection_start_marker));
+
+       while (block && !after_selection_end) {
+               gint ii, length;
+               WebKitDOMNode *next_block;
+               WebKitDOMNodeList *list;
+
+               next_block = webkit_dom_node_get_next_sibling (block);
+
+               list = webkit_dom_element_query_selector_all (
+                       WEBKIT_DOM_ELEMENT (block),
+                       ".-x-evo-indented > *:not(.-x-evo-indented):not(li)",
+                       NULL);
+
+               after_selection_end = webkit_dom_node_contains (
+                       block, WEBKIT_DOM_NODE (selection_end_marker));
+
+               length = webkit_dom_node_list_get_length (list);
+               if (length == 0 && node_is_list_or_item (block)) {
+                       unindent_list (document);
+                       goto next;
+               }
+
+               if (length == 0) {
+                       if (!after_selection_start) {
+                               after_selection_start = webkit_dom_node_contains (
+                                       block, WEBKIT_DOM_NODE (selection_start_marker));
+                               if (!after_selection_start)
+                                       goto next;
+                       }
+
+                       unindent_block (document, block);
+
+                       if (after_selection_end)
+                               goto next;
+               }
+
+               for (ii = 0; ii < length; ii++) {
+                       WebKitDOMNode *block_to_process;
+
+                       block_to_process = webkit_dom_node_list_item (list, ii);
+
+                       after_selection_end = webkit_dom_node_contains (
+                               block_to_process,
+                               WEBKIT_DOM_NODE (selection_end_marker));
+
+                       if (!after_selection_start) {
+                               after_selection_start = webkit_dom_node_contains (
+                                       block_to_process,
+                                       WEBKIT_DOM_NODE (selection_start_marker));
+                               if (!after_selection_start)
+                                       continue;
+                       }
+
+                       unindent_block (document, block_to_process);
+
+                       if (after_selection_end)
+                               break;
+               }
+ next:
+               g_object_unref (list);
+               block = next_block;
+       }
+
+       e_html_editor_selection_dom_restore (document);
+/* FIXME WK2
+       e_html_editor_view_force_spell_check_for_current_paragraph (view);
+
+       g_object_notify (G_OBJECT (selection), "indented"); */
+}
diff --git a/e-util/e-html-editor-selection-dom-functions.h b/e-util/e-html-editor-selection-dom-functions.h
new file mode 100644
index 0000000..4dfafc9
--- /dev/null
+++ b/e-util/e-html-editor-selection-dom-functions.h
@@ -0,0 +1,65 @@
+/*
+ * e-html-editor-selection-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_SELECTION_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_SELECTION_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_selection_dom_replace_base64_image_src
+                                               (WebKitDOMDocument *document,
+                                                const gchar *selector,
+                                                const gchar *base64_content,
+                                                const gchar *filename,
+                                                const gchar *uri);
+
+void           e_html_editor_selection_dom_clear_caret_position_marker
+                                               (WebKitDOMDocument *document);
+/*
+WebKitDOMNode *
+               e_html_editor_selection_dom_get_caret_position_node
+                                               (WebKitDOMDocument *document);
+
+WebKitDOMRange *
+               e_html_editor_selection_dom_get_current_range
+                                               (WebKitDOMDocument *document);
+*/
+WebKitDOMElement *
+               e_html_editor_selection_dom_save_caret_position
+                                               (WebKitDOMDocument *document);
+/*
+void
+               e_html_editor_selection_dom_move_caret_into_element
+                                               (WebKitDOMDocument *document,
+                                                WebKitDOMElement *element);
+*/
+void           e_html_editor_selection_dom_restore_caret_position
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_selection_dom_unlink
+                                               (WebKitDOMDocument *document);
+
+void           e_html_editor_selection_dom_create_link
+                                               (WebKitDOMDocument *document,
+                                                const gchar *uri);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_SELECTION_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index c4555f1..cd6cdd7 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -1066,7 +1066,7 @@ e_html_editor_selection_replace (EHTMLEditorSelection *selection,
  *
  * Returns: #EHTMLEditorSelectionAlignment
  */
-EHTMLEditorSelectionAlignment
+static EHTMLEditorSelectionAlignment
 e_html_editor_selection_get_list_alignment_from_node (WebKitDOMNode *node)
 {
        if (element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-list-item-align-left"))
@@ -1174,45 +1174,6 @@ e_html_editor_selection_get_alignment (EHTMLEditorSelection *selection)
        return alignment;
 }
 
-static void
-set_ordered_list_type_to_element (WebKitDOMElement *list,
-                                  EHTMLEditorSelectionBlockFormat format)
-{
-       if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST)
-               webkit_dom_element_remove_attribute (list, "type");
-       else if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA)
-               webkit_dom_element_set_attribute (list, "type", "A", NULL);
-       else if (format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN)
-               webkit_dom_element_set_attribute (list, "type", "I", NULL);
-}
-
-static WebKitDOMElement *
-create_list_element (EHTMLEditorSelection *selection,
-                     WebKitDOMDocument *document,
-                     EHTMLEditorSelectionBlockFormat format,
-                    gint level,
-                     gboolean html_mode)
-{
-       WebKitDOMElement *list;
-       gint offset = -SPACES_PER_LIST_LEVEL;
-       gboolean inserting_unordered_list =
-               format == E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST;
-
-       list = webkit_dom_document_create_element (
-               document, inserting_unordered_list  ? "UL" : "OL", NULL);
-
-       set_ordered_list_type_to_element (list, format);
-
-       if (level >= 0)
-               offset = (level + 1) * -SPACES_PER_LIST_LEVEL;
-
-       if (!html_mode)
-               e_html_editor_selection_set_paragraph_style (
-                       selection, list, -1, offset, "");
-
-       return list;
-}
-
 static WebKitDOMNode *
 get_list_item_node_from_child (WebKitDOMNode *child)
 {
@@ -1302,23 +1263,6 @@ format_change_list_from_list (EHTMLEditorSelection *selection,
                remove_node (source_list);
 }
 
-static gboolean
-node_is_list_or_item (WebKitDOMNode *node)
-{
-       return node && (
-               WEBKIT_DOM_IS_HTMLO_LIST_ELEMENT (node) ||
-               WEBKIT_DOM_IS_HTMLU_LIST_ELEMENT (node) ||
-               WEBKIT_DOM_IS_HTMLLI_ELEMENT (node));
-}
-
-static gboolean
-node_is_list (WebKitDOMNode *node)
-{
-       return node && (
-               WEBKIT_DOM_IS_HTMLO_LIST_ELEMENT (node) ||
-               WEBKIT_DOM_IS_HTMLU_LIST_ELEMENT (node));
-}
-
 static void
 set_block_alignment (WebKitDOMElement *element,
                      const gchar *class)
@@ -1536,27 +1480,6 @@ e_html_editor_selection_set_background_color (EHTMLEditorSelection *selection,
        g_object_notify (G_OBJECT (selection), "background-color");
 }
 
-static gint
-get_indentation_level (WebKitDOMElement *element)
-{
-       WebKitDOMElement *parent;
-       gint level = 0;
-
-       if (element_has_class (element, "-x-evo-indented"))
-               level++;
-
-       parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (element));
-       /* Count level of indentation */
-       while (parent && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
-               if (element_has_class (parent, "-x-evo-indented"))
-                       level++;
-
-               parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (parent));
-       }
-
-       return level;
-}
-
 static WebKitDOMNode *
 get_block_node (WebKitDOMRange *range)
 {
@@ -1569,47 +1492,6 @@ get_block_node (WebKitDOMRange *range)
 }
 
 /**
- * e_html_editor_selection_get_list_format_from_node:
- * @node: an #WebKitDOMNode
- *
- * Returns block format of given list.
- *
- * Returns: #EHTMLEditorSelectionBlockFormat
- */
-EHTMLEditorSelectionBlockFormat
-e_html_editor_selection_get_list_format_from_node (WebKitDOMNode *node)
-{
-       EHTMLEditorSelectionBlockFormat format =
-               E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST;
-
-       if (WEBKIT_DOM_IS_HTMLLI_ELEMENT (node))
-               return -1;
-
-       if (WEBKIT_DOM_IS_HTMLU_LIST_ELEMENT (node))
-               return format;
-
-       if (WEBKIT_DOM_IS_HTMLO_LIST_ELEMENT (node)) {
-               gchar *type_value = webkit_dom_element_get_attribute (
-                       WEBKIT_DOM_ELEMENT (node), "type");
-
-               if (!type_value)
-                       return E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST;
-
-               if (!*type_value)
-                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST;
-               else if (g_ascii_strcasecmp (type_value, "A") == 0)
-                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA;
-               else if (g_ascii_strcasecmp (type_value, "I") == 0)
-                       format = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN;
-               g_free (type_value);
-
-               return format;
-       }
-
-       return -1;
-}
-
-/**
  * e_html_editor_selection_get_block_format:
  * @selection: an #EHTMLEditorSelection
  *
@@ -1741,7 +1623,7 @@ merge_lists_if_possible (WebKitDOMNode *list)
                merge_list_into_list (next_sibling, list, FALSE);
 }
 
-void
+static void
 remove_wrapping_from_element (WebKitDOMElement *element)
 {
        WebKitDOMNodeList *list;
@@ -1758,7 +1640,7 @@ remove_wrapping_from_element (WebKitDOMElement *element)
        g_object_unref (list);
 }
 
-void
+static void
 remove_quoting_from_element (WebKitDOMElement *element)
 {
        gint ii, length;
@@ -2607,8 +2489,7 @@ get_parent_indented_block (WebKitDOMNode *node)
        if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-indented"))
                block = parent;
 
-       while (parent && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent) &&
-              !WEBKIT_DOM_IS_HTML_HTML_ELEMENT (parent)) {
+       while (parent && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
                if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-indented"))
                        block = parent;
                parent = webkit_dom_node_get_parent_node (parent);
@@ -2681,584 +2562,6 @@ e_html_editor_selection_is_indented (EHTMLEditorSelection *selection)
        return FALSE;
 }
 
-static gboolean
-is_in_html_mode (EHTMLEditorSelection *selection)
-{
-       EHTMLEditorView *view = e_html_editor_selection_ref_html_editor_view (selection);
-       gboolean ret_val;
-
-       g_return_val_if_fail (view != NULL, FALSE);
-
-       ret_val = e_html_editor_view_get_html_mode (view);
-
-       g_object_unref (view);
-
-       return ret_val;
-}
-
-static gint
-get_list_level (WebKitDOMNode *node)
-{
-       gint level = 0;
-
-       while (node && !WEBKIT_DOM_IS_HTML_BODY_ELEMENT (node)) {
-               if (node_is_list (node))
-                       level++;
-               node = webkit_dom_node_get_parent_node (node);
-       }
-
-       return level;
-}
-
-static void
-indent_list (EHTMLEditorSelection *selection,
-             WebKitDOMDocument *document)
-{
-       WebKitDOMElement *selection_start_marker, *selection_end_marker;
-       WebKitDOMNode *item, *next_item;
-       gboolean after_selection_end = FALSE;
-
-       selection_start_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-start-marker", NULL);
-
-       selection_end_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-end-marker", NULL);
-
-       item = get_parent_block_node_from_child (
-               WEBKIT_DOM_NODE (selection_start_marker));
-
-       if (WEBKIT_DOM_IS_HTMLLI_ELEMENT (item)) {
-               gboolean html_mode = is_in_html_mode (selection);
-               WebKitDOMElement *list;
-               WebKitDOMNode *source_list = webkit_dom_node_get_parent_node (item);
-               EHTMLEditorSelectionBlockFormat format;
-
-               format = e_html_editor_selection_get_list_format_from_node (source_list);
-
-               list = create_list_element (
-                       selection, document, format, get_list_level (item), html_mode);
-
-               element_add_class (list, "-x-evo-indented");
-
-               webkit_dom_node_insert_before (
-                       source_list, WEBKIT_DOM_NODE (list), item, NULL);
-
-               while (item && !after_selection_end) {
-                       after_selection_end = webkit_dom_node_contains (
-                               item, WEBKIT_DOM_NODE (selection_end_marker));
-
-                       next_item = webkit_dom_node_get_next_sibling (item);
-
-                       webkit_dom_node_append_child (
-                               WEBKIT_DOM_NODE (list), item, NULL);
-
-                       item = next_item;
-               }
-
-               merge_lists_if_possible (WEBKIT_DOM_NODE (list));
-       }
-}
-
-static void
-indent_block (EHTMLEditorSelection *selection,
-              WebKitDOMDocument *document,
-              WebKitDOMNode *block,
-              gint width)
-{
-       WebKitDOMElement *element;
-
-       element = e_html_editor_selection_get_indented_element (
-               selection, document, width);
-
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (block),
-               WEBKIT_DOM_NODE (element),
-               block,
-               NULL);
-
-       /* Remove style and let the paragraph inherit it from parent */
-       if (element_has_class (WEBKIT_DOM_ELEMENT (block), "-x-evo-paragraph"))
-               webkit_dom_element_remove_attribute (
-                       WEBKIT_DOM_ELEMENT (block), "style");
-
-       webkit_dom_node_append_child (
-               WEBKIT_DOM_NODE (element),
-               block,
-               NULL);
-}
-
-/**
- * e_html_editor_selection_indent:
- * @selection: an #EHTMLEditorSelection
- *
- * Indents current paragraph by one level.
- */
-void
-e_html_editor_selection_indent (EHTMLEditorSelection *selection)
-{
-       EHTMLEditorView *view;
-       gboolean after_selection_start = FALSE, after_selection_end = FALSE;
-       WebKitDOMDocument *document;
-       WebKitDOMElement *selection_start_marker, *selection_end_marker;
-       WebKitDOMNode *block;
-
-       g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
-
-       view = e_html_editor_selection_ref_html_editor_view (selection);
-       g_return_if_fail (view != NULL);
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
-       e_html_editor_selection_save (selection);
-
-       selection_start_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-start-marker", NULL);
-
-       selection_end_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-end-marker", NULL);
-
-       /* If the selection was not saved, move it into the first child of body */
-       if (!selection_start_marker || !selection_end_marker) {
-               WebKitDOMHTMLElement *body;
-
-               body = webkit_dom_document_get_body (document);
-               selection_start_marker = webkit_dom_document_create_element (
-                       document, "SPAN", NULL);
-               webkit_dom_element_set_id (
-                       selection_start_marker, "-x-evo-selection-start-marker");
-               webkit_dom_node_insert_before (
-                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
-                       WEBKIT_DOM_NODE (selection_start_marker),
-                       webkit_dom_node_get_first_child (
-                               webkit_dom_node_get_first_child (
-                                       WEBKIT_DOM_NODE (body))),
-                       NULL);
-               selection_end_marker = webkit_dom_document_create_element (
-                       document, "SPAN", NULL);
-               webkit_dom_element_set_id (
-                       selection_end_marker, "-x-evo-selection-end-marker");
-               webkit_dom_node_insert_before (
-                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
-                       WEBKIT_DOM_NODE (selection_end_marker),
-                       webkit_dom_node_get_first_child (
-                               webkit_dom_node_get_first_child (
-                                       WEBKIT_DOM_NODE (body))),
-                       NULL);
-       }
-
-       block = get_parent_indented_block (
-               WEBKIT_DOM_NODE (selection_start_marker));
-       if (!block)
-               block = get_parent_block_node_from_child (
-                       WEBKIT_DOM_NODE (selection_start_marker));
-
-       while (block && !after_selection_end) {
-               gint ii, length, level, final_width = 0;
-               gint word_wrap_length = selection->priv->word_wrap_length;
-               WebKitDOMNode *next_block;
-               WebKitDOMNodeList *list;
-
-               next_block = webkit_dom_node_get_next_sibling (block);
-
-               list = webkit_dom_element_query_selector_all (
-                       WEBKIT_DOM_ELEMENT (block),
-                       ".-x-evo-indented > *:not(.-x-evo-indented):not(li)",
-                       NULL);
-
-               after_selection_end = webkit_dom_node_contains (
-                       block, WEBKIT_DOM_NODE (selection_end_marker));
-
-               length = webkit_dom_node_list_get_length (list);
-               if (length == 0 && node_is_list_or_item (block)) {
-                       indent_list (selection, document);
-                       goto next;
-               }
-
-               if (length == 0) {
-                       if (!after_selection_start) {
-                               after_selection_start = webkit_dom_node_contains (
-                                       block, WEBKIT_DOM_NODE (selection_start_marker));
-                               if (!after_selection_start)
-                                       goto next;
-                       }
-
-                       level = get_indentation_level (WEBKIT_DOM_ELEMENT (block));
-
-                       final_width = word_wrap_length - SPACES_PER_INDENTATION * (level + 1);
-                       if (final_width < MINIMAL_PARAGRAPH_WIDTH &&
-                           !is_in_html_mode (selection))
-                               goto next;
-
-                       indent_block (selection, document, block, final_width);
-
-                       if (after_selection_end)
-                               goto next;
-               }
-
-               for (ii = 0; ii < length; ii++) {
-                       WebKitDOMNode *block_to_process;
-
-                       block_to_process = webkit_dom_node_list_item (list, ii);
-
-                       after_selection_end = webkit_dom_node_contains (
-                               block_to_process, WEBKIT_DOM_NODE (selection_end_marker));
-
-                       if (!after_selection_start) {
-                               after_selection_start = webkit_dom_node_contains (
-                                       block_to_process,
-                                       WEBKIT_DOM_NODE (selection_start_marker));
-                               if (!after_selection_start)
-                                       continue;
-                       }
-
-                       level = get_indentation_level (
-                               WEBKIT_DOM_ELEMENT (block_to_process));
-
-                       final_width = word_wrap_length - SPACES_PER_INDENTATION * (level + 1);
-                       if (final_width < MINIMAL_PARAGRAPH_WIDTH &&
-                           !is_in_html_mode (selection))
-                               continue;
-
-                       indent_block (selection, document, block_to_process, final_width);
-
-                       if (after_selection_end)
-                               break;
-               }
-
- next:
-               g_object_unref (list);
-
-               if (!after_selection_end)
-                       block = next_block;
-       }
-
-       e_html_editor_selection_restore (selection);
-       e_html_editor_view_force_spell_check_for_current_paragraph (view);
-
-       g_object_unref (view);
-
-       g_object_notify (G_OBJECT (selection), "indented");
-}
-
-static const gchar *
-get_css_alignment_value_class (EHTMLEditorSelectionAlignment alignment)
-{
-       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT)
-               return ""; /* Left is by default on ltr */
-
-       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_CENTER)
-               return "-x-evo-align-center";
-
-       if (alignment == E_HTML_EDITOR_SELECTION_ALIGNMENT_RIGHT)
-               return "-x-evo-align-right";
-
-       return "";
-}
-
-static void
-unindent_list (EHTMLEditorSelection *selection,
-               WebKitDOMDocument *document)
-{
-       gboolean after = FALSE;
-       WebKitDOMElement *new_list;
-       WebKitDOMElement *selection_start_marker, *selection_end_marker;
-       WebKitDOMNode *source_list, *source_list_clone, *current_list, *item;
-       WebKitDOMNode *prev_item;
-
-       selection_start_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-start-marker", NULL);
-       selection_end_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-end-marker", NULL);
-
-       if (!selection_start_marker || !selection_end_marker)
-               return;
-
-       /* Copy elements from previous block to list */
-       item = get_parent_block_node_from_child (
-               WEBKIT_DOM_NODE (selection_start_marker));
-       source_list = webkit_dom_node_get_parent_node (item);
-       new_list = WEBKIT_DOM_ELEMENT (
-               webkit_dom_node_clone_node (source_list, FALSE));
-       current_list = source_list;
-       source_list_clone = webkit_dom_node_clone_node (source_list, FALSE);
-
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (source_list),
-               WEBKIT_DOM_NODE (source_list_clone),
-               webkit_dom_node_get_next_sibling (source_list),
-               NULL);
-
-       if (element_has_class (WEBKIT_DOM_ELEMENT (source_list), "-x-evo-indented"))
-               element_add_class (WEBKIT_DOM_ELEMENT (new_list), "-x-evo-indented");
-
-       prev_item = source_list;
-
-       while (item) {
-               WebKitDOMNode *next_item = webkit_dom_node_get_next_sibling (item);
-
-               if (WEBKIT_DOM_IS_HTMLLI_ELEMENT (item)) {
-                       if (after)
-                               prev_item = webkit_dom_node_append_child (
-                                       source_list_clone, WEBKIT_DOM_NODE (item), NULL);
-                       else
-                               prev_item = webkit_dom_node_insert_before (
-                                       webkit_dom_node_get_parent_node (prev_item),
-                                       item,
-                                       webkit_dom_node_get_next_sibling (prev_item),
-                                       NULL);
-               }
-
-               if (webkit_dom_node_contains (item, WEBKIT_DOM_NODE (selection_end_marker)))
-                       after = TRUE;
-
-               if (!next_item) {
-                       if (after)
-                               break;
-
-                       current_list = webkit_dom_node_get_next_sibling (current_list);
-                       next_item = webkit_dom_node_get_first_child (current_list);
-               }
-               item = next_item;
-       }
-
-       remove_node_if_empty (source_list_clone);
-       remove_node_if_empty (source_list);
-}
-
-static void
-unindent_block (EHTMLEditorSelection *selection,
-                WebKitDOMDocument *document,
-                WebKitDOMNode *block)
-{
-       gboolean before_node = TRUE;
-       gint word_wrap_length = selection->priv->word_wrap_length;
-       gint level, width;
-       EHTMLEditorSelectionAlignment alignment;
-       WebKitDOMElement *element;
-       WebKitDOMElement *prev_blockquote = NULL, *next_blockquote = NULL;
-       WebKitDOMNode *block_to_process, *node_clone, *child;
-
-       block_to_process = block;
-
-       alignment = e_html_editor_selection_get_alignment_from_node (block_to_process);
-
-       element = webkit_dom_node_get_parent_element (block_to_process);
-
-       if (!WEBKIT_DOM_IS_HTML_DIV_ELEMENT (element) &&
-           !element_has_class (element, "-x-evo-indented"))
-               return;
-
-       element_add_class (WEBKIT_DOM_ELEMENT (block_to_process), "-x-evo-to-unindent");
-
-       level = get_indentation_level (element);
-       width = word_wrap_length - SPACES_PER_INDENTATION * level;
-
-       /* Look if we have previous siblings, if so, we have to
-        * create new blockquote that will include them */
-       if (webkit_dom_node_get_previous_sibling (block_to_process))
-               prev_blockquote = e_html_editor_selection_get_indented_element (
-                       selection, document, width);
-
-       /* Look if we have next siblings, if so, we have to
-        * create new blockquote that will include them */
-       if (webkit_dom_node_get_next_sibling (block_to_process))
-               next_blockquote = e_html_editor_selection_get_indented_element (
-                       selection, document, width);
-
-       /* Copy nodes that are before / after the element that we want to unindent */
-       while ((child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (element)))) {
-               if (webkit_dom_node_is_equal_node (child, block_to_process)) {
-                       before_node = FALSE;
-                       node_clone = webkit_dom_node_clone_node (child, TRUE);
-                       remove_node (child);
-                       continue;
-               }
-
-               webkit_dom_node_append_child (
-                       before_node ?
-                               WEBKIT_DOM_NODE (prev_blockquote) :
-                               WEBKIT_DOM_NODE (next_blockquote),
-                       child,
-                       NULL);
-       }
-
-       element_remove_class (WEBKIT_DOM_ELEMENT (node_clone), "-x-evo-to-unindent");
-
-       /* Insert blockqoute with nodes that were before the element that we want to unindent */
-       if (prev_blockquote) {
-               if (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (prev_blockquote))) {
-                       webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
-                               WEBKIT_DOM_NODE (prev_blockquote),
-                               WEBKIT_DOM_NODE (element),
-                               NULL);
-               }
-       }
-
-       if (level == 1 && element_has_class (WEBKIT_DOM_ELEMENT (node_clone), "-x-evo-paragraph")) {
-               e_html_editor_selection_set_paragraph_style (
-                       selection, WEBKIT_DOM_ELEMENT (node_clone), word_wrap_length, 0, "");
-               element_add_class (
-                       WEBKIT_DOM_ELEMENT (node_clone),
-                       get_css_alignment_value_class (alignment));
-       }
-
-       /* Insert the unindented element */
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
-               node_clone,
-               WEBKIT_DOM_NODE (element),
-               NULL);
-
-       /* Insert blockqoute with nodes that were after the element that we want to unindent */
-       if (next_blockquote) {
-               if (webkit_dom_node_has_child_nodes (WEBKIT_DOM_NODE (next_blockquote))) {
-                       webkit_dom_node_insert_before (
-                               webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element)),
-                               WEBKIT_DOM_NODE (next_blockquote),
-                               WEBKIT_DOM_NODE (element),
-                               NULL);
-               }
-       }
-
-       /* Remove old blockquote */
-       remove_node (WEBKIT_DOM_NODE (element));
-}
-
-/**
- * e_html_editor_selection_unindent:
- * @selection: an #EHTMLEditorSelection
- *
- * Unindents current paragraph by one level.
- */
-void
-e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
-{
-       EHTMLEditorView *view;
-       gboolean after_selection_start = FALSE, after_selection_end = FALSE;
-       WebKitDOMDocument *document;
-       WebKitDOMElement *selection_start_marker, *selection_end_marker;
-       WebKitDOMNode *block;
-
-       g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
-
-       view = e_html_editor_selection_ref_html_editor_view (selection);
-       g_return_if_fail (view != NULL);
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
-       e_html_editor_selection_save (selection);
-
-       selection_start_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-start-marker", NULL);
-       selection_end_marker = webkit_dom_document_query_selector (
-               document, "span#-x-evo-selection-end-marker", NULL);
-
-       /* If the selection was not saved, move it into the first child of body */
-       if (!selection_start_marker || !selection_end_marker) {
-               WebKitDOMHTMLElement *body;
-
-               body = webkit_dom_document_get_body (document);
-               selection_start_marker = webkit_dom_document_create_element (
-                       document, "SPAN", NULL);
-               webkit_dom_element_set_id (
-                       selection_start_marker, "-x-evo-selection-start-marker");
-               webkit_dom_node_insert_before (
-                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
-                       WEBKIT_DOM_NODE (selection_start_marker),
-                       webkit_dom_node_get_first_child (
-                               webkit_dom_node_get_first_child (
-                                       WEBKIT_DOM_NODE (body))),
-                       NULL);
-               selection_end_marker = webkit_dom_document_create_element (
-                       document, "SPAN", NULL);
-               webkit_dom_element_set_id (
-                       selection_end_marker, "-x-evo-selection-end-marker");
-               webkit_dom_node_insert_before (
-                       webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
-                       WEBKIT_DOM_NODE (selection_end_marker),
-                       webkit_dom_node_get_first_child (
-                               webkit_dom_node_get_first_child (
-                                       WEBKIT_DOM_NODE (body))),
-                       NULL);
-       }
-
-       block = get_parent_indented_block (
-               WEBKIT_DOM_NODE (selection_start_marker));
-       if (!block)
-               block = get_parent_block_node_from_child (
-                       WEBKIT_DOM_NODE (selection_start_marker));
-
-       while (block && !after_selection_end) {
-               gint ii, length;
-               WebKitDOMNode *next_block;
-               WebKitDOMNodeList *list;
-
-               next_block = webkit_dom_node_get_next_sibling (block);
-
-               list = webkit_dom_element_query_selector_all (
-                       WEBKIT_DOM_ELEMENT (block),
-                       ".-x-evo-indented > *:not(.-x-evo-indented):not(li)",
-                       NULL);
-
-               after_selection_end = webkit_dom_node_contains (
-                       block, WEBKIT_DOM_NODE (selection_end_marker));
-
-               length = webkit_dom_node_list_get_length (list);
-               if (length == 0 && node_is_list_or_item (block)) {
-                       unindent_list (selection, document);
-                       goto next;
-               }
-
-               if (length == 0) {
-                       if (!after_selection_start) {
-                               after_selection_start = webkit_dom_node_contains (
-                                       block, WEBKIT_DOM_NODE (selection_start_marker));
-                               if (!after_selection_start)
-                                       goto next;
-                       }
-
-                       unindent_block (selection, document, block);
-
-                       if (after_selection_end)
-                               goto next;
-               }
-
-               for (ii = 0; ii < length; ii++) {
-                       WebKitDOMNode *block_to_process;
-
-                       block_to_process = webkit_dom_node_list_item (list, ii);
-
-                       after_selection_end = webkit_dom_node_contains (
-                               block_to_process,
-                               WEBKIT_DOM_NODE (selection_end_marker));
-
-                       if (!after_selection_start) {
-                               after_selection_start = webkit_dom_node_contains (
-                                       block_to_process,
-                                       WEBKIT_DOM_NODE (selection_start_marker));
-                               if (!after_selection_start)
-                                       continue;
-                       }
-
-                       unindent_block (selection, document, block_to_process);
-
-                       if (after_selection_end)
-                               break;
-               }
- next:
-               g_object_unref (list);
-               block = next_block;
-       }
-
-       e_html_editor_selection_restore (selection);
-       e_html_editor_view_force_spell_check_for_current_paragraph (view);
-
-       g_object_unref (view);
-
-       g_object_notify (G_OBJECT (selection), "indented");
-}
-
 /**
  * e_html_editor_selection_is_bold:
  * @selection: an #EHTMLEditorSelection
@@ -4151,81 +3454,6 @@ e_html_editor_selection_set_underline (EHTMLEditorSelection *selection,
 }
 
 /**
- * e_html_editor_selection_unlink:
- * @selection: an #EHTMLEditorSelection
- *
- * Removes any links (&lt;A&gt; elements) from current selection or at current
- * cursor position.
- */
-void
-e_html_editor_selection_unlink (EHTMLEditorSelection *selection)
-{
-       EHTMLEditorView *view;
-       EHTMLEditorViewCommand command;
-       WebKitDOMDocument *document;
-       WebKitDOMDOMWindow *window;
-       WebKitDOMDOMSelection *dom_selection;
-       WebKitDOMRange *range;
-       WebKitDOMElement *link;
-
-       g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
-
-       view = e_html_editor_selection_ref_html_editor_view (selection);
-       g_return_if_fail (view != NULL);
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       window = webkit_dom_document_get_default_view (document);
-       dom_selection = webkit_dom_dom_window_get_selection (window);
-
-       range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
-       link = e_html_editor_dom_node_find_parent_element (
-                       webkit_dom_range_get_start_container (range, NULL), "A");
-
-       if (!link) {
-               gchar *text;
-               /* get element that was clicked on */
-               link = e_html_editor_view_get_element_under_mouse_click (view);
-               if (!WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (link))
-                       link = NULL;
-
-               text = webkit_dom_html_element_get_inner_text (
-                               WEBKIT_DOM_HTML_ELEMENT (link));
-               webkit_dom_html_element_set_outer_html (WEBKIT_DOM_HTML_ELEMENT (link), text, NULL);
-               g_free (text);
-       } else {
-               command = E_HTML_EDITOR_VIEW_COMMAND_UNLINK;
-               e_html_editor_view_exec_command (view, command, NULL);
-       }
-       g_object_unref (view);
-}
-
-/**
- * e_html_editor_selection_create_link:
- * @selection: an #EHTMLEditorSelection
- * @uri: destination of the new link
- *
- * Converts current selection into a link pointing to @url.
- */
-void
-e_html_editor_selection_create_link (EHTMLEditorSelection *selection,
-                                     const gchar *uri)
-{
-       EHTMLEditorView *view;
-       EHTMLEditorViewCommand command;
-
-       g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
-       g_return_if_fail (uri != NULL && *uri != '\0');
-
-       view = e_html_editor_selection_ref_html_editor_view (selection);
-       g_return_if_fail (view != NULL);
-
-       command = E_HTML_EDITOR_VIEW_COMMAND_CREATE_LINK;
-       e_html_editor_view_exec_command (view, command, uri);
-
-       g_object_unref (view);
-}
-
-/**
  * e_html_editor_selection_insert_text:
  * @selection: an #EHTMLEditorSelection
  * @plain_text: text to insert
@@ -4308,7 +3536,6 @@ typedef struct _LoadContext LoadContext;
 
 struct _LoadContext {
        EHTMLEditorSelection *selection;
-       WebKitDOMElement *element;
        GInputStream *input_stream;
        GOutputStream *output_stream;
        GFile *file;
@@ -4317,6 +3544,7 @@ struct _LoadContext {
        gssize bytes_read;
        const gchar *content_type;
        const gchar *filename;
+       const gchar *selector;
        gchar buffer[4096];
 };
 
@@ -4357,36 +3585,40 @@ image_load_context_free (LoadContext *load_context)
 
 static void
 replace_base64_image_src (EHTMLEditorSelection *selection,
-                          WebKitDOMElement *element,
+                          const gchar *selector,
                           const gchar *base64_content,
                           const gchar *filename,
                           const gchar *uri)
 {
        EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
        view = e_html_editor_selection_ref_html_editor_view (selection);
        g_return_if_fail (view != NULL);
 
        e_html_editor_view_set_changed (view, TRUE);
-       g_object_unref (view);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               goto out;
 
-       if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (element))
-               webkit_dom_html_image_element_set_src (
-                       WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
-                       base64_content);
-       else
-               webkit_dom_element_set_attribute (
-                       WEBKIT_DOM_ELEMENT (element),
-                       "background",
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorSelectionReplaceBase64ImageSrc",
+               g_variant_new (
+                       "(tssss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       selector,
                        base64_content,
-                       NULL);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-uri", uri, NULL);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-inline", "", NULL);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-name",
-               filename ? filename : "", NULL);
+                       filename,
+                       uri),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
+
+ out:
+       g_object_unref (view);
 }
 
 static void
@@ -4396,62 +3628,33 @@ insert_base64_image (EHTMLEditorSelection *selection,
                      const gchar *uri)
 {
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMElement *element, *caret_position, *resizable_wrapper;
-       WebKitDOMText *text;
-
-       caret_position = e_html_editor_selection_save_caret_position (selection);
+       GDBusProxy *web_extension;
 
        view = e_html_editor_selection_ref_html_editor_view (selection);
        g_return_if_fail (view != NULL);
 
-       document = webkit_web_view_get_dom_document (
-               WEBKIT_WEB_VIEW (view));
-
        e_html_editor_view_set_changed (view, TRUE);
-       g_object_unref (view);
-
-       resizable_wrapper =
-               webkit_dom_document_create_element (document, "span", NULL);
-       webkit_dom_element_set_attribute (
-               resizable_wrapper, "class", "-x-evo-resizable-wrapper", NULL);
-
-       element = webkit_dom_document_create_element (document, "img", NULL);
-       webkit_dom_html_image_element_set_src (
-               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
-               base64_content);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-uri", uri, NULL);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-inline", "", NULL);
-       webkit_dom_element_set_attribute (
-               WEBKIT_DOM_ELEMENT (element), "data-name",
-               filename ? filename : "", NULL);
-       webkit_dom_node_append_child (
-               WEBKIT_DOM_NODE (resizable_wrapper),
-               WEBKIT_DOM_NODE (element),
-               NULL);
-
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (
-                       WEBKIT_DOM_NODE (caret_position)),
-               WEBKIT_DOM_NODE (resizable_wrapper),
-               WEBKIT_DOM_NODE (caret_position),
-               NULL);
-
-       /* We have to again use UNICODE_ZERO_WIDTH_SPACE character to restore
-        * caret on right position */
-       text = webkit_dom_document_create_text_node (
-               document, UNICODE_ZERO_WIDTH_SPACE);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               goto out;
 
-       webkit_dom_node_insert_before (
-               webkit_dom_node_get_parent_node (
-                       WEBKIT_DOM_NODE (caret_position)),
-               WEBKIT_DOM_NODE (text),
-               WEBKIT_DOM_NODE (caret_position),
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorSelectionInsertBase64Image",
+               g_variant_new (
+                       "(tssss)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       base64_content,
+                       filename,
+                       uri),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
                NULL);
 
-       e_html_editor_selection_restore_caret_position (selection);
+ out:
+       g_object_unref (view);
 }
 
 static void
@@ -4459,6 +3662,7 @@ image_load_finish (LoadContext *load_context)
 {
        EHTMLEditorSelection *selection;
        GMemoryOutputStream *output_stream;
+       const gchar *selector;
        gchar *base64_encoded, *mime_type, *output, *uri;
        gsize size;
        gpointer data;
@@ -4475,9 +3679,10 @@ image_load_finish (LoadContext *load_context)
 
        base64_encoded = g_base64_encode ((const guchar *) data, size);
        output = g_strconcat ("data:", mime_type, ";base64,", base64_encoded, NULL);
-       if (load_context->element)
+       selector = load_context->selector;
+       if (selector && *selector)
                replace_base64_image_src (
-                       selection, load_context->element, output, load_context->filename, uri);
+                       selection, selector, output, load_context->filename, uri);
        else
                insert_base64_image (selection, output, load_context->filename, uri);
 
@@ -4687,26 +3892,26 @@ e_html_editor_selection_insert_image (EHTMLEditorSelection *selection,
 /**
  * e_html_editor_selection_replace_image_src:
  * @selection: an #EHTMLEditorSelection
- * @element: #WebKitDOMElement element
+ * @selector: CSS selector that describes the element that we want to change
  * @image_uri: an URI of the source image
  *
- * If given @element is image we will replace the src attribute of it with base64
- * data from given @image_uri. Otherwise we will set the base64 data to
- * the background attribute of given @element.
+ * If element described by given selector is image, we will replace the src
+ * attribute of it with base64 data from given @image_uri. Otherwise we will
+ * set the base64 data to the background attribute of given element.
  */
 void
 e_html_editor_selection_replace_image_src (EHTMLEditorSelection *selection,
-                                           WebKitDOMElement *element,
+                                           const gchar *selector
                                            const gchar *image_uri)
 {
        g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
        g_return_if_fail (image_uri != NULL);
-       g_return_if_fail (element && WEBKIT_DOM_IS_ELEMENT (element));
+       g_return_if_fail (selector && *selector);
 
        if (strstr (image_uri, ";base64,")) {
                if (g_str_has_prefix (image_uri, "data:"))
                        replace_base64_image_src (
-                               selection, element, image_uri, "", "");
+                               selection, selector, image_uri, "", "");
                if (strstr (image_uri, ";data")) {
                        const gchar *base64_data = strstr (image_uri, ";") + 1;
                        gchar *filename;
@@ -4718,14 +3923,14 @@ e_html_editor_selection_replace_image_src (EHTMLEditorSelection *selection,
                        filename = g_strndup (image_uri, filename_length);
 
                        replace_base64_image_src (
-                               selection, element, base64_data, filename, "");
+                               selection, selector, base64_data, filename, "");
                        g_free (filename);
                }
        } else
-               image_load_and_insert_async (selection, element, image_uri);
+               image_load_and_insert_async (selection, selector, image_uri);
 }
 
-void
+static void
 e_html_editor_selection_move_caret_into_element (WebKitDOMDocument *document,
                                                  WebKitDOMElement *element)
 {
@@ -4753,7 +3958,7 @@ e_html_editor_selection_move_caret_into_element (WebKitDOMDocument *document,
  *
  * Removes previously set caret position marker from composer.
  */
-void
+static void
 e_html_editor_selection_clear_caret_position_marker (EHTMLEditorSelection *selection)
 {
        EHTMLEditorView *view;
@@ -4775,7 +3980,7 @@ e_html_editor_selection_clear_caret_position_marker (EHTMLEditorSelection *selec
        g_object_unref (view);
 }
 
-WebKitDOMNode *
+static WebKitDOMNode *
 e_html_editor_selection_get_caret_position_node (WebKitDOMDocument *document)
 {
        WebKitDOMElement *element;
@@ -5457,70 +4662,7 @@ wrap_lines (EHTMLEditorSelection *selection,
        }
 }
 
-void
-e_html_editor_selection_set_indented_style (EHTMLEditorSelection *selection,
-                                            WebKitDOMElement *element,
-                                            gint width)
-{
-       gchar *style;
-       gint word_wrap_length = (width == -1) ? selection->priv->word_wrap_length : width;
-
-       webkit_dom_element_set_class_name (element, "-x-evo-indented");
-
-       if (is_in_html_mode (selection))
-               style = g_strdup_printf ("margin-left: %dch;", SPACES_PER_INDENTATION);
-       else
-               style = g_strdup_printf (
-                       "margin-left: %dch; word-wrap: normal; width: %dch;",
-                       SPACES_PER_INDENTATION, word_wrap_length);
-
-       webkit_dom_element_set_attribute (element, "style", style, NULL);
-       g_free (style);
-}
-
-WebKitDOMElement *
-e_html_editor_selection_get_indented_element (EHTMLEditorSelection *selection,
-                                              WebKitDOMDocument *document,
-                                              gint width)
-{
-       WebKitDOMElement *element;
-
-       element = webkit_dom_document_create_element (document, "DIV", NULL);
-       e_html_editor_selection_set_indented_style (selection, element, width);
-
-       return element;
-}
-
-void
-e_html_editor_selection_set_paragraph_style (EHTMLEditorSelection *selection,
-                                             WebKitDOMElement *element,
-                                             gint width,
-                                             gint offset,
-                                             const gchar *style_to_add)
-{
-       EHTMLEditorSelectionAlignment alignment;
-       char *style = NULL;
-       gint word_wrap_length = (width == -1) ? selection->priv->word_wrap_length : width;
-
-       alignment = e_html_editor_selection_get_alignment (selection);
-
-       element_add_class (element, "-x-evo-paragraph");
-       element_add_class (element, get_css_alignment_value_class (alignment));
-       if (!is_in_html_mode (selection)) {
-               style = g_strdup_printf (
-                       "width: %dch; word-wrap: normal; %s",
-                       (word_wrap_length + offset), style_to_add);
-       } else {
-               if (*style_to_add)
-                       style = g_strdup_printf ("%s", style_to_add);
-       }
-       if (style) {
-               webkit_dom_element_set_attribute (element, "style", style, NULL);
-               g_free (style);
-       }
-}
-
-WebKitDOMElement *
+static WebKitDOMElement *
 e_html_editor_selection_get_paragraph_element (EHTMLEditorSelection *selection,
                                                WebKitDOMDocument *document,
                                                gint width,
@@ -5534,7 +4676,7 @@ e_html_editor_selection_get_paragraph_element (EHTMLEditorSelection *selection,
        return element;
 }
 
-WebKitDOMElement *
+static WebKitDOMElement *
 e_html_editor_selection_put_node_into_paragraph (EHTMLEditorSelection *selection,
                                                  WebKitDOMDocument *document,
                                                  WebKitDOMNode *node,
@@ -5686,7 +4828,7 @@ e_html_editor_selection_wrap_lines (EHTMLEditorSelection *selection)
                        WEBKIT_DOM_ELEMENT (active_paragraph), "id");
 }
 
-WebKitDOMElement *
+static WebKitDOMElement *
 e_html_editor_selection_wrap_paragraph_length (EHTMLEditorSelection *selection,
                                                WebKitDOMElement *paragraph,
                                                gint length)
@@ -5703,7 +4845,7 @@ e_html_editor_selection_wrap_paragraph_length (EHTMLEditorSelection *selection,
                NULL, WEBKIT_DOM_NODE (paragraph), document, FALSE, length);
 }
 
-void
+static void
 e_html_editor_selection_wrap_paragraphs_in_document (EHTMLEditorSelection *selection,
                                                      WebKitDOMDocument *document)
 {
@@ -5744,7 +4886,7 @@ e_html_editor_selection_wrap_paragraphs_in_document (EHTMLEditorSelection *selec
        g_object_unref (list);
 }
 
-WebKitDOMElement *
+static WebKitDOMElement *
 e_html_editor_selection_wrap_paragraph (EHTMLEditorSelection *selection,
                                         WebKitDOMElement *paragraph)
 {
diff --git a/e-util/e-html-editor-selection.h b/e-util/e-html-editor-selection.h
index a08ae5b..e434e2f 100644
--- a/e-util/e-html-editor-selection.h
+++ b/e-util/e-html-editor-selection.h
@@ -178,11 +178,12 @@ void              e_html_editor_selection_insert_as_text
                                                 const gchar *html_text);
 void           e_html_editor_selection_replace_image_src
                                                (EHTMLEditorSelection *selection,
-                                                WebKitDOMElement *element,
+                                                const gchar *selector,
                                                 const gchar *image_uri);
 void           e_html_editor_selection_insert_image
                                                (EHTMLEditorSelection *selection,
                                                 const gchar *image_uri);
+/*
 void           e_html_editor_selection_move_caret_into_element
                                                (WebKitDOMDocument *document,
                                                 WebKitDOMElement *element);
@@ -237,6 +238,7 @@ WebKitDOMElement *
                e_html_editor_selection_wrap_paragraph
                                                (EHTMLEditorSelection *selection,
                                                 WebKitDOMElement *paragraph);
+*/
 void           e_html_editor_selection_save    (EHTMLEditorSelection *selection);
 void           e_html_editor_selection_restore (EHTMLEditorSelection *selection);
 void           e_html_editor_selection_move    (EHTMLEditorSelection *selection,
@@ -247,6 +249,7 @@ void                e_html_editor_selection_extend  (EHTMLEditorSelection *selection,
                                                 EHTMLEditorSelectionGranularity granularity);
 void           e_html_editor_selection_scroll_to_caret
                                                (EHTMLEditorSelection *selection);
+/*
 EHTMLEditorSelectionBlockFormat
                e_html_editor_selection_get_list_format_from_node
                                                (WebKitDOMNode *node);
@@ -255,6 +258,7 @@ EHTMLEditorSelectionAlignment
                                                (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-table-dialog-dom-functions.c 
b/e-util/e-html-editor-table-dialog-dom-functions.c
new file mode 100644
index 0000000..cc3325d
--- /dev/null
+++ b/e-util/e-html-editor-table-dialog-dom-functions.c
@@ -0,0 +1,334 @@
+/*
+ * e-html-editor-cell-dialog-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-cell-dialog-dom-functions.h"
+
+#include "e-dom-utils.h"
+
+static WebKitDOMElement *
+get_current_table_element (WebKitDOMDocument *document)
+{
+       return webkit_dom_document_get_element_by_id (document, "-x-evo-current-table");
+}
+
+static WebKitDOMElement *
+e_html_editor_table_dialog_create_table (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table, *br, *caret, *parent, *element;
+       gint i;
+
+       /* Default 3x3 table */
+       table = webkit_dom_document_create_element (document, "TABLE", NULL);
+       for (i = 0; i < 3; i++) {
+               WebKitDOMHTMLElement *row;
+               gint j;
+
+               row = webkit_dom_html_table_element_insert_row (
+                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), -1, NULL);
+
+               for (j = 0; j < 3; j++) {
+                       webkit_dom_html_table_row_element_insert_cell (
+                               WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), -1, NULL);
+               }
+       }
+
+       caret = e_html_editor_selection_dom_save_caret_position (document);
+
+       parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (caret));
+       element = caret;
+
+       while (!WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
+               element = parent;
+               parent = webkit_dom_node_get_parent_element (
+                       WEBKIT_DOM_NODE (parent));
+       }
+
+       br = webkit_dom_document_create_element (document, "BR", NULL);
+       webkit_dom_node_insert_before (
+               WEBKIT_DOM_NODE (parent),
+               WEBKIT_DOM_NODE (br),
+               webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
+               NULL);
+
+       /* Insert the table into body below the caret */
+       webkit_dom_node_insert_before (
+               WEBKIT_DOM_NODE (parent),
+               WEBKIT_DOM_NODE (table),
+               webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
+               NULL);
+
+       e_html_editor_selection_dom_clear_caret_position_marker (document);
+
+       /* FIXME WK2
+       e_html_editor_view_set_changed (view, TRUE);*/
+
+       return table;
+}
+
+void
+e_html_editor_table_dialog_set_row_count (WebKitDOMDocument *document,
+                                          gulong expected_count)
+{
+       WebKitDOMElement *table_element;
+       WebKitDOMHTMLCollection *rows;
+       gulong ii, current_count;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       rows = webkit_dom_html_table_element_get_rows (table_element);
+       current_count = webkit_dom_html_collection_get_length (rows);
+
+       if (current_count < expected_count) {
+               for (ii = 0; ii < expected_count - current_count; ii++) {
+                       webkit_dom_html_table_element_insert_row (
+                               table_element, -1, NULL);
+               }
+       } else if (current_count > expected_count) {
+               for (ii = 0; ii < current_count - expected_count; ii++) {
+                       webkit_dom_html_table_element_delete_row (
+                               table_element, -1, NULL);
+               }
+       }
+}
+
+gulong
+e_html_editor_table_dialog_get_row_count (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+       WebKitDOMHTMLCollection *rows;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return 0;
+
+       rows = webkit_dom_html_table_element_get_rows (able_element);
+
+       return webkit_dom_html_collection_get_length (rows);
+}
+
+void
+e_html_editor_table_dialog_set_column_count (WebKitDOMDocument *document,
+                                             gulong expected_columns)
+{
+       WebKitDOMElement *table_element;
+       WebKitDOMHTMLCollection *rows;
+       gulong ii, row_count;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+       row_count = webkit_dom_html_collection_get_length (rows);
+
+       for (ii = 0; ii < row_count; ii++) {
+               WebKitDOMHTMLTableRowElement *row;
+               WebKitDOMHTMLCollection *cells;
+               gulong jj, current_columns;
+
+               row = WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (
+                       webkit_dom_html_collection_item (rows, ii));
+
+               cells = webkit_dom_html_table_row_element_get_cells (row);
+               current_columns = webkit_dom_html_collection_get_length (cells);
+
+               if (current_columns < expected_columns) {
+                       for (jj = 0; jj < expected_columns - current_columns; jj++) {
+                               webkit_dom_html_table_row_element_insert_cell (
+                                       row, -1, NULL);
+                       }
+               } else if (expected_columns < current_columns) {
+                       for (jj = 0; jj < current_columns - expected_columns; jj++) {
+                               webkit_dom_html_table_row_element_delete_cell (
+                                       row, -1, NULL);
+                       }
+               }
+       }
+}
+
+gulong
+e_html_editor_table_dialog_get_column_count (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+       WebKitDOMHTMLCollection *rows, *columns;
+       WebKitDOMNode *row;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return 0;
+
+       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+       row = webkit_dom_html_collection_item (rows, 0);
+
+       columns = webkit_dom_html_table_row_element_get_cells (
+               WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+
+       return webkit_dom_html_collection_get_length (columns);
+}
+
+void
+e_html_editor_table_dialog_set_width (WebKitDOMDocument *document,
+                                      const gchar *width)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_width (table_element, width);
+}
+
+gchar *
+e_html_editor_table_dialog_get_width (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_width (table_element);
+}
+
+void
+e_html_editor_table_dialog_set_alignment (WebKitDOMDocument *document.
+                                          const gchar *value)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_align (table_element, value);
+}
+
+gchar *
+e_html_editor_table_dialog_get_alignment (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_align (table_element);
+}
+
+void
+e_html_editor_table_dialog_set_padding (WebKitDOMDocument *document.
+                                        const gchar *value)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_cell_padding (table_element, value);
+}
+
+gchar *
+e_html_editor_table_dialog_get_padding (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_cell_padding (table_element);
+}
+
+void
+e_html_editor_table_dialog_set_spacing (WebKitDOMDocument *document.
+                                        const gchar *value)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_cell_spacing (table_element, value);
+}
+
+gchar *
+e_html_editor_table_dialog_get_spacing (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_cell_spacing (table_element);
+}
+
+void
+e_html_editor_table_dialog_set_border (WebKitDOMDocument *document.
+                                       const gchar *value)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_border (table_element, value);
+}
+
+gchar *
+e_html_editor_table_dialog_get_border (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_border (table_element);
+}
+
+void
+e_html_editor_table_dialog_set_bg_color (WebKitDOMDocument *document.
+                                         const gchar *value)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return;
+
+       webkit_dom_html_table_element_set_bg_color (table_element, value);
+}
+
+gchar *
+e_html_editor_table_dialog_get_bg_color (WebKitDOMDocument *document)
+{
+       WebKitDOMElement *table_element;
+
+       table_element = get_current_table_element (document);
+       if (!table_element)
+               return NULL;
+
+       return webkit_dom_html_table_element_get_bg_color (table_element);
+}
diff --git a/e-util/e-html-editor-table-dialog-dom-functions.h 
b/e-util/e-html-editor-table-dialog-dom-functions.h
new file mode 100644
index 0000000..c27e506
--- /dev/null
+++ b/e-util/e-html-editor-table-dialog-dom-functions.h
@@ -0,0 +1,72 @@
+/*
+ * e-html-editor-actions-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+G_BEGIN_DECLS
+
+void           e_html_editor_cell_dialog_mark_current_cell_element
+                                               (WebKitDOMDocument *document,
+                                                const gchar *id);
+
+void           e_html_editor_cell_dialog_set_element_v_align
+                                               (WebKitDOMDocument *document,
+                                                const gchar *v_align,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_align
+                                               (WebKitDOMDocument *document,
+                                                const gchar *align,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_no_wrap
+                                               (WebKitDOMDocument *document,
+                                                gboolean wrap_text,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_header_style
+                                               (WebKitDOMDocument *document,
+                                                gboolean header_style,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_width
+                                               (WebKitDOMDocument *document,
+                                                const gchar *width,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_col_span
+                                               (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_row_span
+                                               (WebKitDOMDocument *document,
+                                                glong span,
+                                                guint scope);
+
+void           e_html_editor_cell_dialog_set_element_bg_color
+                                               (WebKitDOMDocument *document,
+                                                const gchar *color,
+                                                guint scope);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_ACTIONS_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-table-dialog.c b/e-util/e-html-editor-table-dialog.c
index bd434a2..91953cd 100644
--- a/e-util/e-html-editor-table-dialog.c
+++ b/e-util/e-html-editor-table-dialog.c
@@ -66,173 +66,145 @@ G_DEFINE_TYPE (
        e_html_editor_table_dialog,
        E_TYPE_HTML_EDITOR_DIALOG);
 
-static WebKitDOMElement *
-html_editor_table_dialog_create_table (EHTMLEditorTableDialog *dialog)
+static void
+html_editor_table_dialog_set_row_count (EHTMLEditorTableDialog *dialog)
 {
        EHTMLEditor *editor;
-       EHTMLEditorSelection *editor_selection;
        EHTMLEditorView *view;
-       WebKitDOMDocument *document;
-       WebKitDOMElement *table, *br, *caret, *parent, *element;
-       gint i;
+       GDBusProxy *web_extension;
 
        editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
        view = e_html_editor_get_view (editor);
-       editor_selection = e_html_editor_view_get_selection (view);
-
-       document = webkit_web_view_get_dom_document (
-               WEBKIT_WEB_VIEW (view));
-
-       /* Default 3x3 table */
-       table = webkit_dom_document_create_element (document, "TABLE", NULL);
-       for (i = 0; i < 3; i++) {
-               WebKitDOMHTMLElement *row;
-               gint j;
-
-               row = webkit_dom_html_table_element_insert_row (
-                       WEBKIT_DOM_HTML_TABLE_ELEMENT (table), -1, NULL);
-
-               for (j = 0; j < 3; j++) {
-                       webkit_dom_html_table_row_element_insert_cell (
-                               WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row), -1, NULL);
-               }
-       }
-
-       caret = e_html_editor_selection_save_caret_position (editor_selection);
-
-       parent = webkit_dom_node_get_parent_element (WEBKIT_DOM_NODE (caret));
-       element = caret;
-
-       while (!WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent)) {
-               element = parent;
-               parent = webkit_dom_node_get_parent_element (
-                       WEBKIT_DOM_NODE (parent));
-       }
-
-       br = webkit_dom_document_create_element (document, "BR", NULL);
-       webkit_dom_node_insert_before (
-               WEBKIT_DOM_NODE (parent),
-               WEBKIT_DOM_NODE (br),
-               webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
-               NULL);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       /* Insert the table into body below the caret */
-       webkit_dom_node_insert_before (
-               WEBKIT_DOM_NODE (parent),
-               WEBKIT_DOM_NODE (table),
-               webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (element)),
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetRowCount",
+               g_variant_new (
+                       "(tu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_spin_button_get_value (
+                               GTK_SPIN_BUTTON (dialog->priv->rows_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
                NULL);
-
-       e_html_editor_selection_clear_caret_position_marker (editor_selection);
-
-       e_html_editor_view_set_changed (view, TRUE);
-
-       return table;
-}
-
-static void
-html_editor_table_dialog_set_row_count (EHTMLEditorTableDialog *dialog)
-{
-       WebKitDOMHTMLCollection *rows;
-       gulong ii, current_count, expected_count;
-
-       g_return_if_fail (dialog->priv->table_element);
-
-       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
-       current_count = webkit_dom_html_collection_get_length (rows);
-       expected_count = gtk_spin_button_get_value (
-                               GTK_SPIN_BUTTON (dialog->priv->rows_edit));
-
-       if (current_count < expected_count) {
-               for (ii = 0; ii < expected_count - current_count; ii++) {
-                       webkit_dom_html_table_element_insert_row (
-                               dialog->priv->table_element, -1, NULL);
-               }
-       } else if (current_count > expected_count) {
-               for (ii = 0; ii < current_count - expected_count; ii++) {
-                       webkit_dom_html_table_element_delete_row (
-                               dialog->priv->table_element, -1, NULL);
-               }
-       }
 }
 
 static void
 html_editor_table_dialog_get_row_count (EHTMLEditorTableDialog *dialog)
 {
-       WebKitDOMHTMLCollection *rows;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetRowCount",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->rows_edit),
-               webkit_dom_html_collection_get_length (rows));
+       if (result) {
+               gulong value;
+
+               g_variant_get (result, "(u)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->rows_edit), value);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_column_count (EHTMLEditorTableDialog *dialog)
 {
-       WebKitDOMHTMLCollection *rows;
-       gulong ii, row_count, expected_columns;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
-       row_count = webkit_dom_html_collection_get_length (rows);
-       expected_columns = gtk_spin_button_get_value (
-                       GTK_SPIN_BUTTON (dialog->priv->columns_edit));
-
-       for (ii = 0; ii < row_count; ii++) {
-               WebKitDOMHTMLTableRowElement *row;
-               WebKitDOMHTMLCollection *cells;
-               gulong jj, current_columns;
-
-               row = WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (
-                       webkit_dom_html_collection_item (rows, ii));
-
-               cells = webkit_dom_html_table_row_element_get_cells (row);
-               current_columns = webkit_dom_html_collection_get_length (cells);
-
-               if (current_columns < expected_columns) {
-                       for (jj = 0; jj < expected_columns - current_columns; jj++) {
-                               webkit_dom_html_table_row_element_insert_cell (
-                                       row, -1, NULL);
-                       }
-               } else if (expected_columns < current_columns) {
-                       for (jj = 0; jj < current_columns - expected_columns; jj++) {
-                               webkit_dom_html_table_row_element_delete_cell (
-                                       row, -1, NULL);
-                       }
-               }
-       }
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetColumnCount",
+               g_variant_new (
+                       "(tu)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_spin_button_get_value (
+                               GTK_SPIN_BUTTON (dialog->priv->columns_edit))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_table_dialog_get_column_count (EHTMLEditorTableDialog *dialog)
 {
-       WebKitDOMHTMLCollection *rows, *columns;
-       WebKitDOMNode *row;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
-       row = webkit_dom_html_collection_item (rows, 0);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetColumnsCount",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       columns = webkit_dom_html_table_row_element_get_cells (
-                               WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row));
+       if (result) {
+               gulong value;
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->columns_edit),
-               webkit_dom_html_collection_get_length (columns));
+               g_variant_get (result, "(u)", &value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->columns_edit), value);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_width (EHTMLEditorTableDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
        gchar *width;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        if (gtk_toggle_button_get_active (
                        GTK_TOGGLE_BUTTON (dialog->priv->width_check))) {
@@ -256,17 +228,53 @@ html_editor_table_dialog_set_width (EHTMLEditorTableDialog *dialog)
                gtk_widget_set_sensitive (dialog->priv->width_units, FALSE);
        }
 
-       webkit_dom_html_table_element_set_width (
-               dialog->priv->table_element, width);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetWidth",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       width),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
+
        g_free (width);
 }
 
 static void
 html_editor_table_dialog_get_width (EHTMLEditorTableDialog *dialog)
 {
-       gchar *width;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
+       const gchar *width;
+
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetWidth",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
+
+       if (!result)
+               return;
+
+       g_variant_get (result, "(&s)", &width);
 
-       width = webkit_dom_html_table_element_get_width (dialog->priv->table_element);
        if (!width || !*width || g_ascii_strncasecmp (width, "auto", 4) == 0) {
                gtk_toggle_button_set_active (
                        GTK_TOGGLE_BUTTON (dialog->priv->width_check), FALSE);
@@ -286,50 +294,104 @@ html_editor_table_dialog_get_width (EHTMLEditorTableDialog *dialog)
                        ((strstr (width, "%") == NULL) ?
                                "units-px" : "units-percent"));
        }
-       g_free (width);
+
+       g_variant_unref (result);
 }
 
 static void
 html_editor_table_dialog_set_alignment (EHTMLEditorTableDialog *dialog)
 {
-       g_return_if_fail (dialog->priv->table_element);
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
 
-       webkit_dom_html_table_element_set_align (
-               dialog->priv->table_element,
-               gtk_combo_box_get_active_id (
-                       GTK_COMBO_BOX (dialog->priv->alignment_combo)));
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetAlignment",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       gtk_combo_box_get_active_id (
+                               GTK_COMBO_BOX (dialog->priv->alignment_combo))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 }
 
 static void
 html_editor_table_dialog_get_alignment (EHTMLEditorTableDialog *dialog)
 {
-       gchar *alignment;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       alignment = webkit_dom_html_table_element_get_align (
-                       dialog->priv->table_element);
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetAlignment",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       gtk_combo_box_set_active_id (
-               GTK_COMBO_BOX (dialog->priv->alignment_combo), alignment);
+       if (result) {
+               gchar *value;
 
-       g_free (alignment);
+               g_variant_get (result, "(&s)", &value);
+               gtk_combo_box_set_active_id (
+                       GTK_COMBO_BOX (dialog->priv->alignment_combo), value);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_padding (EHTMLEditorTableDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
        gchar *padding;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        padding = g_strdup_printf (
                "%d",
-                       gtk_spin_button_get_value_as_int (
-                               GTK_SPIN_BUTTON (dialog->priv->padding_edit)));
-
-       webkit_dom_html_table_element_set_cell_padding (
-               dialog->priv->table_element, padding);
+               gtk_spin_button_get_value_as_int (
+                       GTK_SPIN_BUTTON (dialog->priv->padding_edit)));
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetPadding",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       padding).
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (padding);
 }
@@ -337,39 +399,74 @@ html_editor_table_dialog_set_padding (EHTMLEditorTableDialog *dialog)
 static void
 html_editor_table_dialog_get_padding (EHTMLEditorTableDialog *dialog)
 {
-       gchar *padding;
-       gint padding_int;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       padding = webkit_dom_html_table_element_get_cell_padding (
-                       dialog->priv->table_element);
-       if (!padding || !*padding) {
-               padding_int = 0;
-       } else {
-               padding_int = atoi (padding);
-       }
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetPadding",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->padding_edit), padding_int);
+       if (result) {
+               gchar *value;
+               gint value_int;
 
-       g_free (padding);
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value)
+                       value_int = 0;
+               else
+                       value_int = atoi (value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->padding_edit), value_int);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_spacing (EHTMLEditorTableDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
        gchar *spacing;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        spacing = g_strdup_printf (
                "%d",
-                       gtk_spin_button_get_value_as_int (
-                               GTK_SPIN_BUTTON (dialog->priv->spacing_edit)));
-
-       webkit_dom_html_table_element_set_cell_spacing (
-               dialog->priv->table_element, spacing);
+               gtk_spin_button_get_value_as_int (
+                       GTK_SPIN_BUTTON (dialog->priv->spacing_edit)));
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetSpacing",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       spacing).
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (spacing);
 }
@@ -377,39 +474,74 @@ html_editor_table_dialog_set_spacing (EHTMLEditorTableDialog *dialog)
 static void
 html_editor_table_dialog_get_spacing (EHTMLEditorTableDialog *dialog)
 {
-       gchar *spacing;
-       gint spacing_int;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       spacing = webkit_dom_html_table_element_get_cell_spacing (
-                       dialog->priv->table_element);
-       if (!spacing || !*spacing) {
-               spacing_int = 0;
-       } else {
-               spacing_int = atoi (spacing);
-       }
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetSpacing",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->spacing_edit), spacing_int);
+       if (result) {
+               gchar *value;
+               gint value_int;
 
-       g_free (spacing);
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value)
+                       value_int = 0;
+               else
+                       value_int = atoi (value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->spacing_edit), value_int);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_border (EHTMLEditorTableDialog *dialog)
 {
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
        gchar *border;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        border = g_strdup_printf (
                "%d",
-                       gtk_spin_button_get_value_as_int (
-                               GTK_SPIN_BUTTON (dialog->priv->border_edit)));
-
-       webkit_dom_html_table_element_set_border (
-               dialog->priv->table_element, border);
+               gtk_spin_button_get_value_as_int (
+                       GTK_SPIN_BUTTON (dialog->priv->border_edit)));
+
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetBorder",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       border).
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (border);
 }
@@ -417,43 +549,77 @@ html_editor_table_dialog_set_border (EHTMLEditorTableDialog *dialog)
 static void
 html_editor_table_dialog_get_border (EHTMLEditorTableDialog *dialog)
 {
-       gchar *border;
-       gint border_int;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       GVariant *result;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
-       border = webkit_dom_html_table_element_get_border (
-                       dialog->priv->table_element);
-       if (!border || !*border) {
-               border_int = 0;
-       } else {
-               border_int = atoi (border);
-       }
+       result = g_dbus_proxy_call_sync (
+               web_extension,
+               "EHTMLEditorTableDialogGetBorder",
+               g_variant_new (
+                       "(t)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view))),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
-       gtk_spin_button_set_value (
-               GTK_SPIN_BUTTON (dialog->priv->border_edit), border_int);
+       if (result) {
+               gchar *value;
+               gint value_int;
 
-       g_free (border);
+               g_variant_get (result, "(&s)", &value);
+               if (!value || !*value)
+                       value_int = 0;
+               else
+                       value_int = atoi (value);
+               gtk_spin_button_set_value (
+                       GTK_SPIN_BUTTON (dialog->priv->border_edit), value_int);
+               g_variant_unref (result);
+       }
 }
 
 static void
 html_editor_table_dialog_set_background_color (EHTMLEditorTableDialog *dialog)
 {
-       gchar *color;
+       EHTMLEditor *editor;
+       EHTMLEditorView *view;
+       GDBusProxy *web_extension;
+       gchar *color
        GdkRGBA rgba;
 
-       g_return_if_fail (dialog->priv->table_element);
+       editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+       view = e_html_editor_get_view (editor);
+       web_extension = e_html_editor_view_get_web_extension_proxy (view);
+       if (!web_extension)
+               return;
 
        e_color_combo_get_current_color (
                E_COLOR_COMBO (dialog->priv->background_color_button), &rgba);
-
        if (rgba.alpha != 0.0)
                color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
        else
                color = g_strdup ("");
 
-       webkit_dom_html_table_element_set_bg_color (
-               dialog->priv->table_element, color);
+       g_dbus_proxy_call (
+               web_extension,
+               "EHTMLEditorCellDialogSetBgColor",
+               g_variant_new (
+                       "(ts)",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)),
+                       color).
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL,
+               NULL);
 
        g_free (color);
 }
diff --git a/e-util/e-html-editor-view-dom-functions.c b/e-util/e-html-editor-view-dom-functions.c
new file mode 100644
index 0000000..c1dc9fd
--- /dev/null
+++ b/e-util/e-html-editor-view-dom-functions.c
@@ -0,0 +1,103 @@
+/*
+ * e-html-editor-view-dom-functions.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-view-dom-functions.h"
+
+/**
+ * e_html_editor_view_dom_exec_command:
+ * @document: a #WebKitDOMDocument
+ * @command: an #EHTMLEditorViewCommand to execute
+ * @value: value of the command (or @NULL if the command does not require value)
+ *
+ * The function will fail when @value is @NULL or empty but the current @command
+ * requires a value to be passed. The @value is ignored when the @command does
+ * not expect any value.
+ *
+ * Returns: @TRUE when the command was succesfully executed, @FALSE otherwise.
+ */
+gboolean
+e_html_editor_view_dom_exec_command (WebKitDOMDocument *document,
+                                     EHTMLEditorViewCommand command,
+                                     const gchar *value)
+{
+       const gchar *cmd_str = 0;
+       gboolean has_value;
+
+#define CHECK_COMMAND(cmd,str,val) case cmd:\
+       if (val) {\
+               g_return_val_if_fail (value && *value, FALSE);\
+       }\
+       has_value = val; \
+       cmd_str = str;\
+       break;
+
+       switch (command) {
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_BACKGROUND_COLOR, "BackColor", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_BOLD, "Bold", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_COPY, "Copy", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_CREATE_LINK, "CreateLink", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_CUT, "Cut", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_DEFAULT_PARAGRAPH_SEPARATOR, 
"DefaultParagraphSeparator", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_DELETE, "Delete", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FIND_STRING, "FindString", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_NAME, "FontName", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_SIZE, "FontSize", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_SIZE_DELTA, "FontSizeDelta", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORE_COLOR, "ForeColor", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORMAT_BLOCK, "FormatBlock", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORWARD_DELETE, "ForwardDelete", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_HILITE_COLOR, "HiliteColor", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INDENT, "Indent", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_HORIZONTAL_RULE, "InsertHorizontalRule", 
FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, "InsertHTML", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_IMAGE, "InsertImage", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_LINE_BREAK, "InsertLineBreak", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT, 
"InsertNewlineInQuotedContent", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_ORDERED_LIST, "InsertOrderedList", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_PARAGRAPH, "InsertParagraph", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_TEXT, "InsertText", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_UNORDERED_LIST, "InsertUnorderedList", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_ITALIC, "Italic", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_CENTER, "JustifyCenter", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_FULL, "JustifyFull", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_LEFT, "JustifyLeft", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_NONE, "JustifyNone", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_RIGHT, "JustifyRight", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_OUTDENT, "Outdent", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE, "Paste", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE_AND_MATCH_STYLE, "PasteAndMatchStyle", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE_AS_PLAIN_TEXT, "PasteAsPlainText", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PRINT, "Print", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_REDO, "Redo", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_REMOVE_FORMAT, "RemoveFormat", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SELECT_ALL, "SelectAll", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_STRIKETHROUGH, "Strikethrough", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_STYLE_WITH_CSS, "StyleWithCSS", TRUE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SUBSCRIPT, "Subscript", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SUPERSCRIPT, "Superscript", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_TRANSPOSE, "Transpose", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNDERLINE, "Underline", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNDO, "Undo", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNLINK, "Unlink", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNSELECT, "Unselect", FALSE)
+               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_USE_CSS, "UseCSS", TRUE)
+       }
+
+       return webkit_dom_document_exec_command (
+               document, cmd_str, FALSE, has_value ? value : "" );
+}
diff --git a/e-util/e-html-editor-view-dom-functions.h b/e-util/e-html-editor-view-dom-functions.h
new file mode 100644
index 0000000..94085b2
--- /dev/null
+++ b/e-util/e-html-editor-view-dom-functions.h
@@ -0,0 +1,35 @@
+/*
+ * e-html-editor-view-dom-functions.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_VIEW_DOM_FUNCTIONS_H
+#define E_HTML_EDITOR_VIEW_DOM_FUNCTIONS_H
+
+#include <webkitdom/webkitdom.h>
+
+#include "e-util-enums.h"
+
+G_BEGIN_DECLS
+
+gboolean       e_html_editor_view_dom_exec_command
+                                               (WebKitDOMDocument *document,
+                                                EHTMLEditorViewCommand command,
+                                                const gchar *value);
+
+G_END_DECLS
+
+#endif /* E_HTML_EDITOR_VIEW_DOM_FUNCTIONS_H */
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 44fd52e..1e85438 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -31,6 +31,8 @@
 #include <glib/gi18n-lib.h>
 #include <gdk/gdkkeysyms.h>
 
+#include "web-extensions/e-html-editor-web-extension.h"
+
 #define E_HTML_EDITOR_VIEW_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_HTML_EDITOR_VIEW, EHTMLEditorViewPrivate))
@@ -89,6 +91,9 @@ struct _EHTMLEditorViewPrivate {
 
        WebKitWebView *convertor_web_view;
 
+       GDBusProxy *web_extension;
+       guint web_extension_watch_name_id;
+
        GHashTable *old_settings;
 };
 
@@ -2114,8 +2119,6 @@ html_editor_view_dispose (GObject *object)
 
        priv = E_HTML_EDITOR_VIEW_GET_PRIVATE (object);
 
-       g_clear_object (&priv->selection);
-
        if (priv->convertor_web_view != NULL) {
                g_object_unref (priv->convertor_web_view);
                priv->convertor_web_view = NULL;
@@ -2139,6 +2142,14 @@ html_editor_view_dispose (GObject *object)
                priv->mail_settings = NULL;
        }
 
+       if (priv->web_extension_watch_name_id > 0) {
+               g_bus_unwatch_name (priv->web_extension_watch_name_id);
+               priv->web_extension_watch_name_id = 0;
+       }
+
+       g_clear_object (&priv->selection);
+       g_clear_object (&priv->web_extension);
+
        g_hash_table_remove_all (priv->inline_images);
 
        /* Chain up to parent's dispose() method. */
@@ -2166,10 +2177,22 @@ html_editor_view_finalize (GObject *object)
 static void
 html_editor_view_constructed (GObject *object)
 {
+
        e_extensible_load_extensions (E_EXTENSIBLE (object));
 
        /* Chain up to parent's constructed() method. */
        G_OBJECT_CLASS (e_html_editor_view_parent_class)->constructed (object);
+/* FIXME WK2
+       WebKitSettings *web_settings;
+
+       web_settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (object));
+       g_object_set (
+               G_OBJECT (web_settings),
+               "enable-dom-paste", TRUE,
+               "enable-file-access-from-file-uris", TRUE,
+               "enable-spell-checking", TRUE,
+               NULL);
+*/
 }
 
 static void
@@ -2944,6 +2967,118 @@ html_editor_view_resource_requested (WebKitWebView *web_view,
 }
 
 static void
+web_extension_proxy_created_cb (GDBusProxy *proxy,
+                                GAsyncResult *result,
+                                EHTMLEditorView *view)
+{
+       GError *error = NULL;
+
+       view->priv->web_extension = g_dbus_proxy_new_finish (result, &error);
+       if (!view->priv->web_extension) {
+               g_warning ("Error creating web extension proxy: %s\n", error->message);
+               g_error_free (error);
+       }
+}
+
+static void
+web_extension_appeared_cb (GDBusConnection *connection,
+                           const gchar *name,
+                           const gchar *name_owner,
+                           EHTMLEditorView *view)
+{
+       g_dbus_proxy_new (
+               connection,
+               G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
+               G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+               NULL,
+               name,
+               E_HTML_EDITOR_WEB_EXTENSION_OBJECT_PATH,
+               E_HTML_EDITOR_WEB_EXTENSION_INTERFACE
+               NULL,
+               (GAsyncReadyCallback) web_extension_proxy_created_cb,
+               view);
+}
+
+static void
+web_extension_vanished_cb (GDBusConnection *connection,
+                           const gchar *name,
+                           EHTMLEditorView *view)
+{
+       g_clear_object (&web_view->priv->web_extension);
+}
+
+static void
+html_editor_view_watch_web_extension (EHTMLEditorView *view)
+{
+       view->priv->web_extension_watch_name_id =
+               g_bus_watch_name (
+                       G_BUS_TYPE_SESSION,
+                       E_HTML_EDITOR_WEB_EXTENSION_SERVICE_NAME,
+                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                       (GBusNameAppearedCallback) web_extension_appeared_cb,
+                       (GBusNameVanishedCallback) web_extension_vanished_cb,
+                       view,
+                       NULL);
+}
+
+GDBusProxy *
+e_html_editor_view_get_web_extension_proxy (EHTMLEditorView *view)
+{
+       g_return_val_if_fail (E_IS_HTML_EDITOR_VIEW (view), NULL);
+
+       return view->priv->web_extension;
+}
+
+static GObjectConstructParam*
+find_property(guint n_properties,
+              GObjectConstructParam* properties,
+              GParamSpec* param_spec)
+{
+       while (n_properties--) {
+               if (properties->pspec == param_spec)
+                       return properties;
+               properties++;
+       }
+
+       return NULL;
+}
+
+static GObject*
+html_editor_view_constructor (GType type,
+                              guint n_construct_properties,
+                              GObjectConstructParam *construct_properties)
+{
+       GObjectClass* object_class;
+       GParamSpec* param_spec;
+       GObjectConstructParam *param = NULL;
+
+       object_class = G_OBJECT_CLASS(g_type_class_ref(type));
+       g_return_val_if_fail(object_class != NULL, NULL);
+
+       if (construct_properties && n_construct_properties != 0) {
+               param_spec = g_object_class_find_property(object_class, "settings");
+               if ((param = find_property(n_construct_properties, construct_properties, param_spec)))
+                       g_value_take_object (param->value, e_web_view_get_default_webkit_settings ());
+               param_spec = g_object_class_find_property(object_class, "user-content-manager");
+               if ((param = find_property(n_construct_properties, construct_properties, param_spec)))
+                       g_value_take_object (param->value, webkit_user_content_manager_new ());
+       }
+
+       g_type_class_unref (object_class);
+
+       return G_OBJECT_CLASS (e_web_view_parent_class)->constructor(type, n_construct_properties, 
construct_properties);
+}
+
+static void
+html_editor_view_initialize_web_context (void)
+{
+       WebKitWebContext *web_context = webkit_web_context_get_default ();
+
+       webkit_web_context_set_cache_model (
+               web_context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
+}
+
+static void
 e_html_editor_view_class_init (EHTMLEditorViewClass *class)
 {
        GObjectClass *object_class;
@@ -2951,7 +3086,10 @@ e_html_editor_view_class_init (EHTMLEditorViewClass *class)
 
        g_type_class_add_private (class, sizeof (EHTMLEditorViewPrivate));
 
+       html_editor_view_initialize_web_context ();
+
        object_class = G_OBJECT_CLASS (class);
+       object_class->constructor = html_editor_view_constructor;
        object_class->get_property = html_editor_view_get_property;
        object_class->set_property = html_editor_view_set_property;
        object_class->dispose = html_editor_view_dispose;
@@ -4843,6 +4981,14 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
 }
 
 static void
+initialize_web_extensions_cb (WebKitWebContext *web_context)
+{
+       /* Set the web extensions dir before the process is launched */
+       webkit_web_context_set_web_extensions_directory (
+               web_context, EVOLUTION_WEB_EXTENSIONS_DIR);
+}
+
+static void
 html_plain_text_convertor_load_changed (WebKitWebView *web_view,
                                         WebKitLoadEvent event,
                                         EHTMLEditorView *view)
@@ -4900,19 +5046,6 @@ e_html_editor_view_init (EHTMLEditorView *view)
        webkit_web_view_set_editable (WEBKIT_WEB_VIEW (view), TRUE);
        settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (view));
 
-       g_object_set (
-               G_OBJECT (settings),
-               "enable-developer-extras", TRUE,
-               "enable-dom-paste", TRUE,
-               "enable-file-access-from-file-uris", TRUE,
-               "enable-plugins", FALSE,
-               "enable-scripts", FALSE,
-               "enable-spell-checking", TRUE,
-               "respect-image-orientation", TRUE,
-               NULL);
-
-       webkit_web_view_set_settings (WEBKIT_WEB_VIEW (view), settings);
-
        view->priv->old_settings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) 
g_variant_unref);
 
        /* Override the spell-checker, use our own */
@@ -4941,11 +5074,17 @@ e_html_editor_view_init (EHTMLEditorView *view)
                view, "load-changed",
                G_CALLBACK (html_editor_view_load_changed), NULL);
 
+       e_signal_connect (
+               webkit_web_context_get_default (), "initialize-web-extensions",
+               G_CALLBACK (initialize_web_extensions_cb), NULL);
+
        view->priv->selection = g_object_new (
                E_TYPE_HTML_EDITOR_SELECTION,
                "html-editor-view", view,
                NULL);
 
+       html_editor_view_watch_web_extension (view);
+
        g_settings = g_settings_new ("org.gnome.desktop.interface");
        g_signal_connect (
                g_settings, "changed::font-name",
@@ -5058,94 +5197,6 @@ e_html_editor_view_get_selection (EHTMLEditorView *view)
 }
 
 /**
- * e_html_editor_view_exec_command:
- * @view: an #EHTMLEditorView
- * @command: an #EHTMLEditorViewCommand to execute
- * @value: value of the command (or @NULL if the command does not require value)
- *
- * The function will fail when @value is @NULL or empty but the current @command
- * requires a value to be passed. The @value is ignored when the @command does
- * not expect any value.
- *
- * Returns: @TRUE when the command was succesfully executed, @FALSE otherwise.
- */
-gboolean
-e_html_editor_view_exec_command (EHTMLEditorView *view,
-                                 EHTMLEditorViewCommand command,
-                                 const gchar *value)
-{
-       WebKitDOMDocument *document;
-       const gchar *cmd_str = 0;
-       gboolean has_value;
-
-       g_return_val_if_fail (E_IS_HTML_EDITOR_VIEW (view), FALSE);
-
-#define CHECK_COMMAND(cmd,str,val) case cmd:\
-       if (val) {\
-               g_return_val_if_fail (value && *value, FALSE);\
-       }\
-       has_value = val; \
-       cmd_str = str;\
-       break;
-
-       switch (command) {
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_BACKGROUND_COLOR, "BackColor", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_BOLD, "Bold", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_COPY, "Copy", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_CREATE_LINK, "CreateLink", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_CUT, "Cut", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_DEFAULT_PARAGRAPH_SEPARATOR, 
"DefaultParagraphSeparator", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_DELETE, "Delete", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FIND_STRING, "FindString", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_NAME, "FontName", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_SIZE, "FontSize", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FONT_SIZE_DELTA, "FontSizeDelta", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORE_COLOR, "ForeColor", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORMAT_BLOCK, "FormatBlock", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_FORWARD_DELETE, "ForwardDelete", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_HILITE_COLOR, "HiliteColor", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INDENT, "Indent", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_HORIZONTAL_RULE, "InsertHorizontalRule", 
FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, "InsertHTML", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_IMAGE, "InsertImage", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_LINE_BREAK, "InsertLineBreak", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT, 
"InsertNewlineInQuotedContent", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_ORDERED_LIST, "InsertOrderedList", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_PARAGRAPH, "InsertParagraph", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_TEXT, "InsertText", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_INSERT_UNORDERED_LIST, "InsertUnorderedList", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_ITALIC, "Italic", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_CENTER, "JustifyCenter", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_FULL, "JustifyFull", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_LEFT, "JustifyLeft", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_NONE, "JustifyNone", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_JUSTIFY_RIGHT, "JustifyRight", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_OUTDENT, "Outdent", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE, "Paste", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE_AND_MATCH_STYLE, "PasteAndMatchStyle", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PASTE_AS_PLAIN_TEXT, "PasteAsPlainText", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_PRINT, "Print", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_REDO, "Redo", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_REMOVE_FORMAT, "RemoveFormat", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SELECT_ALL, "SelectAll", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_STRIKETHROUGH, "Strikethrough", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_STYLE_WITH_CSS, "StyleWithCSS", TRUE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SUBSCRIPT, "Subscript", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_SUPERSCRIPT, "Superscript", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_TRANSPOSE, "Transpose", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNDERLINE, "Underline", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNDO, "Undo", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNLINK, "Unlink", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_UNSELECT, "Unselect", FALSE)
-               CHECK_COMMAND (E_HTML_EDITOR_VIEW_COMMAND_USE_CSS, "UseCSS", TRUE)
-       }
-
-       document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-       return webkit_dom_document_exec_command (
-               document, cmd_str, FALSE, has_value ? value : "" );
-}
-
-/**
  * e_html_editor_view_get_changed:
  * @view: an #EHTMLEditorView
  *
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index 70d5fb7..d2bc6d3 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -78,12 +78,12 @@ struct _EHTMLEditorViewClass {
 GType          e_html_editor_view_get_type     (void) G_GNUC_CONST;
 EHTMLEditorView *
                e_html_editor_view_new          (void);
+GDBusProxy *
+               e_html_editor_view_get_web_extension_proxy
+                                               (EHTMLEditorView *view);
 EHTMLEditorSelection *
                e_html_editor_view_get_selection
                                                (EHTMLEditorView *view);
-gboolean       e_html_editor_view_exec_command (EHTMLEditorView *view,
-                                                EHTMLEditorViewCommand command,
-                                                const gchar *value);
 gboolean       e_html_editor_view_get_changed  (EHTMLEditorView *view);
 void           e_html_editor_view_set_changed  (EHTMLEditorView *view,
                                                 gboolean changed);
@@ -138,12 +138,15 @@ void              e_html_editor_view_embed_styles (EHTMLEditorView *view);
 void           e_html_editor_view_remove_embed_styles
                                                (EHTMLEditorView *view);
 void           e_html_editor_view_update_fonts (EHTMLEditorView *view);
+/*
 WebKitDOMElement *
                e_html_editor_view_get_element_under_mouse_click
                                                (EHTMLEditorView *view);
+*/
 void           e_html_editor_view_check_magic_links
                                                (EHTMLEditorView *view,
                                                 gboolean while_typing);
+/*
 WebKitDOMElement *
                e_html_editor_view_quote_plain_text_element
                                                (EHTMLEditorView *view,
@@ -151,6 +154,7 @@ WebKitDOMElement *
 WebKitDOMElement *
                e_html_editor_view_quote_plain_text
                                                (EHTMLEditorView *view);
+*/
 void           e_html_editor_view_dequote_plain_text
                                                (EHTMLEditorView *view);
 void           e_html_editor_view_turn_spell_check_off
diff --git a/e-util/e-html-editor.c b/e-util/e-html-editor.c
index ec06334..cdb3d81 100644
--- a/e-util/e-html-editor.c
+++ b/e-util/e-html-editor.c
@@ -304,7 +304,7 @@ html_editor_spell_checkers_foreach (EHTMLEditor *editor,
 
 static void
 html_editor_update_actions (EHTMLEditor *editor,
-                            GdkEventButton *event)
+                            guint flags)
 {
        WebKitWebView *web_view;
        WebKitSpellChecker *checker;
@@ -329,29 +329,16 @@ html_editor_update_actions (EHTMLEditor *editor,
        web_view = WEBKIT_WEB_VIEW (view);
        manager = e_html_editor_get_ui_manager (editor);
 
-       editor->priv->image = NULL;
-       editor->priv->table_cell = NULL;
-
-       /* Update context menu item visibility. */
-       hit_test = webkit_web_view_get_hit_test_result (web_view, event);
-       g_object_get (
-               G_OBJECT (hit_test),
-               "context", &context,
-               "inner-node", &node, NULL);
-       g_object_unref (hit_test);
-
-       visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE);
+       visible = (flags & E_HTML_EDITOR_NODE_IS_IMAGE);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_IMAGE), visible);
-       if (visible)
-               editor->priv->image = node;
 
-       visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK);
+       visible = (flags & E_HTML_EDITOR_NODE_IS_ANCHOR);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_LINK), visible);
 
-       visible = (WEBKIT_DOM_IS_HTMLHR_ELEMENT (node));
+       visible = (flags & E_HTML_EDITOR_NODE_IS_HR);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_RULE), visible);
 
-       visible = (WEBKIT_DOM_IS_TEXT (node));
+       visible = (flags & E_HTML_EDITOR_NODE_IS_TEXT);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_TEXT), visible);
 
        visible =
@@ -365,13 +352,10 @@ html_editor_update_actions (EHTMLEditor *editor,
         *   - Cursor is on a link.
         *   - Cursor is on an image that has a URL or target.
         */
-       visible = (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (node) ||
-               (e_html_editor_dom_node_find_parent_element (node, "A") != NULL));
+       visible = (flags & E_HTML_EDITOR_NODE_IS_ANCHOR);
        gtk_action_set_visible (ACTION (CONTEXT_REMOVE_LINK), visible);
 
-       visible = (WEBKIT_DOM_IS_HTML_TABLE_CELL_ELEMENT (node) ||
-               (e_html_editor_dom_node_find_parent_element (node, "TD") != NULL) ||
-               (e_html_editor_dom_node_find_parent_element (node, "TH") != NULL));
+       visible = (flags & E_HTML_EDITOR_NODE_IS_TABLE_CELL);
        gtk_action_set_visible (ACTION (CONTEXT_DELETE_CELL), visible);
        gtk_action_set_visible (ACTION (CONTEXT_DELETE_COLUMN), visible);
        gtk_action_set_visible (ACTION (CONTEXT_DELETE_ROW), visible);
@@ -382,12 +366,8 @@ html_editor_update_actions (EHTMLEditor *editor,
        gtk_action_set_visible (ACTION (CONTEXT_INSERT_ROW_BELOW), visible);
        gtk_action_set_visible (ACTION (CONTEXT_INSERT_TABLE), visible);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_CELL), visible);
-       if (visible)
-               editor->priv->table_cell = node;
 
-       /* Note the |= (cursor must be in a table cell). */
-       visible |= (WEBKIT_DOM_IS_HTML_TABLE_ELEMENT (node) ||
-               (e_html_editor_dom_node_find_parent_element (node, "TABLE") != NULL));
+       visible = (flags & E_HTML_EDITOR_NODE_IS_TABLE);
        gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_TABLE), visible);
 
        /********************** Spell Check Suggestions **********************/
@@ -494,24 +474,34 @@ html_editor_spell_languages_changed (EHTMLEditor *editor)
 }
 
 static gboolean
-html_editor_show_popup (EHTMLEditor *editor,
-                        GdkEventButton *event,
-                        gpointer user_data)
+html_editor_context_menu_cb (WebKitWebView *webkit_web_view,
+                             WebKitContextMenu *context_menu,
+                             GdkEvent *event,
+                             WebKitHitTestResult *hit_test_result,
+                             EHTMLEditor *editor)
 {
+       WebKitHitTestResultContext context;
        GtkWidget *menu;
+       guint flags = 0;
+
+       if (!hit_test_result)
+               return FALSE;
+
+       webkit_context_menu_remove_all (context_menu);
 
+       /* COUNT FLAGS */
        menu = e_html_editor_get_managed_widget (editor, "/context-menu");
 
-       g_signal_emit (editor, signals[UPDATE_ACTIONS], 0, event);
+       g_signal_emit (editor, signals[UPDATE_ACTIONS], 0, flags);
 
-       if (event != NULL)
+       if (event)
                gtk_menu_popup (
                        GTK_MENU (menu), NULL, NULL, NULL,
-                       user_data, event->button, event->time);
+                       GTK_WIDGET (webkit_web_view), event->button, event->time);
        else
                gtk_menu_popup (
                        GTK_MENU (menu), NULL, NULL, NULL,
-                       user_data, 0, gtk_get_current_event_time ());
+                       GTK_WIDGET (webkit_web_view), 0, gtk_get_current_event_time ());
 
        return TRUE;
 }
@@ -652,9 +642,9 @@ html_editor_constructed (GObject *object)
        widget = GTK_WIDGET (e_html_editor_get_view (editor));
        gtk_container_add (GTK_CONTAINER (priv->scrolled_window), widget);
        gtk_widget_show (widget);
-       g_signal_connect_swapped (
-               widget, "popup-event",
-               G_CALLBACK (html_editor_show_popup), editor);
+       g_signal_connect (
+               widget, "context-menu",
+               G_CALLBACK (html_editor_context_menu_cb), editor);
 
        /* Add some combo boxes to the "edit" toolbar. */
 
@@ -833,7 +823,7 @@ e_html_editor_class_init (EHTMLEditorClass *class)
                NULL, NULL,
                g_cclosure_marshal_VOID__BOXED,
                G_TYPE_NONE, 1,
-               GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+               G_TYPE_UINT);
 
        signals[SPELL_LANGUAGES_CHANGED] = g_signal_new (
                "spell-languages-changed",
diff --git a/e-util/e-mail-signature-preview.c b/e-util/e-mail-signature-preview.c
index 9312ff7..d511ab8 100644
--- a/e-util/e-mail-signature-preview.c
+++ b/e-util/e-mail-signature-preview.c
@@ -56,30 +56,27 @@ G_DEFINE_TYPE (
        E_TYPE_WEB_VIEW)
 
 static void
-signature_preview_document_loaded_cb (WebKitWebView *web_view,
-                                      WebKitWebFrame *web_frame,
-                                      gpointer user_data)
+signature_preview_load_changed_cb (WebKitWebView *web_view,
+                                   WebKitLoadEvent load_event)
 {
        GDBusProxy *web_extension;
-       GVariant* result;
 
        if (load_event != WEBKIT_LOAD_FINISHED)
                return;
 
        web_extension = e_web_view_get_web_extension_proxy (E_WEB_VIEW (web_view));
        if (web_extension) {
-               result = g_dbus_proxy_call_sync (
-                               web_extension,
-                               "ReplaceLocalImageLinks",
-                               g_variant_new (
-                                       "(t)",
-                                       webkit_web_view_get_page_id (web_view)),
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL, //cancellable
-                               NULL);
-               if (result)
-                       g_variant_unref (result);
+               g_dbus_proxy_call (
+                       web_extension,
+                       "ReplaceLocalImageLinks",
+                       g_variant_new (
+                               "(t)",
+                               webkit_web_view_get_page_id (web_view)),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       NULL,
+                       NULL);
        }
 }
 
@@ -122,16 +119,14 @@ mail_signature_preview_load_cb (ESource *source,
        mime_type = e_source_mail_signature_get_mime_type (extension);
 
        if (g_strcmp0 (mime_type, "text/html") == 0) {
-               webkit_web_view_load_string (
-                       WEBKIT_WEB_VIEW (preview), contents,
-                       "text/html", "UTF-8", "file:///");
+               webkit_web_view_load_html (
+                       WEBKIT_WEB_VIEW (preview), contents, "file:///");
        } else {
                gchar *string;
 
                string = g_markup_printf_escaped ("<pre>%s</pre>", contents);
-               webkit_web_view_load_string (
-                       WEBKIT_WEB_VIEW (preview), string,
-                       "text/html", "UTF-8", "file:///");
+               webkit_web_view_load_html (
+                       WEBKIT_WEB_VIEW (preview), string, "file:///");
                g_free (string);
        }
 
@@ -337,7 +332,7 @@ e_mail_signature_preview_init (EMailSignaturePreview *preview)
 
        g_signal_connect (
                preview, "load-changed",
-               G_CALLBACK (signature_preview_document_loaded_cb), NULL);
+               G_CALLBACK (signature_preview_load_changed_cb), NULL);
 }
 
 GtkWidget *
diff --git a/e-util/e-search-bar.c b/e-util/e-search-bar.c
index 3410509..f3026e2 100644
--- a/e-util/e-search-bar.c
+++ b/e-util/e-search-bar.c
@@ -245,26 +245,17 @@ search_bar_toggled_cb (ESearchBar *search_bar)
 static void
 web_view_load_changed_cb (WebKitWebView *webkit_web_view,
                           WebKitLoadEvent load_event,
-                          gpointer user_data)
+                          ESearchBar *search_bar)
 {
-       ESearchBar *search_bar;
-
-       status = webkit_web_view_get_load_status (webkit_web_view);
        if (load_event != WEBKIT_LOAD_FINISHED)
                return;
 
-       if (!user_data)
-               return;
-
-       search_bar = E_SEARCH_BAR (user_data);
-
        if (gtk_widget_get_visible (GTK_WIDGET (search_bar))) {
                if (search_bar->priv->active_search != NULL) {
                       search_bar_find (search_bar, TRUE);
                }
-       } else {
+       } else
                e_web_view_update_highlights (search_bar->priv->web_view);
-       }
 }
 
 static void
@@ -284,7 +275,7 @@ search_bar_set_web_view (ESearchBar *search_bar,
        search_bar->priv->find_controller = find_controller;
 
        e_signal_connect_notify (
-               web_view, "notify::changed",
+               web_view, "load-changed",
                G_CALLBACK (web_view_load_changed_cb), search_bar);
 
        g_signal_connect (
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 9f0c885..4c9a550 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -78,6 +78,8 @@ struct _EWebViewPrivate {
        guint web_extension_watch_name_id;
 
        WebKitFindController *find_controller;
+       gulong found_text_handler_id;
+       gulong failed_to_find_text_handler_id;
 };
 
 struct _AsyncContext {
@@ -397,11 +399,11 @@ web_view_set_find_controller (EWebView *web_view)
        find_controller =
                webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW (web_view));
 
-       g_signal_connect (
+       web_view->priv->found_text_handler_id = g_signal_connect (
                find_controller, "found-text",
                G_CALLBACK (webkit_find_controller_found_text_cb), web_view);
 
-       g_signal_connect (
+       web_view->priv->failed_to_find_text_handler_id = g_signal_connect (
                find_controller, "failed-to-find-text",
                G_CALLBACK (webkit_find_controller_failed_to_found_text_cb), web_view);
 
@@ -411,19 +413,13 @@ web_view_set_find_controller (EWebView *web_view)
 static void
 web_view_update_document_highlights (EWebView *web_view)
 {
-       WebKitFindController *find_controller;
        GList *head, *link;
 
-       if (!web_view->priv->find_controller)
-               web_view_set_find_controller (web_view);
-
-       find_controller = web_view->priv->find_controller;
-
        head = g_queue_peek_head_link (&web_view->priv->highlights);
 
        for (link = head; link != NULL; link = g_list_next (link)) {
                webkit_find_controller_search (
-                       find_controller,
+                       web_view->priv->find_controller,
                        link->data,
                        WEBKIT_FIND_OPTIONS_NONE,
                        G_MAXUINT);
@@ -896,6 +892,20 @@ web_view_dispose (GObject *object)
                priv->web_extension_watch_name_id = 0;
        }
 
+       if (priv->found_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->found_text_handler_id);
+               priv->found_text_handler_id = 0;
+       }
+
+       if (priv->failed_to_find_text_handler_id > 0) {
+               g_signal_handler_disconnect (
+                       priv->find_controller,
+                       priv->failed_to_find_text_handler_id);
+               priv->failed_to_find_text_handler_id = 0;
+       }
+
        g_clear_object (&priv->ui_manager);
        g_clear_object (&priv->open_proxy);
        g_clear_object (&priv->print_proxy);
@@ -1266,7 +1276,7 @@ web_extension_appeared_cb (GDBusConnection *connection,
                EVOLUTION_WEB_EXTENSION_OBJECT_PATH,
                EVOLUTION_WEB_EXTENSION_INTERFACE,
                NULL,
-               (GAsyncReadyCallback)web_extension_proxy_created_cb,
+               (GAsyncReadyCallback) web_extension_proxy_created_cb,
                web_view);
 }
 
@@ -1288,7 +1298,8 @@ web_view_watch_web_extension (EWebView *web_view)
                        G_BUS_NAME_WATCHER_FLAGS_NONE,
                        (GBusNameAppearedCallback) web_extension_appeared_cb,
                        (GBusNameVanishedCallback) web_extension_vanished_cb,
-                       web_view, NULL);
+                       web_view,
+                       NULL);
 }
 
 GDBusProxy *
@@ -2078,6 +2089,8 @@ e_web_view_init (EWebView *web_view)
                web_view, "state-flags-changed",
                G_CALLBACK (style_updated_cb), NULL);
 
+       web_view_set_find_controller (web_view);
+
        ui_manager = gtk_ui_manager_new ();
        web_view->priv->ui_manager = ui_manager;
 
@@ -2715,9 +2728,6 @@ e_web_view_clear_highlights (EWebView *web_view)
 {
        g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-       if (!web_view->priv->find_controller)
-               web_view_set_find_controller (web_view);
-
        webkit_find_controller_search_finish (web_view->priv->find_controller);
 
        while (!g_queue_is_empty (&web_view->priv->highlights))
@@ -4020,161 +4030,3 @@ e_web_view_add_css_rule_into_style_sheet (EWebView *web_view,
                        NULL);
        }
 }
-
-gboolean
-element_has_id (WebKitDOMElement *element,
-                const gchar* id)
-{
-       gchar *element_id;
-
-       if (!element)
-               return FALSE;
-
-       if (!WEBKIT_DOM_IS_ELEMENT (element))
-               return FALSE;
-
-       element_id = webkit_dom_element_get_id (element);
-
-       if (g_ascii_strcasecmp (element_id, id) != 0) {
-               g_free (element_id);
-               return FALSE;
-       }
-       g_free (element_id);
-
-       return TRUE;
-}
-
-gboolean
-element_has_tag (WebKitDOMElement *element,
-                 const gchar* tag)
-{
-       gchar *element_tag;
-
-       if (!WEBKIT_DOM_IS_ELEMENT (element))
-               return FALSE;
-
-       element_tag = webkit_dom_node_get_local_name (WEBKIT_DOM_NODE (element));
-
-       if (g_ascii_strcasecmp (element_tag, tag) != 0) {
-               g_free (element_tag);
-               return FALSE;
-       }
-       g_free (element_tag);
-
-       return TRUE;
-}
-
-gboolean
-element_has_class (WebKitDOMElement *element,
-                const gchar* class)
-{
-       gchar *element_class;
-
-       if (!element)
-               return FALSE;
-
-       if (!WEBKIT_DOM_IS_ELEMENT (element))
-               return FALSE;
-
-       element_class = webkit_dom_element_get_class_name (element);
-
-       if (g_strstr_len (element_class, -1, class)) {
-               g_free (element_class);
-               return TRUE;
-       }
-       g_free (element_class);
-
-       return FALSE;
-}
-
-void
-element_add_class (WebKitDOMElement *element,
-                   const gchar* class)
-{
-       gchar *element_class;
-       gchar *new_class;
-
-       if (!WEBKIT_DOM_IS_ELEMENT (element))
-               return;
-
-       if (element_has_class (element, class))
-               return;
-
-       element_class = webkit_dom_element_get_class_name (element);
-
-       if (g_strcmp0 (element_class, "") == 0)
-               new_class = g_strdup (class);
-       else
-               new_class = g_strconcat (element_class, " ", class, NULL);
-
-       webkit_dom_element_set_class_name (element, new_class);
-
-       g_free (element_class);
-       g_free (new_class);
-}
-
-void
-element_remove_class (WebKitDOMElement *element,
-                      const gchar* class)
-{
-       gchar *element_class;
-       GString *result;
-
-       if (!WEBKIT_DOM_IS_ELEMENT (element))
-               return;
-
-       if (!element_has_class (element, class))
-               return;
-
-       element_class = webkit_dom_element_get_class_name (element);
-
-       if (g_strcmp0 (element_class, class) == 0) {
-               webkit_dom_element_remove_attribute (element, "class");
-               g_free (element_class);
-               return;
-       }
-
-       result = e_str_replace_string (element_class, class, "");
-       if (result) {
-               webkit_dom_element_set_class_name (element, result->str);
-               g_string_free (result, TRUE);
-       }
-
-       g_free (element_class);
-}
-
-void
-remove_node (WebKitDOMNode *node)
-{
-       WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
-
-       /* Check if the parent exists, if so it means that the node is still
-        * in the DOM or at least the parent is. If it doesn't exists it is not
-        * in the DOM and we can free it. */
-       if (parent)
-               webkit_dom_node_remove_child (parent, node, NULL);
-       else
-               g_object_unref (node);
-}
-
-void
-remove_node_if_empty (WebKitDOMNode *node)
-{
-       if (!WEBKIT_DOM_IS_NODE (node))
-               return;
-
-       if (!webkit_dom_node_get_first_child (node)) {
-               remove_node (node);
-       } else {
-               gchar *text_content;
-
-               text_content = webkit_dom_node_get_text_content (node);
-               if (!text_content)
-                       remove_node (node);
-
-               if (text_content && !*text_content)
-                       remove_node (node);
-
-               g_free (text_content);
-       }
-}
diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h
index a1ddde6..015bd50 100644
--- a/e-util/e-web-view.h
+++ b/e-util/e-web-view.h
@@ -235,10 +235,6 @@ void               e_web_view_request              (EWebView *web_view,
 GInputStream * e_web_view_request_finish       (EWebView *web_view,
                                                 GAsyncResult *result,
                                                 GError **error);
-void           e_web_view_register_uri_scheme  (EWebView *web_view,
-                                                EURIScheme scheme,
-                                                gpointer user_callback,
-                                                gpointer user_data);
 void           e_web_view_install_request_handler
                                                (EWebView *web_view,
                                                 GType handler_type);
@@ -250,18 +246,6 @@ void               e_web_view_add_css_rule_into_style_sheet
                                                 const gchar *style_sheet_id,
                                                 const gchar *selector,
                                                 const gchar *style);
-gboolean       element_has_id                  (WebKitDOMElement *element,
-                                                const gchar* id);
-gboolean       element_has_tag                 (WebKitDOMElement *element,
-                                                const gchar* tag);
-gboolean       element_has_class               (WebKitDOMElement *element,
-                                                const gchar* class);
-void           element_add_class               (WebKitDOMElement *element,
-                                                const gchar* class);
-void           element_remove_class            (WebKitDOMElement *element,
-                                                const gchar* class);
-void           remove_node                     (WebKitDOMNode *node);
-void           remove_node_if_empty            (WebKitDOMNode *node);
 G_END_DECLS
 
 #endif /* E_WEB_VIEW_H */
diff --git a/e-util/web-extensions/Makefile.am b/e-util/web-extensions/Makefile.am
new file mode 100644
index 0000000..335ea9b
--- /dev/null
+++ b/e-util/web-extensions/Makefile.am
@@ -0,0 +1,23 @@
+webextensions_LTLIBRARIES = libehtmleditorwebextension.la
+
+libevolutionwebextension_la_SOURCES =                  \
+       e-html-editor-web-extension.c                   \
+       e-html-editor-web-extension.h
+
+libevolutionwebextension_la_CPPFLAGS =                 \
+       $(AM_CPPFLAGS)                                  \
+       -I$(top_srcdir)                                 \
+       $(EVOLUTION_DATA_SERVER_CFLAGS)                 \
+       $(GNOME_PLATFORM_CFLAGS)                        \
+       $(GTKHTML_CFLAGS)                               \
+       $(WEB_EXTENSIONS_CFLAGS)
+
+libevolutionwebextension_la_LIBADD =                   \
+       $(top_builddir)/e-util/libevolution-util.la     \
+       $(EVOLUTION_DATA_SERVER_LIBS)                   \
+       $(GNOME_PLATFORM_LIBS)                          \
+       $(GTKHTML_LIBS)                                 \
+       $(WEB_EXTENSIONS_LIBS)
+
+libevolutionwebextension_la_LDFLAGS =                  \
+       -module -avoid-version -no-undefined
diff --git a/e-util/web-extensions/e-html-editor-web-extension.c 
b/e-util/web-extensions/e-html-editor-web-extension.c
new file mode 100644
index 0000000..7c2091e
--- /dev/null
+++ b/e-util/web-extensions/e-html-editor-web-extension.c
@@ -0,0 +1,1724 @@
+/*
+ * e-html-editor-web-extension.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-html-editor-web-extension.h"
+
+#include <gio/gio.h>
+#include <gtk/gtk.h>
+#include <webkit2/webkit-web-extension.h>
+
+#include <string.h>
+
+#include <e-util/e-dom-utils.h>
+#include <e-util/e-html-editor-cell-dialog-dom-functions.h>
+#include <e-util/e-html-editor-image-dialog-dom-functions.h>
+#include <e-util/e-html-editor-link-dialog-dom-functions.h>
+
+/* FIXME Clean it */
+static GDBusConnection *dbus_connection;
+
+/* These properties show the actual state of EHTMLEditorView */
+static EHTMLEditorSelectionAlignment alignment;
+static gchar *background_color = NULL;
+static EHTMLEditorSelectionBlockFormat block_format;
+static gboolean bold = FALSE;
+/* FIXME XXX WK2
+static GdkRGBA *font_color = NULL; */
+static gchar *font_color = NULL;
+static gchar *font_name = NULL;
+static gint font_size;
+static gboolean indented = FALSE;
+static gboolean italic = FALSE;
+static gboolean monospaced = FALSE;
+static gboolean strikethrough = FALSE;
+static gboolean subscript = FALSE;
+static gboolean superscript = FALSE;
+/* FIXME XXX WK2 is it needed?
+static gchar *text = NULL; */
+static gboolean underline = FALSE;
+
+static const char introspection_xml[] =
+"<node>"
+"  <interface name='org.gnome.Evolution.WebExtension'>"
+"<!-- ********************************************************* -->"
+"<!--                       PROPERTIES                          -->"
+"<!-- ********************************************************* -->"
+"    <property type='b' name='ForceImageLoad' access='readwrite'/>"
+"<!-- ********************************************************* -->"
+"<!-- These properties show the actual state of EHTMLEditorView -->"
+"<!-- ********************************************************* -->"
+"    <property type='b' name='Alignment' access='readwrite'/>"
+"    <property type='s' name='BackgroundColor' access='readwrite'/>"
+"    <property type='u' name='BlockFormat' access='readwrite'/>"
+"    <property type='b' name='Bold' access='readwrite'/>"
+"    <property type='s' name='FontColor' access='readwrite'/>"
+"    <property type='s' name='FontName' access='readwrite'/>"
+"    <property type='u' name='FontSize' access='readwrite'/>"
+"    <property type='b' name='Indented' access='readwrite'/>"
+"    <property type='b' name='Italic' access='readwrite'/>"
+"    <property type='b' name='Monospaced' access='readwrite'/>"
+"    <property type='b' name='Strikethrough' access='readwrite'/>"
+"    <property type='b' name='Subscript' access='readwrite'/>"
+"    <property type='b' name='Superscript' access='readwrite'/>"
+"    <property type='b' name='Underline' access='readwrite'/>"
+"<!-- ********************************************************* -->"
+"<!--                          METHODS                          -->"
+"<!-- ********************************************************* -->"
+"<!-- ********************************************************* -->"
+"<!--                          GENERIC                          -->"
+"<!-- ********************************************************* -->"
+"    <method name='ElementHasAttribute'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='attribute' direction='in'/>"
+"      <arg type='b' name='has_attribute' direction='out'/>"
+"    </method>"
+"    <method name='ElementGetAttribute'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='attribute' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ElementRemoveAttribute'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='attribute' direction='in'/>"
+"    </method>"
+"    <method name='ElementSetAttribute'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='attribute' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ElementGetTagName'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='tag_name' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='align' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetVAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='v_align' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetNoWrap'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='b' name='no_wrap' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='width' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetRowSpan'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='row_span' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetColSpan'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='col_span' direction='out'/>"
+"    </method>"
+"    <method name='TableCellElementGetBgColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='color' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetAlt'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetAlt'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetHeight'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetHeight'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementGetNaturalWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementGetNaturalHeight'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementSetHSpace'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetHSpace'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetVSpace'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetVSpace'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='i' name='value' direction='out'/>"
+"    </method>"
+"    <method name='ImageElementSetBorder'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='ImageElementGetBorder'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='BodySetTextColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='BodyGetTextColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='BodySetLinkColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='BodyGetLinkColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='BodySetBgColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='BodyGetBgColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='BodyGetBackground'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='HRElementSetAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='HRElementGetAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='HRElementSetSize'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='HRElementGetSize'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='HRElementSetWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='HRElementGetWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"    <method name='HRElementSetNoShade'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='b' name='value' direction='in'/>"
+"    </method>"
+"    <method name='HRElementGetNoShade'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"      <arg type='b' name='value' direction='out'/>"
+"    </method>"
+"<!-- ********************************************************* -->"
+"<!--     Functions that are used in EHTMLEditorCellDialog      -->"
+"<!-- ********************************************************* -->"
+"    <method name='EHTMLEditorCellDialogMarkCurrentCellElement'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='element_id' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementVAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementAlign'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementNoWrap'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='b' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementHeaderStyle'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='b' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementWidth'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    <method name='EHTMLEditorCellDialogSetElementColSpan'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementRowSpan'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='i' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorCellDialogSetElementBgColor'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"      <arg type='u' name='scope' direction='in'/>"
+"    </method>"
+"<!-- ********************************************************* -->"
+"<!--     Functions that are used in EHTMLEditorImageDialog     -->"
+"<!-- ********************************************************* -->"
+"    <method name='EHTMLEditorImageDialogSetElementUrl'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='in'/>"
+"    </method>"
+"    <method name='EHTMLEditorImageDialogGetElementUrl'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='value' direction='out'/>"
+"    </method>"
+"<!-- ********************************************************* -->"
+"<!--     Functions that are used in EHTMLEditorLinkDialog      -->"
+"<!-- ********************************************************* -->"
+"    <method name='EHTMLEditorLinkDialogOk'>"
+"      <arg type='t' name='page_id' direction='in'/>"
+"      <arg type='s' name='url' direction='in'/>"
+"      <arg type='s' name='inner_text' direction='in'/>"
+"    </method>"
+"  </interface>"
+"</node>";
+
+static WebKitWebPage *
+get_webkit_web_page_or_return_dbus_error (GDBusMethodInvocation *invocation,
+                                          WebKitWebExtension *web_extension,
+                                          guint64 page_id)
+{
+       WebKitWebPage *web_page = webkit_web_extension_get_page (web_extension, page_id);
+       if (!web_page) {
+               g_dbus_method_invocation_return_error (
+                       invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
+                       "Invalid page ID: %"G_GUINT64_FORMAT, page_id);
+       }
+       return web_page;
+}
+
+static void
+handle_method_call (GDBusConnection *connection,
+                    const char *sender,
+                    const char *object_path,
+                    const char *interface_name,
+                    const char *method_name,
+                    GVariant *parameters,
+                    GDBusMethodInvocation *invocation,
+                    gpointer user_data)
+{
+       WebKitWebExtension *web_extension = WEBKIT_WEB_EXTENSION (user_data);
+       WebKitWebPage *web_page;
+       WebKitDOMDocument *document;
+       guint64 page_id;
+
+       if (g_strcmp0 (interface_name, EVOLUTION_WEB_EXTENSION_INTERFACE) != 0)
+               return;
+
+       if (g_strcmp0 (method_name, "ElementHasAttribute") == 0) {
+               gboolean value = FALSE;
+               const gchar *element_id, *attribute;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &attribute);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_element_has_attribute (element, attribute);
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new ("(b)", value));
+       } else if (g_strcmp0 (method_name, "ElementGetAttribute") == 0) {
+               const gchar *element_id, *attribute;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &attribute);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_element_get_attribute (element, attribute);
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "ElementRemoveAttribute") == 0) {
+               const gchar *element_id, *attribute;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &attribute);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_element_remove_attribute (element, attribute);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ElementSetAttribute") == 0) {
+               const gchar *element_id, *attribute, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters,
+                       "(t&s&s&s)",
+                       &page_id, &element_id, &attribute, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_element_set_attribute (
+                               element, attribute, value, NULL);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ElementGetTagName") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_element_get_tag_name (element);
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "TableCellElementGetAlign") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_align (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "TableCellElementGetVAlign") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_v_align (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "TableCellElementGetNoWrap") == 0) {
+               const gchar *element_id;
+               gboolean value = FALSE;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_no_wrap (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_boolean (value));
+       } else if (g_strcmp0 (method_name, "TableCellElementGetWidth") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_width (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "TableCellElementGetRowSpan") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_row_span (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "TableCellElementGetColSpan") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_col_span (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "TableCellElementGetBgColor") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_table_cell_element_get_bg_color (
+                               WEBKIT_DOM_HTML_TABLE_CELL_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetAlt") == 0) {
+               const gchar *element_id, *value;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_alt (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementSetAlt") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_alt (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementSetWidth") == 0) {
+               const gchar *element_id;
+               glong value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&si)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_width (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetWidth") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_width (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "ImageElementSetHeight") == 0) {
+               const gchar *element_id;
+               glong value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&si)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_width (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetHeight") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_height (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "ImageElementGetNaturalWidth") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_natural_width (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "ImageElementGetNaturalHeight") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_natural_height (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value));
+       } else if (g_strcmp0 (method_name, "ImageElementSetAlign") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&ss)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_align (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementSetHSpace") == 0) {
+               const gchar *element_id;
+               glong value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&si)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_hspace (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetHSpace") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_hspace (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value);
+       } else if (g_strcmp0 (method_name, "ImageElementSetVSpace") == 0) {
+               const gchar *element_id;
+               glong value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&si)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_vspace (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetVSpace") == 0) {
+               const gchar *element_id;
+               glong value = 0;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_vspace (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_int32 (value);
+       } else if (g_strcmp0 (method_name, "ImageElementSetBorder") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&si)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_image_element_set_border (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "ImageElementGetBorder") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_image_element_get_border (
+                               WEBKIT_DOM_HTML_IMAGE_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "BodySetTextColor") == 0) {
+               const gchar *value;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               webkit_dom_html_body_element_set_text (
+                       webkit_dom_document_get_body (document), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "BodyGetTextColor") == 0) {
+               gchar *value = NULL;
+
+               g_variant_get (parameters, "(t)", &page_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               value = webkit_dom_html_body_element_get_text (
+                       webkit_dom_document_get_body (document));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "BodySetLinkColor") == 0) {
+               const gchar *value;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               webkit_dom_html_body_element_set_link (
+                       webkit_dom_document_get_body (document), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "BodyGetLinkColor") == 0) {
+               gchar *value = NULL;
+
+               g_variant_get (parameters, "(t)", &page_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               value = webkit_dom_html_body_element_get_link (
+                       webkit_dom_document_get_body (document));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "BodySetBgColor") == 0) {
+               const gchar *value;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               webkit_dom_html_body_element_set_bg_color (
+                       webkit_dom_document_get_body (document), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "BodyGetBgColor") == 0) {
+               gchar *value = NULL;
+
+               g_variant_get (parameters, "(t)", &page_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               value = webkit_dom_html_body_element_get_bg_color (
+                       webkit_dom_document_get_body (document));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "BodyGetBackground") == 0) {
+               gchar *value = NULL;
+
+               g_variant_get (parameters, "(t)", &page_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               value = webkit_dom_html_body_element_get_background (
+                       webkit_dom_document_get_body (document));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "HRElementSetAlign") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_hr_element_set_align (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "HRElementGetAlign") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_hr_element_get_align (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "HRElementSetSize") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_hr_element_set_size (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "HRElementGetSize") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_hr_element_get_size (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "HRElementSetWidth") == 0) {
+               const gchar *element_id, *value;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s&s)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_hr_element_set_width (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "HRElementGetSize") == 0) {
+               const gchar *element_id;
+               gchar *value = NULL;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_hr_element_get_width (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "HRElementSetNoShade") == 0) {
+               gboolean value = FALSE;
+               const gchar *element_id;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&sb)", &page_id, &element_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       webkit_dom_html_hr_element_set_no_shade (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element), value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "HRElementGetNoShade") == 0) {
+               gboolean *value = FALSE;
+               const gchar *element_id;
+               WebKitDOMElement *element;
+
+               g_variant_get (
+                       parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               element = webkit_dom_document_get_element_by_id (document, element_id);
+               if (element)
+                       value = webkit_dom_html_hr_element_get_no_shade (
+                               WEBKIT_DOM_HTML_HR_ELEMENT (element));
+
+               g_dbus_method_invocation_return_value (
+                       invocation, g_variant_new_boolean (value));
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogMarkCurrentCellElement") == 0) {
+               const gchar *element_id;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &element_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_mark_current_cell_element (document, element_id);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementVAlign") == 0) {
+               const gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t&su)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_v_align (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementAlign") == 0) {
+               const gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t&su)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_align (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementNoWrap") == 0) {
+               gboolean value;
+               guint scope;
+
+               g_variant_get (parameters, "(tbu)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_no_wrap (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementHeaderStyle") == 0) {
+               gboolean value;
+               guint scope;
+
+               g_variant_get (parameters, "(tbu)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_header_style (
+                       document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementWidth") == 0) {
+               const gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t&su)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_width (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementColSpan") == 0) {
+               glong value;
+               guint scope;
+
+               g_variant_get (parameters, "(tiu)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_col_span (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementRowSpan") == 0) {
+               glong value;
+               guint scope;
+
+               g_variant_get (parameters, "(tiu)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_row_span (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorCellDialogSetElementBgColor") == 0) {
+               const gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t&su)", &page_id, &value, &scope);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_cell_dialog_set_element_bg_color (document, value, scope);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorImageDialogSetElementUrl") == 0) {
+               const gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t&s)", &page_id, &value);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_image_dialog_set_element_url (document, value);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorImageDialogGetElementUrl") == 0) {
+               gchar *value;
+               guint scope;
+
+               g_variant_get (parameters, "(t)", &page_id);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               value = e_html_editor_image_dialog_get_element_url (document);
+
+               g_dbus_method_invocation_return_value (
+                       invocation,
+                       value ? g_variant_new_take_string (value) : NULL);
+       } else if (g_strcmp0 (method_name, "EHTMLEditorLinkDialogOk") == 0) {
+               const gchar *url, *inner_text;
+
+               g_variant_get (parameters, "(t&s&s)", &page_id, &url, &inner_text);
+
+               web_page = get_webkit_web_page_or_return_dbus_error (
+                       invocation, web_extension, page_id);
+               if (!web_page)
+                       return;
+
+               document = webkit_web_page_get_dom_document (web_page);
+               e_html_editor_link_dialog_ok (document, url, inner_text);
+
+               g_dbus_method_invocation_return_value (invocation, NULL);
+       }
+}
+
+static GVariant *
+handle_get_property (GDBusConnection *connection,
+                     const gchar *sender,
+                     const gchar *object_path,
+                     const gchar *interface_name,
+                     const gchar *property_name,
+                     GError **error,
+                     gpointer user_data)
+{
+       GVariant *variant;
+
+       if (g_strcmp0 (property_name, "ForceImageLoad") == 0)
+               variant = g_variant_new_boolean (force_image_load);
+       else if (g_strcmp0 (property_name, "Alignment") == 0)
+               variant = g_variant_new_int32 (alignment);
+       else if (g_strcmp0 (property_name, "BackgroundColor") == 0)
+               variant = g_variant_new_string (background_color);
+       else if (g_strcmp0 (property_name, "BlockFormat") == 0)
+               variant = g_variant_new_int32 (block_format);
+       else if (g_strcmp0 (property_name, "Bold") == 0)
+               variant = g_variant_new_boolean (bold);
+       else if (g_strcmp0 (property_name, "FontColor") == 0)
+               variant = g_variant_new_string (font_color);
+       else if (g_strcmp0 (property_name, "FontName") == 0)
+               variant = g_variant_new_string (font_name);
+       else if (g_strcmp0 (property_name, "FontSize") == 0)
+               variant = g_variant_new_int32 (font_size);
+       else if (g_strcmp0 (property_name, "Indented") == 0)
+               variant = g_variant_new_boolean (indented);
+       else if (g_strcmp0 (property_name, "Italic") == 0)
+               variant = g_variant_new_boolean (italic);
+       else if (g_strcmp0 (property_name, "Monospaced") == 0)
+               variant = g_variant_new_boolean (monospaced);
+       else if (g_strcmp0 (property_name, "Strikethrough") == 0)
+               variant = g_variant_new_boolean (strikethrough);
+       else if (g_strcmp0 (property_name, "Subscript") == 0)
+               variant = g_variant_new_boolean (subscript);
+       else if (g_strcmp0 (property_name, "Superscript") == 0)
+               variant = g_variant_new_boolean (superscript);
+       else if (g_strcmp0 (property_name, "Superscript") == 0)
+               variant = g_variant_new_boolean (superscript);
+       else if (g_strcmp0 (property_name, "Underline") == 0)
+               variant = g_variant_new_boolean (underline);
+
+       return variant;
+}
+
+static gboolean
+handle_set_property (GDBusConnection *connection,
+                     const gchar *sender,
+                     const gchar *object_path,
+                     const gchar *interface_name,
+                     const gchar *property_name,
+                     GVariant *variant,
+                     GError **error,
+                     gpointer user_data)
+{
+       GError *local_error = NULL;
+       GVariantBuilder *builder;
+
+       builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+
+       if (g_strcmp0 (property_name, "ForceImageLoad") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == force_image_load)
+                       goto exit;
+
+               force_image_load = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "ForceImageLoad",
+                       g_variant_new_boolean (force_image_load));
+       } else if (g_strcmp0 (property_name, "Alignment") == 0) {
+               gint32 value = g_variant_get_int32 (variant);
+
+               if (value == alignment)
+                       goto exit;
+
+               alignment = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Alignment",
+                       g_variant_new_int32 (alignment));
+       } else if (g_strcmp0 (property_name, "BackgroundColor") == 0) {
+               const gchar *value = g_variant_get_string (variant);
+
+               if (g_strcmp0 (value, background_color) != 0)
+                       goto exit;
+
+               g_free (background_color);
+               background_color = g_strdup (value);
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "BackgroundColor",
+                       g_variant_new_string (background_color));
+       } else if (g_strcmp0 (property_name, "BlockFormat") == 0) {
+               gint32 value = g_variant_get_int32 (variant);
+
+               if (value == block_format)
+                       goto exit;
+
+               block_format = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "BlockFormat",
+                       g_variant_new_int32 (block_format));
+       } else if (g_strcmp0 (property_name, "Bold") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == bold)
+                       goto exit;
+
+               bold = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Bold",
+                       g_variant_new_boolean (bold));
+       } else if (g_strcmp0 (property_name, "FontColor") == 0) {
+               const gchar *value = g_variant_get_string (variant);
+
+               if (g_strcmp0 (value, font_color) != 0)
+                       goto exit;
+
+               g_free (font_color);
+               font_color = g_strdup (value);
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "FontColor",
+                       g_variant_new_string (font_color));
+       } else if (g_strcmp0 (property_name, "FontName") == 0) {
+               const gchar *value = g_variant_get_string (variant);
+
+               if (g_strcmp0 (value, font_name) != 0)
+                       goto exit;
+
+               g_free (font_name);
+               font_name = g_strdup (value);
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "FontName",
+                       g_variant_new_string (font_name));
+       } else if (g_strcmp0 (property_name, "FontSize") == 0) {
+               gint32 value = g_variant_get_int32 (variant);
+
+               if (value == font_size)
+                       goto exit;
+
+               font_size = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "FontSize",
+                       g_variant_new_int32 (font_size));
+       } else if (g_strcmp0 (property_name, "Indented") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == indented)
+                       goto exit;
+
+               indented = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Indented",
+                       g_variant_new_boolean (indented));
+       } else if (g_strcmp0 (property_name, "Italic") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == italic)
+                       goto exit;
+
+               italic = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Italic",
+                       g_variant_new_boolean (italic));
+       } else if (g_strcmp0 (property_name, "Monospaced") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == monospaced)
+                       goto exit;
+
+               monospaced = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Monospaced",
+                       g_variant_new_boolean (monospaced));
+       } else if (g_strcmp0 (property_name, "Strikethrough") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == strikethrough)
+                       goto exit;
+
+               strikethrough = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Strikethrough",
+                       g_variant_new_boolean (strikethrough));
+       } else if (g_strcmp0 (property_name, "Subscript") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == subscript)
+                       goto exit;
+
+               subscript = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Subscript",
+                       g_variant_new_boolean (subscript));
+       } else if (g_strcmp0 (property_name, "Superscript") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == superscript)
+                       goto exit;
+
+               superscript = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Superscript",
+                       g_variant_new_boolean (superscript));
+       } else if (g_strcmp0 (property_name, "Underline") == 0) {
+               gboolean value = g_variant_get_boolean (variant);
+
+               if (value == underline)
+                       goto exit;
+
+               underline = value;
+
+               g_variant_builder_add (builder,
+                       "{sv}",
+                       "Undeline",
+                       g_variant_new_boolean (underline));
+       }
+
+       g_dbus_connection_emit_signal (connection,
+               NULL,
+               object_path,
+               "org.freedesktop.DBus.Properties",
+               "PropertiesChanged",
+               g_variant_new (
+                       "(sa{sv}as)",
+                       interface_name,
+                       builder,
+                       NULL),
+               &local_error);
+
+       g_assert_no_error (local_error);
+
+ exit:
+       g_variant_builder_unref (builder);
+
+       return TRUE;
+}
+
+static const GDBusInterfaceVTable interface_vtable = {
+       handle_method_call,
+       handle_get_property,
+       handle_set_property
+};
+
+static void
+bus_acquired_cb (GDBusConnection *connection,
+                 const char *name,
+                 gpointer user_data)
+{
+       guint registration_id;
+       GError *error = NULL;
+       static GDBusNodeInfo *introspection_data = NULL;
+
+       if (!introspection_data)
+               introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+
+       registration_id =
+               g_dbus_connection_register_object (
+                       connection,
+                       EVOLUTION_WEB_EXTENSION_OBJECT_PATH,
+                       introspection_data->interfaces[0],
+                       &interface_vtable,
+                       g_object_ref (user_data),
+                       g_object_unref,
+                       &error);
+
+       if (!registration_id) {
+               g_warning ("Failed to register object: %s\n", error->message);
+               g_error_free (error);
+       } else {
+               dbus_connection = connection;
+               g_object_add_weak_pointer (G_OBJECT (connection), (gpointer *)&dbus_connection);
+       }
+}
+
+/* Forward declaration */
+G_MODULE_EXPORT void webkit_web_extension_initialize (WebKitWebExtension *extension);
+
+G_MODULE_EXPORT void
+webkit_web_extension_initialize (WebKitWebExtension *extension)
+{
+       g_bus_own_name (
+               G_BUS_TYPE_SESSION,
+               EVOLUTION_WEB_EXTENSION_SERVICE_NAME,
+               G_BUS_NAME_OWNER_FLAGS_NONE,
+               bus_acquired_cb,
+               NULL, NULL,
+               g_object_ref (extension),
+               g_object_unref);
+}
diff --git a/e-util/web-extensions/e-html-editor-web-extension.h 
b/e-util/web-extensions/e-html-editor-web-extension.h
new file mode 100644
index 0000000..ec99d21
--- /dev/null
+++ b/e-util/web-extensions/e-html-editor-web-extension.h
@@ -0,0 +1,26 @@
+/*
+ * e-html-editor-web-extension.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_HTML_EDITOR_WEB_EXTENSION_H
+#define E_HTML_EDITOR_WEB_EXTENSION_H
+
+#define E_HTML_EDITOR_WEB_EXTENSION_SERVICE_NAME "org.gnome.Evolution.EHTMLEditor.WebExtension"
+#define E_HTML_EDITOR_WEB_EXTENSION_OBJECT_PATH  "/org/gnome/Evolution/EHTMLEditor/WebExtension"
+#define E_HTML_EDITOR_WEB_EXTENSION_INTERFACE    "org.gnome.Evolution.EHTMLEditor.WebExtension"
+
+#endif /* E_HTML_EDITOR_WEB_EXTENSION_H */
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 54c0777..e80119d 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -1102,7 +1102,14 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
        } else {
                g_object_ref (stream);
        }
+/* FIXME WK2
+       if (g_strcmp0 (e_mail_part_get_mime_type (part), "text/html") == 0) {
+               meta_remove = e_mail_meta_remove_filter_new (FALSE);
 
+               camel_stream_filter_add (
+                       CAMEL_STREAM_FILTER (filter_stream), meta_remove);
+       }
+*/
        camel_data_wrapper_decode_to_output_stream_sync (
                camel_medium_get_content (CAMEL_MEDIUM (mime_part)),
                stream, cancellable, NULL);
@@ -1110,6 +1117,10 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
 
        g_object_unref (stream);
 
+       /* FIXME WK2 g_clear_object? */
+       if (meta_remove != NULL)
+               g_object_unref (meta_remove);
+
        g_clear_object (&windows);
        g_clear_object (&mime_part);
 }
diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c
index b3519cf..7b43f27 100644
--- a/modules/itip-formatter/itip-view.c
+++ b/modules/itip-formatter/itip-view.c
@@ -2657,13 +2657,13 @@ itip_view_ref_source (ItipView *view)
        }
 
        result = g_dbus_proxy_call_sync (
-                       view->priv->web_extension,
-                       "SelectGetValue",
-                       g_variant_new ("(s)", SELECT_ESOURCE),
-                       G_DBUS_CALL_FLAGS_NONE,
-                       -1,
-                       NULL,
-                       NULL);
+               view->priv->web_extension,
+               "SelectGetValue",
+               g_variant_new ("(s)", SELECT_ESOURCE),
+               G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               NULL,
+               NULL);
 
        if (result) {
                const gchar *uid;



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