mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 434a86b48ee0 (bug 1129567) because it wasn't meant to land on trunk.
This commit is contained in:
parent
e8e0e0c2b0
commit
5f7e590a4b
@ -14,11 +14,10 @@ const { getAttachEventType, WorkerHost } = require('./content/utils');
|
|||||||
const { Class } = require('./core/heritage');
|
const { Class } = require('./core/heritage');
|
||||||
const { Disposable } = require('./core/disposable');
|
const { Disposable } = require('./core/disposable');
|
||||||
const { WeakReference } = require('./core/reference');
|
const { WeakReference } = require('./core/reference');
|
||||||
const { Worker } = require('./deprecated/sync-worker');
|
const { Worker } = require('./content/worker');
|
||||||
const { EventTarget } = require('./event/target');
|
const { EventTarget } = require('./event/target');
|
||||||
const { on, emit, once, setListeners } = require('./event/core');
|
const { on, emit, once, setListeners } = require('./event/core');
|
||||||
const { on: domOn, removeListener: domOff } = require('./dom/events');
|
const { on: domOn, removeListener: domOff } = require('./dom/events');
|
||||||
const { pipe } = require('./event/utils');
|
|
||||||
const { isRegExp, isUndefined } = require('./lang/type');
|
const { isRegExp, isUndefined } = require('./lang/type');
|
||||||
const { merge } = require('./util/object');
|
const { merge } = require('./util/object');
|
||||||
const { windowIterator } = require('./deprecated/window-utils');
|
const { windowIterator } = require('./deprecated/window-utils');
|
||||||
@ -114,7 +113,6 @@ const PageMod = Class({
|
|||||||
modContract.properties(modelFor),
|
modContract.properties(modelFor),
|
||||||
EventTarget,
|
EventTarget,
|
||||||
Disposable,
|
Disposable,
|
||||||
WeakReference
|
|
||||||
],
|
],
|
||||||
extends: WorkerHost(workerFor),
|
extends: WorkerHost(workerFor),
|
||||||
setup: function PageMod(options) {
|
setup: function PageMod(options) {
|
||||||
@ -191,6 +189,10 @@ function applyOnExistingDocuments (mod) {
|
|||||||
getTabs().forEach(tab => {
|
getTabs().forEach(tab => {
|
||||||
// Fake a newly created document
|
// Fake a newly created document
|
||||||
let window = getTabContentWindow(tab);
|
let window = getTabContentWindow(tab);
|
||||||
|
// on startup with e10s, contentWindow might not exist yet,
|
||||||
|
// in which case we will get notified by "document-element-inserted".
|
||||||
|
if (!window || !window.frames)
|
||||||
|
return;
|
||||||
let uri = getTabURI(tab);
|
let uri = getTabURI(tab);
|
||||||
if (has(mod.attachTo, "top") && modMatchesURI(mod, uri))
|
if (has(mod.attachTo, "top") && modMatchesURI(mod, uri))
|
||||||
onContent(mod, window);
|
onContent(mod, window);
|
||||||
@ -213,11 +215,15 @@ function createWorker (mod, window) {
|
|||||||
onError: (e) => emit(mod, 'error', e)
|
onError: (e) => emit(mod, 'error', e)
|
||||||
});
|
});
|
||||||
workers.set(mod, worker);
|
workers.set(mod, worker);
|
||||||
pipe(worker, mod);
|
worker.on('*', (event, ...args) => {
|
||||||
emit(mod, 'attach', worker);
|
// worker's "attach" event passes a window as the argument
|
||||||
once(worker, 'detach', function detach() {
|
// page-mod's "attach" event needs a worker
|
||||||
worker.destroy();
|
if (event === 'attach')
|
||||||
});
|
emit(mod, event, worker)
|
||||||
|
else
|
||||||
|
emit(mod, event, ...args);
|
||||||
|
})
|
||||||
|
once(worker, 'detach', () => worker.destroy());
|
||||||
}
|
}
|
||||||
|
|
||||||
function onContent (mod, window) {
|
function onContent (mod, window) {
|
||||||
@ -256,6 +262,20 @@ function onContent (mod, window) {
|
|||||||
return;
|
return;
|
||||||
domOff(window, eventName, onReady, true);
|
domOff(window, eventName, onReady, true);
|
||||||
createWorker(mod, window);
|
createWorker(mod, window);
|
||||||
|
|
||||||
|
// Attaching is asynchronous so if the document is already loaded we will
|
||||||
|
// miss the pageshow event so send a synthetic one.
|
||||||
|
if (window.document.readyState == "complete") {
|
||||||
|
mod.on('attach', worker => {
|
||||||
|
try {
|
||||||
|
worker.send('pageshow');
|
||||||
|
emit(worker, 'pageshow');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// This can fail if an earlier attach listener destroyed the worker
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user