Bug 1330257 - 3. Inline session store event listeners; r=droeh

Make the session store event listeners inline, because it makes the code
more readable, and also because auto-fill requires a pageshow listener
that is always registered, so the existing pageshow listener needs to be
moved elsewhere.

Differential Revision: https://phabricator.services.mozilla.com/D3252
This commit is contained in:
Jim Chen 2018-08-20 22:28:20 -04:00
parent fa4ec16cc2
commit 8a8e82e9bd

View File

@ -179,8 +179,20 @@ class GeckoViewContent extends GeckoViewContentModule {
if (this._savedState.history) {
let restoredHistory = SessionHistory.restore(docShell, this._savedState.history);
addEventListener("load", this, {capture: true, mozSystemGroup: true, once: true});
addEventListener("pageshow", this, {capture: true, mozSystemGroup: true, once: true});
addEventListener("load", _ => {
const formdata = this._savedState.formdata;
if (formdata) {
FormData.restoreTree(content, formdata);
}
}, {capture: true, mozSystemGroup: true, once: true});
addEventListener("pageshow", _ => {
const scrolldata = this._savedState.scrolldata;
if (scrolldata) {
ScrollPosition.restoreTree(content, scrolldata);
}
delete this._savedState;
}, {capture: true, mozSystemGroup: true, once: true});
if (!this.progressFilter) {
this.progressFilter =
@ -269,21 +281,6 @@ class GeckoViewContent extends GeckoViewContentModule {
type: "GeckoView:DOMWindowClose"
});
break;
case "load": {
const formdata = this._savedState.formdata;
if (formdata) {
FormData.restoreTree(content, formdata);
}
break;
}
case "pageshow": {
const scrolldata = this._savedState.scrolldata;
if (scrolldata) {
ScrollPosition.restoreTree(content, scrolldata);
}
delete this._savedState;
break;
}
}
}