mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-21 20:03:08 +09:00
Issue #618 - Keep track of which modules in a graph have been fetched using a visited set
Ref: BZ 1365187
This commit is contained in:
parent
f0d6e293a3
commit
6639e9cdac
4 changed files with 92 additions and 72 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_ModuleLoadRequest_h
|
||||
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "nsURIHashKey.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -16,6 +17,16 @@ namespace dom {
|
|||
class ModuleScript;
|
||||
class ScriptLoader;
|
||||
|
||||
// A reference counted set of URLs we have visited in the process of loading a
|
||||
// module graph.
|
||||
class VisitedURLSet : public nsTHashtable<nsURIHashKey>
|
||||
{
|
||||
NS_INLINE_DECL_REFCOUNTING(VisitedURLSet)
|
||||
|
||||
private:
|
||||
~VisitedURLSet() = default;
|
||||
};
|
||||
|
||||
// A load request for a module, created for every top level module script and
|
||||
// every module import. Load request can share a ModuleScript if there are
|
||||
// multiple imports of the same module.
|
||||
|
|
@ -31,12 +42,18 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ModuleLoadRequest, ScriptLoadRequest)
|
||||
|
||||
ModuleLoadRequest(nsIScriptElement* aElement,
|
||||
// Create a top-level module load request.
|
||||
ModuleLoadRequest(nsIURI* aURI,
|
||||
nsIScriptElement* aElement,
|
||||
uint32_t aVersion,
|
||||
CORSMode aCORSMode,
|
||||
const SRIMetadata& aIntegrity,
|
||||
ScriptLoader* aLoader);
|
||||
|
||||
// Create a module load request for an imported module.
|
||||
ModuleLoadRequest(nsIURI* aURI,
|
||||
ModuleLoadRequest* aParent);
|
||||
|
||||
bool IsTopLevel() const {
|
||||
return mIsTopLevel;
|
||||
}
|
||||
|
|
@ -55,7 +72,7 @@ private:
|
|||
|
||||
public:
|
||||
// Is this a request for a top level module script or an import?
|
||||
bool mIsTopLevel;
|
||||
const bool mIsTopLevel;
|
||||
|
||||
// The base URL used for resolving relative module imports.
|
||||
nsCOMPtr<nsIURI> mBaseURL;
|
||||
|
|
@ -64,10 +81,6 @@ public:
|
|||
// finishes.
|
||||
RefPtr<ScriptLoader> mLoader;
|
||||
|
||||
// The importing module, or nullptr for top level module scripts. Used to
|
||||
// implement the ancestor list checked when fetching module dependencies.
|
||||
RefPtr<ModuleLoadRequest> mParent;
|
||||
|
||||
// Set to a module script object after a successful load or nullptr on
|
||||
// failure.
|
||||
RefPtr<ModuleScript> mModuleScript;
|
||||
|
|
@ -79,9 +92,13 @@ public:
|
|||
|
||||
// Array of imported modules.
|
||||
nsTArray<RefPtr<ModuleLoadRequest>> mImports;
|
||||
|
||||
// Set of module URLs visited while fetching the module graph this request is
|
||||
// part of.
|
||||
RefPtr<VisitedURLSet> mVisitedSet;
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
#endif // mozilla_dom_ModuleLoadRequest_h
|
||||
#endif // mozilla_dom_ModuleLoadRequest_h
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue