[evolution] Composer - Last empty block in pasted content could be inaccessible
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Composer - Last empty block in pasted content could be inaccessible
- Date: Wed, 2 Dec 2015 13:37:47 +0000 (UTC)
commit d70b6ef32f46c920789f62a19ee4fb6f173af429
Author: Tomas Popela <tpopela redhat com>
Date: Wed Dec 2 14:33:35 2015 +0100
Composer - Last empty block in pasted content could be inaccessible
There were just quote characters (that are non-selectable) as the elementary BR
was removed while wrapping. Also simplify a code a little bit by switching to id
instead of class while marking first or last BR element.
e-util/e-html-editor-selection.c | 18 +++++++++++++-
e-util/e-html-editor-view.c | 48 ++++++++++++--------------------------
2 files changed, 32 insertions(+), 34 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 8bc800c..efab355 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -6407,11 +6407,27 @@ wrap_lines (EHTMLEditorSelection *selection,
start_node = node;
} else {
WebKitDOMElement *selection_start_marker, *selection_end_marker;
- WebKitDOMNode *start_point = NULL;
+ WebKitDOMNode *start_point = NULL, *first_child;
if (!webkit_dom_node_has_child_nodes (block))
return WEBKIT_DOM_ELEMENT (block);
+ /* Avoid wrapping when the block contains just the BR element alone
+ * or with selection markers. */
+ if ((first_child = webkit_dom_node_get_first_child (block)) &&
+ WEBKIT_DOM_IS_HTMLBR_ELEMENT (first_child)) {
+ WebKitDOMNode *next_sibling;
+
+ if ((next_sibling = webkit_dom_node_get_next_sibling (first_child))) {
+ if (e_html_editor_node_is_selection_position_node (next_sibling) &&
+ (next_sibling = webkit_dom_node_get_next_sibling (next_sibling)) &&
+ e_html_editor_node_is_selection_position_node (next_sibling) &&
+ !webkit_dom_node_get_next_sibling (next_sibling))
+ return WEBKIT_DOM_ELEMENT (block);
+ } else
+ return WEBKIT_DOM_ELEMENT (block);
+ }
+
block_clone = webkit_dom_node_clone_node (block, TRUE);
/* When we wrap, we are wrapping just the text after caret, text
* before the caret is already wrapped, so unwrap the text after
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 2d31e6c..700ba67 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -6590,8 +6590,8 @@ quote_plain_text_recursive (WebKitDOMDocument *document,
goto next_node;
}
goto not_br;
- } else if (element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-first-br") ||
- element_has_class (WEBKIT_DOM_ELEMENT (node), "-x-evo-last-br")) {
+ } else if (element_has_id (WEBKIT_DOM_ELEMENT (node), "-x-evo-first-br") ||
+ element_has_id (WEBKIT_DOM_ELEMENT (node), "-x-evo-last-br")) {
quote_br_node (node, quote_level);
node = next_sibling;
skip_node = TRUE;
@@ -7357,7 +7357,7 @@ parse_html_into_blocks (EHTMLEditorView *view,
document,
parent,
block_template,
- "<br class=\"-x-evo-first-br\">");
+ "<br id=\"-x-evo-first-br\">");
} else
preserve_next_line = FALSE;
} else if (first_element && !citation_was_first_element) {
@@ -7366,7 +7366,7 @@ parse_html_into_blocks (EHTMLEditorView *view,
document,
parent,
block_template,
- "<br class=\"-x-evo-first-br\">");
+ "<br id=\"-x-evo-first-br\">");
} else
preserve_next_line = FALSE;
next:
@@ -7395,9 +7395,9 @@ parse_html_into_blocks (EHTMLEditorView *view,
child = webkit_dom_node_get_first_child (child);
if (child && WEBKIT_DOM_IS_HTMLBR_ELEMENT (child)) {
/* If the processed HTML contained just
- * the BR don't overwrite its class. */
- if (!element_has_class (WEBKIT_DOM_ELEMENT (child),
"-x-evo-first-br"))
- element_add_class (
+ * the BR don't overwrite its id. */
+ if (!element_has_id (WEBKIT_DOM_ELEMENT (child), "-x-evo-first-br"))
+ webkit_dom_element_set_id (
WEBKIT_DOM_ELEMENT (child),
"-x-evo-last-br");
} else if (!view->priv->is_editting_message)
@@ -8059,12 +8059,10 @@ html_editor_convert_view_content (EHTMLEditorView *view,
document, WEBKIT_DOM_ELEMENT (child), NULL, NULL);
}
- paragraph = webkit_dom_document_query_selector (document, "br.-x-evo-last-br", NULL);
- if (paragraph)
- webkit_dom_element_remove_attribute (paragraph, "class");
- paragraph = webkit_dom_document_query_selector (document, "br.-x-evo-first-br", NULL);
- if (paragraph)
- webkit_dom_element_remove_attribute (paragraph, "class");
+ if ((paragraph = webkit_dom_document_get_element_by_id (document, "-x-evo-last-br")))
+ webkit_dom_element_remove_attribute (paragraph, "id");
+ if ((paragraph = webkit_dom_document_get_element_by_id (document, "-x-evo-first-br")))
+ webkit_dom_element_remove_attribute (paragraph, "id");
merge_siblings_if_necessary (document, NULL);
@@ -8353,27 +8351,11 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
e_html_editor_view_quote_plain_text_element_after_wrapping (
document, WEBKIT_DOM_ELEMENT (current_block), citation_level);
- /* If the pasted text begun or ended with a new line we have to
- * quote these paragraphs as well */
- br = webkit_dom_element_query_selector (
- WEBKIT_DOM_ELEMENT (last_paragraph), "br.-x-evo-last-br", NULL);
- if (br) {
- WebKitDOMNode *parent;
-
- parent = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (br));
- quote_plain_text_recursive (document, parent, parent, citation_level);
+ if ((br = webkit_dom_document_get_element_by_id (document, "-x-evo-last-br")))
webkit_dom_element_remove_attribute (br, "class");
- }
- br = webkit_dom_document_query_selector (
- document, "* > br.-x-evo-first-br", NULL);
- if (br) {
- WebKitDOMNode *parent;
-
- parent = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (br));
- quote_plain_text_recursive (document, parent, parent, citation_level);
+ if ((br = webkit_dom_document_get_element_by_id (document, "-x-evo-first-br")))
webkit_dom_element_remove_attribute (br, "class");
- }
e_html_editor_selection_restore (selection);
@@ -8406,7 +8388,7 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
e_html_editor_selection_save (selection);
element = webkit_dom_document_query_selector (
- document, "* > br.-x-evo-first-br", NULL);
+ document, "* > br#-x-evo-first-br", NULL);
if (element) {
WebKitDOMNode *sibling;
WebKitDOMNode *parent;
@@ -8422,7 +8404,7 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
}
element = webkit_dom_document_query_selector (
- document, "* > br.-x-evo-last-br", NULL);
+ document, "* > br#-x-evo-last-br", NULL);
if (element) {
WebKitDOMNode *parent;
WebKitDOMNode *child;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]