evolution/evolution-3.28.5-webkitgtk-2.40.patch

111 lines
4.7 KiB
Diff
Raw Normal View History

diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 3568f6e..f695ed8 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -626,6 +626,20 @@ e_editor_dom_exec_command (EEditorPage *editor_page,
e_editor_page_get_document (editor_page), cmd_str, FALSE, has_value ? value : "" );
}
+static WebKitDOMRange *
+clone_and_unref_range (WebKitDOMRange *range)
+{
+ WebKitDOMRange *clone;
+
+ if (!range)
+ return NULL;
+
+ clone = webkit_dom_range_clone_range (range, NULL);
+ g_object_unref (range);
+
+ return clone;
+}
+
static void
perform_spell_check (WebKitDOMDOMSelection *dom_selection,
WebKitDOMRange *start_range,
@@ -642,8 +656,7 @@ perform_spell_check (WebKitDOMDOMSelection *dom_selection,
g_object_unref (actual);
webkit_dom_dom_selection_modify (
dom_selection, "move", "forward", "word");
- actual = webkit_dom_dom_selection_get_range_at (
- dom_selection, 0, NULL);
+ actual = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
}
g_clear_object (&actual);
}
@@ -1524,8 +1537,10 @@ e_editor_dom_check_magic_links (EEditorPage *editor_page,
selection_end_marker = webkit_dom_document_get_element_by_id (
document, "-x-evo-selection-end-marker");
- node = webkit_dom_node_get_previous_sibling (
- WEBKIT_DOM_NODE (selection_end_marker));
+ if (selection_end_marker)
+ node = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (selection_end_marker));
+ else
+ node = NULL;
}
}
@@ -4120,7 +4135,7 @@ caret_is_on_the_line_beginning_html (WebKitDOMDocument *document)
dom_window = webkit_dom_document_get_default_view (document);
dom_selection = webkit_dom_dom_window_get_selection (dom_window);
- actual_range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+ actual_range = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
webkit_dom_dom_selection_modify (dom_selection, "move", "left", "lineBoundary");
@@ -9388,7 +9403,7 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
return;
}
- range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+ range = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
/* Check if we can delete something */
if (webkit_dom_range_get_collapsed (range, NULL)) {
@@ -9503,7 +9518,7 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
} else {
WebKitDOMRange *tmp_range = NULL, *actual_range = NULL;
- actual_range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+ actual_range = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
webkit_dom_dom_selection_modify (
dom_selection, "move", delete_key ? "right" : "left", "character");
@@ -11348,7 +11363,7 @@ e_editor_dom_save_history_for_drag (EEditorPage *editor_page)
}
/* Obtain the dragged content. */
- range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+ range = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
range_clone = webkit_dom_range_clone_range (range, NULL);
/* Create the history event for the content that will
@@ -11708,7 +11723,7 @@ e_editor_dom_get_current_range (EEditorPage *editor_page)
if (webkit_dom_dom_selection_get_range_count (dom_selection) < 1)
goto exit;
- range = webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
+ range = clone_and_unref_range (webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL));
exit:
g_clear_object (&dom_selection);
g_clear_object (&dom_window);
diff --git a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
index d799db4..a286583 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-web-extension.c
@@ -2465,8 +2465,10 @@ web_page_document_loaded_cb (WebKitWebPage *web_page,
if (!webkit_dom_dom_selection_get_anchor_node (dom_selection) &&
!webkit_dom_dom_selection_get_focus_node (dom_selection)) {
range = webkit_dom_document_caret_range_from_point (document, 0, 0);
- webkit_dom_dom_selection_remove_all_ranges (dom_selection);
- webkit_dom_dom_selection_add_range (dom_selection, range);
+ if (range) {
+ webkit_dom_dom_selection_remove_all_ranges (dom_selection);
+ webkit_dom_dom_selection_add_range (dom_selection, range);
+ }
}
g_clear_object (&range);