diff options
author | Tomas Popela <tpopela@redhat.com> | 2014-09-05 19:40:28 +0800 |
---|---|---|
committer | Tomas Popela <tpopela@redhat.com> | 2014-09-05 19:51:43 +0800 |
commit | f7953bea98be2ca5fe80bd4f49c622c7e05241fc (patch) | |
tree | dc47ca028f04685f12bdbb5e96a024c806b75129 /e-util/e-html-editor-selection.c | |
parent | fa55238d1ebf5e454d66858e7a523e8acc91ee65 (diff) | |
download | gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar.gz gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar.bz2 gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar.lz gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar.xz gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.tar.zst gsoc2013-evolution-f7953bea98be2ca5fe80bd4f49c622c7e05241fc.zip |
EHTMLEditor - Use get_parent_block_node_from_child where possible
This will ensure that the right node (the block node) will be returned
when the selection is saved inside the bold/italic/underlined text or
inside the anchor.
Diffstat (limited to 'e-util/e-html-editor-selection.c')
-rw-r--r-- | e-util/e-html-editor-selection.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c index 017eb324f0..08bcd62040 100644 --- a/e-util/e-html-editor-selection.c +++ b/e-util/e-html-editor-selection.c @@ -1338,6 +1338,21 @@ set_block_alignment (WebKitDOMElement *element, } } +static WebKitDOMNode * +get_parent_block_node_from_child (WebKitDOMNode *node) +{ + WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node); + + if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-temp-text-wrapper") || + WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent) || + element_has_tag (WEBKIT_DOM_ELEMENT (parent), "b") || + element_has_tag (WEBKIT_DOM_ELEMENT (parent), "i") || + element_has_tag (WEBKIT_DOM_ELEMENT (parent), "u")) + parent = webkit_dom_node_get_parent_node (parent); + + return parent; +} + /** * e_html_editor_selection_set_alignment: * @selection: an #EHTMLEditorSelection @@ -1395,7 +1410,7 @@ e_html_editor_selection_set_alignment (EHTMLEditorSelection *selection, return; } - block = webkit_dom_node_get_parent_node ( + block = get_parent_block_node_from_child ( WEBKIT_DOM_NODE (selection_start_marker)); while (block && !after_selection_end) { @@ -1549,11 +1564,7 @@ get_block_node (WebKitDOMRange *range) WebKitDOMNode *node; node = webkit_dom_range_get_common_ancestor_container (range, NULL); - if (!WEBKIT_DOM_IS_ELEMENT (node)) - node = WEBKIT_DOM_NODE (webkit_dom_node_get_parent_element (node)); - - if (element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-temp-text-wrapper")) - node = WEBKIT_DOM_NODE (webkit_dom_node_get_parent_element (node)); + node = get_parent_block_node_from_child (node); return node; } @@ -1806,21 +1817,6 @@ get_citation_level (WebKitDOMNode *node) return level; } -static WebKitDOMNode * -get_parent_block_node_from_child (WebKitDOMNode *node) -{ - WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node); - - if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-temp-text-wrapper") || - WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (parent) || - element_has_tag (WEBKIT_DOM_ELEMENT (parent), "b") || - element_has_tag (WEBKIT_DOM_ELEMENT (parent), "i") || - element_has_tag (WEBKIT_DOM_ELEMENT (parent), "u")) - parent = webkit_dom_node_get_parent_node (parent); - - return parent; -} - static void format_change_block_to_block (EHTMLEditorSelection *selection, EHTMLEditorSelectionBlockFormat format, |