Bug 1761938 - Part 4: Give module loaders a global object field r=smaug,yulia

This gives the module loader a field for the current global, since a module map
is only associated with a single global.

This adds a method to Document to tell the script loader when its global
changes. I'm not sure of when we do this exactly.

Differential Revision: https://phabricator.services.mozilla.com/D142831
This commit is contained in:
Jon Coppeard
2022-04-11 15:35:29 +00:00
parent 9847491365
commit 95257109ee
8 changed files with 60 additions and 14 deletions

View File

@@ -132,6 +132,12 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(ScriptLoader)
/**
* Called when the document that owns this script loader changes global. The
* argument is null when the document is detached from a window.
*/
void SetGlobalObject(nsIGlobalObject* aGlobalObject);
/**
* The loader maintains a weak reference to the document with
* which it is initialized. This call forces the reference to
@@ -322,7 +328,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
/**
* Returns wether any request is queued, and not executed yet.
*/
bool HasPendingRequests();
bool HasPendingRequests() const;
/**
* Returns wether there are any dynamic module import requests pending.