[evolution/gnome-3-16] Editor - Width limits are wrong for lists when switching composer modes



commit 3a1cc2df566ccfcba4461466f31dcd7e580ff351
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jul 2 16:42:54 2015 +0200

    Editor - Width limits are wrong for lists when switching composer modes
    
    If switching from Plain text mode to HTML mode and back with some lists in
    message the width limits are correctly removed for HTML mode, but incorrectly
    set for Plain text mode. Actually it is enough to set the width limit just to
    the main blocks and not to sub-blocks as the width limit is inherited.
    
    Also don't set an alignment for lists when setting width limits as the lists
    are handled separately.

 e-util/e-html-editor-selection.c |   20 +++++++++++++++-----
 e-util/e-html-editor-view.c      |   12 +++++++++++-
 2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 8d7f0a1..9705a73 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -6871,15 +6871,25 @@ e_html_editor_selection_set_paragraph_style (EHTMLEditorSelection *selection,
                                              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);
+       WebKitDOMNode *parent;
 
        element_add_class (element, "-x-evo-paragraph");
-       element_add_class (element, get_css_alignment_value_class (alignment));
-       if (!is_in_html_mode (selection)) {
+
+       /* Don't set the alignment for nodes as they are handled separately. */
+       if (!node_is_list (WEBKIT_DOM_NODE (element))) {
+               EHTMLEditorSelectionAlignment alignment;
+
+               alignment = e_html_editor_selection_get_alignment (selection);
+               element_add_class (element, get_css_alignment_value_class (alignment));
+       }
+
+       parent = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element));
+       /* Don't set the width limit to sub-blocks as the width limit is inhered
+        * from its parents. */
+       if (!is_in_html_mode (selection) &&
+           (!parent || WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent))) {
                style = g_strdup_printf (
                        "width: %dch; word-wrap: normal; %s",
                        (word_wrap_length + offset), style_to_add);
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 04b42e4..f0036af 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -8821,7 +8821,17 @@ toggle_paragraphs_style_in_element (EHTMLEditorView *view,
                        parent = webkit_dom_node_get_parent_node (node);
                        /* If the paragraph is inside indented paragraph don't set
                         * the style as it will be inherited */
-                       if (!element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-indented")) {
+                       if (WEBKIT_DOM_IS_HTML_BODY_ELEMENT (parent) &&
+                           (WEBKIT_DOM_IS_HTMLO_LIST_ELEMENT (node) ||
+                            WEBKIT_DOM_IS_HTMLU_LIST_ELEMENT (node))) {
+                               gint offset;
+
+                               offset = WEBKIT_DOM_IS_HTMLU_LIST_ELEMENT (node) ?
+                                       SPACES_PER_LIST_LEVEL : SPACES_ORDERED_LIST_FIRST_LEVEL;
+                               /* In plain text mode the paragraphs have width limit */
+                               e_html_editor_selection_set_paragraph_style (
+                                       selection, WEBKIT_DOM_ELEMENT (node), -1, -offset, "");
+                       } else if (!element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-indented")) {
                                const gchar *style_to_add = "";
                                style = webkit_dom_element_get_attribute (
                                        WEBKIT_DOM_ELEMENT (node), "style");


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