[evolution/wip/webkit-composer: 715/966] Bug #702444 - [webkit-composer] Text paste doesn't wrap lines



commit d18fae9a6591a5beaa82b2a54a9be028092e8986
Author: Tomas Popela <tpopela redhat com>
Date:   Tue Jul 2 11:41:07 2013 +0200

    Bug #702444 - [webkit-composer] Text paste doesn't wrap lines

 composer/e-composer-private.c |    2 +-
 e-util/e-editor-selection.c   |   41 ++++++++++++++++++++---------------------
 2 files changed, 21 insertions(+), 22 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 26bde06..6479629 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -593,7 +593,7 @@ e_composer_paste_text (EMsgComposer *composer,
 
        if (e_editor_selection_get_block_format (editor_selection) ==
                        E_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH) {
-               e_editor_selection_wrap_lines (editor_selection, TRUE, NULL);
+               e_editor_selection_wrap_lines (editor_selection, FALSE, NULL);
        }
 
        g_free (text);
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 60ce19b..90994b3 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -3162,6 +3162,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
        } else {
                /* When there is nothing selected, we select and wrap everything
                 * that is not containing signature */
+               e_editor_selection_save_caret_position (selection);
                if (g_strcmp0 (e_editor_selection_get_string (selection), "") == 0) {
                        WebKitDOMNodeList *list;
                        WebKitDOMNode *signature = NULL;
@@ -3174,30 +3175,25 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
                        if (webkit_dom_node_list_get_length (list) > 0)
                                signature = webkit_dom_node_list_item (list, 0);
 
-                       if (signature) {
-                               list = webkit_dom_document_query_selector_all (document, "div, pre, p", NULL);
-
-                               for (ii = 0; ii < webkit_dom_node_list_get_length (list); ii++) {
-                                       WebKitDOMNode *node;
-                                       node = webkit_dom_node_list_item (list, ii);
+                       list = webkit_dom_document_query_selector_all (document, "div.-x-evo-paragraph, 
p.-x-evo-paragraph", NULL);
+                       for (ii = 0; ii < webkit_dom_node_list_get_length (list); ii++) {
+                               WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
 
-                                       /* Select elements that actualy have some text content */
-                                       if (g_utf8_strlen (webkit_dom_node_get_text_content (node), -1) == 0)
-                                               continue;
+                               /* Select elements that actualy have some text content */
+                               if (g_utf8_strlen (webkit_dom_node_get_text_content (node), -1) == 0)
+                                       continue;
 
-                                       if (!webkit_dom_node_contains (node, signature)
-                                               && !webkit_dom_node_contains (signature, node)) {
+                               if (signature) {
+                                       if (!webkit_dom_node_contains (node, signature) &&
+                                           !webkit_dom_node_contains (signature, node)) {
 
                                                wrap_lines (NULL, node, web_view, jump_to_previous_line,
                                                            FALSE, selection->priv->word_wrap_length, 
delete_pressed);
                                        }
+                               } else {
+                                       wrap_lines (NULL, node, web_view, jump_to_previous_line,
+                                                   FALSE, selection->priv->word_wrap_length, delete_pressed);
                                }
-                       } else {
-                               /* Wrap all */
-                               WebKitDOMNode *body;
-                               body = WEBKIT_DOM_NODE (webkit_dom_document_get_body (document));
-                               wrap_lines (NULL, body, web_view, jump_to_previous_line,
-                                           FALSE, selection->priv->word_wrap_length, delete_pressed);
                        }
                } else {
                        /* If we have selection -> wrap it */
@@ -3206,19 +3202,22 @@ e_editor_selection_wrap_lines (EEditorSelection *selection,
                }
        }
 
+       active_paragraph = webkit_dom_document_get_element_by_id (document, "-x-evo-active-paragraph");
        /* We have to move caret on position where it was before modifying the text */
        if (return_pressed) {
-               active_paragraph = webkit_dom_document_get_element_by_id (document, 
"-x-evo-active-paragraph");
                e_editor_selection_clear_caret_position_marker (selection);
                move_caret_into_element (document, active_paragraph);
                webkit_dom_dom_selection_modify (window_selection, "move", "forward", "character");
        } else {
-               e_editor_selection_restore_caret_position (selection);
+               if (while_typing)
+                       e_editor_selection_restore_caret_position (selection);
+               else
+                       e_editor_selection_clear_caret_position_marker (selection);
        }
 
        /* Set paragraph as non-active */
-       active_paragraph = webkit_dom_document_get_element_by_id (document, "-x-evo-active-paragraph");
-       webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (active_paragraph), "id");
+       if (active_paragraph)
+               webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (active_paragraph), "id");
 
        g_object_unref (editor_widget);
 }


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