commit 261321856931d3db57698b047becfe188c6879f2
parent 2cb4e84b914e3a552015fbf9cbffa46f46a88d8a
Author: Tooru Fujisawa <arai_a@mac.com>
Date: Tue, 2 Dec 2025 01:25:52 +0000
Bug 2002199 - Part 4: Remove LoadedScriptDelegate::ClearScriptSource. r=bthrall
Differential Revision: https://phabricator.services.mozilla.com/D273971
Diffstat:
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp
@@ -2532,10 +2532,11 @@ nsresult ScriptLoader::ProcessRequest(ScriptLoadRequest* aRequest) {
aRequest->GetScriptLoadContext()->MaybeCancelOffThreadScript();
}
- // Free any source data, but keep the serialized Stencil as we might have to
- // save it later.
- aRequest->ClearScriptSource();
- if (aRequest->IsSerializedStencil()) {
+ if (aRequest->IsTextSource()) {
+ // Free text source, but keep the serialized Stencil as we might have to
+ // save it later.
+ aRequest->ClearScriptText();
+ } else if (aRequest->IsSerializedStencil()) {
// We received serialized Stencil as input, thus we were decoding, and we
// will not be encoding it once more. We can safely clear the content of
// this buffer.
diff --git a/js/loader/LoadedScript.h b/js/loader/LoadedScript.h
@@ -208,12 +208,6 @@ class LoadedScript : public nsIMemoryReporter {
nsresult GetScriptSource(JSContext* aCx, MaybeSourceText* aMaybeSource,
LoadContextBase* aMaybeLoadContext);
- void ClearScriptSource() {
- if (IsTextSource()) {
- ClearScriptText();
- }
- }
-
void ClearScriptText() {
MOZ_ASSERT(IsTextSource());
return IsUTF16Text() ? ScriptText<char16_t>().clearAndFree()
@@ -539,8 +533,6 @@ class LoadedScriptDelegate {
return GetLoadedScript()->GetScriptSource(aCx, aMaybeSource, aLoadContext);
}
- void ClearScriptSource() { GetLoadedScript()->ClearScriptSource(); }
-
void ClearScriptText() { GetLoadedScript()->ClearScriptText(); }
bool HasNoSRIOrSRIAndSerializedStencil() const {
diff --git a/js/loader/ModuleLoaderBase.cpp b/js/loader/ModuleLoaderBase.cpp
@@ -755,7 +755,9 @@ nsresult ModuleLoaderBase::OnFetchComplete(ModuleLoadRequest* aRequest,
}
#endif
- aRequest->ClearScriptSource();
+ if (aRequest->IsTextSource()) {
+ aRequest->ClearScriptText();
+ }
if (NS_FAILED(rv)) {
aRequest->LoadFailed();