[evolution/wip/webkit2] EHTMLEditorView - Moving a Preformatted block one level up in the quoted content will change it to N



commit 7576905c306c29af60a6d407201992bba00700dc
Author: Tomas Popela <tpopela redhat com>
Date:   Tue May 31 11:26:41 2016 +0200

    EHTMLEditorView - Moving a Preformatted block one level up in the quoted content will change it to Normal

 .../e-html-editor-undo-redo-manager.c              |    2 +-
 .../e-html-editor-view-dom-functions.c             |   51 +++++++++++++-------
 .../e-html-editor-view-dom-functions.h             |    4 +-
 3 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c 
b/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
index 005f32c..b59e4fd 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-undo-redo-manager.c
@@ -2104,7 +2104,7 @@ undo_redo_unquote (WebKitDOMDocument *document,
 
                remove_node (WEBKIT_DOM_NODE (block));
        } else
-               dom_change_quoted_block_to_normal (document, extension);
+               dom_move_quoted_block_level_up (document, extension);
 
        if (undo)
                restore_selection_to_history_event_state (document, event->before);
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c 
b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
index 45b6378..606e123 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.c
@@ -2304,14 +2304,14 @@ set_monospace_font_family_on_body (WebKitDOMElement *body,
         * text between the caret and the end of the element will be wrapped
         * inside a SPAN element. */
        if (!html_mode) {
-               dom_element_rename_attribute (WEBKIT_DOM_ELEMENT (body), "data-style", "style");
+               element_rename_attribute (WEBKIT_DOM_ELEMENT (body), "data-style", "style");
                webkit_dom_element_set_attribute (
                        WEBKIT_DOM_ELEMENT (body),
                        "style",
                        "font-family: Monospace;",
                        NULL);
        } else {
-               dom_element_rename_attribute (WEBKIT_DOM_ELEMENT (body), "style", "data-style");
+               element_rename_attribute (WEBKIT_DOM_ELEMENT (body), "style", "data-style");
        }
 }
 
@@ -3496,8 +3496,8 @@ delete_hidden_space (WebKitDOMDocument *document,
 }
 
 gboolean
-dom_change_quoted_block_to_normal (WebKitDOMDocument *document,
-                                   EHTMLEditorWebExtension *extension)
+dom_move_quoted_block_level_up (WebKitDOMDocument *document,
+                                EHTMLEditorWebExtension *extension)
 {
        EHTMLEditorHistoryEvent *ev = NULL;
        gboolean html_mode;
@@ -3579,24 +3579,41 @@ dom_change_quoted_block_to_normal (WebKitDOMDocument *document,
                g_free (inner_html);
 
                if (paragraph) {
-                       if (html_mode) {
+                       webkit_dom_node_insert_before (
+                               WEBKIT_DOM_NODE (paragraph),
+                               WEBKIT_DOM_NODE (selection_start_marker),
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (paragraph)),
+                               NULL);
+                       webkit_dom_node_insert_before (
+                               WEBKIT_DOM_NODE (paragraph),
+                               WEBKIT_DOM_NODE (selection_end_marker),
+                               webkit_dom_node_get_first_child (
+                                       WEBKIT_DOM_NODE (paragraph)),
+                               NULL);
+
+                       dom_remove_quoting_from_element (paragraph);
+                       dom_remove_wrapping_from_element (paragraph);
+
+                       /* Moving PRE block from citation to body */
+                       if (WEBKIT_DOM_IS_HTML_PRE_ELEMENT (block)) {
+                               WebKitDOMElement *pre;
+                               WebKitDOMNode *child;
+
+                               pre = webkit_dom_document_create_element (document, "pre", NULL);
                                webkit_dom_node_insert_before (
-                                       WEBKIT_DOM_NODE (paragraph),
-                                       WEBKIT_DOM_NODE (selection_start_marker),
-                                       webkit_dom_node_get_first_child (
+                                       webkit_dom_node_get_parent_node (
                                                WEBKIT_DOM_NODE (paragraph)),
-                                       NULL);
-                               webkit_dom_node_insert_before (
+                                       WEBKIT_DOM_NODE (pre),
                                        WEBKIT_DOM_NODE (paragraph),
-                                       WEBKIT_DOM_NODE (selection_end_marker),
-                                       webkit_dom_node_get_first_child (
-                                               WEBKIT_DOM_NODE (paragraph)),
                                        NULL);
 
-                       }
+                               while ((child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE 
(paragraph))))
+                                       webkit_dom_node_append_child (WEBKIT_DOM_NODE (pre), child, NULL);
 
-                       dom_remove_quoting_from_element (paragraph);
-                       dom_remove_wrapping_from_element (paragraph);
+                               remove_node (WEBKIT_DOM_NODE (paragraph));
+                               paragraph = pre;
+                       }
                }
 
                if (block)
@@ -9617,7 +9634,7 @@ key_press_event_process_backspace_key (WebKitDOMDocument *document,
         * format to normal and inserts text into body */
        if (dom_selection_is_collapsed (document)) {
                dom_selection_save (document);
-               if (dom_change_quoted_block_to_normal (document, extension) || delete_hidden_space (document, 
extension)) {
+               if (dom_move_quoted_block_level_up (document, extension) || delete_hidden_space (document, 
extension)) {
                        dom_selection_restore (document);
                        dom_force_spell_check_for_current_paragraph (document, extension);
                        e_html_editor_web_extension_set_content_changed (extension);
diff --git a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.h 
b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.h
index 75467ff..1e757c7 100644
--- a/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.h
+++ b/modules/webkit-content-editor/web-extension/e-html-editor-view-dom-functions.h
@@ -170,9 +170,9 @@ void                dom_set_link_color              (WebKitDOMDocument *document,
 void           dom_set_visited_link_color      (WebKitDOMDocument *document,
                                                 const gchar *color);
 
-gboolean       dom_change_quoted_block_to_normal
-                                               (WebKitDOMDocument *document,
+gboolean       dom_move_quoted_block_level_up  (WebKitDOMDocument *document,
                                                 EHTMLEditorWebExtension *extension);
+
 gboolean       dom_delete_last_character_on_line_in_quoted_block
                                                (WebKitDOMDocument *document,
                                                 EHTMLEditorWebExtension *extension,


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