/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// NOTE: Stencil is reported by SpiderMonkey. return bytes;
}
void LoadedScript::AssociateWithScript(JSScript* aScript) { // Verify that the rewritten URL is available when manipulating LoadedScript.
MOZ_ASSERT(mBaseURL);
// Set a JSScript's private value to point to this object. The JS engine will // increment our reference count by calling HostAddRefTopLevelScript(). This // is decremented by HostReleaseTopLevelScript() below when the JSScript dies.
nsresult LoadedScript::GetScriptSource(JSContext* aCx,
MaybeSourceText* aMaybeSource,
LoadContextBase* aMaybeLoadContext) { // If there's no script text, we try to get it from the element bool isWindowContext =
aMaybeLoadContext && aMaybeLoadContext->IsWindowContext(); if (isWindowContext && aMaybeLoadContext->AsWindowContext()->mIsInline) {
nsAutoString inlineData; auto* scriptLoadContext = aMaybeLoadContext->AsWindowContext();
scriptLoadContext->GetInlineScriptText(inlineData);
void HostAddRefTopLevelScript(const JS::Value& aPrivate) { // Increment the reference count of a LoadedScript object that is now pointed // to by a JSScript. The reference count is decremented by // HostReleaseTopLevelScript() below.
auto script = static_cast<LoadedScript*>(aPrivate.toPrivate());
CheckModuleScriptPrivate(script, aPrivate);
script->AddRef();
}
void HostReleaseTopLevelScript(const JS::Value& aPrivate) { // Decrement the reference count of a LoadedScript object that was pointed to // by a JSScript. The reference count was originally incremented by // HostAddRefTopLevelScript() above.
auto script = static_cast<LoadedScript*>(aPrivate.toPrivate());
CheckModuleScriptPrivate(script, aPrivate);
script->Release();
}
EventScript::EventScript(mozilla::dom::ReferrerPolicy aReferrerPolicy,
ScriptFetchOptions* aFetchOptions, nsIURI* aURI)
: LoadedScript(ScriptKind::eEvent, aReferrerPolicy, aFetchOptions, aURI) { // EventScripts are not using ScriptLoadRequest, and mBaseURL and mURI are // the same thing.
SetBaseURL(aURI);
}
void ModuleScript::Shutdown() { if (mModuleRecord) {
JS::ClearModuleEnvironment(mModuleRecord);
}
UnlinkModuleRecord();
}
void ModuleScript::UnlinkModuleRecord() { // Remove the module record's pointer to this object if present and decrement // our reference count. The reference is added by SetModuleRecord() below. // if (mModuleRecord) { // Take care not to trigger gray unmarking because this takes a lot of time // when we're tearing down the entire page. This is safe because we are only // writing undefined into the module private, so it won't create any // black-gray edges.
JSObject* module = mModuleRecord.unbarrieredGet(); if (JS::IsCyclicModule(module)) {
MOZ_ASSERT(JS::GetModulePrivate(module).toPrivate() == this);
JS::ClearModulePrivate(module);
}
mModuleRecord = nullptr;
}
}
ModuleScript::~ModuleScript() { // The object may be destroyed without being unlinked first.
UnlinkModuleRecord();
}
if (JS::IsCyclicModule(mModuleRecord)) { // Make module's host defined field point to this object. The JS engine will // increment our reference count by calling HostAddRefTopLevelScript(). This // is decremented when the field is cleared in UnlinkModuleRecord() above or // when the module record dies.
MOZ_ASSERT(JS::GetModulePrivate(mModuleRecord).isUndefined());
JS::SetModulePrivate(mModuleRecord, JS::PrivateValue(this));
}
// This is only called after SetModuleRecord() or SetParseError() so we don't // need to call HoldJSObjects() here.
MOZ_ASSERT(ModuleRecord() || HasParseError());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.