[evolution/gnome-3-16] EHTMLEditorSelection - Rework how the indented block is detected



commit 94e18633f665d705a3a3b066e8bbd32e27069196
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Mar 20 10:30:29 2015 +0100

    EHTMLEditorSelection - Rework how the indented block is detected
    
    The DocumentFragment solution was too heavy. Let's just check the start
    and end containers of active selection.

 e-util/e-html-editor-selection.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index f55e5c4..ee5047e 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -3253,26 +3253,28 @@ e_html_editor_selection_is_indented (EHTMLEditorSelection *selection)
                element = get_element_for_inspection (range);
                return element_has_class (element, "-x-evo-indented");
        } else {
-               /* If there is a selection search in it and don't look just in
-                * the end container */
-               WebKitDOMDocumentFragment *fragment;
+               WebKitDOMNode *node;
+               gboolean ret_val;
 
-               fragment = webkit_dom_range_clone_contents (range, NULL);
+               node = webkit_dom_range_get_end_container (range, NULL);
+               /* No selection or whole body selected */
+               if (WEBKIT_DOM_IS_HTML_BODY_ELEMENT (node))
+                       return FALSE;
 
-               if (fragment) {
-                       gboolean ret_val = TRUE;
+               element = WEBKIT_DOM_ELEMENT (get_parent_indented_block (node));
+               ret_val = element_has_class (element, "-x-evo-indented");
+               if (!ret_val)
+                       return FALSE;
 
-                       element = webkit_dom_document_fragment_query_selector (
-                               fragment, ".-x-evo-indented", NULL);
+               node = webkit_dom_range_get_start_container (range, NULL);
+               /* No selection or whole body selected */
+               if (WEBKIT_DOM_IS_HTML_BODY_ELEMENT (node))
+                       return FALSE;
 
-                       if (!element) {
-                               element = get_element_for_inspection (range);
-                               ret_val = element_has_class (element, "-x-evo-indented");
-                       }
+               element = WEBKIT_DOM_ELEMENT (get_parent_indented_block (node));
+               ret_val = element_has_class (element, "-x-evo-indented");
 
-                       g_object_unref (fragment);
-                       return ret_val;
-               }
+               return ret_val;
        }
 
        return FALSE;


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