[evolution/wip/webkit2] Composer - Last empty block in pasted content could be inaccessible
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Composer - Last empty block in pasted content could be inaccessible
- Date: Wed, 2 Mar 2016 18:52:32 +0000 (UTC)
commit 251efd89e6f96f90a6f80ff15553b28560ca302b
Author: Tomas Popela <tpopela redhat com>
Date: Wed Mar 2 19:47:49 2016 +0100
Composer - Last empty block in pasted content could be inaccessible
.../e-html-editor-selection-dom-functions.c | 18 +++++++-
.../composer/e-html-editor-view-dom-functions.c | 48 ++++++-------------
2 files changed, 32 insertions(+), 34 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 f6863d7..5a6b847 100644
--- a/web-extensions/composer/e-html-editor-selection-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-selection-dom-functions.c
@@ -2215,11 +2215,27 @@ wrap_lines (WebKitDOMDocument *document,
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_HTML_BR_ELEMENT (first_child)) {
+ WebKitDOMNode *next_sibling;
+
+ if ((next_sibling = webkit_dom_node_get_next_sibling (first_child))) {
+ if (dom_is_selection_position_node (next_sibling) &&
+ (next_sibling = webkit_dom_node_get_next_sibling (next_sibling)) &&
+ dom_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
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 1356ef1..b9c82cd 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -3700,8 +3700,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;
@@ -4446,7 +4446,7 @@ parse_html_into_blocks (WebKitDOMDocument *document,
extension,
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) {
@@ -4455,7 +4455,7 @@ parse_html_into_blocks (WebKitDOMDocument *document,
extension,
parent,
block_template,
- "<br class=\"-x-evo-first-br\">");
+ "<br id=\"-x-evo-first-br\">");
} else
preserve_next_line = FALSE;
next:
@@ -4484,9 +4484,9 @@ parse_html_into_blocks (WebKitDOMDocument *document,
child = webkit_dom_node_get_first_child (child);
if (child && WEBKIT_DOM_IS_HTML_BR_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 (!e_html_editor_web_extension_is_editting_message (extension))
@@ -5178,12 +5178,10 @@ dom_convert_content (WebKitDOMDocument *document,
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");
dom_merge_siblings_if_necessary (document, NULL);
@@ -5471,27 +5469,11 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
dom_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");
- }
if (ev) {
dom_selection_get_coordinates (
@@ -5534,7 +5516,7 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
dom_selection_save (document);
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;
@@ -5550,7 +5532,7 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
}
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]