[evolution/wip/webkit2] EHTMLEditorSelection - Wrong block format detected in HTML mode
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorSelection - Wrong block format detected in HTML mode
- Date: Fri, 26 Feb 2016 12:42:14 +0000 (UTC)
commit d868d1a5751d9e7372e1e07faa1e4831b31339cc
Author: Tomas Popela <tpopela redhat com>
Date: Fri Feb 26 13:16:37 2016 +0100
EHTMLEditorSelection - Wrong block format detected in HTML mode
.../e-html-editor-selection-dom-functions.c | 13 +++++-----
.../e-html-editor-selection-dom-functions.h | 2 +
.../composer/e-html-editor-view-dom-functions.c | 24 ++++++-------------
3 files changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-selection-dom-functions.c
b/web-extensions/composer/e-html-editor-selection-dom-functions.c
index 755ce90..44cbe30 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -2070,8 +2070,8 @@ dom_selection_save (WebKitDOMDocument *document)
g_object_unref (dom_window);
}
-static gboolean
-is_selection_position_node (WebKitDOMNode *node)
+gboolean
+dom_is_selection_position_node (WebKitDOMNode *node)
{
WebKitDOMElement *element;
@@ -2127,7 +2127,7 @@ dom_selection_restore (WebKitDOMDocument *document)
selection_start_marker =
webkit_dom_node_get_next_sibling (selection_start_marker);
- ok = is_selection_position_node (selection_start_marker);
+ ok = dom_is_selection_position_node (selection_start_marker);
if (ok) {
ok = FALSE;
@@ -2135,7 +2135,7 @@ dom_selection_restore (WebKitDOMDocument *document)
selection_end_marker = webkit_dom_node_get_next_sibling (
selection_start_marker);
- ok = is_selection_position_node (selection_end_marker);
+ ok = dom_is_selection_position_node (selection_end_marker);
if (ok) {
parent_start = webkit_dom_node_get_parent_node (selection_end_marker);
@@ -2546,7 +2546,7 @@ wrap_lines (WebKitDOMDocument *document,
}
g_free (text_content);
} else {
- if (is_selection_position_node (node)) {
+ if (dom_is_selection_position_node (node)) {
node = webkit_dom_node_get_next_sibling (node);
continue;
}
@@ -4894,7 +4894,8 @@ dom_selection_get_block_format (WebKitDOMDocument *document,
else {
WebKitDOMNode *block = get_block_node (range);
- if (element_has_class (WEBKIT_DOM_ELEMENT (block), "-x-evo-paragraph"))
+ if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (block) ||
+ element_has_class (WEBKIT_DOM_ELEMENT (block), "-x-evo-paragraph"))
result = E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH;
else {
/* Paragraphs inside quote */
diff --git a/web-extensions/composer/e-html-editor-selection-dom-functions.h
b/web-extensions/composer/e-html-editor-selection-dom-functions.h
index 670d46a..61f3b12 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.h
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.h
@@ -286,6 +286,8 @@ void dom_selection_get_coordinates (WebKitDOMDocument *document,
guint *end_x,
guint *end_y);
void dom_remove_selection_markers (WebKitDOMDocument *document);
+gboolean dom_is_selection_position_node (WebKitDOMNode *node);
+
G_END_DECLS
#endif /* E_HTML_EDITOR_SELECTION_DOM_FUNCTIONS_H */
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.c
b/web-extensions/composer/e-html-editor-view-dom-functions.c
index e3082d8..dd30788 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -554,7 +554,11 @@ return_pressed_in_empty_line (WebKitDOMDocument *document)
WebKitDOMNode *
get_parent_block_node_from_child (WebKitDOMNode *node)
{
- WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
+ WebKitDOMNode *parent = node;
+
+ if (!WEBKIT_DOM_IS_ELEMENT (parent) ||
+ dom_is_selection_position_node (parent))
+ parent = webkit_dom_node_get_parent_node (parent);
if (element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-temp-text-wrapper") ||
element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-quoted") ||
@@ -3312,25 +3316,13 @@ insert_quote_symbols_before_node (WebKitDOMDocument *document,
}
static gboolean
-element_is_selection_marker (WebKitDOMElement *element)
-{
- gboolean is_marker = FALSE;
-
- is_marker =
- element_has_id (element, "-x-evo-selection-start-marker") ||
- element_has_id (element, "-x-evo-selection-end-marker");
-
- return is_marker;
-}
-
-static gboolean
check_if_suppress_next_node (WebKitDOMNode *node)
{
if (!node)
return FALSE;
if (node && WEBKIT_DOM_IS_ELEMENT (node))
- if (element_is_selection_marker (WEBKIT_DOM_ELEMENT (node)))
+ if (dom_is_selection_position_node (node))
if (!webkit_dom_node_get_previous_sibling (node))
return FALSE;
@@ -3412,7 +3404,7 @@ quote_plain_text_recursive (WebKitDOMDocument *document,
if (!(WEBKIT_DOM_IS_ELEMENT (node) || WEBKIT_DOM_IS_HTML_ELEMENT (node)))
goto next_node;
- if (element_is_selection_marker (WEBKIT_DOM_ELEMENT (node))) {
+ if (dom_is_selection_position_node (node)) {
/* If there is collapsed selection in the beginning of line
* we cannot suppress first text that is after the end of
* selection */
@@ -3548,7 +3540,7 @@ quote_plain_text_recursive (WebKitDOMDocument *document,
if (WEBKIT_DOM_IS_HTML_BR_ELEMENT (node) &&
!next_sibling && WEBKIT_DOM_IS_ELEMENT (prev_sibling) &&
- element_is_selection_marker (WEBKIT_DOM_ELEMENT (prev_sibling))) {
+ dom_is_selection_position_node (prev_sibling)) {
insert_quote_symbols_before_node (
document, node, quote_level, FALSE);
goto next_node;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]