[geary/bug/728002-webkit2: 99/140] Don't send JS selectionChanged message unless param value has changed.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/bug/728002-webkit2: 99/140] Don't send JS selectionChanged message unless param value has changed.
- Date: Tue, 31 Jan 2017 23:06:52 +0000 (UTC)
commit 805a052f1f7b3ecd6cf11e763ef87af65ad3b0d4
Author: Michael James Gratton <mike vee net>
Date: Thu Jan 19 01:58:26 2017 +1100
Don't send JS selectionChanged message unless param value has changed.
src/client/web-process/web-process-extension.vala | 4 ++++
ui/client-web-view.js | 6 +++++-
2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/client/web-process/web-process-extension.vala
b/src/client/web-process/web-process-extension.vala
index 1b4980b..2fc4067 100644
--- a/src/client/web-process/web-process-extension.vala
+++ b/src/client/web-process/web-process-extension.vala
@@ -39,6 +39,10 @@ public class GearyWebExtension : Object {
extension.page_created.connect((extension, web_page) => {
web_page.console_message_sent.connect(on_console_message);
web_page.send_request.connect(on_send_request);
+ // XXX investigate whether the earliest supported
+ // version of WK supports the DOM "selectionchanged"
+ // event, and if so use that rather that doing it in
+ // here in the extension
web_page.get_editor().selection_changed.connect(() => {
selection_changed(web_page);
});
diff --git a/ui/client-web-view.js b/ui/client-web-view.js
index eb87c2f..ba224ae 100644
--- a/ui/client-web-view.js
+++ b/ui/client-web-view.js
@@ -16,6 +16,7 @@ PageState.prototype = {
init: function() {
this.allowRemoteImages = false;
this.isLoaded = false;
+ this.hasSelection = false;
let state = this;
let timeoutId = window.setInterval(function() {
@@ -54,6 +55,9 @@ PageState.prototype = {
},
selectionChanged: function() {
let hasSelection = !window.getSelection().isCollapsed;
- window.webkit.messageHandlers.selectionChanged.postMessage(hasSelection);
+ if (this.hasSelection != hasSelection) {
+ this.hasSelection = hasSelection;
+ window.webkit.messageHandlers.selectionChanged.postMessage(hasSelection);
+ }
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]