LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtr

This commit is contained in:
Linus Groh 2022-12-14 17:40:33 +00:00 committed by Tim Flynn
parent 2a66fc6cae
commit 22089436ed
Notes: sideshowbarker 2024-07-17 08:55:54 +09:00
161 changed files with 367 additions and 370 deletions

View file

@ -321,7 +321,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (!@js_name@@js_suffix@.is_object())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObject, @js_name@@js_suffix@.to_string_without_side_effects());
auto* callback_type = vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object());
auto callback_type = vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object());
@cpp_name@ = @cpp_type@::create(realm, *callback_type).ptr();
}
)~~~");
@ -330,8 +330,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (!@js_name@@js_suffix@.is_object())
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObject, @js_name@@js_suffix@.to_string_without_side_effects());
auto* callback_type = vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object());
auto @cpp_name@ = adopt_ref(*new @cpp_type@(move(callback_type)));
auto callback_type = vm.heap().allocate_without_realm<WebIDL::CallbackType>(@js_name@@js_suffix@.as_object(), HTML::incumbent_settings_object());
auto @cpp_name@ = adopt_ref(*new @cpp_type@(callback_type));
)~~~");
}
} else if (IDL::is_platform_object(*parameter.type)) {

View file

@ -50,7 +50,7 @@ public:
static JS::ThrowCompletionOr<WebAssemblyModule*> create(JS::Realm& realm, Wasm::Module module, HashMap<Wasm::Linker::Name, Wasm::ExternValue> const& imports)
{
auto& vm = realm.vm();
auto* instance = realm.heap().allocate<WebAssemblyModule>(realm, *realm.intrinsics().object_prototype());
auto instance = realm.heap().allocate<WebAssemblyModule>(realm, *realm.intrinsics().object_prototype());
instance->m_module = move(module);
Wasm::Linker linker(*instance->m_module);
linker.link(imports);
@ -62,7 +62,7 @@ public:
if (result.is_error())
return vm.throw_completion<JS::TypeError>(result.release_error().error);
instance->m_module_instance = result.release_value();
return instance;
return instance.ptr();
}
void initialize(JS::Realm&) override;

View file

@ -816,7 +816,7 @@ void ContinuePendingUnwind::replace_references_impl(BasicBlock const& from, Basi
ThrowCompletionOr<void> PushDeclarativeEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto* environment = interpreter.vm().heap().allocate_without_realm<DeclarativeEnvironment>(interpreter.vm().lexical_environment());
auto environment = interpreter.vm().heap().allocate_without_realm<DeclarativeEnvironment>(interpreter.vm().lexical_environment());
interpreter.vm().running_execution_context().lexical_environment = environment;
interpreter.vm().running_execution_context().variable_environment = environment;
return {};

View file

@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::clear_kept_objects)
JS_DEFINE_NATIVE_FUNCTION($262Object::create_realm)
{
auto realm = Realm::create(vm);
auto* realm_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm);
auto realm_global_object = vm.heap().allocate_without_realm<GlobalObject>(*realm);
VERIFY(realm_global_object);
realm->set_global_object(realm_global_object, nullptr);
set_default_global_bindings(*realm);

View file

@ -33,21 +33,21 @@ public:
~Heap();
template<typename T, typename... Args>
T* allocate_without_realm(Args&&... args)
NonnullGCPtr<T> allocate_without_realm(Args&&... args)
{
auto* memory = allocate_cell(sizeof(T));
new (memory) T(forward<Args>(args)...);
return static_cast<T*>(memory);
return *static_cast<T*>(memory);
}
template<typename T, typename... Args>
T* allocate(Realm& realm, Args&&... args)
NonnullGCPtr<T> allocate(Realm& realm, Args&&... args)
{
auto* memory = allocate_cell(sizeof(T));
new (memory) T(forward<Args>(args)...);
auto* cell = static_cast<T*>(memory);
memory->initialize(realm);
return cell;
return *cell;
}
enum class CollectionType {

View file

@ -114,7 +114,7 @@ Object* Module::module_namespace_create(VM& vm, Vector<FlyString> unambiguous_na
// 6. Let sortedExports be a List whose elements are the elements of exports ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn.
// 7. Set M.[[Exports]] to sortedExports.
// 8. Create own properties of M corresponding to the definitions in 28.3.
Object* module_namespace = vm.heap().allocate<ModuleNamespaceObject>(realm, realm, this, move(unambiguous_names));
auto module_namespace = vm.heap().allocate<ModuleNamespaceObject>(realm, realm, this, move(unambiguous_names));
// 9. Set module.[[Namespace]] to M.
m_namespace = make_handle(module_namespace);

View file

@ -412,7 +412,7 @@ FunctionEnvironment* new_function_environment(ECMAScriptFunctionObject& function
auto& heap = function.heap();
// 1. Let env be a new function Environment Record containing no bindings.
auto* env = heap.allocate_without_realm<FunctionEnvironment>(function.environment());
auto env = heap.allocate_without_realm<FunctionEnvironment>(function.environment());
// 2. Set env.[[FunctionObject]] to F.
env->set_function_object(function);
@ -1101,7 +1101,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector<
// 7. Set obj.[[Set]] as specified in 10.4.4.4.
// 8. Set obj.[[Delete]] as specified in 10.4.4.5.
// 9. Set obj.[[Prototype]] to %Object.prototype%.
auto* object = vm.heap().allocate<ArgumentsObject>(realm, realm, environment);
auto object = vm.heap().allocate<ArgumentsObject>(realm, realm, environment);
// 14. Let index be 0.
// 15. Repeat, while index < len,

View file

@ -135,7 +135,7 @@ ThrowCompletionOr<T*> ordinary_create_from_constructor(VM& vm, FunctionObject co
{
auto& realm = *vm.current_realm();
auto* prototype = TRY(get_prototype_from_constructor(vm, constructor, intrinsic_default_prototype));
return realm.heap().allocate<T>(realm, forward<Args>(args)..., *prototype);
return realm.heap().allocate<T>(realm, forward<Args>(args)..., *prototype).ptr();
}
// 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists

View file

@ -19,7 +19,7 @@ class Accessor final : public Cell {
public:
static NonnullGCPtr<Accessor> create(VM& vm, FunctionObject* getter, FunctionObject* setter)
{
return *vm.heap().allocate_without_realm<Accessor>(getter, setter);
return vm.heap().allocate_without_realm<Accessor>(getter, setter);
}
FunctionObject* getter() const { return m_getter; }

View file

@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<AggregateError> AggregateError::create(Realm& realm)
{
return *realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype());
return realm.heap().allocate<AggregateError>(realm, *realm.intrinsics().aggregate_error_prototype());
}
AggregateError::AggregateError(Object& prototype)

View file

@ -32,13 +32,13 @@ ThrowCompletionOr<NonnullGCPtr<Array>> Array::create(Realm& realm, u64 length, O
// 3. Let A be MakeBasicObject(« [[Prototype]], [[Extensible]] »).
// 4. Set A.[[Prototype]] to proto.
// 5. Set A.[[DefineOwnProperty]] as specified in 10.4.2.1.
auto* array = realm.heap().allocate<Array>(realm, *prototype);
auto array = realm.heap().allocate<Array>(realm, *prototype);
// 6. Perform ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
MUST(array->internal_define_own_property(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = false }));
// 7. Return A.
return NonnullGCPtr { *array };
return array;
}
// 7.3.18 CreateArrayFromList ( elements ), https://tc39.es/ecma262/#sec-createarrayfromlist

View file

@ -17,17 +17,17 @@ ThrowCompletionOr<NonnullGCPtr<ArrayBuffer>> ArrayBuffer::create(Realm& realm, s
if (buffer.is_error())
return realm.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length);
return NonnullGCPtr { *realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype()) };
return realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype());
}
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer buffer)
{
return *realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype());
return realm.heap().allocate<ArrayBuffer>(realm, move(buffer), *realm.intrinsics().array_buffer_prototype());
}
NonnullGCPtr<ArrayBuffer> ArrayBuffer::create(Realm& realm, ByteBuffer* buffer)
{
return *realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype());
return realm.heap().allocate<ArrayBuffer>(realm, buffer, *realm.intrinsics().array_buffer_prototype());
}
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
{
return *realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype());
return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, *realm.intrinsics().array_iterator_prototype());
}
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -13,7 +13,7 @@ namespace JS {
NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm, Iterator sync_iterator_record)
{
return *realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record);
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record);
}
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)

View file

@ -13,7 +13,7 @@ namespace JS {
NonnullGCPtr<BigInt> BigInt::create(VM& vm, Crypto::SignedBigInteger big_integer)
{
return *vm.heap().allocate_without_realm<BigInt>(move(big_integer));
return vm.heap().allocate_without_realm<BigInt>(move(big_integer));
}
BigInt::BigInt(Crypto::SignedBigInteger big_integer)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<BigIntObject> BigIntObject::create(Realm& realm, BigInt& bigint)
{
return *realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype());
return realm.heap().allocate<BigIntObject>(realm, bigint, *realm.intrinsics().bigint_prototype());
}
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<BooleanObject> BooleanObject::create(Realm& realm, bool value)
{
return *realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype());
return realm.heap().allocate<BooleanObject>(realm, value, *realm.intrinsics().boolean_prototype());
}
BooleanObject::BooleanObject(bool value, Object& prototype)

View file

@ -26,10 +26,10 @@ ThrowCompletionOr<NonnullGCPtr<BoundFunction>> BoundFunction::create(Realm& real
// 7. Set obj.[[BoundTargetFunction]] to targetFunction.
// 8. Set obj.[[BoundThis]] to boundThis.
// 9. Set obj.[[BoundArguments]] to boundArgs.
auto* object = realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype);
auto object = realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype);
// 10. Return obj.
return NonnullGCPtr { *object };
return object;
}
BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype)

View file

@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<DataView> DataView::create(Realm& realm, ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset)
{
return *realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype());
return realm.heap().allocate<DataView>(realm, viewed_buffer, byte_length, byte_offset, *realm.intrinsics().data_view_prototype());
}
DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype)

View file

@ -23,7 +23,7 @@ static Crypto::SignedBigInteger const s_one_thousand_bigint { 1'000 };
NonnullGCPtr<Date> Date::create(Realm& realm, double date_value)
{
return *realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype());
return realm.heap().allocate<Date>(realm, date_value, *realm.intrinsics().date_prototype());
}
Date::Date(double date_value, Object& prototype)

View file

@ -45,12 +45,12 @@ NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& r
prototype = realm.intrinsics().async_generator_function_prototype();
break;
}
return *realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
}
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
{
return *realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
}
ECMAScriptFunctionObject::ECMAScriptFunctionObject(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)

View file

@ -16,7 +16,7 @@ namespace JS {
NonnullGCPtr<Error> Error::create(Realm& realm)
{
return *realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
}
NonnullGCPtr<Error> Error::create(Realm& realm, DeprecatedString const& message)
@ -98,24 +98,24 @@ DeprecatedString Error::stack_string() const
return stack_string_builder.build();
}
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
{ \
return *realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
} \
\
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, DeprecatedString const& message) \
{ \
auto& vm = realm.vm(); \
auto error = ClassName::create(realm); \
u8 attr = Attribute::Writable | Attribute::Configurable; \
error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \
return error; \
} \
\
ClassName::ClassName(Object& prototype) \
: Error(prototype) \
{ \
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
NonnullGCPtr<ClassName> ClassName::create(Realm& realm) \
{ \
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
} \
\
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, DeprecatedString const& message) \
{ \
auto& vm = realm.vm(); \
auto error = ClassName::create(realm); \
u8 attr = Attribute::Writable | Attribute::Configurable; \
error->define_direct_property(vm.names.message, PrimitiveString::create(vm, message), attr); \
return error; \
} \
\
ClassName::ClassName(Object& prototype) \
: Error(prototype) \
{ \
}
JS_ENUMERATE_NATIVE_ERRORS

View file

@ -32,7 +32,7 @@ ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> GeneratorObject::create(Realm&
object->m_generating_function = generating_function;
object->m_frame = move(frame);
object->m_previous_value = initial_value;
return NonnullGCPtr { *object };
return object;
}
GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context)

View file

@ -13,7 +13,7 @@ namespace JS::Intl {
NonnullGCPtr<CollatorCompareFunction> CollatorCompareFunction::create(Realm& realm, Collator& collator)
{
return *realm.heap().allocate<CollatorCompareFunction>(realm, realm, collator);
return realm.heap().allocate<CollatorCompareFunction>(realm, realm, collator);
}
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)

View file

@ -16,7 +16,7 @@ namespace JS::Intl {
// 11.5.5 DateTime Format Functions, https://tc39.es/ecma402/#sec-datetime-format-functions
NonnullGCPtr<DateTimeFormatFunction> DateTimeFormatFunction::create(Realm& realm, DateTimeFormat& date_time_format)
{
return *realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
return realm.heap().allocate<DateTimeFormatFunction>(realm, date_time_format, *realm.intrinsics().function_prototype());
}
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)

View file

@ -16,7 +16,7 @@ namespace JS::Intl {
NonnullGCPtr<Locale> Locale::create(Realm& realm, ::Locale::LocaleID const& locale_id)
{
return *realm.heap().allocate<Locale>(realm, locale_id, *realm.intrinsics().intl_locale_prototype());
return realm.heap().allocate<Locale>(realm, locale_id, *realm.intrinsics().intl_locale_prototype());
}
// 14 Locale Objects, https://tc39.es/ecma402/#locale-objects

View file

@ -14,7 +14,7 @@ namespace JS::Intl {
// 1.1.4 Number Format Functions, https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-number-format-functions
NonnullGCPtr<NumberFormatFunction> NumberFormatFunction::create(Realm& realm, NumberFormat& number_format)
{
return *realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype());
return realm.heap().allocate<NumberFormatFunction>(realm, number_format, *realm.intrinsics().function_prototype());
}
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)

View file

@ -19,7 +19,7 @@ NonnullGCPtr<SegmentIterator> SegmentIterator::create(Realm& realm, Segmenter& s
// 4. Set iterator.[[IteratedString]] to string.
// 5. Set iterator.[[IteratedStringNextSegmentCodeUnitIndex]] to 0.
// 6. Return iterator.
return *realm.heap().allocate<SegmentIterator>(realm, realm, segmenter, move(string), segments);
return realm.heap().allocate<SegmentIterator>(realm, realm, segmenter, move(string), segments);
}
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects

View file

@ -18,7 +18,7 @@ NonnullGCPtr<Segments> Segments::create(Realm& realm, Segmenter& segmenter, Utf1
// 3. Set segments.[[SegmentsSegmenter]] to segmenter.
// 4. Set segments.[[SegmentsString]] to string.
// 5. Return segments.
return *realm.heap().allocate<Segments>(realm, realm, segmenter, move(string));
return realm.heap().allocate<Segments>(realm, realm, segmenter, move(string));
}
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects

View file

@ -137,8 +137,8 @@ NonnullGCPtr<Intrinsics> Intrinsics::create(Realm& realm)
auto& vm = realm.vm();
// 1. Set realmRec.[[Intrinsics]] to a new Record.
auto* intrinsics = vm.heap().allocate_without_realm<Intrinsics>(realm);
realm.set_intrinsics({}, *intrinsics);
auto intrinsics = vm.heap().allocate_without_realm<Intrinsics>(realm);
realm.set_intrinsics({}, intrinsics);
// 2. Set fields of realmRec.[[Intrinsics]] with the values listed in Table 6.
// The field names are the names listed in column one of the table.

View file

@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<Map> Map::create(Realm& realm)
{
return *realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype());
return realm.heap().allocate<Map>(realm, *realm.intrinsics().map_prototype());
}
Map::Map(Object& prototype)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
{
return *realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype());
return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, *realm.intrinsics().map_iterator_prototype());
}
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -36,7 +36,7 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Saf
// 7. Set func.[[Extensible]] to true.
// 8. Set func.[[Realm]] to realm.
// 9. Set func.[[InitialName]] to null.
auto* function = allocating_realm.heap().allocate<NativeFunction>(allocating_realm, move(behaviour), prototype.value(), *realm.value());
auto function = allocating_realm.heap().allocate<NativeFunction>(allocating_realm, move(behaviour), prototype.value(), *realm.value());
// 10. Perform SetFunctionLength(func, length).
function->set_function_length(length);
@ -48,12 +48,12 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Saf
function->set_function_name(name, prefix);
// 13. Return func.
return *function;
return function;
}
NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& realm, FlyString const& name, SafeFunction<ThrowCompletionOr<Value>(VM&)> function)
{
return *realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype());
return realm.heap().allocate<NativeFunction>(realm, name, move(function), *realm.intrinsics().function_prototype());
}
NativeFunction::NativeFunction(SafeFunction<ThrowCompletionOr<Value>(VM&)> native_function, Object* prototype, Realm& realm)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<NumberObject> NumberObject::create(Realm& realm, double value)
{
return *realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype());
return realm.heap().allocate<NumberObject>(realm, value, *realm.intrinsics().number_prototype());
}
NumberObject::NumberObject(double value, Object& prototype)

View file

@ -30,11 +30,11 @@ static HashMap<Object const*, HashMap<FlyString, Object::IntrinsicAccessor>> s_i
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
{
if (!prototype)
return *realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape());
else if (prototype == realm.intrinsics().object_prototype())
return *realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape());
else
return *realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
}
Object::Object(GlobalObjectTag, Realm& realm)

View file

@ -125,7 +125,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, Utf16String string
return vm.single_ascii_character_string(static_cast<u8>(code_unit));
}
return *vm.heap().allocate_without_realm<PrimitiveString>(move(string));
return vm.heap().allocate_without_realm<PrimitiveString>(move(string));
}
NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString string)
@ -142,7 +142,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString s
auto& string_cache = vm.string_cache();
auto it = string_cache.find(string);
if (it == string_cache.end()) {
auto* new_string = vm.heap().allocate_without_realm<PrimitiveString>(string);
auto new_string = vm.heap().allocate_without_realm<PrimitiveString>(string);
string_cache.set(move(string), new_string);
return *new_string;
}
@ -166,7 +166,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, PrimitiveString& l
if (rhs_empty)
return lhs;
return *vm.heap().allocate_without_realm<PrimitiveString>(lhs, rhs);
return vm.heap().allocate_without_realm<PrimitiveString>(lhs, rhs);
}
void PrimitiveString::resolve_rope_if_needed() const

View file

@ -44,7 +44,7 @@ ThrowCompletionOr<Object*> promise_resolve(VM& vm, Object& constructor, Value va
NonnullGCPtr<Promise> Promise::create(Realm& realm)
{
return *realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype());
return realm.heap().allocate<Promise>(realm, *realm.intrinsics().promise_prototype());
}
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
@ -62,7 +62,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
auto& realm = *vm.current_realm();
// 1. Let alreadyResolved be the Record { [[Value]]: false }.
auto* already_resolved = vm.heap().allocate_without_realm<AlreadyResolved>();
auto already_resolved = vm.heap().allocate_without_realm<AlreadyResolved>();
// 2. Let stepsResolve be the algorithm steps defined in Promise Resolve Functions.
// 3. Let lengthResolve be the number of non-optional parameters of the function definition in Promise Resolve Functions.

View file

@ -13,7 +13,7 @@ namespace JS {
NonnullGCPtr<PromiseCapability> PromiseCapability::create(VM& vm, GCPtr<Object> promise, GCPtr<FunctionObject> resolve, GCPtr<FunctionObject> reject)
{
return NonnullGCPtr { *vm.heap().allocate_without_realm<PromiseCapability>(promise, resolve, reject) };
return vm.heap().allocate_without_realm<PromiseCapability>(promise, resolve, reject);
}
PromiseCapability::PromiseCapability(GCPtr<Object> promise, GCPtr<FunctionObject> resolve, GCPtr<FunctionObject> reject)

View file

@ -45,10 +45,10 @@ static ThrowCompletionOr<Value> perform_promise_common(VM& vm, Iterator& iterato
VERIFY(promise_resolve.is_function());
// 1. Let values be a new empty List.
auto* values = vm.heap().allocate_without_realm<PromiseValueList>();
auto values = vm.heap().allocate_without_realm<PromiseValueList>();
// 2. Let remainingElementsCount be the Record { [[Value]]: 1 }.
auto* remaining_elements_count = vm.heap().allocate_without_realm<RemainingElements>(1);
auto remaining_elements_count = vm.heap().allocate_without_realm<RemainingElements>(1);
// 3. Let index be 0.
size_t index = 0;

View file

@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<PromiseReaction> PromiseReaction::create(VM& vm, Type type, GCPtr<PromiseCapability> capability, Optional<JobCallback> handler)
{
return *vm.heap().allocate_without_realm<PromiseReaction>(type, capability, move(handler));
return vm.heap().allocate_without_realm<PromiseReaction>(type, capability, move(handler));
}
PromiseReaction::PromiseReaction(Type type, GCPtr<PromiseCapability> capability, Optional<JobCallback> handler)

View file

@ -55,7 +55,7 @@ void PromiseResolvingElementFunction::visit_edges(Cell::Visitor& visitor)
NonnullGCPtr<PromiseAllResolveElementFunction> PromiseAllResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
{
return *realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
return realm.heap().allocate<PromiseAllResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
@ -87,7 +87,7 @@ ThrowCompletionOr<Value> PromiseAllResolveElementFunction::resolve_element()
NonnullGCPtr<PromiseAllSettledResolveElementFunction> PromiseAllSettledResolveElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
{
return *realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
return realm.heap().allocate<PromiseAllSettledResolveElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
@ -128,7 +128,7 @@ ThrowCompletionOr<Value> PromiseAllSettledResolveElementFunction::resolve_elemen
NonnullGCPtr<PromiseAllSettledRejectElementFunction> PromiseAllSettledRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
{
return *realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
return realm.heap().allocate<PromiseAllSettledRejectElementFunction>(realm, index, values, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
@ -169,7 +169,7 @@ ThrowCompletionOr<Value> PromiseAllSettledRejectElementFunction::resolve_element
NonnullGCPtr<PromiseAnyRejectElementFunction> PromiseAnyRejectElementFunction::create(Realm& realm, size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements)
{
return *realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype());
return realm.heap().allocate<PromiseAnyRejectElementFunction>(realm, index, errors, capability, remaining_elements, *realm.intrinsics().function_prototype());
}
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)

View file

@ -13,7 +13,7 @@ namespace JS {
NonnullGCPtr<PromiseResolvingFunction> PromiseResolvingFunction::create(Realm& realm, Promise& promise, AlreadyResolved& already_resolved, FunctionType function)
{
return *realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
return realm.heap().allocate<PromiseResolvingFunction>(realm, promise, already_resolved, move(function), *realm.intrinsics().function_prototype());
}
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)

View file

@ -17,7 +17,7 @@ namespace JS {
NonnullGCPtr<ProxyObject> ProxyObject::create(Realm& realm, Object& target, Object& handler)
{
return *realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype());
return realm.heap().allocate<ProxyObject>(realm, target, handler, *realm.intrinsics().object_prototype());
}
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)

View file

@ -18,7 +18,7 @@ namespace JS {
NonnullGCPtr<Realm> Realm::create(VM& vm)
{
// 1. Let realmRec be a new Realm Record.
auto* realm = vm.heap().allocate_without_realm<Realm>();
auto realm = vm.heap().allocate_without_realm<Realm>();
// 2. Perform CreateIntrinsics(realmRec).
Intrinsics::create(*realm);
@ -28,7 +28,7 @@ NonnullGCPtr<Realm> Realm::create(VM& vm)
// 5. Set realmRec.[[TemplateMap]] to a new empty List.
// 6. Return realmRec.
return *realm;
return realm;
}
// 9.6 InitializeHostDefinedRealm ( ), https://tc39.es/ecma262/#sec-initializehostdefinedrealm

View file

@ -126,12 +126,12 @@ ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView patte
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
{
return *realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
return realm.heap().allocate<RegExpObject>(realm, *realm.intrinsics().regexp_prototype());
}
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
{
return *realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), *realm.intrinsics().regexp_prototype());
}
RegExpObject::RegExpObject(Object& prototype)

View file

@ -12,7 +12,7 @@ namespace JS {
// 22.2.7.1 CreateRegExpStringIterator ( R, S, global, fullUnicode ), https://tc39.es/ecma262/#sec-createregexpstringiterator
NonnullGCPtr<RegExpStringIterator> RegExpStringIterator::create(Realm& realm, Object& regexp_object, Utf16String string, bool global, bool unicode)
{
return *realm.heap().allocate<RegExpStringIterator>(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
return realm.heap().allocate<RegExpStringIterator>(realm, *realm.intrinsics().regexp_string_iterator_prototype(), regexp_object, move(string), global, unicode);
}
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)

View file

@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<Set> Set::create(Realm& realm)
{
return *realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype());
return realm.heap().allocate<Set>(realm, *realm.intrinsics().set_prototype());
}
Set::Set(Object& prototype)

View file

@ -11,7 +11,7 @@ namespace JS {
NonnullGCPtr<SetIterator> SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind)
{
return *realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype());
return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, *realm.intrinsics().set_iterator_prototype());
}
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)

View file

@ -12,7 +12,7 @@ namespace JS {
Shape* Shape::create_unique_clone() const
{
auto* new_shape = heap().allocate_without_realm<Shape>(m_realm);
auto new_shape = heap().allocate_without_realm<Shape>(m_realm);
new_shape->m_unique = true;
new_shape->m_prototype = m_prototype;
ensure_property_table();
@ -57,10 +57,10 @@ Shape* Shape::create_put_transition(StringOrSymbol const& property_key, Property
TransitionKey key { property_key, attributes };
if (auto* existing_shape = get_or_prune_cached_forward_transition(key))
return existing_shape;
auto* new_shape = heap().allocate_without_realm<Shape>(*this, property_key, attributes, TransitionType::Put);
auto new_shape = heap().allocate_without_realm<Shape>(*this, property_key, attributes, TransitionType::Put);
if (!m_forward_transitions)
m_forward_transitions = make<HashMap<TransitionKey, WeakPtr<Shape>>>();
m_forward_transitions->set(key, new_shape);
m_forward_transitions->set(key, new_shape.ptr());
return new_shape;
}
@ -69,10 +69,10 @@ Shape* Shape::create_configure_transition(StringOrSymbol const& property_key, Pr
TransitionKey key { property_key, attributes };
if (auto* existing_shape = get_or_prune_cached_forward_transition(key))
return existing_shape;
auto* new_shape = heap().allocate_without_realm<Shape>(*this, property_key, attributes, TransitionType::Configure);
auto new_shape = heap().allocate_without_realm<Shape>(*this, property_key, attributes, TransitionType::Configure);
if (!m_forward_transitions)
m_forward_transitions = make<HashMap<TransitionKey, WeakPtr<Shape>>>();
m_forward_transitions->set(key, new_shape);
m_forward_transitions->set(key, new_shape.ptr());
return new_shape;
}
@ -80,10 +80,10 @@ Shape* Shape::create_prototype_transition(Object* new_prototype)
{
if (auto* existing_shape = get_or_prune_cached_prototype_transition(new_prototype))
return existing_shape;
auto* new_shape = heap().allocate_without_realm<Shape>(*this, new_prototype);
auto new_shape = heap().allocate_without_realm<Shape>(*this, new_prototype);
if (!m_prototype_transitions)
m_prototype_transitions = make<HashMap<Object*, WeakPtr<Shape>>>();
m_prototype_transitions->set(new_prototype, new_shape);
m_prototype_transitions->set(new_prototype, new_shape.ptr());
return new_shape;
}

View file

@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, DeprecatedString string)
{
return *realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype());
return realm.heap().allocate<StringIterator>(realm, move(string), *realm.intrinsics().string_iterator_prototype());
}
StringIterator::StringIterator(DeprecatedString string, Object& prototype)

View file

@ -17,7 +17,7 @@ namespace JS {
// 10.4.3.4 StringCreate ( value, prototype ), https://tc39.es/ecma262/#sec-stringcreate
NonnullGCPtr<StringObject> StringObject::create(Realm& realm, PrimitiveString& primitive_string, Object& prototype)
{
return *realm.heap().allocate<StringObject>(realm, primitive_string, prototype);
return realm.heap().allocate<StringObject>(realm, primitive_string, prototype);
}
StringObject::StringObject(PrimitiveString& string, Object& prototype)

View file

@ -19,7 +19,7 @@ Symbol::Symbol(Optional<DeprecatedString> description, bool is_global)
NonnullGCPtr<Symbol> Symbol::create(VM& vm, Optional<DeprecatedString> description, bool is_global)
{
return *vm.heap().allocate_without_realm<Symbol>(move(description), is_global);
return vm.heap().allocate_without_realm<Symbol>(move(description), is_global);
}
}

View file

@ -12,7 +12,7 @@ namespace JS {
NonnullGCPtr<SymbolObject> SymbolObject::create(Realm& realm, Symbol& primitive_symbol)
{
return *realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
return realm.heap().allocate<SymbolObject>(realm, primitive_symbol, *realm.intrinsics().symbol_prototype());
}
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)

View file

@ -425,7 +425,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
{ \
auto* prototype = TRY(get_prototype_from_constructor(realm.vm(), new_target, &Intrinsics::snake_name##_prototype)); \
auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
return NonnullGCPtr { *realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer) }; \
return realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer); \
} \
\
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
@ -436,7 +436,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
\
NonnullGCPtr<ClassName> ClassName::create(Realm& realm, u32 length, ArrayBuffer& array_buffer) \
{ \
return *realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype(), length, array_buffer); \
} \
\
ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \

View file

@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<WeakMap> WeakMap::create(Realm& realm)
{
return *realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype());
return realm.heap().allocate<WeakMap>(realm, *realm.intrinsics().weak_map_prototype());
}
WeakMap::WeakMap(Object& prototype)

View file

@ -10,12 +10,12 @@ namespace JS {
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Object& value)
{
return *realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
}
NonnullGCPtr<WeakRef> WeakRef::create(Realm& realm, Symbol& value)
{
return *realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
return realm.heap().allocate<WeakRef>(realm, value, *realm.intrinsics().weak_ref_prototype());
}
WeakRef::WeakRef(Object& value, Object& prototype)

View file

@ -10,7 +10,7 @@ namespace JS {
NonnullGCPtr<WeakSet> WeakSet::create(Realm& realm)
{
return *realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype());
return realm.heap().allocate<WeakSet>(realm, *realm.intrinsics().weak_set_prototype());
}
WeakSet::WeakSet(Object& prototype)

View file

@ -22,7 +22,7 @@ ThrowCompletionOr<NonnullGCPtr<WrappedFunction>> WrappedFunction::create(Realm&
// 5. Set wrapped.[[WrappedTargetFunction]] to Target.
// 6. Set wrapped.[[Realm]] to callerRealm.
auto& prototype = *caller_realm.intrinsics().function_prototype();
auto* wrapped = vm.heap().allocate<WrappedFunction>(realm, caller_realm, target, prototype);
auto wrapped = vm.heap().allocate<WrappedFunction>(realm, caller_realm, target, prototype);
// 7. Let result be CopyNameAndLength(wrapped, Target).
auto result = copy_name_and_length(vm, *wrapped, target);
@ -32,7 +32,7 @@ ThrowCompletionOr<NonnullGCPtr<WrappedFunction>> WrappedFunction::create(Realm&
return vm.throw_completion<TypeError>(ErrorType::WrappedFunctionCopyNameAndLengthThrowCompletion);
// 9. Return wrapped.
return NonnullGCPtr { *wrapped };
return wrapped;
}
// 2 Wrapped Function Exotic Objects, https://tc39.es/proposal-shadowrealm/#sec-wrapped-function-exotic-objects

View file

@ -24,7 +24,7 @@ Result<NonnullGCPtr<Script>, Vector<ParserError>> Script::parse(StringView sourc
return parser.errors();
// 3. Return Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[HostDefined]]: hostDefined }.
return NonnullGCPtr(*realm.heap().allocate_without_realm<Script>(realm, filename, move(script), host_defined));
return realm.heap().allocate_without_realm<Script>(realm, filename, move(script), host_defined);
}
Script::Script(Realm& realm, StringView filename, NonnullRefPtr<Program> parse_node, HostDefined* host_defined)

View file

@ -244,7 +244,7 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
// [[HostDefined]]: hostDefined, [[ECMAScriptCode]]: body, [[Context]]: empty, [[ImportMeta]]: empty,
// [[RequestedModules]]: requestedModules, [[ImportEntries]]: importEntries, [[LocalExportEntries]]: localExportEntries,
// [[IndirectExportEntries]]: indirectExportEntries, [[StarExportEntries]]: starExportEntries, [[DFSIndex]]: empty, [[DFSAncestorIndex]]: empty }.
return NonnullGCPtr(*realm.heap().allocate_without_realm<SourceTextModule>(
return realm.heap().allocate_without_realm<SourceTextModule>(
realm,
filename,
host_defined,
@ -255,7 +255,7 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
move(local_export_entries),
move(indirect_export_entries),
move(star_export_entries),
move(default_export)));
move(default_export));
}
// 16.2.1.6.2 GetExportedNames ( [ exportStarSet ] ), https://tc39.es/ecma262/#sec-getexportednames
@ -347,7 +347,7 @@ ThrowCompletionOr<void> SourceTextModule::initialize_environment(VM& vm)
// Note: This must be true because we use a reference.
// 5. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
auto* environment = vm.heap().allocate_without_realm<ModuleEnvironment>(&realm().global_environment());
auto environment = vm.heap().allocate_without_realm<ModuleEnvironment>(&realm().global_environment());
// 6. Set module.[[Environment]] to env.
set_environment(environment);

View file

@ -51,7 +51,7 @@ ThrowCompletionOr<void> SyntheticModule::link(VM& vm)
// Note: This must be true because we use a reference.
// 3. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
auto* environment = vm.heap().allocate_without_realm<ModuleEnvironment>(&realm().global_environment());
auto environment = vm.heap().allocate_without_realm<ModuleEnvironment>(&realm().global_environment());
// 4. Set module.[[Environment]] to env.
set_environment(environment);
@ -139,7 +139,7 @@ NonnullGCPtr<SyntheticModule> SyntheticModule::create_default_export_synthetic_m
};
// 2. Return CreateSyntheticModule("default", closure, realm)
return *realm.heap().allocate_without_realm<SyntheticModule>(Vector<FlyString> { "default" }, move(closure), realm, filename);
return realm.heap().allocate_without_realm<SyntheticModule>(Vector<FlyString> { "default" }, move(closure), realm, filename);
}
// 1.4 ParseJSONModule ( source ), https://tc39.es/proposal-json-modules/#sec-parse-json-module

View file

@ -34,9 +34,9 @@ public:
if (it != m_prototypes.end())
return *it->value;
auto& realm = *m_realm;
auto* prototype = heap().allocate<T>(realm, realm);
auto prototype = heap().allocate<T>(realm, realm);
m_prototypes.set(class_name, prototype);
return *prototype;
return prototype;
}
template<typename T>
@ -46,9 +46,9 @@ public:
if (it != m_constructors.end())
return *it->value;
auto& realm = *m_realm;
auto* constructor = heap().allocate<T>(realm, realm);
auto constructor = heap().allocate<T>(realm, realm);
m_constructors.set(class_name, constructor);
return *constructor;
return constructor;
}
private:

View file

@ -375,8 +375,8 @@ JS::VM& main_thread_vm()
custom_data.root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(*vm, nullptr, nullptr));
auto* root_realm = custom_data.root_execution_context->realm;
auto* intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
auto host_defined = make<HostDefined>(nullptr, *intrinsics);
auto intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
auto host_defined = make<HostDefined>(nullptr, intrinsics);
root_realm->set_host_defined(move(host_defined));
custom_data.internal_realm = root_realm;

View file

@ -19,7 +19,7 @@ namespace Web::CSS {
CSSRuleList* CSSRuleList::create(JS::Realm& realm, JS::MarkedVector<CSSRule*> const& rules)
{
auto* rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
auto rule_list = realm.heap().allocate<CSSRuleList>(realm, realm);
for (auto* rule : rules)
rule_list->m_rules.append(*rule);
return rule_list;

View file

@ -17,7 +17,7 @@ namespace Web::CSS {
JS::NonnullGCPtr<MediaQueryList> MediaQueryList::create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
{
return *document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
return document.heap().allocate<MediaQueryList>(document.realm(), document, move(media));
}
MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -15,7 +15,7 @@ namespace Web::CSS {
JS::NonnullGCPtr<Screen> Screen::create(HTML::Window& window)
{
return *window.heap().allocate<Screen>(window.realm(), window);
return window.heap().allocate<Screen>(window.realm(), window);
}
Screen::Screen(HTML::Window& window)

View file

@ -16,7 +16,7 @@ namespace Web::Crypto {
JS::NonnullGCPtr<Crypto> Crypto::create(JS::Realm& realm)
{
return *realm.heap().allocate<Crypto>(realm, realm);
return realm.heap().allocate<Crypto>(realm, realm);
}
Crypto::Crypto(JS::Realm& realm)

View file

@ -16,7 +16,7 @@ namespace Web::Crypto {
JS::NonnullGCPtr<SubtleCrypto> SubtleCrypto::create(JS::Realm& realm)
{
return *realm.heap().allocate<SubtleCrypto>(realm, realm);
return realm.heap().allocate<SubtleCrypto>(realm, realm);
}
SubtleCrypto::SubtleCrypto(JS::Realm& realm)

View file

@ -13,7 +13,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<AbortController> AbortController::construct_impl(JS::Realm& realm)
{
auto signal = AbortSignal::construct_impl(realm);
return *realm.heap().allocate<AbortController>(realm, realm, move(signal));
return realm.heap().allocate<AbortController>(realm, realm, move(signal));
}
// https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller

View file

@ -14,7 +14,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<AbortSignal> AbortSignal::construct_impl(JS::Realm& realm)
{
return *realm.heap().allocate<AbortSignal>(realm, realm);
return realm.heap().allocate<AbortSignal>(realm, realm);
}
AbortSignal::AbortSignal(JS::Realm& realm)

View file

@ -15,7 +15,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<Attr> Attr::create(Document& document, FlyString local_name, DeprecatedString value, Element const* owner_element)
{
return *document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element);
return document.heap().allocate<Attr>(document.realm(), document, QualifiedName(move(local_name), {}, {}), move(value), owner_element);
}
JS::NonnullGCPtr<Attr> Attr::clone(Document& document)

View file

@ -19,7 +19,7 @@ Comment::Comment(Document& document, DeprecatedString const& data)
JS::NonnullGCPtr<Comment> Comment::construct_impl(JS::Realm& realm, DeprecatedString const& data)
{
auto& window = verify_cast<HTML::Window>(realm.global_object());
return *realm.heap().allocate<Comment>(realm, window.associated_document(), data);
return realm.heap().allocate<Comment>(realm, window.associated_document(), data);
}
}

View file

@ -20,7 +20,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<DOMImplementation> DOMImplementation::create(Document& document)
{
auto& realm = document.realm();
return *realm.heap().allocate<DOMImplementation>(realm, document);
return realm.heap().allocate<DOMImplementation>(realm, document);
}
DOMImplementation::DOMImplementation(Document& document)

View file

@ -289,7 +289,7 @@ JS::NonnullGCPtr<Document> Document::construct_impl(JS::Realm& realm)
JS::NonnullGCPtr<Document> Document::create(JS::Realm& realm, AK::URL const& url)
{
return *realm.heap().allocate<Document>(realm, realm, url);
return realm.heap().allocate<Document>(realm, realm, url);
}
Document::Document(JS::Realm& realm, const AK::URL& url)
@ -680,7 +680,7 @@ void Document::set_title(DeprecatedString const& title)
}
title_element->remove_all_children(true);
MUST(title_element->append_child(*heap().allocate<Text>(realm(), *this, title)));
MUST(title_element->append_child(heap().allocate<Text>(realm(), *this, title)));
if (auto* page = this->page()) {
if (browsing_context() == &page->top_level_browsing_context())
@ -1221,17 +1221,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(Depre
JS::NonnullGCPtr<DocumentFragment> Document::create_document_fragment()
{
return *heap().allocate<DocumentFragment>(realm(), *this);
return heap().allocate<DocumentFragment>(realm(), *this);
}
JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
{
return *heap().allocate<Text>(realm(), *this, data);
return heap().allocate<Text>(realm(), *this, data);
}
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
{
return *heap().allocate<Comment>(realm(), *this, data);
return heap().allocate<Comment>(realm(), *this, data);
}
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction

View file

@ -30,7 +30,7 @@ void DocumentFragment::set_host(Web::DOM::Element* element)
JS::NonnullGCPtr<DocumentFragment> DocumentFragment::construct_impl(JS::Realm& realm)
{
auto& window = verify_cast<HTML::Window>(realm.global_object());
return *realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
return realm.heap().allocate<DocumentFragment>(realm, window.associated_document());
}
}

View file

@ -11,7 +11,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<DocumentType> DocumentType::create(Document& document)
{
return *document.heap().allocate<DocumentType>(document.realm(), document);
return document.heap().allocate<DocumentType>(document.realm(), document);
}
DocumentType::DocumentType(Document& document)

View file

@ -1174,11 +1174,11 @@ WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(Depreca
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data)
{
// 1. Let text be a new Text node whose data is data and node document is thiss node document.
JS::NonnullGCPtr<Text> text = *heap().allocate<DOM::Text>(realm(), document(), data);
auto text = heap().allocate<DOM::Text>(realm(), document(), data);
// 2. Run insert adjacent, given this, where, and text.
// Spec Note: This method returns nothing because it existed before we had a chance to design it.
(void)TRY(insert_adjacent(where, move(text)));
(void)TRY(insert_adjacent(where, text));
return {};
}

View file

@ -120,180 +120,180 @@ JS::NonnullGCPtr<Element> create_element(Document& document, FlyString local_nam
auto qualified_name = QualifiedName { local_name, prefix, namespace_ };
if (lowercase_tag_name == HTML::TagNames::a)
return *realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLAnchorElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::area)
return *realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLAreaElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::audio)
return *realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLAudioElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::base)
return *realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLBaseElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::blink)
return *realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLBlinkElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::body)
return *realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLBodyElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::br)
return *realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLBRElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::button)
return *realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLButtonElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::canvas)
return *realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLCanvasElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::data)
return *realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDataElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::datalist)
return *realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDataListElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::details)
return *realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDetailsElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::dialog)
return *realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDialogElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::dir)
return *realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDirectoryElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::div)
return *realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDivElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::dl)
return *realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLDListElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::embed)
return *realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLEmbedElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::fieldset)
return *realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLFieldSetElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::font)
return *realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLFontElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::form)
return *realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLFormElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::frame)
return *realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLFrameElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::frameset)
return *realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLFrameSetElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::head)
return *realm.heap().allocate<HTML::HTMLHeadElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLHeadElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6))
return *realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLHeadingElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::hr)
return *realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLHRElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::html)
return *realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLHtmlElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::iframe)
return *realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLIFrameElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::img)
return *realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLImageElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::input)
return *realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLInputElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::label)
return *realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLLabelElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::legend)
return *realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLLegendElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::li)
return *realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLLIElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::link)
return *realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLLinkElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::map)
return *realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLMapElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::marquee)
return *realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLMarqueeElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::menu)
return *realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLMenuElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::meta)
return *realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLMetaElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::meter)
return *realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLMeterElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(HTML::TagNames::ins, HTML::TagNames::del))
return *realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLModElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::object)
return *realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLObjectElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::ol)
return *realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLOListElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::optgroup)
return *realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLOptGroupElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::option)
return *realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLOptionElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::output)
return *realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLOutputElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::p)
return *realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLParagraphElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::param)
return *realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLParamElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::picture)
return *realm.heap().allocate<HTML::HTMLPictureElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLPictureElement>(realm, document, move(qualified_name));
// NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification.
if (lowercase_tag_name.is_one_of(HTML::TagNames::pre, HTML::TagNames::listing, HTML::TagNames::xmp))
return *realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLPreElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::progress)
return *realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLProgressElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(HTML::TagNames::blockquote, HTML::TagNames::q))
return *realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLQuoteElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::script)
return *realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLScriptElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::select)
return *realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLSelectElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::slot)
return *realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLSlotElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::source)
return *realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLSourceElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::span)
return *realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLSpanElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::style)
return *realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLStyleElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::caption)
return *realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableCaptionElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th))
return *realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableCellElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(HTML::TagNames::colgroup, HTML::TagNames::col))
return *realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableColElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::table)
return *realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::tr)
return *realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableRowElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot))
return *realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTableSectionElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::template_)
return *realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTemplateElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::textarea)
return *realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTextAreaElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::time)
return *realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTimeElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::title)
return *realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTitleElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::track)
return *realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLTrackElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::ul)
return *realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLUListElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == HTML::TagNames::video)
return *realm.heap().allocate<HTML::HTMLVideoElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLVideoElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.is_one_of(
HTML::TagNames::article, HTML::TagNames::section, HTML::TagNames::nav, HTML::TagNames::aside, HTML::TagNames::hgroup, HTML::TagNames::header, HTML::TagNames::footer, HTML::TagNames::address, HTML::TagNames::dt, HTML::TagNames::dd, HTML::TagNames::figure, HTML::TagNames::figcaption, HTML::TagNames::main, HTML::TagNames::em, HTML::TagNames::strong, HTML::TagNames::small, HTML::TagNames::s, HTML::TagNames::cite, HTML::TagNames::dfn, HTML::TagNames::abbr, HTML::TagNames::ruby, HTML::TagNames::rt, HTML::TagNames::rp, HTML::TagNames::code, HTML::TagNames::var, HTML::TagNames::samp, HTML::TagNames::kbd, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::i, HTML::TagNames::b, HTML::TagNames::u, HTML::TagNames::mark, HTML::TagNames::bdi, HTML::TagNames::bdo, HTML::TagNames::wbr, HTML::TagNames::summary, HTML::TagNames::noscript,
// Obsolete
HTML::TagNames::acronym, HTML::TagNames::basefont, HTML::TagNames::big, HTML::TagNames::center, HTML::TagNames::nobr, HTML::TagNames::noembed, HTML::TagNames::noframes, HTML::TagNames::plaintext, HTML::TagNames::rb, HTML::TagNames::rtc, HTML::TagNames::strike, HTML::TagNames::tt))
return *realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::svg)
return *realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGSVGElement>(realm, document, move(qualified_name));
// FIXME: Support SVG's mixedCase tag names properly.
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::clipPath))
return *realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGClipPathElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::circle)
return *realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGCircleElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::defs))
return *realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGDefsElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::ellipse)
return *realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGEllipseElement>(realm, document, move(qualified_name));
if (lowercase_tag_name.equals_ignoring_case(SVG::TagNames::foreignObject))
return *realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGForeignObjectElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::line)
return *realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGLineElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::path)
return *realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGPathElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::polygon)
return *realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGPolygonElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::polyline)
return *realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGPolylineElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::rect)
return *realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGRectElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::g)
return *realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGGElement>(realm, document, move(qualified_name));
if (lowercase_tag_name == SVG::TagNames::text)
return *realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name));
return realm.heap().allocate<SVG::SVGTextContentElement>(realm, document, move(qualified_name));
// FIXME: If name is a valid custom element name, then return HTMLElement.
return *realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name));
return realm.heap().allocate<HTML::HTMLUnknownElement>(realm, document, move(qualified_name));
}
}

View file

@ -16,7 +16,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
{
return *realm.heap().allocate<Event>(realm, realm, event_name, event_init);
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);
}
JS::NonnullGCPtr<Event> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)

View file

@ -128,7 +128,7 @@ void EventTarget::add_event_listener(FlyString const& type, IDLEventListener* ca
// 2. Add an event listener with this and an event listener whose type is type, callback is callback, capture is capture, passive is passive,
// once is once, and signal is signal.
auto* event_listener = heap().allocate_without_realm<DOMEventListener>();
auto event_listener = heap().allocate_without_realm<DOMEventListener>();
event_listener->type = type;
event_listener->callback = callback;
event_listener->signal = move(flattened_options.signal);
@ -464,7 +464,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString
function->set_script_or_module({});
// 12. Set eventHandler's value to the result of creating a Web IDL EventHandler callback function object whose object reference is function and whose callback context is settings object.
event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object);
event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object).ptr();
}
// 4. Return eventHandler's value.
@ -498,7 +498,7 @@ void EventTarget::set_event_handler_attribute(FlyString const& name, WebIDL::Cal
// 3. Set eventHandler's value to the given value.
if (event_handler_iterator == handler_map.end()) {
// NOTE: See the optimization comment in get_current_value_of_event_handler about why this is done.
auto* new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(*value);
auto new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(*value);
// 4. Activate an event handler given eventTarget and name.
// Optimization: We pass in the event handler here instead of having activate_event_handler do another hash map lookup just to get the same object.
@ -556,10 +556,10 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
0, "", &realm);
// NOTE: As per the spec, the callback context is arbitrary.
auto* callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::host_defined_environment_settings_object(realm));
auto callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::host_defined_environment_settings_object(realm));
// 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback.
auto* listener = realm.heap().allocate_without_realm<DOMEventListener>();
auto listener = realm.heap().allocate_without_realm<DOMEventListener>();
listener->type = name;
listener->callback = IDLEventListener::create(realm, *callback).ptr();
@ -714,7 +714,7 @@ void EventTarget::element_event_handler_attribute_changed(FlyString const& local
// NOTE: See the optimization comments in set_event_handler_attribute.
if (event_handler_iterator == handler_map.end()) {
auto* new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(value);
auto new_event_handler = heap().allocate_without_realm<HTML::EventHandler>(value);
// 6. Activate an event handler given eventTarget and name.
event_target->activate_event_handler(local_name, *new_event_handler);

View file

@ -15,7 +15,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<HTMLCollection> HTMLCollection::create(ParentNode& root, Function<bool(Element const&)> filter)
{
return *root.heap().allocate<HTMLCollection>(root.realm(), root, move(filter));
return root.heap().allocate<HTMLCollection>(root.realm(), root, move(filter));
}
HTMLCollection::HTMLCollection(ParentNode& root, Function<bool(Element const&)> filter)

View file

@ -10,7 +10,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<IDLEventListener> IDLEventListener::create(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
{
return *realm.heap().allocate<IDLEventListener>(realm, realm, move(callback));
return realm.heap().allocate<IDLEventListener>(realm, realm, move(callback));
}
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)

View file

@ -12,7 +12,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<NodeList> LiveNodeList::create(JS::Realm& realm, Node& root, Function<bool(Node const&)> filter)
{
return *realm.heap().allocate<LiveNodeList>(realm, realm, root, move(filter));
return realm.heap().allocate<LiveNodeList>(realm, realm, root, move(filter));
}
LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Function<bool(Node const&)> filter)

View file

@ -13,7 +13,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<MutationObserver> MutationObserver::construct_impl(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackType> callback)
{
return *realm.heap().allocate<MutationObserver>(realm, realm, callback);
return realm.heap().allocate<MutationObserver>(realm, realm, callback);
}
// https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver
@ -142,7 +142,7 @@ Vector<JS::Handle<MutationRecord>> MutationObserver::take_records()
JS::NonnullGCPtr<RegisteredObserver> RegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options)
{
return *observer.heap().allocate_without_realm<RegisteredObserver>(observer, options);
return observer.heap().allocate_without_realm<RegisteredObserver>(observer, options);
}
RegisteredObserver::RegisteredObserver(MutationObserver& observer, MutationObserverInit const& options)
@ -161,7 +161,7 @@ void RegisteredObserver::visit_edges(Cell::Visitor& visitor)
JS::NonnullGCPtr<TransientRegisteredObserver> TransientRegisteredObserver::create(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)
{
return *observer.heap().allocate_without_realm<TransientRegisteredObserver>(observer, options, source);
return observer.heap().allocate_without_realm<TransientRegisteredObserver>(observer, options, source);
}
TransientRegisteredObserver::TransientRegisteredObserver(MutationObserver& observer, MutationObserverInit const& options, RegisteredObserver& source)

View file

@ -14,7 +14,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
{
return *realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
return realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
}
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)

View file

@ -15,7 +15,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<NamedNodeMap> NamedNodeMap::create(Element& element)
{
auto& realm = element.realm();
return *realm.heap().allocate<NamedNodeMap>(realm, element);
return realm.heap().allocate<NamedNodeMap>(realm, element);
}
NamedNodeMap::NamedNodeMap(Element& element)

View file

@ -11,7 +11,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<NodeFilter> NodeFilter::create(JS::Realm& realm, WebIDL::CallbackType& callback)
{
return *realm.heap().allocate<NodeFilter>(realm, realm, callback);
return realm.heap().allocate<NodeFilter>(realm, realm, callback);
}
NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback)

View file

@ -45,7 +45,7 @@ JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to
// 2. Set iterators root and iterators reference to root.
// 3. Set iterators pointer before reference to true.
auto& realm = root.realm();
auto* iterator = realm.heap().allocate<NodeIterator>(realm, root);
auto iterator = realm.heap().allocate<NodeIterator>(realm, root);
// 4. Set iterators whatToShow to whatToShow.
iterator->m_what_to_show = what_to_show;
@ -54,7 +54,7 @@ JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to
iterator->m_filter = filter;
// 6. Return iterator.
return *iterator;
return iterator;
}
// https://dom.spec.whatwg.org/#dom-nodeiterator-detach

View file

@ -26,14 +26,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<
if (node.has<JS::Handle<Node>>())
return *node.get<JS::Handle<Node>>();
return *document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>());
return document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>());
};
if (nodes.size() == 1)
return potentially_convert_string_to_text_node(nodes.first());
// This is NNGCP<Node> instead of NNGCP<DocumentFragment> to be compatible with the return type.
JS::NonnullGCPtr<Node> document_fragment = *document.heap().allocate<DOM::DocumentFragment>(document.realm(), document);
auto document_fragment = document.heap().allocate<DOM::DocumentFragment>(document.realm(), document);
for (auto& unconverted_node : nodes) {
auto node = potentially_convert_string_to_text_node(unconverted_node);
(void)TRY(document_fragment->append_child(node));

View file

@ -34,13 +34,13 @@ JS::NonnullGCPtr<Range> Range::create(HTML::Window& window)
JS::NonnullGCPtr<Range> Range::create(Document& document)
{
auto& realm = document.realm();
return *realm.heap().allocate<Range>(realm, document);
return realm.heap().allocate<Range>(realm, document);
}
JS::NonnullGCPtr<Range> Range::create(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset)
{
auto& realm = start_container.realm();
return *realm.heap().allocate<Range>(realm, start_container, start_offset, end_container, end_offset);
return realm.heap().allocate<Range>(realm, start_container, start_offset, end_container, end_offset);
}
JS::NonnullGCPtr<Range> Range::construct_impl(JS::Realm& realm)
@ -396,12 +396,12 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(Node const& node)
JS::NonnullGCPtr<Range> Range::clone_range() const
{
return *heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset);
return heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_start_container), m_start_offset, const_cast<Node&>(*m_end_container), m_end_offset);
}
JS::NonnullGCPtr<Range> Range::inverted() const
{
return *heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset);
return heap().allocate<Range>(shape().realm(), const_cast<Node&>(*m_end_container), m_end_offset, const_cast<Node&>(*m_start_container), m_start_offset);
}
JS::NonnullGCPtr<Range> Range::normalized() const
@ -555,11 +555,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract_contents(
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
{
// 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document.
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
// 2. If range is collapsed, then return fragment.
if (collapsed())
return JS::NonnullGCPtr(*fragment);
return fragment;
// 3. Let original start node, original start offset, original end node, and original end offset
// be ranges start node, start offset, end node, and end offset, respectively.
@ -585,7 +585,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
TRY(static_cast<CharacterData&>(*original_start_node).replace_data(original_start_offset, original_end_offset - original_start_offset, ""));
// 5. Return fragment.
return JS::NonnullGCPtr(*fragment);
return fragment;
}
// 5. Let common ancestor be original start node.
@ -735,7 +735,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
TRY(set_end(*new_node, new_offset));
// 21. Return fragment.
return JS::NonnullGCPtr(*fragment);
return fragment;
}
// https://dom.spec.whatwg.org/#contained
@ -884,11 +884,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_contents()
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_contents()
{
// 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document.
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
// 2. If range is collapsed, then return fragment.
if (collapsed())
return JS::NonnullGCPtr(*fragment);
return fragment;
// 3. Let original start node, original start offset, original end node, and original end offset
// be ranges start node, start offset, end node, and end offset, respectively.
@ -911,7 +911,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
TRY(fragment->append_child(clone));
// 4. Return fragment.
return JS::NonnullGCPtr(*fragment);
return fragment;
}
// 5. Let common ancestor be original start node.
@ -1033,7 +1033,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_content
}
// 18. Return fragment.
return JS::NonnullGCPtr(*fragment);
return fragment;
}
// https://dom.spec.whatwg.org/#dom-range-deletecontents

View file

@ -11,7 +11,7 @@ namespace Web::DOM {
JS::NonnullGCPtr<NodeList> StaticNodeList::create(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
{
return *realm.heap().allocate<StaticNodeList>(realm, realm, move(static_nodes));
return realm.heap().allocate<StaticNodeList>(realm, realm, move(static_nodes));
}
StaticNodeList::StaticNodeList(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)

View file

@ -33,7 +33,7 @@ WebIDL::ExceptionOr<StaticRange*> StaticRange::construct_impl(JS::Realm& realm,
return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node.");
// 2. Set thiss start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]).
return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset);
return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).ptr();
}
}

View file

@ -37,7 +37,7 @@ JS::NonnullGCPtr<Text> Text::construct_impl(JS::Realm& realm, DeprecatedString c
{
// The new Text(data) constructor steps are to set thiss data to data and thiss node document to current global objects associated Document.
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
return *realm.heap().allocate<Text>(realm, window.associated_document(), data);
return realm.heap().allocate<Text>(realm, window.associated_document(), data);
}
void Text::set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement& input_element)
@ -63,7 +63,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
auto new_data = TRY(substring_data(offset, count));
// 5. Let new node be a new Text node, with the same node document as node. Set new nodes data to new data.
auto new_node = JS::NonnullGCPtr(*heap().allocate<Text>(realm(), document(), new_data));
auto new_node = heap().allocate<Text>(realm(), document(), new_data);
// 6. Let parent be nodes parent.
JS::GCPtr<Node> parent = this->parent();

View file

@ -36,7 +36,7 @@ JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_sho
// 1. Let walker be a new TreeWalker object.
// 2. Set walkers root and walkers current to root.
auto& realm = root.realm();
auto* walker = realm.heap().allocate<TreeWalker>(realm, root);
auto walker = realm.heap().allocate<TreeWalker>(realm, root);
// 3. Set walkers whatToShow to whatToShow.
walker->m_what_to_show = what_to_show;
@ -45,7 +45,7 @@ JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_sho
walker->m_filter = filter;
// 5. Return walker.
return *walker;
return walker;
}
// https://dom.spec.whatwg.org/#dom-treewalker-currentnode

View file

@ -28,7 +28,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(Depr
(void)TRY(fragment->append_child(*child));
}
return JS::NonnullGCPtr(*fragment);
return fragment;
}
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml

View file

@ -22,7 +22,7 @@ namespace Web::DOMParsing {
JS::NonnullGCPtr<XMLSerializer> XMLSerializer::construct_impl(JS::Realm& realm)
{
return *realm.heap().allocate<XMLSerializer>(realm, realm);
return realm.heap().allocate<XMLSerializer>(realm, realm);
}
XMLSerializer::XMLSerializer(JS::Realm& realm)

View file

@ -18,7 +18,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::construct_impl(J
if (!decoder)
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Invalid encoding {}", encoding) };
return JS::NonnullGCPtr(*realm.heap().allocate<TextDecoder>(realm, realm, *decoder, move(encoding), false, false));
return realm.heap().allocate<TextDecoder>(realm, realm, *decoder, move(encoding), false, false);
}
// https://encoding.spec.whatwg.org/#dom-textdecoder

View file

@ -13,7 +13,7 @@ namespace Web::Encoding {
JS::NonnullGCPtr<TextEncoder> TextEncoder::construct_impl(JS::Realm& realm)
{
return *realm.heap().allocate<TextEncoder>(realm, realm);
return realm.heap().allocate<TextEncoder>(realm, realm);
}
TextEncoder::TextEncoder(JS::Realm& realm)

View file

@ -14,12 +14,12 @@ namespace Web::Fetch::Fetching {
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request)
{
return { *vm.heap().allocate_without_realm<PendingResponse>(request) };
return vm.heap().allocate_without_realm<PendingResponse>(request);
}
JS::NonnullGCPtr<PendingResponse> PendingResponse::create(JS::VM& vm, JS::NonnullGCPtr<Infrastructure::Request> request, JS::NonnullGCPtr<Infrastructure::Response> response)
{
return { *vm.heap().allocate_without_realm<PendingResponse>(request, response) };
return vm.heap().allocate_without_realm<PendingResponse>(request, response);
}
PendingResponse::PendingResponse(JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Infrastructure::Response> response)

View file

@ -16,7 +16,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
auto& vm = realm.vm();
// The new Headers(init) constructor steps are:
auto* headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
auto headers = realm.heap().allocate<Headers>(realm, realm, Infrastructure::HeaderList::create(vm));
// 1. Set thiss guard to "none".
headers->m_guard = Guard::None;
@ -25,7 +25,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::construct_impl(JS::Realm
if (init.has_value())
TRY(headers->fill(*init));
return JS::NonnullGCPtr(*headers);
return headers;
}
Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> header_list)

Some files were not shown because too many files have changed in this diff Show more