mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +00:00
LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocate
Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
This commit is contained in:
parent
109b190a19
commit
b75b7f0c0d
|
@ -174,10 +174,10 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea
|
|||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
auto prototype = heap().allocate<@prototype_class@>(realm, realm);
|
||||
auto prototype = heap().allocate<@prototype_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_prototypes.set("@interface_name@"sv, prototype);
|
||||
|
||||
auto constructor = heap().allocate<@constructor_class@>(realm, realm);
|
||||
auto constructor = heap().allocate<@constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_constructors.set("@interface_name@"sv, constructor);
|
||||
|
||||
prototype->define_direct_property(vm.names.constructor, constructor.ptr(), JS::Attribute::Writable | JS::Attribute::Configurable);
|
||||
|
@ -188,7 +188,7 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea
|
|||
gen.set("legacy_interface_name", legacy_constructor->name);
|
||||
gen.set("legacy_constructor_class", legacy_constructor->constructor_class);
|
||||
gen.append(R"~~~(
|
||||
auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm);
|
||||
auto legacy_constructor = heap().allocate<@legacy_constructor_class@>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_constructors.set("@legacy_interface_name@"sv, legacy_constructor);
|
||||
|
||||
legacy_constructor->define_direct_property(vm.names.name, JS::PrimitiveString::create(vm, "@legacy_interface_name@"sv), JS::Attribute::Configurable);)~~~");
|
||||
|
|
|
@ -51,7 +51,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 = MUST_OR_THROW_OOM(realm.heap().allocate<WebAssemblyModule>(realm, *realm.intrinsics().object_prototype()));
|
||||
instance->m_module = move(module);
|
||||
Wasm::Linker linker(*instance->m_module);
|
||||
linker.link(imports);
|
||||
|
|
|
@ -27,7 +27,7 @@ Workbook::Workbook(NonnullRefPtrVector<Sheet>&& sheets, GUI::Window& parent_wind
|
|||
, m_main_execution_context(m_vm->heap())
|
||||
, m_parent_window(parent_window)
|
||||
{
|
||||
m_workbook_object = m_vm->heap().allocate<WorkbookObject>(m_interpreter->realm(), m_interpreter->realm(), *this);
|
||||
m_workbook_object = m_vm->heap().allocate<WorkbookObject>(m_interpreter->realm(), m_interpreter->realm(), *this).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_interpreter->realm().global_object().define_direct_property("workbook", workbook_object(), JS::default_attributes);
|
||||
|
||||
m_main_execution_context.current_node = nullptr;
|
||||
|
|
|
@ -28,8 +28,8 @@ ThrowCompletionOr<void> $262Object::initialize(Realm& realm)
|
|||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
m_agent = vm().heap().allocate<AgentObject>(realm, realm);
|
||||
m_is_htmldda = vm().heap().allocate<IsHTMLDDA>(realm, realm);
|
||||
m_agent = MUST_OR_THROW_OOM(vm().heap().allocate<AgentObject>(realm, realm));
|
||||
m_is_htmldda = MUST_OR_THROW_OOM(vm().heap().allocate<IsHTMLDDA>(realm, realm));
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, "clearKeptObjects", clear_kept_objects, 0, attr);
|
||||
|
|
|
@ -18,7 +18,7 @@ ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm)
|
|||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
|
||||
m_$262 = vm().heap().allocate<$262Object>(realm, realm);
|
||||
m_$262 = MUST_OR_THROW_OOM(vm().heap().allocate<$262Object>(realm, realm));
|
||||
|
||||
// https://github.com/tc39/test262/blob/master/INTERPRETING.md#host-defined-functions
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
|
|
|
@ -41,15 +41,12 @@ public:
|
|||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
NonnullGCPtr<T> allocate(Realm& realm, Args&&... args)
|
||||
ThrowCompletionOr<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);
|
||||
|
||||
// FIXME: Propagate this error.
|
||||
(void)memory->initialize(realm);
|
||||
|
||||
MUST_OR_THROW_OOM(memory->initialize(realm));
|
||||
return *cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ Object* Module::module_namespace_create(VM& vm, Vector<DeprecatedFlyString> unam
|
|||
// 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.
|
||||
auto 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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 9. Set module.[[Namespace]] to M.
|
||||
m_namespace = make_handle(module_namespace);
|
||||
|
|
|
@ -1104,7 +1104,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 14. Let index be 0.
|
||||
// 15. Repeat, while index < len,
|
||||
|
|
|
@ -146,7 +146,7 @@ ThrowCompletionOr<NonnullGCPtr<T>> ordinary_create_from_constructor(VM& vm, Func
|
|||
{
|
||||
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 MUST_OR_THROW_OOM(realm.heap().allocate<T>(realm, forward<Args>(args)..., *prototype));
|
||||
}
|
||||
|
||||
// 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AggregateError::AggregateError(Object& prototype)
|
||||
|
|
|
@ -32,7 +32,7 @@ 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 = MUST_OR_THROW_OOM(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 }));
|
||||
|
|
|
@ -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 realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.intrinsics().array_buffer_prototype());
|
||||
return MUST_OR_THROW_OOM(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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ArrayBuffer::ArrayBuffer(ByteBuffer buffer, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace JS {
|
|||
|
||||
ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object)
|
||||
{
|
||||
auto wrapper = realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, generator_object);
|
||||
auto wrapper = MUST_OR_THROW_OOM(realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, generator_object));
|
||||
return wrapper->react_to_async_task_completion(realm.vm(), js_undefined(), true);
|
||||
}
|
||||
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
BigIntObject::BigIntObject(BigInt& bigint, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
BooleanObject::BooleanObject(bool value, Object& prototype)
|
||||
|
|
|
@ -26,7 +26,7 @@ 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 = MUST_OR_THROW_OOM(realm.heap().allocate<BoundFunction>(realm, realm, target_function, bound_this, move(bound_arguments), prototype));
|
||||
|
||||
// 10. Return obj.
|
||||
return object;
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
DataView::DataView(ArrayBuffer* viewed_buffer, size_t byte_length, size_t byte_offset, Object& prototype)
|
||||
|
|
|
@ -25,7 +25,7 @@ Crypto::SignedBigInteger const ns_per_day_bigint { static_cast<i64>(ns_per_day)
|
|||
|
||||
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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Date::Date(double date_value, Object& prototype)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString 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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString 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)
|
||||
|
@ -114,7 +114,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::initialize(Realm& realm)
|
|||
Object* prototype = nullptr;
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Normal:
|
||||
prototype = vm.heap().allocate<Object>(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape());
|
||||
prototype = MUST_OR_THROW_OOM(vm.heap().allocate<Object>(realm, *realm.intrinsics().new_ordinary_function_prototype_object_shape()));
|
||||
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NonnullGCPtr<Error> Error::create(Realm& realm, DeprecatedString const& message)
|
||||
|
@ -98,24 +98,24 @@ DeprecatedString Error::stack_string() const
|
|||
return stack_string_builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
#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()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} \
|
||||
\
|
||||
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
|
||||
|
|
|
@ -28,7 +28,7 @@ ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> GeneratorObject::create(Realm&
|
|||
generating_function_prototype = TRY(generating_function->get(vm.names.prototype));
|
||||
}
|
||||
auto* generating_function_prototype_object = TRY(generating_function_prototype.to_object(vm));
|
||||
auto object = realm.heap().allocate<GeneratorObject>(realm, realm, *generating_function_prototype_object, move(execution_context));
|
||||
auto object = MUST_OR_THROW_OOM(realm.heap().allocate<GeneratorObject>(realm, realm, *generating_function_prototype_object, move(execution_context)));
|
||||
object->m_generating_function = generating_function;
|
||||
object->m_frame = move(frame);
|
||||
object->m_previous_value = initial_value;
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collator)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, Object& prototype)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS::Intl {
|
|||
|
||||
ThrowCompletionOr<NonnullGCPtr<Locale>> Locale::create(Realm& realm, ::Locale::LocaleID locale_id)
|
||||
{
|
||||
auto locale = realm.heap().allocate<Locale>(realm, *realm.intrinsics().intl_locale_prototype());
|
||||
auto locale = MUST_OR_THROW_OOM(realm.heap().allocate<Locale>(realm, *realm.intrinsics().intl_locale_prototype()));
|
||||
locale->set_locale(TRY_OR_THROW_OOM(realm.vm(), locale_id.to_string()));
|
||||
|
||||
for (auto& extension : locale_id.extensions) {
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace JS::Intl {
|
|||
// 1.5.2 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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& prototype)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects
|
||||
|
|
|
@ -189,26 +189,26 @@ void Intrinsics::initialize_intrinsics(Realm& realm)
|
|||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name) \
|
||||
VERIFY(!m_##snake_name##_prototype); \
|
||||
m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(realm, realm);
|
||||
m_##snake_name##_prototype = heap().allocate<ClassName##Prototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
JS_ENUMERATE_ITERATOR_PROTOTYPES
|
||||
#undef __JS_ENUMERATE
|
||||
|
||||
// These must be initialized separately as they have no companion constructor
|
||||
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(realm, realm);
|
||||
m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm);
|
||||
m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm);
|
||||
m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(realm, realm);
|
||||
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_generator_prototype = heap().allocate<GeneratorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// These must be initialized before allocating...
|
||||
// - AggregateErrorPrototype, which uses ErrorPrototype as its prototype
|
||||
// - AggregateErrorConstructor, which uses ErrorConstructor as its prototype
|
||||
// - AsyncFunctionConstructor, which uses FunctionConstructor as its prototype
|
||||
m_error_prototype = heap().allocate<ErrorPrototype>(realm, realm);
|
||||
m_error_constructor = heap().allocate<ErrorConstructor>(realm, realm);
|
||||
m_function_constructor = heap().allocate<FunctionConstructor>(realm, realm);
|
||||
m_error_prototype = heap().allocate<ErrorPrototype>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_error_constructor = heap().allocate<ErrorConstructor>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
m_function_constructor = heap().allocate<FunctionConstructor>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
|
||||
m_proxy_constructor = heap().allocate<ProxyConstructor>(realm, realm);
|
||||
m_proxy_constructor = heap().allocate<ProxyConstructor>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// Global object functions
|
||||
m_eval_function = NativeFunction::create(realm, GlobalObject::eval, 1, vm.names.eval, &realm);
|
||||
|
@ -223,7 +223,7 @@ void Intrinsics::initialize_intrinsics(Realm& realm)
|
|||
m_escape_function = NativeFunction::create(realm, GlobalObject::escape, 1, vm.names.escape, &realm);
|
||||
m_unescape_function = NativeFunction::create(realm, GlobalObject::unescape, 1, vm.names.unescape, &realm);
|
||||
|
||||
m_object_constructor = heap().allocate<ObjectConstructor>(realm, realm);
|
||||
m_object_constructor = heap().allocate<ObjectConstructor>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror%
|
||||
m_throw_type_error_function = NativeFunction::create(
|
||||
|
@ -266,52 +266,52 @@ constexpr inline bool IsTypedArrayConstructor = false;
|
|||
JS_ENUMERATE_TYPED_ARRAYS
|
||||
#undef __JS_ENUMERATE
|
||||
|
||||
#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \
|
||||
void Intrinsics::initialize_##snake_namespace##snake_name() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
\
|
||||
VERIFY(!m_##snake_namespace##snake_name##_prototype); \
|
||||
VERIFY(!m_##snake_namespace##snake_name##_constructor); \
|
||||
if constexpr (IsTypedArrayConstructor<Namespace::ConstructorName>) { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype()); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor()); \
|
||||
} else { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, m_realm); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm); \
|
||||
} \
|
||||
\
|
||||
/* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \
|
||||
if constexpr (IsSame<Namespace::ConstructorName, BigIntConstructor>) \
|
||||
initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, BooleanConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, FunctionConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, NumberConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, RegExpConstructor>) \
|
||||
initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, StringConstructor>) \
|
||||
initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, SymbolConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else \
|
||||
initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
} \
|
||||
\
|
||||
Namespace::ConstructorName* Intrinsics::snake_namespace##snake_name##_constructor() \
|
||||
{ \
|
||||
if (!m_##snake_namespace##snake_name##_constructor) \
|
||||
initialize_##snake_namespace##snake_name(); \
|
||||
return m_##snake_namespace##snake_name##_constructor; \
|
||||
} \
|
||||
\
|
||||
Object* Intrinsics::snake_namespace##snake_name##_prototype() \
|
||||
{ \
|
||||
if (!m_##snake_namespace##snake_name##_prototype) \
|
||||
initialize_##snake_namespace##snake_name(); \
|
||||
return m_##snake_namespace##snake_name##_prototype; \
|
||||
#define __JS_ENUMERATE_INNER(ClassName, snake_name, PrototypeName, ConstructorName, Namespace, snake_namespace) \
|
||||
void Intrinsics::initialize_##snake_namespace##snake_name() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
\
|
||||
VERIFY(!m_##snake_namespace##snake_name##_prototype); \
|
||||
VERIFY(!m_##snake_namespace##snake_name##_constructor); \
|
||||
if constexpr (IsTypedArrayConstructor<Namespace::ConstructorName>) { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, *typed_array_prototype()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm, *typed_array_constructor()).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} else { \
|
||||
m_##snake_namespace##snake_name##_prototype = heap().allocate<Namespace::PrototypeName>(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
m_##snake_namespace##snake_name##_constructor = heap().allocate<Namespace::ConstructorName>(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} \
|
||||
\
|
||||
/* FIXME: Add these special cases to JS_ENUMERATE_NATIVE_OBJECTS */ \
|
||||
if constexpr (IsSame<Namespace::ConstructorName, BigIntConstructor>) \
|
||||
initialize_constructor(vm, vm.names.BigInt, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, BooleanConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Boolean, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, FunctionConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Function, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, NumberConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Number, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, RegExpConstructor>) \
|
||||
initialize_constructor(vm, vm.names.RegExp, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, StringConstructor>) \
|
||||
initialize_constructor(vm, vm.names.String, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else if constexpr (IsSame<Namespace::ConstructorName, SymbolConstructor>) \
|
||||
initialize_constructor(vm, vm.names.Symbol, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
else \
|
||||
initialize_constructor(vm, vm.names.ClassName, *m_##snake_namespace##snake_name##_constructor, m_##snake_namespace##snake_name##_prototype); \
|
||||
} \
|
||||
\
|
||||
Namespace::ConstructorName* Intrinsics::snake_namespace##snake_name##_constructor() \
|
||||
{ \
|
||||
if (!m_##snake_namespace##snake_name##_constructor) \
|
||||
initialize_##snake_namespace##snake_name(); \
|
||||
return m_##snake_namespace##snake_name##_constructor; \
|
||||
} \
|
||||
\
|
||||
Object* Intrinsics::snake_namespace##snake_name##_prototype() \
|
||||
{ \
|
||||
if (!m_##snake_namespace##snake_name##_prototype) \
|
||||
initialize_##snake_namespace##snake_name(); \
|
||||
return m_##snake_namespace##snake_name##_prototype; \
|
||||
}
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
|
@ -331,12 +331,12 @@ JS_ENUMERATE_TEMPORAL_OBJECTS
|
|||
|
||||
#undef __JS_ENUMERATE_INNER
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name) \
|
||||
ClassName* Intrinsics::snake_name##_object() \
|
||||
{ \
|
||||
if (!m_##snake_name##_object) \
|
||||
m_##snake_name##_object = heap().allocate<ClassName>(m_realm, m_realm); \
|
||||
return m_##snake_name##_object; \
|
||||
#define __JS_ENUMERATE(ClassName, snake_name) \
|
||||
ClassName* Intrinsics::snake_name##_object() \
|
||||
{ \
|
||||
if (!m_##snake_name##_object) \
|
||||
m_##snake_name##_object = heap().allocate<ClassName>(m_realm, m_realm).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
return m_##snake_name##_object; \
|
||||
}
|
||||
JS_ENUMERATE_BUILTIN_NAMESPACE_OBJECTS
|
||||
#undef __JS_ENUMERATE
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Map::Map(Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 10. Perform SetFunctionLength(func, length).
|
||||
function->set_function_length(length);
|
||||
|
@ -53,7 +53,7 @@ NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& allocating_realm, Saf
|
|||
|
||||
NonnullGCPtr<NativeFunction> NativeFunction::create(Realm& realm, DeprecatedFlyString 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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NativeFunction::NativeFunction(SafeFunction<ThrowCompletionOr<Value>(VM&)> native_function, Object* prototype, Realm& realm)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NumberObject::NumberObject(double value, Object& prototype)
|
||||
|
|
|
@ -30,11 +30,10 @@ static HashMap<Object const*, HashMap<DeprecatedFlyString, Object::IntrinsicAcce
|
|||
NonnullGCPtr<Object> Object::create(Realm& realm, Object* prototype)
|
||||
{
|
||||
if (!prototype)
|
||||
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());
|
||||
else
|
||||
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype);
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().empty_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
if (prototype == realm.intrinsics().object_prototype())
|
||||
return realm.heap().allocate<Object>(realm, *realm.intrinsics().new_object_shape()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return realm.heap().allocate<Object>(realm, ConstructWithPrototypeTag::Tag, *prototype).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Object::Object(GlobalObjectTag, Realm& realm)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// 27.2 Promise Objects, https://tc39.es/ecma262/#sec-promise-objects
|
||||
|
|
|
@ -57,7 +57,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PromiseAllResolveElementFunction::PromiseAllResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -89,7 +89,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PromiseAllSettledResolveElementFunction::PromiseAllSettledResolveElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -130,7 +130,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PromiseAllSettledRejectElementFunction::PromiseAllSettledRejectElementFunction(size_t index, PromiseValueList& values, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
@ -171,7 +171,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PromiseAnyRejectElementFunction::PromiseAnyRejectElementFunction(size_t index, PromiseValueList& errors, NonnullGCPtr<PromiseCapability> capability, RemainingElements& remaining_elements, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyResolved& already_resolved, FunctionType native_function, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ProxyObject::ProxyObject(Object& target, Object& handler, Object& prototype)
|
||||
|
|
|
@ -130,12 +130,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(Object& prototype)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
RegExpStringIterator::RegExpStringIterator(Object& prototype, Object& regexp_object, Utf16String string, bool global, bool unicode)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Set::Set(Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<StringIterator> StringIterator::create(Realm& realm, String 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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StringIterator::StringIterator(String string, Object& prototype)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StringObject::StringObject(PrimitiveString& string, Object& prototype)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace JS {
|
|||
|
||||
NonnullGCPtr<SuppressedError> SuppressedError::create(Realm& realm)
|
||||
{
|
||||
return *realm.heap().allocate<SuppressedError>(realm, *realm.intrinsics().suppressed_error_prototype());
|
||||
return *realm.heap().allocate<SuppressedError>(realm, *realm.intrinsics().suppressed_error_prototype()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SuppressedError::SuppressedError(Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SymbolObject::SymbolObject(Symbol& symbol, Object& prototype)
|
||||
|
|
|
@ -36,7 +36,7 @@ ThrowCompletionOr<void> Temporal::initialize(Realm& realm)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_direct_property(vm.names.Now, heap().allocate<Now>(realm, realm), attr);
|
||||
define_direct_property(vm.names.Now, MUST_OR_THROW_OOM(heap().allocate<Now>(realm, realm)), attr);
|
||||
define_intrinsic_accessor(vm.names.Calendar, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_calendar_constructor(); });
|
||||
define_intrinsic_accessor(vm.names.Duration, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_duration_constructor(); });
|
||||
define_intrinsic_accessor(vm.names.Instant, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_instant_constructor(); });
|
||||
|
|
|
@ -420,141 +420,141 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_viewed_array_buffer);
|
||||
}
|
||||
|
||||
#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
|
||||
{ \
|
||||
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 realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
|
||||
{ \
|
||||
auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
|
||||
return create(realm, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
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); \
|
||||
} \
|
||||
\
|
||||
ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
|
||||
: TypedArray(prototype, \
|
||||
reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&Intrinsics::snake_name##_constructor), length, array_buffer) \
|
||||
{ \
|
||||
if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
|
||||
m_content_type = ContentType::BigInt; \
|
||||
else \
|
||||
m_content_type = ContentType::Number; \
|
||||
} \
|
||||
\
|
||||
ClassName::~ClassName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
DeprecatedFlyString const& ClassName::element_name() const \
|
||||
{ \
|
||||
return vm().names.ClassName.as_string(); \
|
||||
} \
|
||||
\
|
||||
PrototypeName::PrototypeName(Object& prototype) \
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
PrototypeName::~PrototypeName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm)); \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
\
|
||||
return {}; \
|
||||
} \
|
||||
\
|
||||
ConstructorName::ConstructorName(Realm& realm, Object& prototype) \
|
||||
: TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \
|
||||
\
|
||||
/* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
|
||||
\
|
||||
/* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
|
||||
\
|
||||
return {}; \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<Value> ConstructorName::call() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
auto& realm = *vm.current_realm(); \
|
||||
\
|
||||
if (vm.argument_count() == 0) \
|
||||
return TRY(ClassName::create(realm, 0, new_target)); \
|
||||
\
|
||||
auto first_argument = vm.argument(0); \
|
||||
if (first_argument.is_object()) { \
|
||||
auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \
|
||||
if (first_argument.as_object().is_typed_array()) { \
|
||||
auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
|
||||
} else if (is<ArrayBuffer>(first_argument.as_object())) { \
|
||||
auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
|
||||
vm.argument(1), vm.argument(2))); \
|
||||
} else { \
|
||||
auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
|
||||
if (iterator) { \
|
||||
auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
|
||||
TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
|
||||
} else { \
|
||||
TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
|
||||
} \
|
||||
} \
|
||||
return typed_array; \
|
||||
} \
|
||||
\
|
||||
auto array_length_or_error = first_argument.to_index(vm); \
|
||||
if (array_length_or_error.is_error()) { \
|
||||
auto error = array_length_or_error.release_error(); \
|
||||
if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
|
||||
/* Re-throw more specific RangeError */ \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
} \
|
||||
return error; \
|
||||
} \
|
||||
auto array_length = array_length_or_error.release_value(); \
|
||||
if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
/* FIXME: What is the best/correct behavior here? */ \
|
||||
if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
return TRY(ClassName::create(realm, array_length, new_target)); \
|
||||
#define JS_DEFINE_TYPED_ARRAY(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length, FunctionObject& new_target) \
|
||||
{ \
|
||||
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 MUST_OR_THROW_OOM(realm.heap().allocate<ClassName>(realm, *prototype, length, *array_buffer)); \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<NonnullGCPtr<ClassName>> ClassName::create(Realm& realm, u32 length) \
|
||||
{ \
|
||||
auto array_buffer = TRY(ArrayBuffer::create(realm, length * sizeof(UnderlyingBufferDataType))); \
|
||||
return create(realm, length, *array_buffer); \
|
||||
} \
|
||||
\
|
||||
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).release_allocated_value_but_fixme_should_propagate_errors(); \
|
||||
} \
|
||||
\
|
||||
ClassName::ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer) \
|
||||
: TypedArray(prototype, \
|
||||
reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&Intrinsics::snake_name##_constructor), length, array_buffer) \
|
||||
{ \
|
||||
if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
|
||||
m_content_type = ContentType::BigInt; \
|
||||
else \
|
||||
m_content_type = ContentType::Number; \
|
||||
} \
|
||||
\
|
||||
ClassName::~ClassName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
DeprecatedFlyString const& ClassName::element_name() const \
|
||||
{ \
|
||||
return vm().names.ClassName.as_string(); \
|
||||
} \
|
||||
\
|
||||
PrototypeName::PrototypeName(Object& prototype) \
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
PrototypeName::~PrototypeName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm)); \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
\
|
||||
return {}; \
|
||||
} \
|
||||
\
|
||||
ConstructorName::ConstructorName(Realm& realm, Object& prototype) \
|
||||
: TypedArrayConstructor(realm.vm().names.ClassName.as_string(), prototype) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \
|
||||
\
|
||||
/* 23.2.6.2 TypedArray.prototype, https://tc39.es/ecma262/#sec-typedarray.prototype */ \
|
||||
define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \
|
||||
\
|
||||
/* 23.2.6.1 TypedArray.BYTES_PER_ELEMENT, https://tc39.es/ecma262/#sec-typedarray.bytes_per_element */ \
|
||||
define_direct_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(3), Attribute::Configurable); \
|
||||
\
|
||||
return {}; \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<Value> ConstructorName::call() \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \
|
||||
} \
|
||||
\
|
||||
/* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> ConstructorName::construct(FunctionObject& new_target) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
auto& realm = *vm.current_realm(); \
|
||||
\
|
||||
if (vm.argument_count() == 0) \
|
||||
return TRY(ClassName::create(realm, 0, new_target)); \
|
||||
\
|
||||
auto first_argument = vm.argument(0); \
|
||||
if (first_argument.is_object()) { \
|
||||
auto typed_array = TRY(ClassName::create(realm, 0, new_target)); \
|
||||
if (first_argument.as_object().is_typed_array()) { \
|
||||
auto& arg_typed_array = static_cast<TypedArrayBase&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_typed_array(vm, *typed_array, arg_typed_array)); \
|
||||
} else if (is<ArrayBuffer>(first_argument.as_object())) { \
|
||||
auto& array_buffer = static_cast<ArrayBuffer&>(first_argument.as_object()); \
|
||||
TRY(initialize_typed_array_from_array_buffer(vm, *typed_array, array_buffer, \
|
||||
vm.argument(1), vm.argument(2))); \
|
||||
} else { \
|
||||
auto iterator = TRY(first_argument.get_method(vm, *vm.well_known_symbol_iterator())); \
|
||||
if (iterator) { \
|
||||
auto values = TRY(iterable_to_list(vm, first_argument, iterator)); \
|
||||
TRY(initialize_typed_array_from_list(vm, *typed_array, values)); \
|
||||
} else { \
|
||||
TRY(initialize_typed_array_from_array_like(vm, *typed_array, first_argument.as_object())); \
|
||||
} \
|
||||
} \
|
||||
return typed_array; \
|
||||
} \
|
||||
\
|
||||
auto array_length_or_error = first_argument.to_index(vm); \
|
||||
if (array_length_or_error.is_error()) { \
|
||||
auto error = array_length_or_error.release_error(); \
|
||||
if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \
|
||||
/* Re-throw more specific RangeError */ \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
} \
|
||||
return error; \
|
||||
} \
|
||||
auto array_length = array_length_or_error.release_value(); \
|
||||
if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
/* FIXME: What is the best/correct behavior here? */ \
|
||||
if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \
|
||||
return TRY(ClassName::create(realm, array_length, new_target)); \
|
||||
}
|
||||
|
||||
#undef __JS_ENUMERATE
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakMap::WeakMap(Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakRef::WeakRef(Object& value, Object& prototype)
|
||||
|
|
|
@ -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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
WeakSet::WeakSet(Object& prototype)
|
||||
|
|
|
@ -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 = MUST_OR_THROW_OOM(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);
|
||||
|
|
|
@ -375,7 +375,7 @@ 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 intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
auto host_defined = make<HostDefined>(nullptr, intrinsics);
|
||||
root_realm->set_host_defined(move(host_defined));
|
||||
custom_data.internal_realm = root_realm;
|
||||
|
|
|
@ -53,7 +53,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> OptionConstructor::construct
|
|||
if (vm.argument_count() > 0) {
|
||||
auto text = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
if (!text.is_empty()) {
|
||||
auto new_text_node = vm.heap().allocate<DOM::Text>(realm, document, text);
|
||||
auto new_text_node = MUST_OR_THROW_OOM(vm.heap().allocate<DOM::Text>(realm, document, text));
|
||||
MUST(option_element->append_child(*new_text_node));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSFontFaceRule* CSSFontFaceRule::create(JS::Realm& realm, FontFace&& font_face)
|
||||
{
|
||||
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face));
|
||||
return realm.heap().allocate<CSSFontFaceRule>(realm, realm, move(font_face)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face)
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Web::CSS {
|
|||
CSSImportRule* CSSImportRule::create(AK::URL url, DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return realm.heap().allocate<CSSImportRule>(realm, move(url), document);
|
||||
return realm.heap().allocate<CSSImportRule>(realm, move(url), document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSMediaRule* CSSMediaRule::create(JS::Realm& realm, MediaList& media_queries, CSSRuleList& rules)
|
||||
{
|
||||
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules);
|
||||
return realm.heap().allocate<CSSMediaRule>(realm, realm, media_queries, rules).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rules)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
for (auto* rule : rules)
|
||||
rule_list->m_rules.append(*rule);
|
||||
return rule_list;
|
||||
|
@ -32,7 +32,7 @@ CSSRuleList::CSSRuleList(JS::Realm& realm)
|
|||
|
||||
CSSRuleList* CSSRuleList::create_empty(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<CSSRuleList>(realm, realm);
|
||||
return realm.heap().allocate<CSSRuleList>(realm, realm).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<void> CSSRuleList::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -21,7 +21,7 @@ CSSStyleDeclaration::CSSStyleDeclaration(JS::Realm& realm)
|
|||
|
||||
PropertyOwningCSSStyleDeclaration* PropertyOwningCSSStyleDeclaration::create(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
{
|
||||
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties));
|
||||
return realm.heap().allocate<PropertyOwningCSSStyleDeclaration>(realm, realm, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm& realm, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
|
@ -41,7 +41,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const
|
|||
ElementInlineCSSStyleDeclaration* ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
{
|
||||
auto& realm = element.realm();
|
||||
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties));
|
||||
return realm.heap().allocate<ElementInlineCSSStyleDeclaration>(realm, element, move(properties), move(custom_properties)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ElementInlineCSSStyleDeclaration::ElementInlineCSSStyleDeclaration(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSStyleRule* CSSStyleRule::create(JS::Realm& realm, NonnullRefPtrVector<Web::CSS::Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
{
|
||||
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration);
|
||||
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector<Selector>&& selectors, CSSStyleDeclaration& declaration)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSStyleSheet* CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
{
|
||||
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));
|
||||
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::CSS {
|
|||
|
||||
CSSSupportsRule* CSSSupportsRule::create(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
{
|
||||
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules);
|
||||
return realm.heap().allocate<CSSSupportsRule>(realm, realm, move(supports), rules).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& supports, CSSRuleList& rules)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::CSS {
|
|||
|
||||
MediaList* MediaList::create(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
{
|
||||
return realm.heap().allocate<MediaList>(realm, realm, move(media));
|
||||
return realm.heap().allocate<MediaList>(realm, realm, move(media)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
MediaList::MediaList(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::CSS {
|
|||
|
||||
MediaQueryListEvent* MediaQueryListEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init);
|
||||
return realm.heap().allocate<MediaQueryListEvent>(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Web::CSS {
|
|||
|
||||
ResolvedCSSStyleDeclaration* ResolvedCSSStyleDeclaration::create(DOM::Element& element)
|
||||
{
|
||||
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element);
|
||||
return element.realm().heap().allocate<ResolvedCSSStyleDeclaration>(element.realm(), element).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Screen::Screen(HTML::Window& window)
|
||||
|
|
|
@ -48,7 +48,7 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet)
|
|||
StyleSheetList* StyleSheetList::create(DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return realm.heap().allocate<StyleSheetList>(realm, document);
|
||||
return realm.heap().allocate<StyleSheetList>(realm, document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StyleSheetList::StyleSheetList(DOM::Document& document)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Crypto::Crypto(JS::Realm& realm)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
SubtleCrypto::SubtleCrypto(JS::Realm& realm)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-abortcontroller-abortcontroller
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AbortSignal::AbortSignal(JS::Realm& realm)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<AccessibilityTreeNode> AccessibilityTreeNode::create(Document* document, DOM::Node const* value)
|
||||
{
|
||||
return *document->heap().allocate<AccessibilityTreeNode>(document->realm(), value);
|
||||
return *document->heap().allocate<AccessibilityTreeNode>(document->realm(), value).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
AccessibilityTreeNode::AccessibilityTreeNode(JS::GCPtr<DOM::Node> value)
|
||||
|
|
|
@ -15,12 +15,12 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<Attr> Attr::create(Document& document, DeprecatedFlyString 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Attr> Attr::clone(Document& document)
|
||||
{
|
||||
return *heap().allocate<Attr>(realm(), document, m_qualified_name, m_value, nullptr);
|
||||
return *heap().allocate<Attr>(realm(), document, m_qualified_name, m_value, nullptr).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString value, Element const* owner_element)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::DOM {
|
|||
|
||||
CustomEvent* CustomEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init);
|
||||
return realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
CustomEvent* CustomEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
DOMImplementation::DOMImplementation(Document& document)
|
||||
|
@ -84,7 +84,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
|
|||
html_document->set_content_type("text/html");
|
||||
html_document->set_ready_for_post_load_tasks(true);
|
||||
|
||||
auto doctype = heap().allocate<DocumentType>(realm(), html_document);
|
||||
auto doctype = heap().allocate<DocumentType>(realm(), html_document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
doctype->set_name("html");
|
||||
MUST(html_document->append_child(*doctype));
|
||||
|
||||
|
@ -98,7 +98,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(DeprecatedStr
|
|||
auto title_element = create_element(html_document, HTML::TagNames::title, Namespace::HTML);
|
||||
MUST(head_element->append_child(title_element));
|
||||
|
||||
auto text_node = heap().allocate<Text>(realm(), html_document, title);
|
||||
auto text_node = heap().allocate<Text>(realm(), html_document, title).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
MUST(title_element->append_child(*text_node));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Web::DOM {
|
|||
DOMTokenList* DOMTokenList::create(Element const& associated_element, DeprecatedFlyString associated_attribute)
|
||||
{
|
||||
auto& realm = associated_element.realm();
|
||||
return realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute));
|
||||
return realm.heap().allocate<DOMTokenList>(realm, associated_element, move(associated_attribute)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#ref-for-domtokenlist%E2%91%A0%E2%91%A2
|
||||
|
|
|
@ -290,7 +290,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
Document::Document(JS::Realm& realm, const AK::URL& url)
|
||||
|
@ -687,7 +687,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).release_allocated_value_but_fixme_should_propagate_errors()));
|
||||
|
||||
if (auto* page = this->page()) {
|
||||
if (browsing_context() == &page->top_level_browsing_context())
|
||||
|
@ -1230,17 +1230,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Text> Document::create_text_node(DeprecatedString const& data)
|
||||
{
|
||||
return heap().allocate<Text>(realm(), *this, data);
|
||||
return heap().allocate<Text>(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
||||
{
|
||||
return heap().allocate<Comment>(realm(), *this, data);
|
||||
return heap().allocate<Comment>(realm(), *this, data).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||
|
@ -1251,7 +1251,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ProcessingInstruction>> Document::create_pr
|
|||
// FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
|
||||
|
||||
// 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
|
||||
return JS::NonnullGCPtr { *heap().allocate<ProcessingInstruction>(realm(), *this, data, target) };
|
||||
return MUST_OR_THROW_OOM(heap().allocate<ProcessingInstruction>(realm(), *this, data, target));
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Document::create_range()
|
||||
|
|
|
@ -37,7 +37,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()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
DocumentType::DocumentType(Document& document)
|
||||
|
|
|
@ -1180,7 +1180,7 @@ 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 this’s node document.
|
||||
auto text = heap().allocate<DOM::Text>(realm(), document(), data);
|
||||
auto text = MUST_OR_THROW_OOM(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.
|
||||
|
|
|
@ -120,180 +120,180 @@ JS::NonnullGCPtr<Element> create_element(Document& document, DeprecatedFlyString
|
|||
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
// 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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
// 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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, DeprecatedFlyString 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Event> Event::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, EventInit const& event_init)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
HTMLCollection::HTMLCollection(ParentNode& root, Function<bool(Element const&)> filter)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
IDLEventListener::IDLEventListener(JS::Realm& realm, JS::NonnullGCPtr<WebIDL::CallbackType> callback)
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
LiveNodeList::LiveNodeList(JS::Realm& realm, Node& root, Function<bool(Node const&)> filter)
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::DOM {
|
|||
|
||||
JS::NonnullGCPtr<MutationRecord> MutationRecord::create(JS::Realm& realm, DeprecatedFlyString 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString 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)
|
||||
|
|
|
@ -16,7 +16,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NamedNodeMap::NamedNodeMap(Element& element)
|
||||
|
|
|
@ -743,7 +743,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
} else if (is<DocumentType>(this)) {
|
||||
// DocumentType
|
||||
auto document_type = verify_cast<DocumentType>(this);
|
||||
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document);
|
||||
auto document_type_copy = heap().allocate<DocumentType>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// Set copy’s name, public ID, and system ID to those of node.
|
||||
document_type_copy->set_name(document_type->name());
|
||||
|
@ -760,26 +760,26 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
|
|||
auto text = verify_cast<Text>(this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
auto text_copy = heap().allocate<Text>(realm(), *document, text->data());
|
||||
auto text_copy = heap().allocate<Text>(realm(), *document, text->data()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
copy = move(text_copy);
|
||||
} else if (is<Comment>(this)) {
|
||||
// Comment
|
||||
auto comment = verify_cast<Comment>(this);
|
||||
|
||||
// Set copy’s data to that of node.
|
||||
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data());
|
||||
auto comment_copy = heap().allocate<Comment>(realm(), *document, comment->data()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
copy = move(comment_copy);
|
||||
} else if (is<ProcessingInstruction>(this)) {
|
||||
// ProcessingInstruction
|
||||
auto processing_instruction = verify_cast<ProcessingInstruction>(this);
|
||||
|
||||
// Set copy’s target and data to those of node.
|
||||
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target());
|
||||
auto processing_instruction_copy = heap().allocate<ProcessingInstruction>(realm(), *document, processing_instruction->data(), processing_instruction->target()).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
copy = processing_instruction_copy;
|
||||
}
|
||||
// Otherwise, Do nothing.
|
||||
else if (is<DocumentFragment>(this)) {
|
||||
copy = heap().allocate<DocumentFragment>(realm(), *document);
|
||||
copy = heap().allocate<DocumentFragment>(realm(), *document).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// FIXME: 4. Set copy’s node document and document to copy, if copy is a document, and set copy’s node document to document otherwise.
|
||||
|
@ -1179,7 +1179,7 @@ void Node::string_replace_all(DeprecatedString const& string)
|
|||
|
||||
// 2. If string is not the empty string, then set node to a new Text node whose data is string and node document is parent’s node document.
|
||||
if (!string.is_empty())
|
||||
node = heap().allocate<Text>(realm(), document(), string);
|
||||
node = heap().allocate<Text>(realm(), document(), string).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 3. Replace all with node within parent.
|
||||
replace_all(node);
|
||||
|
|
|
@ -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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback)
|
||||
|
|
|
@ -53,7 +53,7 @@ JS::NonnullGCPtr<NodeIterator> NodeIterator::create(Node& root, unsigned what_to
|
|||
// 2. Set iterator’s root and iterator’s reference to root.
|
||||
// 3. Set iterator’s 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 4. Set iterator’s whatToShow to whatToShow.
|
||||
iterator->m_what_to_show = what_to_show;
|
||||
|
|
|
@ -22,19 +22,19 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<
|
|||
// 4. Otherwise, set node to a new DocumentFragment node whose node document is document, and then append each node in nodes, if any, to it.
|
||||
// 5. Return node.
|
||||
|
||||
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, DeprecatedString> const& node) -> JS::NonnullGCPtr<Node> {
|
||||
auto potentially_convert_string_to_text_node = [&document](Variant<JS::Handle<Node>, DeprecatedString> const& node) -> JS::ThrowCompletionOr<JS::NonnullGCPtr<Node>> {
|
||||
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 MUST_OR_THROW_OOM(document.heap().allocate<DOM::Text>(document.realm(), document, node.get<DeprecatedString>()));
|
||||
};
|
||||
|
||||
if (nodes.size() == 1)
|
||||
return potentially_convert_string_to_text_node(nodes.first());
|
||||
return TRY(potentially_convert_string_to_text_node(nodes.first()));
|
||||
|
||||
auto document_fragment = document.heap().allocate<DOM::DocumentFragment>(document.realm(), document);
|
||||
auto document_fragment = MUST_OR_THROW_OOM(document.heap().allocate<DOM::DocumentFragment>(document.realm(), document));
|
||||
for (auto& unconverted_node : nodes) {
|
||||
auto node = potentially_convert_string_to_text_node(unconverted_node);
|
||||
auto node = TRY(potentially_convert_string_to_text_node(unconverted_node));
|
||||
(void)TRY(document_fragment->append_child(node));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::construct_impl(JS::Realm& realm)
|
||||
|
@ -428,12 +428,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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Range> Range::normalized() const
|
||||
|
@ -587,7 +587,7 @@ 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 range’s start node’s node document.
|
||||
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
auto fragment = MUST_OR_THROW_OOM(heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document())));
|
||||
|
||||
// 2. If range is collapsed, then return fragment.
|
||||
if (collapsed())
|
||||
|
@ -916,7 +916,7 @@ 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 range’s start node’s node document.
|
||||
auto fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
|
||||
auto fragment = MUST_OR_THROW_OOM(heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document())));
|
||||
|
||||
// 2. If range is collapsed, then return fragment.
|
||||
if (collapsed())
|
||||
|
|
|
@ -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)).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
StaticNodeList::StaticNodeList(JS::Realm& realm, Vector<JS::Handle<Node>> static_nodes)
|
||||
|
|
|
@ -32,7 +32,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 this’s 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).ptr();
|
||||
return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).release_allocated_value_but_fixme_should_propagate_errors().ptr();
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<void> StaticRange::initialize(JS::Realm& realm)
|
||||
|
|
|
@ -43,7 +43,7 @@ JS::NonnullGCPtr<Text> Text::construct_impl(JS::Realm& realm, DeprecatedString c
|
|||
{
|
||||
// The new Text(data) constructor steps are to set this’s data to data and this’s node document to current global object’s 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).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
void Text::set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement& input_element)
|
||||
|
@ -69,7 +69,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 node’s data to new data.
|
||||
auto new_node = heap().allocate<Text>(realm(), document(), new_data);
|
||||
auto new_node = MUST_OR_THROW_OOM(heap().allocate<Text>(realm(), document(), new_data));
|
||||
|
||||
// 6. Let parent be node’s parent.
|
||||
JS::GCPtr<Node> parent = this->parent();
|
||||
|
|
|
@ -44,7 +44,7 @@ JS::NonnullGCPtr<TreeWalker> TreeWalker::create(Node& root, unsigned what_to_sho
|
|||
// 1. Let walker be a new TreeWalker object.
|
||||
// 2. Set walker’s root and walker’s current to root.
|
||||
auto& realm = root.realm();
|
||||
auto walker = realm.heap().allocate<TreeWalker>(realm, root);
|
||||
auto walker = realm.heap().allocate<TreeWalker>(realm, root).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 3. Set walker’s whatToShow to whatToShow.
|
||||
walker->m_what_to_show = what_to_show;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue