GearyWebExtension: Untangle extension and JS interaction a bit

Move selection changed event listener into JS so it doesn't have to
cross the JS/native boundary twice.

Move sending remote load blocked from JS to the extension since we can
do that directly now and again so the JS/native boundary doesn't need
to be double-crossed again.
This commit is contained in:
Michael Gratton 2020-08-28 11:59:11 +10:00 committed by Michael James Gratton
parent 7b0146274c
commit 7950ce50c6
2 changed files with 8 additions and 60 deletions

View file

@ -22,7 +22,6 @@ PageState.prototype = {
this._selectionChanged = MessageSender("selection_changed");
this._contentLoaded = MessageSender("content_loaded");
this._remoteImageLoadBlocked = MessageSender("remote_image_load_blocked");
this._preferredHeightChanged = MessageSender("preferred_height_changed");
this._commandStackChanged = MessageSender("command_stack_changed");
this._documentModified = MessageSender("document_modified");
@ -46,6 +45,10 @@ PageState.prototype = {
state.loaded();
});
document.addEventListener("selectionchange", function(e) {
state.selectionChanged();
});
// Coalesce multiple calls to updatePreferredHeight using a
// timeout to avoid the overhead of multiple JS messages sent
// to the app and hence view multiple resizes being queued.
@ -148,9 +151,6 @@ PageState.prototype = {
stopBodyObserver: function() {
this.bodyObserver.disconnect();
},
remoteImageLoadBlocked: function() {
this._remoteImageLoadBlocked();
},
/**
* Sends "preferredHeightChanged" message if it has changed.
*/