[evolution/wip/webkit2] EHTMLEditorSelection - Rework how the indented block is detected
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorSelection - Rework how the indented block is detected
- Date: Wed, 7 Oct 2015 07:30:58 +0000 (UTC)
commit ff8661c0b5d26662f0f5f04e657ae4b79f104131
Author: Tomas Popela <tpopela redhat com>
Date: Tue May 12 13:14:35 2015 +0200
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-html-editor-selection-dom-functions.c | 32 ++++++++++---------
1 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/web-extensions/e-html-editor-selection-dom-functions.c
b/web-extensions/e-html-editor-selection-dom-functions.c
index 79063d9..9eb784d 100644
--- a/web-extensions/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/e-html-editor-selection-dom-functions.c
@@ -3677,26 +3677,28 @@ dom_selection_is_indented (WebKitDOMDocument *document)
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]