From 5c08e2981273b719503cc2adc740b8e8ed235467 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Mon, 21 Jul 2014 16:38:53 +0200 Subject: EHTMLEditorSelection - Avoid runtime warning when trying to cast DOMText to DOMElement --- e-util/e-html-editor-selection.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c index 1d7fdf97a8..0ae1780ec9 100644 --- a/e-util/e-html-editor-selection.c +++ b/e-util/e-html-editor-selection.c @@ -1567,11 +1567,15 @@ e_html_editor_selection_get_block_format (EHTMLEditorSelection *selection) } static gboolean -is_selection_position_node (WebKitDOMElement *element) +is_selection_position_node (WebKitDOMNode *node) { - if (!element || !WEBKIT_DOM_IS_ELEMENT (element)) + WebKitDOMElement *element; + + if (!node || !WEBKIT_DOM_IS_ELEMENT (node)) return FALSE; + element = WEBKIT_DOM_ELEMENT (node); + return element_has_id (element, "-x-evo-caret-position") || element_has_id (element, "-x-evo-selection-start-marker") || element_has_id (element, "-x-evo-selection-end-marker"); @@ -5141,7 +5145,7 @@ wrap_lines (EHTMLEditorSelection *selection, } g_free (text_content); } else { - if (is_selection_position_node (WEBKIT_DOM_ELEMENT (node))) { + if (is_selection_position_node (node)) { node = webkit_dom_node_get_next_sibling (node); continue; } @@ -6010,8 +6014,7 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection) selection_start_marker = webkit_dom_node_get_next_sibling (selection_start_marker); - ok = is_selection_position_node ( - WEBKIT_DOM_ELEMENT (selection_start_marker)); + ok = is_selection_position_node (selection_start_marker); if (ok) { ok = FALSE; @@ -6019,8 +6022,7 @@ e_html_editor_selection_restore (EHTMLEditorSelection *selection) selection_end_marker = webkit_dom_node_get_next_sibling ( selection_start_marker); - ok = is_selection_position_node ( - WEBKIT_DOM_ELEMENT (selection_end_marker)); + ok = is_selection_position_node (selection_end_marker); if (ok) { remove_node (selection_start_marker); remove_node (selection_end_marker); -- cgit v1.2.3