[evolution/wip/webkit2] Don't create unnecessary wrappers when quoting a text
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Don't create unnecessary wrappers when quoting a text
- Date: Wed, 29 Jun 2016 15:04:48 +0000 (UTC)
commit d79f63f240bb4da0cfdc38be02f9bf6e9f949bbe
Author: Tomas Popela <tpopela redhat com>
Date: Wed Jun 29 15:36:04 2016 +0200
Don't create unnecessary wrappers when quoting a text
It looks like they are not needed anymore and they could prevent the undo/redo
delete operations to behave correctly.
.../web-extension/e-editor-dom-functions.c | 97 +-------------------
1 files changed, 4 insertions(+), 93 deletions(-)
---
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 59597ad..d60d55f 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -4386,8 +4386,7 @@ quote_node (WebKitDOMDocument *document,
gboolean skip_first = FALSE;
gboolean insert_newline = FALSE;
gboolean is_html_node = FALSE;
- WebKitDOMElement *wrapper;
- WebKitDOMNode *node_clone, *prev_sibling, *next_sibling;
+ WebKitDOMNode *parent, *prev_sibling, *next_sibling;
/* Don't quote when we are not in citation */
if (quote_level == 0)
@@ -4420,28 +4419,10 @@ quote_node (WebKitDOMDocument *document,
if (quote_level == 1 && next_sibling && WEBKIT_DOM_IS_HTML_PRE_ELEMENT (next_sibling))
return;
- /* Do temporary wrapper */
- wrapper = webkit_dom_document_create_element (document, "SPAN", NULL);
- webkit_dom_element_set_class_name (wrapper, "-x-evo-temp-text-wrapper");
-
- node_clone = webkit_dom_node_clone_node_with_error (node, TRUE, NULL);
-
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (wrapper),
- node_clone,
- NULL);
+ parent = webkit_dom_node_get_parent_node (node);
insert_quote_symbols (
- wrapper,
- quote_level,
- skip_first,
- insert_newline);
-
- webkit_dom_node_replace_child (
- webkit_dom_node_get_parent_node (node),
- WEBKIT_DOM_NODE (wrapper),
- node,
- NULL);
+ WEBKIT_DOM_ELEMENT (parent), quote_level, skip_first, insert_newline);
}
static void
@@ -4656,24 +4637,6 @@ quote_plain_text_recursive (WebKitDOMDocument *document,
goto next_node;
}
- if (WEBKIT_DOM_IS_ELEMENT (prev_sibling) &&
- WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (next_sibling) &&
- element_has_class (WEBKIT_DOM_ELEMENT (prev_sibling), "-x-evo-temp-text-wrapper")) {
- /* Situation when anchors are alone on line */
- text_content = webkit_dom_node_get_text_content (prev_sibling);
-
- if (g_str_has_suffix (text_content, "\n")) {
- insert_quote_symbols_before_node (
- document, node, quote_level, FALSE);
- remove_node (node);
- g_free (text_content);
- node = next_sibling;
- skip_node = TRUE;
- goto next_node;
- }
- g_free (text_content);
- }
-
if (WEBKIT_DOM_IS_HTML_BR_ELEMENT (prev_sibling)) {
quote_br_node (prev_sibling, quote_level);
node = next_sibling;
@@ -4695,21 +4658,6 @@ quote_plain_text_recursive (WebKitDOMDocument *document,
}
}
- if (WEBKIT_DOM_IS_ELEMENT (prev_sibling) &&
- element_has_class (WEBKIT_DOM_ELEMENT (prev_sibling), "-x-evo-temp-text-wrapper")) {
- text_content = webkit_dom_node_get_text_content (prev_sibling);
- if (text_content && !*text_content) {
- insert_quote_symbols_before_node (
- document, node, quote_level, FALSE);
-
- g_free (text_content);
- goto next_node;
-
- }
-
- g_free (text_content);
- }
-
if (e_editor_dom_node_is_citation_node (prev_sibling)) {
insert_quote_symbols_before_node (
document, node, quote_level, FALSE);
@@ -6738,25 +6686,7 @@ process_blockquote (WebKitDOMElement *blockquote,
WebKitDOMNodeList *list;
int jj, length;
- /* First replace wrappers */
- list = webkit_dom_element_query_selector_all (
- blockquote, "span.-x-evo-temp-text-wrapper", NULL);
- length = webkit_dom_node_list_get_length (list);
- for (jj = 0; jj < length; jj++) {
- WebKitDOMNode *quoted_node;
- gchar *text_content;
-
- quoted_node = webkit_dom_node_list_item (list, jj);
- text_content = webkit_dom_node_get_text_content (quoted_node);
- webkit_dom_element_set_outer_html (
- WEBKIT_DOM_ELEMENT (quoted_node), text_content, NULL);
-
- g_free (text_content);
- g_object_unref (quoted_node);
- }
- g_object_unref (list);
-
- /* Afterwards replace quote nodes with symbols */
+ /* Replace quote nodes with symbols */
list = webkit_dom_element_query_selector_all (
blockquote, "span.-x-evo-quoted", NULL);
length = webkit_dom_node_list_get_length (list);
@@ -14104,25 +14034,6 @@ e_editor_dom_remove_quoting_from_element (WebKitDOMElement *element)
g_object_unref (list);
list = webkit_dom_element_query_selector_all (
- element, "span.-x-evo-temp-text-wrapper", NULL);
- length = webkit_dom_node_list_get_length (list);
- for (ii = 0; ii < length; ii++) {
- WebKitDOMNode *node = webkit_dom_node_list_item (list, ii);
- WebKitDOMNode *parent = webkit_dom_node_get_parent_node (node);
-
- while (webkit_dom_node_get_first_child (node))
- webkit_dom_node_insert_before (
- parent,
- webkit_dom_node_get_first_child (node),
- node,
- NULL);
-
- remove_node (node);
- g_object_unref (node);
- }
- g_object_unref (list);
-
- list = webkit_dom_element_query_selector_all (
element, "br.-x-evo-temp-br", NULL);
length = webkit_dom_node_list_get_length (list);
for (ii = 0; ii < length; ii++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]