Don't send JS selectionChanged message unless param value has changed.
This commit is contained in:
parent
320134783c
commit
805a052f1f
2 changed files with 9 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue