mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 13:02:28 +00:00
LibJS: Update ShadowRealm to not hold an ExecutionContext
Noone needs to use this any more :^) This is somewhat AD-HOC in the constructor as it is based on an open shadow realm merge request, but applies the intent of the change without any change in behaviour.
This commit is contained in:
parent
3cb62265ab
commit
b927d7f658
Notes:
github-actions[bot]
2024-11-05 00:16:22 +00:00
Author: https://github.com/shannonbooth
Commit: b927d7f658
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2134
Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 4 additions and 12 deletions
|
@ -24,18 +24,13 @@ public:
|
||||||
[[nodiscard]] Realm& shadow_realm() { return *m_shadow_realm; }
|
[[nodiscard]] Realm& shadow_realm() { return *m_shadow_realm; }
|
||||||
void set_shadow_realm(NonnullGCPtr<Realm> realm) { m_shadow_realm = realm; }
|
void set_shadow_realm(NonnullGCPtr<Realm> realm) { m_shadow_realm = realm; }
|
||||||
|
|
||||||
[[nodiscard]] ExecutionContext const& execution_context() const { return *m_execution_context; }
|
|
||||||
[[nodiscard]] ExecutionContext& execution_context() { return *m_execution_context; }
|
|
||||||
void set_execution_context(NonnullOwnPtr<ExecutionContext> context) { m_execution_context = move(context); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ShadowRealm(Object& prototype);
|
ShadowRealm(Object& prototype);
|
||||||
|
|
||||||
virtual void visit_edges(Visitor&) override;
|
virtual void visit_edges(Visitor&) override;
|
||||||
|
|
||||||
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
|
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
|
||||||
GCPtr<Realm> m_shadow_realm; // [[ShadowRealm]]
|
GCPtr<Realm> m_shadow_realm; // [[ShadowRealm]]
|
||||||
OwnPtr<ExecutionContext> m_execution_context; // [[ExecutionContext]]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
||||||
|
|
|
@ -56,7 +56,6 @@ static ThrowCompletionOr<NonnullGCPtr<Object>> initialize_shadow_realm(ShadowRea
|
||||||
|
|
||||||
// AD-HOC: Fallback for when there is no host defined implementation.
|
// AD-HOC: Fallback for when there is no host defined implementation.
|
||||||
vm.pop_execution_context();
|
vm.pop_execution_context();
|
||||||
object.set_execution_context(vm.running_execution_context().copy());
|
|
||||||
object.set_shadow_realm(*vm.running_execution_context().realm);
|
object.set_shadow_realm(*vm.running_execution_context().realm);
|
||||||
return Object::create(realm, realm.intrinsics().object_prototype());
|
return Object::create(realm, realm.intrinsics().object_prototype());
|
||||||
}
|
}
|
||||||
|
@ -74,15 +73,13 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ShadowRealmConstructor::construct(Functi
|
||||||
// 4. Let context be the running Javascript execution context.
|
// 4. Let context be the running Javascript execution context.
|
||||||
auto context = TRY(Realm::initialize_host_defined_realm(vm, [&object](JS::Realm&) -> JS::Object* { return MUST(initialize_shadow_realm(object)); }, nullptr));
|
auto context = TRY(Realm::initialize_host_defined_realm(vm, [&object](JS::Realm&) -> JS::Object* { return MUST(initialize_shadow_realm(object)); }, nullptr));
|
||||||
|
|
||||||
// 5. Set O.[[ExecutionContext]] to context.
|
// 5. Let realmRec be the Realm of context.
|
||||||
// 6. Let realmRec be the Realm of context.
|
|
||||||
auto& realm_record = *context->realm;
|
auto& realm_record = *context->realm;
|
||||||
object->set_execution_context(move(context));
|
|
||||||
|
|
||||||
// 7. Set O.[[ShadowRealm]] to realmRec.
|
// 6. Set O.[[ShadowRealm]] to realmRec.
|
||||||
object->set_shadow_realm(realm_record);
|
object->set_shadow_realm(realm_record);
|
||||||
|
|
||||||
// 8. Return O.
|
// 7. Return O.
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue