Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D143139
This commit is contained in:
Yulia Startsev
2022-04-21 09:53:34 +00:00
parent 70b812515a
commit 8cfef949b3
13 changed files with 19 additions and 164 deletions

View File

@@ -51,34 +51,6 @@
namespace mozilla {
namespace dom {
JSObject* SourceElementCallback(JSContext* aCx, JS::HandleValue aPrivateValue) {
// NOTE: The result of this is only used by DevTools for matching sources, so
// it is safe to silently ignore any errors and return nullptr for them.
JS::loader::LoadedScript* script =
static_cast<JS::loader::LoadedScript*>(aPrivateValue.toPrivate());
JS::Rooted<JS::Value> elementValue(aCx);
{
nsCOMPtr<Element> domElement = script->GetScriptElement();
if (!domElement) {
return nullptr;
}
JSObject* globalObject =
domElement->OwnerDoc()->GetScopeObject()->GetGlobalJSObject();
JSAutoRealm ar(aCx, globalObject);
nsresult rv = nsContentUtils::WrapNative(aCx, domElement, &elementValue,
/* aAllowWrapping = */ true);
if (NS_FAILED(rv)) {
return nullptr;
}
}
return &elementValue.toObject();
}
static MOZ_THREAD_LOCAL(ScriptSettingsStackEntry*) sScriptSettingsTLS;
class ScriptSettingsStack {
@@ -340,7 +312,6 @@ void AutoJSAPI::InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal,
mOldWarningReporter.emplace(JS::GetWarningReporter(aCx));
JS::SetWarningReporter(aCx, WarningOnlyErrorReporter);
JS::SetSourceElementCallback(aCx, SourceElementCallback);
#ifdef DEBUG
if (haveException) {