diff options
Diffstat (limited to 'Userland')
688 files changed, 1741 insertions, 1044 deletions
diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index e0d86fbaba..5544e6e1db 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -144,9 +144,9 @@ JS::ThrowCompletionOr<bool> SheetGlobalObject::internal_set(const JS::PropertyKe return Base::internal_set(property_name, value, receiver); } -void SheetGlobalObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SheetGlobalObject::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function(realm, "get_real_cell_contents", get_real_cell_contents, 1, attr); @@ -157,6 +157,8 @@ void SheetGlobalObject::initialize(JS::Realm& realm) define_native_function(realm, "column_index", column_index, 1, attr); define_native_function(realm, "get_column_bound", get_column_bound, 1, attr); define_native_accessor(realm, "name", get_name, nullptr, attr); + + return {}; } void SheetGlobalObject::visit_edges(Visitor& visitor) @@ -376,10 +378,12 @@ WorkbookObject::WorkbookObject(JS::Realm& realm, Workbook& workbook) { } -void WorkbookObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WorkbookObject::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); define_native_function(realm, "sheet", sheet, 1, JS::default_attributes); + + return {}; } void WorkbookObject::visit_edges(Visitor& visitor) diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h index a071681f34..93a766a11a 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.h +++ b/Userland/Applications/Spreadsheet/JSIntegration.h @@ -24,7 +24,7 @@ class SheetGlobalObject final : public JS::GlobalObject { public: SheetGlobalObject(JS::Realm&, Sheet&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~SheetGlobalObject() override = default; virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override; @@ -53,7 +53,7 @@ public: virtual ~WorkbookObject() override = default; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; JS_DECLARE_NATIVE_FUNCTION(sheet); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 9fff14e5ad..e655200342 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -24,9 +24,9 @@ $262Object::$262Object(Realm& realm) { } -void $262Object::initialize(Realm& realm) +ThrowCompletionOr<void> $262Object::initialize(Realm& realm) { - Base::initialize(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); @@ -41,6 +41,8 @@ void $262Object::initialize(Realm& realm) define_direct_property("gc", realm.global_object().get_without_side_effects("gc"), attr); define_direct_property("global", &realm.global_object(), attr); define_direct_property("IsHTMLDDA", m_is_htmldda, attr); + + return {}; } void $262Object::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h index ac4a21d947..831d761090 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.h @@ -17,7 +17,7 @@ class $262Object final : public Object { JS_OBJECT($262Object, Object); public: - virtual void initialize(JS::Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~$262Object() override = default; private: diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp index f38b229cb9..0408867e07 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.cpp @@ -17,9 +17,9 @@ AgentObject::AgentObject(Realm& realm) { } -void AgentObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> AgentObject::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, "monotonicNow", monotonic_now, 0, attr); @@ -27,6 +27,8 @@ void AgentObject::initialize(JS::Realm& realm) // TODO: broadcast // TODO: getReport // TODO: start + + return {}; } JS_DEFINE_NATIVE_FUNCTION(AgentObject::monotonic_now) diff --git a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h index 3daf6e166d..fe84604096 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h @@ -15,7 +15,7 @@ class AgentObject final : public Object { JS_OBJECT(AgentObject, Object); public: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AgentObject() override = default; private: diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp index 8dd7dca8d7..2175b0c6dd 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.cpp @@ -14,9 +14,9 @@ namespace JS::Test262 { -void GlobalObject::initialize(Realm& realm) +ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); m_$262 = vm().heap().allocate<$262Object>(realm, realm); @@ -24,6 +24,8 @@ void GlobalObject::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, "print", print, 1, attr); define_direct_property("$262", m_$262, attr); + + return {}; } void GlobalObject::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h index 84cbdb5889..618fea6a5a 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h +++ b/Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h @@ -15,7 +15,7 @@ class GlobalObject final : public JS::GlobalObject { JS_OBJECT(GlobalObject, JS::GlobalObject); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GlobalObject() override = default; $262Object* $262() const { return m_$262; } diff --git a/Userland/Libraries/LibJS/Heap/Cell.h b/Userland/Libraries/LibJS/Heap/Cell.h index 827c413860..2e7fb0494c 100644 --- a/Userland/Libraries/LibJS/Heap/Cell.h +++ b/Userland/Libraries/LibJS/Heap/Cell.h @@ -13,6 +13,7 @@ #include <AK/StringView.h> #include <LibJS/Forward.h> #include <LibJS/Heap/GCPtr.h> +#include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Value.h> namespace JS { @@ -31,7 +32,7 @@ class Cell { AK_MAKE_NONMOVABLE(Cell); public: - virtual void initialize(Realm&) { } + virtual ThrowCompletionOr<void> initialize(Realm&) { return {}; } virtual ~Cell() = default; bool is_marked() const { return m_mark; } diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index aa58a11cce..18cc94473a 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -46,7 +46,10 @@ public: auto* memory = allocate_cell(sizeof(T)); new (memory) T(forward<Args>(args)...); auto* cell = static_cast<T*>(memory); - memory->initialize(realm); + + // FIXME: Propagate this error. + (void)memory->initialize(realm); + return *cell; } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp index 540a2a567c..59620b74a4 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.cpp @@ -19,15 +19,17 @@ AggregateErrorConstructor::AggregateErrorConstructor(Realm& realm) { } -void AggregateErrorConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> AggregateErrorConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.5.7.2.1 AggregateError.prototype, https://tc39.es/ecma262/#sec-aggregate-error.prototype define_direct_property(vm.names.prototype, realm.intrinsics().aggregate_error_prototype(), 0); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); + + return {}; } // 20.5.7.1.1 AggregateError ( errors, message [ , options ] ), https://tc39.es/ecma262/#sec-aggregate-error diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h index ee146040ab..56c14127e3 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h @@ -14,7 +14,7 @@ class AggregateErrorConstructor final : public NativeFunction { JS_OBJECT(AggregateErrorConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AggregateErrorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp index 033099d8ec..ba659a139d 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.cpp @@ -15,13 +15,15 @@ AggregateErrorPrototype::AggregateErrorPrototype(Realm& realm) { } -void AggregateErrorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AggregateErrorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "AggregateError"), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h index 420a0864f0..3bab30af24 100644 --- a/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h @@ -14,7 +14,7 @@ class AggregateErrorPrototype final : public Object { JS_OBJECT(AggregateErrorPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AggregateErrorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp index e5e8179958..63d7e0df8c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp @@ -16,11 +16,13 @@ ArgumentsObject::ArgumentsObject(Realm& realm, Environment& environment) { } -void ArgumentsObject::initialize(Realm& realm) +ThrowCompletionOr<void> ArgumentsObject::initialize(Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_has_parameter_map(); m_parameter_map = Object::create(realm, nullptr); + + return {}; } void ArgumentsObject::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h index c3c9f30801..4538d1732f 100644 --- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h +++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.h @@ -16,7 +16,7 @@ class ArgumentsObject final : public Object { JS_OBJECT(ArgumentsObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArgumentsObject() override = default; Environment& environment() { return m_environment; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index f4b3ea0127..698902bdc5 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -19,10 +19,10 @@ ArrayBufferConstructor::ArrayBufferConstructor(Realm& realm) { } -void ArrayBufferConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ArrayBufferConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 25.1.4.2 ArrayBuffer.prototype, https://tc39.es/ecma262/#sec-arraybuffer.prototype define_direct_property(vm.names.prototype, realm.intrinsics().array_buffer_prototype(), 0); @@ -34,6 +34,8 @@ void ArrayBufferConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h index 60a4fb82a7..07b25d94c5 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.h @@ -14,7 +14,7 @@ class ArrayBufferConstructor final : public NativeFunction { JS_OBJECT(ArrayBufferConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArrayBufferConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index 7b73ce72a4..46aa683958 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -19,16 +19,18 @@ ArrayBufferPrototype::ArrayBufferPrototype(Realm& realm) { } -void ArrayBufferPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ArrayBufferPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.slice, slice, 2, attr); define_native_accessor(realm, vm.names.byteLength, byte_length_getter, {}, Attribute::Configurable); // 25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-arraybuffer.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ArrayBuffer.as_string()), Attribute::Configurable); + + return {}; } // 25.1.5.3 ArrayBuffer.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h index 5cec046f5c..efbac65f5b 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.h @@ -15,7 +15,7 @@ class ArrayBufferPrototype final : public PrototypeObject<ArrayBufferPrototype, JS_PROTOTYPE_OBJECT(ArrayBufferPrototype, ArrayBuffer, ArrayBuffer); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArrayBufferPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 3cd058cd8b..faaf5960be 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -21,10 +21,10 @@ ArrayConstructor::ArrayConstructor(Realm& realm) { } -void ArrayConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ArrayConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 23.1.2.4 Array.prototype, https://tc39.es/ecma262/#sec-array.prototype define_direct_property(vm.names.prototype, realm.intrinsics().array_prototype(), 0); @@ -38,6 +38,8 @@ void ArrayConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 23.1.1.1 Array ( ...values ), https://tc39.es/ecma262/#sec-array diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h index ee88e9a08b..d3a780ed0f 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.h @@ -14,7 +14,7 @@ class ArrayConstructor final : public NativeFunction { JS_OBJECT(ArrayConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArrayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index 0ef2029888..b6591bcedf 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -19,15 +19,17 @@ ArrayIteratorPrototype::ArrayIteratorPrototype(Realm& realm) { } -void ArrayIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ArrayIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 23.1.5.2.2 %ArrayIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%arrayiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Array Iterator"), Attribute::Configurable); + + return {}; } // 23.1.5.2.1 %ArrayIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h index 25c53bdcec..003774a82e 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.h @@ -15,7 +15,7 @@ class ArrayIteratorPrototype final : public PrototypeObject<ArrayIteratorPrototy JS_PROTOTYPE_OBJECT(ArrayIteratorPrototype, ArrayIterator, ArrayIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArrayIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 3d97e89425..5fddd36339 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -33,10 +33,10 @@ ArrayPrototype::ArrayPrototype(Realm& realm) { } -void ArrayPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ArrayPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Array::initialize(realm); + MUST_OR_THROW_OOM(Array::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.at, at, 1, attr); @@ -110,6 +110,8 @@ void ArrayPrototype::initialize(Realm& realm) MUST(unscopable_list->create_data_property_or_throw(vm.names.values, Value(true))); define_direct_property(*vm.well_known_symbol_unscopables(), unscopable_list, Attribute::Configurable); + + return {}; } // 10.4.2.3 ArraySpeciesCreate ( originalArray, length ), https://tc39.es/ecma262/#sec-arrayspeciescreate diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h index 1b29a08b5a..a9de2dadee 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.h @@ -15,7 +15,7 @@ class ArrayPrototype final : public Array { JS_OBJECT(ArrayPrototype, Array); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ArrayPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp index 61daf95fd6..7b3d4e53b3 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.cpp @@ -22,9 +22,10 @@ AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterato { } -void AsyncFromSyncIterator::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncFromSyncIterator::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); + return {}; } void AsyncFromSyncIterator::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h index 16f8bd0993..5188e74354 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIterator.h @@ -19,7 +19,7 @@ class AsyncFromSyncIterator final : public Object { public: static NonnullGCPtr<AsyncFromSyncIterator> create(Realm&, Iterator sync_iterator_record); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncFromSyncIterator() override = default; void visit_edges(Visitor& visitor) override; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp index 0b5e38bf60..1cc4dfafb4 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.cpp @@ -19,15 +19,17 @@ AsyncFromSyncIteratorPrototype::AsyncFromSyncIteratorPrototype(Realm& realm) { } -void AsyncFromSyncIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncFromSyncIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 1, attr); define_native_function(realm, vm.names.return_, return_, 1, attr); define_native_function(realm, vm.names.throw_, throw_, 1, attr); + + return {}; } // 27.1.4.4 AsyncFromSyncIteratorContinuation ( result, promiseCapability ), https://tc39.es/ecma262/#sec-asyncfromsynciteratorcontinuation diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h index dd941b9784..5ec46d1d98 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFromSyncIteratorPrototype.h @@ -19,7 +19,7 @@ class AsyncFromSyncIteratorPrototype final : public PrototypeObject<AsyncFromSyn JS_PROTOTYPE_OBJECT(AsyncFromSyncIteratorPrototype, AsyncFromSyncIterator, AsyncFromSyncIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncFromSyncIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp index 892fb7cff2..f7d5061b16 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.cpp @@ -17,15 +17,17 @@ AsyncFunctionConstructor::AsyncFunctionConstructor(Realm& realm) { } -void AsyncFunctionConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncFunctionConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 27.7.2.2 AsyncFunction.prototype, https://tc39.es/ecma262/#sec-async-function-constructor-prototype define_direct_property(vm.names.prototype, realm.intrinsics().async_function_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 27.7.1.1 AsyncFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-async-function-constructor-arguments diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h index cf11753202..585daf942d 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionConstructor.h @@ -14,7 +14,7 @@ class AsyncFunctionConstructor final : public NativeFunction { JS_OBJECT(AsyncFunctionConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp index fab88a66ec..decc505483 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.cpp @@ -14,13 +14,15 @@ AsyncFunctionPrototype::AsyncFunctionPrototype(Realm& realm) { } -void AsyncFunctionPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncFunctionPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // 27.7.3.2 AsyncFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-async-function-prototype-properties-toStringTag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncFunction.as_string()), Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h index 44a532f8bc..10c534f831 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncFunctionPrototype.h @@ -14,7 +14,7 @@ class AsyncFunctionPrototype final : public Object { JS_OBJECT(AsyncFunctionPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncFunctionPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp index c09341312f..172ed57e9e 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.cpp @@ -17,16 +17,18 @@ AsyncGeneratorFunctionConstructor::AsyncGeneratorFunctionConstructor(Realm& real { } -void AsyncGeneratorFunctionConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncGeneratorFunctionConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 27.4.2.1 AsyncGeneratorFunction.length, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-length define_direct_property(vm.names.length, Value(1), Attribute::Configurable); // 27.4.2.2 AsyncGeneratorFunction.prototype, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype define_direct_property(vm.names.prototype, realm.intrinsics().async_generator_function_prototype(), 0); + + return {}; } // 27.4.1.1 AsyncGeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-asyncgeneratorfunction diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h index 0b1a4e26d2..8350ef8a63 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionConstructor.h @@ -14,7 +14,7 @@ class AsyncGeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(AsyncGeneratorFunctionConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncGeneratorFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp index 39459950a2..a37bbbf954 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.cpp @@ -16,10 +16,10 @@ AsyncGeneratorFunctionPrototype::AsyncGeneratorFunctionPrototype(Realm& realm) { } -void AsyncGeneratorFunctionPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncGeneratorFunctionPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // The constructor cannot be set at this point since it has not been initialized. @@ -28,6 +28,8 @@ void AsyncGeneratorFunctionPrototype::initialize(Realm& realm) // 27.4.3.3 AsyncGeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.AsyncGeneratorFunction.as_string()), Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h index 602a947d94..2a2bb7f217 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorFunctionPrototype.h @@ -14,7 +14,7 @@ class AsyncGeneratorFunctionPrototype final : public PrototypeObject<AsyncGenera JS_PROTOTYPE_OBJECT(AsyncGeneratorFunctionPrototype, AsyncGeneratorFunction, AsyncGeneratorFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncGeneratorFunctionPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp index cdb9bf7310..cfd615909e 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.cpp @@ -14,13 +14,15 @@ AsyncGeneratorPrototype::AsyncGeneratorPrototype(Realm& realm) { } -void AsyncGeneratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncGeneratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // 27.6.1.5 AsyncGenerator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-asyncgenerator-prototype-tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "AsyncGenerator"), Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h index 03f7d627b0..4bdd6dea20 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncGeneratorPrototype.h @@ -15,7 +15,7 @@ class AsyncGeneratorPrototype final : public PrototypeObject<AsyncGeneratorProto JS_PROTOTYPE_OBJECT(AsyncGeneratorPrototype, AsyncGenerator, AsyncGenerator) public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncGeneratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp index bcfa3a948f..6a7e3e3f9a 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.cpp @@ -13,12 +13,14 @@ AsyncIteratorPrototype::AsyncIteratorPrototype(Realm& realm) { } -void AsyncIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> AsyncIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, *vm.well_known_symbol_async_iterator(), symbol_async_iterator, 0, attr); + + return {}; } // 27.1.3.1 %AsyncIteratorPrototype% [ @@asyncIterator ] ( ), https://tc39.es/ecma262/#sec-asynciteratorprototype-asynciterator diff --git a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h index 07f2f962aa..0313254778 100644 --- a/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/AsyncIteratorPrototype.h @@ -14,7 +14,7 @@ class AsyncIteratorPrototype final : public Object { JS_OBJECT(AsyncIteratorPrototype, Object) public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AsyncIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index 5003171358..adf841a2f1 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -129,9 +129,9 @@ AtomicsObject::AtomicsObject(Realm& realm) { } -void AtomicsObject::initialize(Realm& realm) +ThrowCompletionOr<void> AtomicsObject::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -148,6 +148,8 @@ void AtomicsObject::initialize(Realm& realm) // 25.4.15 Atomics [ @@toStringTag ], https://tc39.es/ecma262/#sec-atomics-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Atomics"), Attribute::Configurable); + + return {}; } // 25.4.3 Atomics.add ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.add diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.h b/Userland/Libraries/LibJS/Runtime/AtomicsObject.h index 1e245d8590..428e02779d 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.h +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.h @@ -14,7 +14,7 @@ class AtomicsObject : public Object { JS_OBJECT(AtomicsObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~AtomicsObject() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index c0e193782b..958811fe53 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -22,10 +22,10 @@ BigIntConstructor::BigIntConstructor(Realm& realm) { } -void BigIntConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> BigIntConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 21.2.2.3 BigInt.prototype, https://tc39.es/ecma262/#sec-bigint.prototype define_direct_property(vm.names.prototype, realm.intrinsics().bigint_prototype(), 0); @@ -35,6 +35,8 @@ void BigIntConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.asUintN, as_uint_n, 2, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h index 59335e3318..a974a63870 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.h @@ -14,7 +14,7 @@ class BigIntConstructor final : public NativeFunction { JS_OBJECT(BigIntConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~BigIntConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp index 621678d014..30213e9ab3 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -22,10 +22,10 @@ BigIntPrototype::BigIntPrototype(Realm& realm) { } -void BigIntPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> BigIntPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.toString, to_string, 0, attr); define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr); @@ -33,6 +33,8 @@ void BigIntPrototype::initialize(Realm& realm) // 21.2.3.5 BigInt.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-bigint.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.BigInt.as_string()), Attribute::Configurable); + + return {}; } // thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h index ca95f9684b..6b3b80f31c 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.h @@ -14,7 +14,7 @@ class BigIntPrototype final : public Object { JS_OBJECT(BigIntPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~BigIntPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 2e577f45a6..4bb1fa1723 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -17,15 +17,17 @@ BooleanConstructor::BooleanConstructor(Realm& realm) { } -void BooleanConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> BooleanConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.3.2.1 Boolean.prototype, https://tc39.es/ecma262/#sec-boolean.prototype define_direct_property(vm.names.prototype, realm.intrinsics().boolean_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value diff --git a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h index 3520b64a1d..4666e54d69 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanConstructor.h @@ -14,7 +14,7 @@ class BooleanConstructor final : public NativeFunction { JS_OBJECT(BooleanConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~BooleanConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp index bb89ba895d..9a45712bf2 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -18,13 +18,15 @@ BooleanPrototype::BooleanPrototype(Realm& realm) { } -void BooleanPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> BooleanPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - BooleanObject::initialize(realm); + MUST_OR_THROW_OOM(BooleanObject::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.toString, to_string, 0, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); + + return {}; } // thisBooleanValue ( value ), https://tc39.es/ecma262/#thisbooleanvalue diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h index 83af2e841d..b4d6c36b9a 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.h @@ -14,7 +14,7 @@ class BooleanPrototype final : public BooleanObject { JS_OBJECT(BooleanPrototype, BooleanObject); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~BooleanPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp index a9e56d2adb..aa7f0bed7d 100644 --- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.cpp @@ -18,10 +18,10 @@ ConsoleObject::ConsoleObject(Realm& realm) { } -void ConsoleObject::initialize(Realm& realm) +ThrowCompletionOr<void> ConsoleObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Enumerable | Attribute::Configurable; define_native_function(realm, vm.names.log, log, 0, attr); define_native_function(realm, vm.names.debug, debug, 0, attr); @@ -39,6 +39,8 @@ void ConsoleObject::initialize(Realm& realm) define_native_function(realm, vm.names.time, time, 0, attr); define_native_function(realm, vm.names.timeLog, time_log, 0, attr); define_native_function(realm, vm.names.timeEnd, time_end, 0, attr); + + return {}; } // 1.1.6. log(...data), https://console.spec.whatwg.org/#log diff --git a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h index a4bb63f273..6e0833390b 100644 --- a/Userland/Libraries/LibJS/Runtime/ConsoleObject.h +++ b/Userland/Libraries/LibJS/Runtime/ConsoleObject.h @@ -14,7 +14,7 @@ class ConsoleObject final : public Object { JS_OBJECT(ConsoleObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ConsoleObject() override = default; Console& console() { return *m_console; } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index 697f0aaed6..4718474307 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -19,15 +19,17 @@ DataViewConstructor::DataViewConstructor(Realm& realm) { } -void DataViewConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DataViewConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 25.3.3.1 DataView.prototype, https://tc39.es/ecma262/#sec-dataview.prototype define_direct_property(vm.names.prototype, realm.intrinsics().data_view_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h index 632c4e0e86..c78c3bf94f 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.h @@ -14,7 +14,7 @@ class DataViewConstructor final : public NativeFunction { JS_OBJECT(DataViewConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DataViewConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp index 102ca0ef4e..25af7f61c4 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp @@ -15,10 +15,10 @@ DataViewPrototype::DataViewPrototype(Realm& realm) { } -void DataViewPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DataViewPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.getBigInt64, get_big_int_64, 1, attr); @@ -48,6 +48,8 @@ void DataViewPrototype::initialize(Realm& realm) // 25.3.4.25 DataView.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-dataview.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DataView.as_string()), Attribute::Configurable); + + return {}; } // 25.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ), https://tc39.es/ecma262/#sec-getviewvalue diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h index 7138918922..e0f1899ebb 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.h @@ -15,7 +15,7 @@ class DataViewPrototype final : public PrototypeObject<DataViewPrototype, DataVi JS_PROTOTYPE_OBJECT(DataViewPrototype, DataView, DataView); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DataViewPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp index ace3ac4c3c..1e16b68426 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -180,10 +180,10 @@ DateConstructor::DateConstructor(Realm& realm) { } -void DateConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DateConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 21.4.3.3 Date.prototype, https://tc39.es/ecma262/#sec-date.prototype define_direct_property(vm.names.prototype, realm.intrinsics().date_prototype(), 0); @@ -194,6 +194,8 @@ void DateConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.UTC, utc, 7, attr); define_direct_property(vm.names.length, Value(7), Attribute::Configurable); + + return {}; } // 21.4.2.1 Date ( ...values ), https://tc39.es/ecma262/#sec-date diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.h b/Userland/Libraries/LibJS/Runtime/DateConstructor.h index 7e66408ffa..fabfeddda7 100644 --- a/Userland/Libraries/LibJS/Runtime/DateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.h @@ -14,7 +14,7 @@ class DateConstructor final : public NativeFunction { JS_OBJECT(DateConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DateConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 604fb9cac8..b49f341d2d 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -34,10 +34,10 @@ DatePrototype::DatePrototype(Realm& realm) { } -void DatePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DatePrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.getDate, get_date, 0, attr); define_native_function(realm, vm.names.getDay, get_day, 0, attr); @@ -95,6 +95,8 @@ void DatePrototype::initialize(Realm& realm) // B.2.4.3 Date.prototype.toGMTString ( ), https://tc39.es/ecma262/#sec-date.prototype.togmtstring // The initial value of the "toGMTString" property is %Date.prototype.toUTCString%, defined in 21.4.4.43. define_direct_property(vm.names.toGMTString, get_without_side_effects(vm.names.toUTCString), attr); + + return {}; } // thisTimeValue ( value ), https://tc39.es/ecma262/#thistimevalue diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.h b/Userland/Libraries/LibJS/Runtime/DatePrototype.h index c54223ccff..9bbae1316f 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.h @@ -15,7 +15,7 @@ class DatePrototype final : public PrototypeObject<DatePrototype, Date> { JS_PROTOTYPE_OBJECT(DatePrototype, Date, Date); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DatePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp index d70786d5a6..64055d99eb 100644 --- a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.cpp @@ -15,15 +15,17 @@ DisposableStackConstructor::DisposableStackConstructor(Realm& realm) { } -void DisposableStackConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DisposableStackConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 26.2.2.1 DisposableStack.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype define_direct_property(vm.names.prototype, realm.intrinsics().disposable_stack_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 11.3.1.1 DisposableStack ( ), https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.h b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.h index b512657a36..138e81e1a2 100644 --- a/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/DisposableStackConstructor.h @@ -14,7 +14,7 @@ class DisposableStackConstructor final : public NativeFunction { JS_OBJECT(DisposableStackConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DisposableStackConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp index 74c136f638..01a28a335c 100644 --- a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.cpp @@ -17,10 +17,10 @@ DisposableStackPrototype::DisposableStackPrototype(Realm& realm) { } -void DisposableStackPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DisposableStackPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_accessor(realm, vm.names.disposed, disposed_getter, {}, attr); @@ -35,6 +35,8 @@ void DisposableStackPrototype::initialize(Realm& realm) // 11.3.3.8 DisposableStack.prototype [ @@toStringTag ], https://tc39.es/proposal-explicit-resource-management/#sec-disposablestack.prototype-@@toStringTag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.DisposableStack.as_string()), Attribute::Configurable); + + return {}; } // 11.3.3.1 get DisposableStack.prototype.disposed, https://tc39.es/proposal-explicit-resource-management/#sec-get-disposablestack.prototype.disposed diff --git a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.h b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.h index 6b093a12aa..4dfc6fc7f0 100644 --- a/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/DisposableStackPrototype.h @@ -15,7 +15,7 @@ class DisposableStackPrototype final : public PrototypeObject<DisposableStackPro JS_PROTOTYPE_OBJECT(DisposableStackPrototype, DisposableStack, DisposableStack); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DisposableStackPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index ec974298af..af27f64cd4 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -97,10 +97,10 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Dep }); } -void ECMAScriptFunctionObject::initialize(Realm& realm) +ThrowCompletionOr<void> ECMAScriptFunctionObject::initialize(Realm& realm) { auto& vm = this->vm(); - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // Note: The ordering of these properties must be: length, name, prototype which is the order // they are defined in the spec: https://tc39.es/ecma262/#sec-function-instances . // This is observable through something like: https://tc39.es/ecma262/#sec-ordinaryownpropertykeys @@ -132,6 +132,8 @@ void ECMAScriptFunctionObject::initialize(Realm& realm) if (m_kind != FunctionKind::Async) define_direct_property(vm.names.prototype, prototype, Attribute::Writable); } + + return {}; } // 10.2.1 [[Call]] ( thisArgument, argumentsList ), https://tc39.es/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h index ef196ebf55..101a08aa53 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.h @@ -35,7 +35,7 @@ public: static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); static NonnullGCPtr<ECMAScriptFunctionObject> create(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, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {}); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ECMAScriptFunctionObject() override = default; virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override; diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp index c553ffacd6..f7389ce155 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -16,15 +16,17 @@ ErrorConstructor::ErrorConstructor(Realm& realm) { } -void ErrorConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ErrorConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.5.2.1 Error.prototype, https://tc39.es/ecma262/#sec-error.prototype define_direct_property(vm.names.prototype, realm.intrinsics().error_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 20.5.1.1 Error ( message [ , options ] ), https://tc39.es/ecma262/#sec-error-message @@ -67,15 +69,17 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ErrorConstructor::construct(FunctionObje { \ } \ \ - void ConstructorName::initialize(Realm& realm) \ + ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \ { \ auto& vm = this->vm(); \ - NativeFunction::initialize(realm); \ + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); \ \ /* 20.5.6.2.1 NativeError.prototype, https://tc39.es/ecma262/#sec-nativeerror.prototype */ \ define_direct_property(vm.names.prototype, realm.intrinsics().snake_name##_prototype(), 0); \ \ define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \ + \ + return {}; \ } \ \ ConstructorName::~ConstructorName() = default; \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h index 2bc6996308..d991cadf8a 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorConstructor.h @@ -15,7 +15,7 @@ class ErrorConstructor final : public NativeFunction { JS_OBJECT(ErrorConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ErrorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; @@ -32,7 +32,7 @@ private: JS_OBJECT(ConstructorName, NativeFunction); \ \ public: \ - virtual void initialize(Realm&) override; \ + virtual ThrowCompletionOr<void> initialize(Realm&) override; \ virtual ~ConstructorName() override; \ virtual ThrowCompletionOr<Value> call() override; \ virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override; \ diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index bf1c5bc3a1..203da27ccf 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -19,10 +19,10 @@ ErrorPrototype::ErrorPrototype(Realm& realm) { } -void ErrorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ErrorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "Error"), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); @@ -31,6 +31,8 @@ void ErrorPrototype::initialize(Realm& realm) // Every other engine seems to have this in some way or another, and the spec // proposal for this is only Stage 1 define_native_accessor(realm, vm.names.stack, stack_getter, stack_setter, attr); + + return {}; } // 20.5.3.4 Error.prototype.toString ( ), https://tc39.es/ecma262/#sec-error.prototype.tostring @@ -128,13 +130,15 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter) { \ } \ \ - void PrototypeName::initialize(Realm& realm) \ + ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \ { \ auto& vm = this->vm(); \ - Object::initialize(realm); \ + MUST_OR_THROW_OOM(Base::initialize(realm)); \ u8 attr = Attribute::Writable | Attribute::Configurable; \ define_direct_property(vm.names.name, PrimitiveString::create(vm, #ClassName), attr); \ define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); \ + \ + return {}; \ } JS_ENUMERATE_NATIVE_ERRORS diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h index 7be8d62fa4..19f1b42464 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.h @@ -16,7 +16,7 @@ class ErrorPrototype final : public PrototypeObject<ErrorPrototype, Error> { JS_PROTOTYPE_OBJECT(ErrorPrototype, Error, Error); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ErrorPrototype() override = default; private: @@ -32,7 +32,7 @@ private: JS_PROTOTYPE_OBJECT(PrototypeName, ClassName, ClassName); \ \ public: \ - virtual void initialize(Realm&) override; \ + virtual ThrowCompletionOr<void> initialize(Realm&) override; \ virtual ~PrototypeName() override = default; \ \ private: \ diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index 706f293654..5ea6ea9026 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -18,15 +18,17 @@ FinalizationRegistryConstructor::FinalizationRegistryConstructor(Realm& realm) { } -void FinalizationRegistryConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> FinalizationRegistryConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 26.2.2.1 FinalizationRegistry.prototype, https://tc39.es/ecma262/#sec-finalization-registry.prototype define_direct_property(vm.names.prototype, realm.intrinsics().finalization_registry_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h index a93a1c2315..806ac9dabc 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.h @@ -14,7 +14,7 @@ class FinalizationRegistryConstructor final : public NativeFunction { JS_OBJECT(FinalizationRegistryConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~FinalizationRegistryConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp index 057152aef2..a1fee3ca3a 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp @@ -15,10 +15,10 @@ FinalizationRegistryPrototype::FinalizationRegistryPrototype(Realm& realm) { } -void FinalizationRegistryPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> FinalizationRegistryPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.cleanupSome, cleanup_some, 0, attr); @@ -27,6 +27,8 @@ void FinalizationRegistryPrototype::initialize(Realm& realm) // 26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-finalization-registry.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.FinalizationRegistry.as_string()), Attribute::Configurable); + + return {}; } // @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h index a63e759ca7..fac93ba67f 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h @@ -15,7 +15,7 @@ class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationR JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~FinalizationRegistryPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index de2c897175..1c4e137fa5 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -23,15 +23,17 @@ FunctionConstructor::FunctionConstructor(Realm& realm) { } -void FunctionConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> FunctionConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.2.2.2 Function.prototype, https://tc39.es/ecma262/#sec-function.prototype define_direct_property(vm.names.prototype, realm.intrinsics().function_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 20.2.1.1.1 CreateDynamicFunction ( constructor, newTarget, kind, args ), https://tc39.es/ecma262/#sec-createdynamicfunction diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h index 1cf6ad0613..872ad2feb2 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.h @@ -17,7 +17,7 @@ class FunctionConstructor final : public NativeFunction { public: static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~FunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionObject.h b/Userland/Libraries/LibJS/Runtime/FunctionObject.h index 6fc6991a79..ab36f95dcd 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionObject.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionObject.h @@ -20,7 +20,7 @@ class FunctionObject : public Object { public: virtual ~FunctionObject() = default; - virtual void initialize(Realm&) override { } + virtual ThrowCompletionOr<void> initialize(Realm&) override { return {}; } // Table 7: Additional Essential Internal Methods of Function Objects, https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 20530adb18..79b68489a2 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -25,10 +25,10 @@ FunctionPrototype::FunctionPrototype(Realm& realm) { } -void FunctionPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> FunctionPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.apply, apply, 2, attr); define_native_function(realm, vm.names.bind, bind, 1, attr); @@ -37,6 +37,8 @@ void FunctionPrototype::initialize(Realm& realm) define_native_function(realm, *vm.well_known_symbol_has_instance(), symbol_has_instance, 1, 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); define_direct_property(vm.names.name, PrimitiveString::create(vm, ""), Attribute::Configurable); + + return {}; } ThrowCompletionOr<Value> FunctionPrototype::internal_call(Value, MarkedVector<Value>) diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h index 77919d5abc..d400a42490 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.h @@ -14,7 +14,7 @@ class FunctionPrototype final : public FunctionObject { JS_OBJECT(FunctionPrototype, FunctionObject); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~FunctionPrototype() override = default; virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp index 8b9f04fac8..5b71e0dcfb 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.cpp @@ -16,15 +16,17 @@ GeneratorFunctionConstructor::GeneratorFunctionConstructor(Realm& realm) { } -void GeneratorFunctionConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> GeneratorFunctionConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 27.3.2.1 GeneratorFunction.length, https://tc39.es/ecma262/#sec-generatorfunction.length define_direct_property(vm.names.length, Value(1), Attribute::Configurable); // 27.3.2.2 GeneratorFunction.prototype, https://tc39.es/ecma262/#sec-generatorfunction.length define_direct_property(vm.names.prototype, realm.intrinsics().generator_function_prototype(), 0); + + return {}; } // 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h index f73ef9e0d8..a816be43e4 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionConstructor.h @@ -15,7 +15,7 @@ class GeneratorFunctionConstructor final : public NativeFunction { JS_OBJECT(GeneratorFunctionConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GeneratorFunctionConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp index 47a7668c4b..766141ab19 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.cpp @@ -15,15 +15,17 @@ GeneratorFunctionPrototype::GeneratorFunctionPrototype(Realm& realm) { } -void GeneratorFunctionPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> GeneratorFunctionPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype define_direct_property(vm.names.prototype, realm.intrinsics().generator_prototype(), Attribute::Configurable); // 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "GeneratorFunction"), Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h index 84c3483458..18c7509386 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorFunctionPrototype.h @@ -16,7 +16,7 @@ class GeneratorFunctionPrototype final : public Object { JS_OBJECT(GeneratorFunctionPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GeneratorFunctionPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp index 99016bbb66..8cba0588c4 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.cpp @@ -41,8 +41,9 @@ GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext con { } -void GeneratorObject::initialize(Realm&) +ThrowCompletionOr<void> GeneratorObject::initialize(Realm&) { + return {}; } void GeneratorObject::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h index 2a2f790e9a..4d0b1ab145 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorObject.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorObject.h @@ -17,7 +17,7 @@ class GeneratorObject final : public Object { public: static ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> create(Realm&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GeneratorObject() override = default; void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp index ebfc3d21c1..7e57d005f7 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.cpp @@ -14,10 +14,10 @@ GeneratorPrototype::GeneratorPrototype(Realm& realm) { } -void GeneratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> GeneratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 1, attr); define_native_function(realm, vm.names.return_, return_, 1, attr); @@ -25,6 +25,8 @@ void GeneratorPrototype::initialize(Realm& realm) // 27.5.1.5 Generator.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generator.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Generator"), Attribute::Configurable); + + return {}; } // 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next diff --git a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h index 079e76c5ca..f791a5d635 100644 --- a/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/GeneratorPrototype.h @@ -16,7 +16,7 @@ class GeneratorPrototype final : public PrototypeObject<GeneratorPrototype, Gene JS_PROTOTYPE_OBJECT(GeneratorPrototype, GeneratorObject, Generator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GeneratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index d9bc029d2f..97ec602c5e 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -190,15 +190,17 @@ Object& set_default_global_bindings(Realm& realm) return global; } -void GlobalObject::initialize(Realm& realm) +ThrowCompletionOr<void> GlobalObject::initialize(Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); // Non-standard u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.gc, gc, 0, attr); + + return {}; } GlobalObject::~GlobalObject() = default; diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index c40a1f8296..9d72716b01 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -19,7 +19,7 @@ class GlobalObject : public Object { friend class Intrinsics; public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~GlobalObject() override; protected: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp index 0fc6b0f3c1..2e711f43bf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.cpp @@ -22,11 +22,13 @@ CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collato { } -void CollatorCompareFunction::initialize(Realm&) +ThrowCompletionOr<void> CollatorCompareFunction::initialize(Realm&) { auto& vm = this->vm(); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable); + + return {}; } // 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h index 4f56c547c6..944f448233 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorCompareFunction.h @@ -16,7 +16,7 @@ class CollatorCompareFunction : public NativeFunction { public: static NonnullGCPtr<CollatorCompareFunction> create(Realm&, Collator&); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~CollatorCompareFunction() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index dc0534536a..9826a59791 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -135,9 +135,9 @@ CollatorConstructor::CollatorConstructor(Realm& realm) { } -void CollatorConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> CollatorConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -147,6 +147,8 @@ void CollatorConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); + + return {}; } // 10.1.1 Intl.Collator ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.collator diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h index 19ade8f457..257656969d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.h @@ -14,7 +14,7 @@ class CollatorConstructor final : public NativeFunction { JS_OBJECT(CollatorConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~CollatorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp index 465ca42ec7..dcd9059251 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.cpp @@ -17,9 +17,9 @@ CollatorPrototype::CollatorPrototype(Realm& realm) { } -void CollatorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> CollatorPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -29,6 +29,8 @@ void CollatorPrototype::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 10.3.3 get Intl.Collator.prototype.compare, https://tc39.es/ecma402/#sec-intl.collator.prototype.compare diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h index f65e6d2f77..a0c28c5134 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorPrototype.h @@ -15,7 +15,7 @@ class CollatorPrototype final : public PrototypeObject<CollatorPrototype, Collat JS_PROTOTYPE_OBJECT(CollatorPrototype, Collator, Collator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~CollatorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index 71e803d482..6a1a43dfe5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -23,9 +23,9 @@ DateTimeFormatConstructor::DateTimeFormatConstructor(Realm& realm) { } -void DateTimeFormatConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DateTimeFormatConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -36,6 +36,8 @@ void DateTimeFormatConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 11.1.1 Intl.DateTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.datetimeformat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h index 33a144e4cb..af4075b689 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.h @@ -14,7 +14,7 @@ class DateTimeFormatConstructor final : public NativeFunction { JS_OBJECT(DateTimeFormatConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DateTimeFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp index 2ef7ca7a41..85e2c35262 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.cpp @@ -25,13 +25,15 @@ DateTimeFormatFunction::DateTimeFormatFunction(DateTimeFormat& date_time_format, { } -void DateTimeFormatFunction::initialize(Realm& realm) +ThrowCompletionOr<void> DateTimeFormatFunction::initialize(Realm& realm) { auto& vm = this->vm(); - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable); + + return {}; } ThrowCompletionOr<Value> DateTimeFormatFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h index 8634629ba3..c07510ee76 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatFunction.h @@ -19,7 +19,7 @@ public: static NonnullGCPtr<DateTimeFormatFunction> create(Realm&, DateTimeFormat&); virtual ~DateTimeFormatFunction() override = default; - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index 7d81d057a5..869a5cbe7b 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -19,9 +19,9 @@ DateTimeFormatPrototype::DateTimeFormatPrototype(Realm& realm) { } -void DateTimeFormatPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DateTimeFormatPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -35,6 +35,8 @@ void DateTimeFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.formatRange, format_range, 2, attr); define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 11.3.3 get Intl.DateTimeFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.format diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h index c72a7bcae3..94b297a63f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.h @@ -15,7 +15,7 @@ class DateTimeFormatPrototype final : public PrototypeObject<DateTimeFormatProto JS_PROTOTYPE_OBJECT(DateTimeFormatPrototype, DateTimeFormat, Intl.DateTimeFormat); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DateTimeFormatPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index e8917ba13b..d09882ffd3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -21,9 +21,9 @@ DisplayNamesConstructor::DisplayNamesConstructor(Realm& realm) { } -void DisplayNamesConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DisplayNamesConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -34,6 +34,8 @@ void DisplayNamesConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); + + return {}; } // 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h index 68827b3807..656bd07579 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.h @@ -14,7 +14,7 @@ class DisplayNamesConstructor final : public NativeFunction { JS_OBJECT(DisplayNamesConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DisplayNamesConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index a54367745f..eaed147cd5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -19,9 +19,9 @@ DisplayNamesPrototype::DisplayNamesPrototype(Realm& realm) { } -void DisplayNamesPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DisplayNamesPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -31,6 +31,8 @@ void DisplayNamesPrototype::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.of, of, 1, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 12.3.3 Intl.DisplayNames.prototype.of ( code ), https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype.of diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h index 57bb97f0c3..d43009ab3e 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.h @@ -15,7 +15,7 @@ class DisplayNamesPrototype final : public PrototypeObject<DisplayNamesPrototype JS_PROTOTYPE_OBJECT(DisplayNamesPrototype, DisplayNames, Intl.DisplayNames); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DisplayNamesPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 67d254f24c..1e2dab45bc 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -20,9 +20,9 @@ DurationFormatConstructor::DurationFormatConstructor(Realm& realm) { } -void DurationFormatConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DurationFormatConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -32,6 +32,8 @@ void DurationFormatConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); + + return {}; } // 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h index 81e7f99801..b9c0a69076 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.h @@ -14,7 +14,7 @@ class DurationFormatConstructor final : public NativeFunction { JS_OBJECT(DurationFormatConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DurationFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index da2c9a8ae7..a97101b9c0 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -18,9 +18,9 @@ DurationFormatPrototype::DurationFormatPrototype(Realm& realm) { } -void DurationFormatPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DurationFormatPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -31,6 +31,8 @@ void DurationFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.format, format, 1, attr); define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 1.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h index d10942cddf..29b0519590 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.h @@ -15,7 +15,7 @@ class DurationFormatPrototype final : public PrototypeObject<DurationFormatProto JS_PROTOTYPE_OBJECT(DurationFormatPrototype, DurationFormat, Intl.DurationFormat); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DurationFormatPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index b9787f157e..744a79b1ad 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -32,9 +32,9 @@ Intl::Intl(Realm& realm) { } -void Intl::initialize(Realm& realm) +ThrowCompletionOr<void> Intl::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -55,6 +55,8 @@ void Intl::initialize(Realm& realm) define_native_function(realm, vm.names.getCanonicalLocales, get_canonical_locales, 1, attr); define_native_function(realm, vm.names.supportedValuesOf, supported_values_of, 1, attr); + + return {}; } // 8.3.1 Intl.getCanonicalLocales ( locales ), https://tc39.es/ecma402/#sec-intl.getcanonicallocales diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.h b/Userland/Libraries/LibJS/Runtime/Intl/Intl.h index 0a9f262f5c..edfe794896 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.h @@ -14,7 +14,7 @@ class Intl final : public Object { JS_OBJECT(Intl, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~Intl() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index 530b007e15..11d8afc2f1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -20,9 +20,9 @@ ListFormatConstructor::ListFormatConstructor(Realm& realm) { } -void ListFormatConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ListFormatConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -33,6 +33,8 @@ void ListFormatConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h index 466b623908..68638c8989 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.h @@ -14,7 +14,7 @@ class ListFormatConstructor final : public NativeFunction { JS_OBJECT(ListFormatConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ListFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index 18c94ef60e..983d1e47c4 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -18,9 +18,9 @@ ListFormatPrototype::ListFormatPrototype(Realm& realm) { } -void ListFormatPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ListFormatPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -31,6 +31,8 @@ void ListFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.format, format, 1, attr); define_native_function(realm, vm.names.formatToParts, format_to_parts, 1, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 13.3.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h index 74d5fe3714..2c42e09737 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h @@ -15,7 +15,7 @@ class ListFormatPrototype final : public PrototypeObject<ListFormatPrototype, Li JS_PROTOTYPE_OBJECT(ListFormatPrototype, ListFormat, Intl.ListFormat); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ListFormatPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index f928208b78..b8d032cd22 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -222,15 +222,17 @@ LocaleConstructor::LocaleConstructor(Realm& realm) { } -void LocaleConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> LocaleConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); // 14.2.1 Intl.Locale.prototype, https://tc39.es/ecma402/#sec-Intl.Locale.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_locale_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h index 645f966805..887ef7eb35 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.h @@ -14,7 +14,7 @@ class LocaleConstructor final : public NativeFunction { JS_OBJECT(LocaleConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~LocaleConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp index 17305112ea..dc08af4b60 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp @@ -19,9 +19,9 @@ LocalePrototype::LocalePrototype(Realm& realm) { } -void LocalePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> LocalePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -50,6 +50,8 @@ void LocalePrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.timeZones, time_zones, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.textInfo, text_info, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.weekInfo, week_info, {}, Attribute::Configurable); + + return {}; } // 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h index 03078adbfb..4cf1b29731 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h @@ -15,7 +15,7 @@ class LocalePrototype final : public PrototypeObject<LocalePrototype, Locale> { JS_PROTOTYPE_OBJECT(LocalePrototype, Locale, Intl.Locale); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~LocalePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index 30e4dbb816..dabc866e61 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -19,9 +19,9 @@ NumberFormatConstructor::NumberFormatConstructor(Realm& realm) { } -void NumberFormatConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> NumberFormatConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -32,6 +32,8 @@ void NumberFormatConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h index 92014e80cf..382f68017a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.h @@ -15,7 +15,7 @@ class NumberFormatConstructor final : public NativeFunction { JS_OBJECT(NumberFormatConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~NumberFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index eb0b69a488..bd3e1fef56 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -23,13 +23,15 @@ NumberFormatFunction::NumberFormatFunction(NumberFormat& number_format, Object& { } -void NumberFormatFunction::initialize(Realm& realm) +ThrowCompletionOr<void> NumberFormatFunction::initialize(Realm& realm) { auto& vm = this->vm(); - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable); + + return {}; } ThrowCompletionOr<Value> NumberFormatFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h index 1cba9b402c..8303644dfd 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.h @@ -19,7 +19,7 @@ public: static NonnullGCPtr<NumberFormatFunction> create(Realm&, NumberFormat&); virtual ~NumberFormatFunction() override = default; - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index 5674f87961..ed080fd0d2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -19,9 +19,9 @@ NumberFormatPrototype::NumberFormatPrototype(Realm& realm) { } -void NumberFormatPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> NumberFormatPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -35,6 +35,8 @@ void NumberFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.formatRange, format_range, 2, attr); define_native_function(realm, vm.names.formatRangeToParts, format_range_to_parts, 2, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 15.3.3 get Intl.NumberFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h index 4f5740662a..d022b0d558 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.h @@ -15,7 +15,7 @@ class NumberFormatPrototype final : public PrototypeObject<NumberFormatPrototype JS_PROTOTYPE_OBJECT(NumberFormatPrototype, NumberFormat, Intl.NumberFormat); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~NumberFormatPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp index 97b068623d..7836a45ffa 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp @@ -21,9 +21,9 @@ PluralRulesConstructor::PluralRulesConstructor(Realm& realm) { } -void PluralRulesConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PluralRulesConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -33,6 +33,8 @@ void PluralRulesConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); + + return {}; } // 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h index 256f38d73d..8c5c69fd5d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.h @@ -14,7 +14,7 @@ class PluralRulesConstructor final : public NativeFunction { JS_OBJECT(PluralRulesConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PluralRulesConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index c760b1444f..4fcd02e270 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -18,9 +18,9 @@ PluralRulesPrototype::PluralRulesPrototype(Realm& realm) { } -void PluralRulesPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PluralRulesPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -31,6 +31,8 @@ void PluralRulesPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.select, select, 1, attr); define_native_function(realm, vm.names.selectRange, select_range, 2, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 16.3.3 Intl.PluralRules.prototype.select ( value ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h index 5c48fa106e..ad62242b2d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.h @@ -15,7 +15,7 @@ class PluralRulesPrototype final : public PrototypeObject<PluralRulesPrototype, JS_PROTOTYPE_OBJECT(PluralRulesPrototype, PluralRules, Intl.PluralRules); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PluralRulesPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index 0f59839606..1cd0353d40 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -24,9 +24,9 @@ RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm) { } -void RelativeTimeFormatConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> RelativeTimeFormatConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -36,6 +36,8 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); + + return {}; } // 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h index 9459dc1fde..65d910529d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.h @@ -14,7 +14,7 @@ class RelativeTimeFormatConstructor final : public NativeFunction { JS_OBJECT(RelativeTimeFormatConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~RelativeTimeFormatConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp index 44478487d2..06a18a4dbf 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp @@ -16,9 +16,9 @@ RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm) { } -void RelativeTimeFormatPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> RelativeTimeFormatPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -29,6 +29,8 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.format, format, 2, attr); define_native_function(realm, vm.names.formatToParts, format_to_parts, 2, attr); define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); + + return {}; } // 17.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h index 4012ed2184..454f9aebda 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.h @@ -15,7 +15,7 @@ class RelativeTimeFormatPrototype final : public PrototypeObject<RelativeTimeFor JS_PROTOTYPE_OBJECT(RelativeTimeFormatPrototype, RelativeTimeFormat, Intl.RelativeTimeFormat); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~RelativeTimeFormatPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp index bd4a598832..2d7489c3a1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp @@ -18,9 +18,9 @@ SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm) { } -void SegmentIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SegmentIteratorPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -29,6 +29,8 @@ void SegmentIteratorPrototype::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 0, attr); + + return {}; } // 18.6.2.1 %SegmentIteratorPrototype%.next ( ), https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h index 6be503d84f..88d60e4e50 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.h @@ -15,7 +15,7 @@ class SegmentIteratorPrototype final : public PrototypeObject<SegmentIteratorPro JS_PROTOTYPE_OBJECT(SegmentIteratorPrototype, SegmentIterator, SegmentIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SegmentIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index 89940fbf64..bc8f15d5b3 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -21,9 +21,9 @@ SegmenterConstructor::SegmenterConstructor(Realm& realm) { } -void SegmenterConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> SegmenterConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -33,6 +33,8 @@ void SegmenterConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); + + return {}; } // 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h index 6cd08b38c9..1eda9940e1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.h @@ -14,7 +14,7 @@ class SegmenterConstructor final : public NativeFunction { JS_OBJECT(SegmenterConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SegmenterConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp index 6faa5fa342..19af16d852 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp @@ -17,9 +17,9 @@ SegmenterPrototype::SegmenterPrototype(Realm& realm) { } -void SegmenterPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SegmenterPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -29,6 +29,8 @@ void SegmenterPrototype::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); define_native_function(realm, vm.names.segment, segment, 1, attr); + + return {}; } // 18.3.4 Intl.Segmenter.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.resolvedoptions diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h index 672318f1cf..3447388963 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.h @@ -15,7 +15,7 @@ class SegmenterPrototype final : public PrototypeObject<SegmenterPrototype, Segm JS_PROTOTYPE_OBJECT(SegmenterPrototype, Segmenter, Segmenter); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SegmenterPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp index 2edf03efd0..8758fd8df1 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp @@ -17,15 +17,17 @@ SegmentsPrototype::SegmentsPrototype(Realm& realm) { } -void SegmentsPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SegmentsPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); define_native_function(realm, vm.names.containing, containing, 1, attr); + + return {}; } // 18.5.2.1 %SegmentsPrototype%.containing ( index ), https://tc39.es/ecma402/#sec-%segmentsprototype%.containing diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h index 24ca244130..586fac1e91 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.h @@ -15,7 +15,7 @@ class SegmentsPrototype final : public PrototypeObject<SegmentsPrototype, Segmen JS_PROTOTYPE_OBJECT(SegmentsPrototype, Segments, Segments); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SegmentsPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 914eda870c..16e8ad99e4 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -16,12 +16,14 @@ IteratorPrototype::IteratorPrototype(Realm& realm) { } -void IteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> IteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, *vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); + + return {}; } // 27.1.2.1 %IteratorPrototype% [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h index 7dd85792ae..5cb870070e 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.h @@ -14,7 +14,7 @@ class IteratorPrototype : public Object { JS_OBJECT(IteratorPrototype, Object) public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~IteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index 18843be5c6..ced029676b 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -31,16 +31,18 @@ JSONObject::JSONObject(Realm& realm) { } -void JSONObject::initialize(Realm& realm) +ThrowCompletionOr<void> JSONObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.stringify, stringify, 3, attr); define_native_function(realm, vm.names.parse, parse, 2, attr); // 25.5.3 JSON [ @@toStringTag ], https://tc39.es/ecma262/#sec-json-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "JSON"), Attribute::Configurable); + + return {}; } // 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.h b/Userland/Libraries/LibJS/Runtime/JSONObject.h index fc2d8be9e5..936f8f3670 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.h +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.h @@ -14,7 +14,7 @@ class JSONObject final : public Object { JS_OBJECT(JSONObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~JSONObject() override = default; // The base implementation of stringify is exposed because it is used by diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index c71aaab39d..9a3d570c6c 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -18,10 +18,10 @@ MapConstructor::MapConstructor(Realm& realm) { } -void MapConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> MapConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 24.1.2.1 Map.prototype, https://tc39.es/ecma262/#sec-map.prototype define_direct_property(vm.names.prototype, realm.intrinsics().map_prototype(), 0); @@ -29,6 +29,8 @@ void MapConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.h b/Userland/Libraries/LibJS/Runtime/MapConstructor.h index 1338d0eabb..b5e2347333 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.h @@ -14,7 +14,7 @@ class MapConstructor final : public NativeFunction { JS_OBJECT(MapConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~MapConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp index 3ad6888a05..6a7d5fe9be 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.cpp @@ -18,13 +18,15 @@ MapIteratorPrototype::MapIteratorPrototype(Realm& realm) { } -void MapIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> MapIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Map Iterator"), Attribute::Configurable); + + return {}; } // 24.1.5.2.1 %MapIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%mapiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h index 5f1e1db3c7..7b66b9b4b0 100644 --- a/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/MapIteratorPrototype.h @@ -15,7 +15,7 @@ class MapIteratorPrototype final : public PrototypeObject<MapIteratorPrototype, JS_PROTOTYPE_OBJECT(MapIteratorPrototype, MapIterator, MapIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~MapIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp index c0336b52cd..2082b663f9 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp @@ -17,10 +17,10 @@ MapPrototype::MapPrototype(Realm& realm) { } -void MapPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> MapPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.clear, clear, 0, attr); @@ -37,6 +37,8 @@ void MapPrototype::initialize(Realm& realm) define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.entries), attr); define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Map.as_string()), Attribute::Configurable); + + return {}; } // 24.1.3.1 Map.prototype.clear ( ), https://tc39.es/ecma262/#sec-map.prototype.clear diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.h b/Userland/Libraries/LibJS/Runtime/MapPrototype.h index 53a32640dc..5997e8078e 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.h @@ -15,7 +15,7 @@ class MapPrototype final : public PrototypeObject<MapPrototype, Map> { JS_PROTOTYPE_OBJECT(MapPrototype, Map, Map); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~MapPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.cpp b/Userland/Libraries/LibJS/Runtime/MathObject.cpp index 8c537bcc92..e59b85ac36 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/MathObject.cpp @@ -20,10 +20,10 @@ MathObject::MathObject(Realm& realm) { } -void MathObject::initialize(Realm& realm) +ThrowCompletionOr<void> MathObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.abs, abs, 1, attr); define_native_function(realm, vm.names.random, random, 0, attr); @@ -73,6 +73,8 @@ void MathObject::initialize(Realm& realm) // 21.3.1.9 Math [ @@toStringTag ], https://tc39.es/ecma262/#sec-math-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Math.as_string()), Attribute::Configurable); + + return {}; } // 21.3.2.1 Math.abs ( x ), https://tc39.es/ecma262/#sec-math.abs diff --git a/Userland/Libraries/LibJS/Runtime/MathObject.h b/Userland/Libraries/LibJS/Runtime/MathObject.h index a7253a5ba9..8113347274 100644 --- a/Userland/Libraries/LibJS/Runtime/MathObject.h +++ b/Userland/Libraries/LibJS/Runtime/MathObject.h @@ -14,7 +14,7 @@ class MathObject final : public Object { JS_OBJECT(MathObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~MathObject() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp index 7b5a18aed3..6d57e77b83 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp @@ -22,12 +22,14 @@ ModuleNamespaceObject::ModuleNamespaceObject(Realm& realm, Module* module, Vecto }); } -void ModuleNamespaceObject::initialize(Realm& realm) +ThrowCompletionOr<void> ModuleNamespaceObject::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // 28.3.1 @@toStringTag, https://tc39.es/ecma262/#sec-@@tostringtag define_direct_property(*vm().well_known_symbol_to_string_tag(), PrimitiveString::create(vm(), "Module"sv), 0); + + return {}; } // 10.4.6.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-getprototypeof diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h index 97f9e7440b..bd679a52e1 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.h @@ -29,7 +29,7 @@ public: virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver) override; virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override; virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override; - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; private: ModuleNamespaceObject(Realm&, Module* module, Vector<DeprecatedFlyString> exports); diff --git a/Userland/Libraries/LibJS/Runtime/NativeFunction.h b/Userland/Libraries/LibJS/Runtime/NativeFunction.h index 8c45ba38ec..0430ec1f13 100644 --- a/Userland/Libraries/LibJS/Runtime/NativeFunction.h +++ b/Userland/Libraries/LibJS/Runtime/NativeFunction.h @@ -23,7 +23,7 @@ public: static NonnullGCPtr<NativeFunction> create(Realm&, SafeFunction<ThrowCompletionOr<Value>(VM&)> behaviour, i32 length, PropertyKey const& name, Optional<Realm*> = {}, Optional<Object*> prototype = {}, Optional<StringView> const& prefix = {}); static NonnullGCPtr<NativeFunction> create(Realm&, DeprecatedFlyString const& name, SafeFunction<ThrowCompletionOr<Value>(VM&)>); - virtual void initialize(Realm&) override { } + virtual ThrowCompletionOr<void> initialize(Realm&) override { return {}; } virtual ~NativeFunction() override = default; virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override; diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp index 53b0825bb3..c7cb0a906e 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -29,10 +29,10 @@ NumberConstructor::NumberConstructor(Realm& realm) { } -void NumberConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> NumberConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 21.1.2.15 Number.prototype, https://tc39.es/ecma262/#sec-number.prototype define_direct_property(vm.names.prototype, realm.intrinsics().number_prototype(), 0); @@ -54,6 +54,8 @@ void NumberConstructor::initialize(Realm& realm) define_direct_property(vm.names.NaN, js_nan(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // Most of 21.1.1.1 Number ( value ) factored into a separate function for sharing between call() and construct(). diff --git a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h index 45d32f1e21..54144d08ac 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/NumberConstructor.h @@ -14,7 +14,7 @@ class NumberConstructor final : public NativeFunction { JS_OBJECT(NumberConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~NumberConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index 762c266476..13d6bd5e63 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -42,10 +42,10 @@ NumberPrototype::NumberPrototype(Realm& realm) { } -void NumberPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> NumberPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Configurable | Attribute::Writable; define_native_function(realm, vm.names.toExponential, to_exponential, 1, attr); define_native_function(realm, vm.names.toFixed, to_fixed, 1, attr); @@ -53,6 +53,8 @@ void NumberPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toPrecision, to_precision, 1, attr); define_native_function(realm, vm.names.toString, to_string, 1, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); + + return {}; } // thisNumberValue ( value ), https://tc39.es/ecma262/#thisnumbervalue diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h index 22139df606..d396e43fac 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.h @@ -14,7 +14,7 @@ class NumberPrototype final : public NumberObject { JS_OBJECT(NumberPrototype, NumberObject); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~NumberPrototype() override = default; JS_DECLARE_NATIVE_FUNCTION(to_exponential); diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 489a838733..28a463e702 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -74,8 +74,9 @@ Object::~Object() s_intrinsics.remove(this); } -void Object::initialize(Realm&) +ThrowCompletionOr<void> Object::initialize(Realm&) { + return {}; } // 7.2 Testing and Comparison Operations, https://tc39.es/ecma262/#sec-testing-and-comparison-operations diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h index 5cabe99c4b..824965ec79 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.h +++ b/Userland/Libraries/LibJS/Runtime/Object.h @@ -46,7 +46,7 @@ class Object : public Cell { public: static NonnullGCPtr<Object> create(Realm&, Object* prototype); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~Object(); enum class PropertyKind { diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 6c35411b28..0d2b6f4acc 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -22,10 +22,10 @@ ObjectConstructor::ObjectConstructor(Realm& realm) { } -void ObjectConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ObjectConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.1.2.19 Object.prototype, https://tc39.es/ecma262/#sec-object.prototype define_direct_property(vm.names.prototype, realm.intrinsics().object_prototype(), 0); @@ -55,6 +55,8 @@ void ObjectConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.assign, assign, 2, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 20.1.1.1 Object ( [ value ] ), https://tc39.es/ecma262/#sec-object-value diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h index c7900468a8..ea1aa35ef0 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.h @@ -15,7 +15,7 @@ class ObjectConstructor final : public NativeFunction { JS_OBJECT(ObjectConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ObjectConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 4ebcda17fd..eeaab14e9c 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -26,10 +26,10 @@ ObjectPrototype::ObjectPrototype(Realm& realm) { } -void ObjectPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ObjectPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // This must be called after the constructor has returned, so that the below code // can find the ObjectPrototype through normal paths. u8 attr = Attribute::Writable | Attribute::Configurable; @@ -46,6 +46,8 @@ void ObjectPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.__lookupGetter__, lookup_getter, 1, attr); define_native_function(realm, vm.names.__lookupSetter__, lookup_setter, 1, attr); define_native_accessor(realm, vm.names.__proto__, proto_getter, proto_setter, Attribute::Configurable); + + return {}; } // 10.4.7.1 [[SetPrototypeOf]] ( V ), https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects-setprototypeof-v diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h index abb3a4976c..c64f8f0d59 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.h @@ -15,7 +15,7 @@ class ObjectPrototype final : public Object { JS_OBJECT(ObjectPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ObjectPrototype() override = default; // 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index bc265f413f..ed78bbdf77 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -244,10 +244,10 @@ PromiseConstructor::PromiseConstructor(Realm& realm) { } -void PromiseConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PromiseConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 27.2.4.4 Promise.prototype, https://tc39.es/ecma262/#sec-promise.prototype define_direct_property(vm.names.prototype, realm.intrinsics().promise_prototype(), 0); @@ -263,6 +263,8 @@ void PromiseConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h index 917c317ed7..a3874eaf2d 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.h @@ -14,7 +14,7 @@ class PromiseConstructor final : public NativeFunction { JS_OBJECT(PromiseConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PromiseConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index 721969639d..5812ef56c7 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -21,10 +21,10 @@ PromisePrototype::PromisePrototype(Realm& realm) { } -void PromisePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PromisePrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.then, then, 2, attr); @@ -33,6 +33,8 @@ void PromisePrototype::initialize(Realm& realm) // 27.2.5.5 Promise.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-promise.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Promise.as_string()), Attribute::Configurable); + + return {}; } // 27.2.5.4 Promise.prototype.then ( onFulfilled, onRejected ), https://tc39.es/ecma262/#sec-promise.prototype.then diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h index 9fc359d8cf..94edd3826c 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.h @@ -14,7 +14,7 @@ class PromisePrototype final : public PrototypeObject<PromisePrototype, Promise> JS_PROTOTYPE_OBJECT(PromisePrototype, Promise, Promise); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PromisePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp index 4354e59aef..0ba3dd2cdd 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.cpp @@ -29,10 +29,12 @@ PromiseResolvingElementFunction::PromiseResolvingElementFunction(size_t index, P { } -void PromiseResolvingElementFunction::initialize(Realm& realm) +ThrowCompletionOr<void> PromiseResolvingElementFunction::initialize(Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property(vm().names.length, Value(1), Attribute::Configurable); + + return {}; } ThrowCompletionOr<Value> PromiseResolvingElementFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h index c9f1ace269..8fb3c75960 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingElementFunctions.h @@ -45,7 +45,7 @@ class PromiseResolvingElementFunction : public NativeFunction { JS_OBJECT(PromiseResolvingFunction, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PromiseResolvingElementFunction() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp index c79e9e1f3b..e1d7c2ce2f 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.cpp @@ -24,10 +24,12 @@ PromiseResolvingFunction::PromiseResolvingFunction(Promise& promise, AlreadyReso { } -void PromiseResolvingFunction::initialize(Realm& realm) +ThrowCompletionOr<void> PromiseResolvingFunction::initialize(Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property(vm().names.length, Value(1), Attribute::Configurable); + + return {}; } ThrowCompletionOr<Value> PromiseResolvingFunction::call() diff --git a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h index d532a585d0..17ef85b7d3 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h +++ b/Userland/Libraries/LibJS/Runtime/PromiseResolvingFunction.h @@ -30,7 +30,7 @@ public: static NonnullGCPtr<PromiseResolvingFunction> create(Realm&, Promise&, AlreadyResolved&, FunctionType); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PromiseResolvingFunction() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index db37f85008..4d34e822c4 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -29,14 +29,16 @@ ProxyConstructor::ProxyConstructor(Realm& realm) { } -void ProxyConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ProxyConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.revocable, revocable, 2, attr); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); + + return {}; } // 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h index 46414bee0f..25699cf761 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.h @@ -15,7 +15,7 @@ class ProxyConstructor final : public NativeFunction { JS_OBJECT(ProxyConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ProxyConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index 6134c40fa5..9f4a1044c9 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -20,10 +20,10 @@ ReflectObject::ReflectObject(Realm& realm) { } -void ReflectObject::initialize(Realm& realm) +ThrowCompletionOr<void> ReflectObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.apply, apply, 3, attr); define_native_function(realm, vm.names.construct, construct, 2, attr); @@ -41,6 +41,8 @@ void ReflectObject::initialize(Realm& realm) // 28.1.14 Reflect [ @@toStringTag ], https://tc39.es/ecma262/#sec-reflect-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Reflect.as_string()), Attribute::Configurable); + + return {}; } // 28.1.1 Reflect.apply ( target, thisArgument, argumentsList ), https://tc39.es/ecma262/#sec-reflect.apply diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.h b/Userland/Libraries/LibJS/Runtime/ReflectObject.h index 4f0058e930..cce1defea3 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.h +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.h @@ -14,7 +14,7 @@ class ReflectObject final : public Object { JS_OBJECT(ReflectObject, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ReflectObject() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp index 0059177abe..877df6fc58 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -17,10 +17,10 @@ RegExpConstructor::RegExpConstructor(Realm& realm) { } -void RegExpConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> RegExpConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 22.2.4.1 RegExp.prototype, https://tc39.es/ecma262/#sec-regexp.prototype define_direct_property(vm.names.prototype, realm.intrinsics().regexp_prototype(), 0); @@ -49,6 +49,8 @@ void RegExpConstructor::initialize(Realm& realm) define_native_accessor(realm, vm.names.$7, group_7_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.$8, group_8_getter, {}, Attribute::Configurable); define_native_accessor(realm, vm.names.$9, group_9_getter, {}, Attribute::Configurable); + + return {}; } // 22.2.3.1 RegExp ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp-pattern-flags diff --git a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h index a754513739..90bae1f8d9 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpConstructor.h @@ -15,7 +15,7 @@ class RegExpConstructor final : public NativeFunction { JS_OBJECT(RegExpConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~RegExpConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index 8a407c9d6a..cbbca774ba 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -152,12 +152,14 @@ RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, Depre VERIFY(m_regex->parser_result.error == regex::Error::NoError); } -void RegExpObject::initialize(Realm& realm) +ThrowCompletionOr<void> RegExpObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property(vm.names.lastIndex, Value(0), Attribute::Writable); + + return {}; } // 22.2.3.2.2 RegExpInitialize ( obj, pattern, flags ), https://tc39.es/ecma262/#sec-regexpinitialize diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index eadb108e53..b93ca70624 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -42,7 +42,7 @@ public: ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_initialize(VM&, Value pattern, Value flags); DeprecatedString escape_regexp_pattern() const; - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~RegExpObject() override = default; DeprecatedString const& pattern() const { return m_pattern; } diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index b52cfe7019..d6bd019b0c 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -27,10 +27,10 @@ RegExpPrototype::RegExpPrototype(Realm& realm) { } -void RegExpPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> RegExpPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.toString, to_string, 0, attr); define_native_function(realm, vm.names.test, test, 1, attr); @@ -50,6 +50,8 @@ void RegExpPrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.flagName, flag_name, {}, Attribute::Configurable); JS_ENUMERATE_REGEXP_FLAGS #undef __JS_ENUMERATE + + return {}; } // Non-standard abstraction around steps used by multiple prototypes. diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h index 69bbb6b14e..79d8683546 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.h @@ -19,7 +19,7 @@ class RegExpPrototype final : public PrototypeObject<RegExpPrototype, RegExpObje JS_PROTOTYPE_OBJECT(RegExpPrototype, RegExpObject, RegExp); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~RegExpPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp index 87f865d155..4233de17b8 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp @@ -17,9 +17,9 @@ RegExpStringIteratorPrototype::RegExpStringIteratorPrototype(Realm& realm) { } -void RegExpStringIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> RegExpStringIteratorPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -27,6 +27,8 @@ void RegExpStringIteratorPrototype::initialize(Realm& realm) // 22.2.7.2.2 %RegExpStringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "RegExp String Iterator"), Attribute::Configurable); + + return {}; } // 22.2.7.2.1 %RegExpStringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h index 77ac5f678d..2a464902e0 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h @@ -17,7 +17,7 @@ class RegExpStringIteratorPrototype final : public PrototypeObject<RegExpStringI public: virtual ~RegExpStringIteratorPrototype() override = default; - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; private: explicit RegExpStringIteratorPrototype(Realm&); diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp index 4f1966dc2c..f971acc571 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.cpp +++ b/Userland/Libraries/LibJS/Runtime/Set.cpp @@ -18,9 +18,11 @@ Set::Set(Object& prototype) { } -void Set::initialize(Realm& realm) +ThrowCompletionOr<void> Set::initialize(Realm& realm) { m_values = Map::create(realm); + + return {}; } NonnullGCPtr<Set> Set::copy() const diff --git a/Userland/Libraries/LibJS/Runtime/Set.h b/Userland/Libraries/LibJS/Runtime/Set.h index fc00ad687e..8fec5efa49 100644 --- a/Userland/Libraries/LibJS/Runtime/Set.h +++ b/Userland/Libraries/LibJS/Runtime/Set.h @@ -19,7 +19,7 @@ class Set : public Object { public: static NonnullGCPtr<Set> create(Realm&); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~Set() override = default; // NOTE: Unlike what the spec says, we implement Sets using an underlying map, diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index 3534769a87..dd692d3e9c 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -18,10 +18,10 @@ SetConstructor::SetConstructor(Realm& realm) { } -void SetConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> SetConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 24.2.2.1 Set.prototype, https://tc39.es/ecma262/#sec-set.prototype define_direct_property(vm.names.prototype, realm.intrinsics().set_prototype(), 0); @@ -29,6 +29,8 @@ void SetConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.h b/Userland/Libraries/LibJS/Runtime/SetConstructor.h index b11a2cf90d..ef596954dd 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.h @@ -14,7 +14,7 @@ class SetConstructor final : public NativeFunction { JS_OBJECT(SetConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SetConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp index aa7cce8380..6b95c681d7 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.cpp @@ -18,15 +18,17 @@ SetIteratorPrototype::SetIteratorPrototype(Realm& realm) { } -void SetIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SetIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%setiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Set Iterator"), Attribute::Configurable); + + return {}; } // 24.2.5.2.1 %SetIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%setiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h index 4bf9e6b85b..e71a2b1ee3 100644 --- a/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetIteratorPrototype.h @@ -15,7 +15,7 @@ class SetIteratorPrototype final : public PrototypeObject<SetIteratorPrototype, JS_PROTOTYPE_OBJECT(SetIteratorPrototype, SetIterator, SetIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SetIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index e2f74e8fbd..9d2651afa2 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -19,10 +19,10 @@ SetPrototype::SetPrototype(Realm& realm) { } -void SetPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SetPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.add, add, 1, attr); @@ -48,6 +48,8 @@ void SetPrototype::initialize(Realm& realm) // 24.2.3.12 Set.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-set.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.Set.as_string()), Attribute::Configurable); + + return {}; } // 24.2.3.1 Set.prototype.add ( value ), https://tc39.es/ecma262/#sec-set.prototype.add diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.h b/Userland/Libraries/LibJS/Runtime/SetPrototype.h index 24708ba481..df9ca0da90 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.h @@ -15,7 +15,7 @@ class SetPrototype final : public PrototypeObject<SetPrototype, Set> { JS_PROTOTYPE_OBJECT(SetPrototype, Set, Set); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SetPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp index 6252e83ce7..9d9d45ae05 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp @@ -16,15 +16,17 @@ ShadowRealmConstructor::ShadowRealmConstructor(Realm& realm) { } -void ShadowRealmConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ShadowRealmConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 3.3.1 ShadowRealm.prototype, https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype define_direct_property(vm.names.prototype, realm.intrinsics().shadow_realm_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 3.2.1 ShadowRealm ( ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h index 16fae21238..f7f5688aec 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.h @@ -14,7 +14,7 @@ class ShadowRealmConstructor final : public NativeFunction { JS_OBJECT(ShadowRealmConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ShadowRealmConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp index adce5d73ee..ae4d20b434 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp @@ -16,10 +16,10 @@ ShadowRealmPrototype::ShadowRealmPrototype(Realm& realm) { } -void ShadowRealmPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ShadowRealmPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.evaluate, evaluate, 1, attr); @@ -27,6 +27,8 @@ void ShadowRealmPrototype::initialize(Realm& realm) // 3.4.3 ShadowRealm.prototype [ @@toStringTag ], https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable); + + return {}; } // 3.4.1 ShadowRealm.prototype.evaluate ( sourceText ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.evaluate diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h index 6e85ad4089..b55a0e86be 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h @@ -15,7 +15,7 @@ class ShadowRealmPrototype final : public PrototypeObject<ShadowRealmPrototype, JS_PROTOTYPE_OBJECT(ShadowRealmPrototype, ShadowRealm, ShadowRealm); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ShadowRealmPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 13d5bd9f73..a633074abe 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -22,10 +22,10 @@ StringConstructor::StringConstructor(Realm& realm) { } -void StringConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> StringConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 22.1.2.3 String.prototype, https://tc39.es/ecma262/#sec-string.prototype define_direct_property(vm.names.prototype, realm.intrinsics().string_prototype(), 0); @@ -36,6 +36,8 @@ void StringConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.fromCodePoint, from_code_point, 1, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 22.1.1.1 String ( value ), https://tc39.es/ecma262/#sec-string-constructor-string-value diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.h b/Userland/Libraries/LibJS/Runtime/StringConstructor.h index f05574d541..3fb0ddb80f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.h @@ -14,7 +14,7 @@ class StringConstructor final : public NativeFunction { JS_OBJECT(StringConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~StringConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp index 174672d79e..e0626f8b24 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.cpp @@ -18,14 +18,16 @@ StringIteratorPrototype::StringIteratorPrototype(Realm& realm) { } -void StringIteratorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> StringIteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_function(realm, vm.names.next, next, 0, Attribute::Configurable | Attribute::Writable); // 22.1.5.1.2 %StringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%stringiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "String Iterator"), Attribute::Configurable); + + return {}; } // 22.1.5.1.1 %StringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next diff --git a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h index 3c7720786b..883710a359 100644 --- a/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringIteratorPrototype.h @@ -16,7 +16,7 @@ class StringIteratorPrototype final : public PrototypeObject<StringIteratorProto JS_PROTOTYPE_OBJECT(StringIteratorPrototype, StringIterator, StringIterator); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~StringIteratorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.cpp b/Userland/Libraries/LibJS/Runtime/StringObject.cpp index 2f71dcfaf8..7778cd909a 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringObject.cpp @@ -26,13 +26,15 @@ StringObject::StringObject(PrimitiveString& string, Object& prototype) { } -void StringObject::initialize(Realm& realm) +ThrowCompletionOr<void> StringObject::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); // FIXME: Propagate this error. define_direct_property(vm.names.length, Value(MUST(m_string.utf16_string_view()).length_in_code_units()), 0); + + return {}; } void StringObject::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibJS/Runtime/StringObject.h b/Userland/Libraries/LibJS/Runtime/StringObject.h index 5bbae2eaa4..8c65cc61e1 100644 --- a/Userland/Libraries/LibJS/Runtime/StringObject.h +++ b/Userland/Libraries/LibJS/Runtime/StringObject.h @@ -16,7 +16,7 @@ class StringObject : public Object { public: static NonnullGCPtr<StringObject> create(Realm&, PrimitiveString&, Object& prototype); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~StringObject() override = default; PrimitiveString const& primitive_string() const { return m_string; } diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index 0877f3ee60..2a1287fa1e 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -153,10 +153,10 @@ StringPrototype::StringPrototype(Realm& realm) { } -void StringPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> StringPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - StringObject::initialize(realm); + MUST_OR_THROW_OOM(StringObject::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; // 22.1.3 Properties of the String Prototype Object, https://tc39.es/ecma262/#sec-properties-of-the-string-prototype-object @@ -213,6 +213,8 @@ void StringPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.sup, sup, 0, attr); define_direct_property(vm.names.trimLeft, get_without_side_effects(vm.names.trimStart), attr); define_direct_property(vm.names.trimRight, get_without_side_effects(vm.names.trimEnd), attr); + + return {}; } // thisStringValue ( value ), https://tc39.es/ecma262/#thisstringvalue diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.h b/Userland/Libraries/LibJS/Runtime/StringPrototype.h index 76670eb3a8..e7425523c9 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.h @@ -26,7 +26,7 @@ class StringPrototype final : public StringObject { public: explicit StringPrototype(Realm&); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~StringPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp index 74ac04741f..8269b9cfb5 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.cpp @@ -19,15 +19,17 @@ SuppressedErrorConstructor::SuppressedErrorConstructor(Realm& realm) { } -void SuppressedErrorConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> SuppressedErrorConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 10.1.4.2.1 SuppressedError.prototype, https://tc39.es/proposal-explicit-resource-management/#sec-suppressederror.prototype define_direct_property(vm.names.prototype, realm.intrinsics().suppressed_error_prototype(), 0); define_direct_property(vm.names.length, Value(3), Attribute::Configurable); + + return {}; } // 10.1.4.1.1 SuppressedError ( error, suppressed, message [ , options ] ), https://tc39.es/proposal-explicit-resource-management/#sec-suppressederror diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.h b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.h index f27672ed20..3ee5d83073 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorConstructor.h @@ -14,7 +14,7 @@ class SuppressedErrorConstructor final : public NativeFunction { JS_OBJECT(SuppressedErrorConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SuppressedErrorConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp index 224226cd64..c0b3cc6234 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.cpp @@ -15,13 +15,15 @@ SuppressedErrorPrototype::SuppressedErrorPrototype(Realm& realm) { } -void SuppressedErrorPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SuppressedErrorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_direct_property(vm.names.name, PrimitiveString::create(vm, "SuppressedError"), attr); define_direct_property(vm.names.message, PrimitiveString::create(vm, ""), attr); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.h b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.h index 27791d6d7d..83d01dbd5d 100644 --- a/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SuppressedErrorPrototype.h @@ -14,7 +14,7 @@ class SuppressedErrorPrototype final : public Object { JS_OBJECT(SuppressedErrorPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SuppressedErrorPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index c8a7843c5e..35f5aa97e1 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -16,10 +16,10 @@ SymbolConstructor::SymbolConstructor(Realm& realm) { } -void SymbolConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> SymbolConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 20.4.2.9 Symbol.prototype, https://tc39.es/ecma262/#sec-symbol.prototype define_direct_property(vm.names.prototype, realm.intrinsics().symbol_prototype(), 0); @@ -34,6 +34,8 @@ void SymbolConstructor::initialize(Realm& realm) #undef __JS_ENUMERATE define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h index 01fee91c62..a80528124d 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.h @@ -14,7 +14,7 @@ class SymbolConstructor final : public NativeFunction { JS_OBJECT(SymbolConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SymbolConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index 0f9e555a92..7450ef70ec 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -23,10 +23,10 @@ SymbolPrototype::SymbolPrototype(Realm& realm) { } -void SymbolPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> SymbolPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.toString, to_string, 0, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); @@ -35,6 +35,8 @@ void SymbolPrototype::initialize(Realm& realm) // 20.4.3.6 Symbol.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Symbol"), Attribute::Configurable); + + return {}; } // thisSymbolValue ( value ), https://tc39.es/ecma262/#thissymbolvalue diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h index 9f0bd4e8eb..d2997e322e 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h @@ -14,7 +14,7 @@ class SymbolPrototype final : public Object { JS_OBJECT(SymbolPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~SymbolPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp index 60189b5c21..18f0f7cb7f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp @@ -16,9 +16,9 @@ CalendarConstructor::CalendarConstructor(Realm& realm) { } -void CalendarConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> CalendarConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -29,6 +29,8 @@ void CalendarConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.from, from, 1, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 12.2.1 Temporal.Calendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h index 67476a8238..e7dab014af 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.h @@ -14,7 +14,7 @@ class CalendarConstructor final : public NativeFunction { JS_OBJECT(CalendarConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~CalendarConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index 73df08b8bb..0ab0b6afa7 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -29,9 +29,9 @@ CalendarPrototype::CalendarPrototype(Realm& realm) { } -void CalendarPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> CalendarPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -65,6 +65,8 @@ void CalendarPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toJSON, to_json, 0, attr); define_native_function(realm, vm.names.era, era, 1, attr); define_native_function(realm, vm.names.eraYear, era_year, 1, attr); + + return {}; } // 12.4.3 get Temporal.Calendar.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.calendar.prototype.id diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h index 38cc71dab1..1765e74c39 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.h @@ -15,7 +15,7 @@ class CalendarPrototype final : public PrototypeObject<CalendarPrototype, Calend JS_PROTOTYPE_OBJECT(CalendarPrototype, Calendar, Temporal.Calendar); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~CalendarPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp index b64bc486cc..8896f7ed69 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp @@ -19,9 +19,9 @@ DurationConstructor::DurationConstructor(Realm& realm) { } -void DurationConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> DurationConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -33,6 +33,8 @@ void DurationConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 7.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h index ffe4d78245..e4e8ecb78e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.h @@ -14,7 +14,7 @@ class DurationConstructor final : public NativeFunction { JS_OBJECT(DurationConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DurationConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index 359acf2f09..a109b58ad2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -20,9 +20,9 @@ DurationPrototype::DurationPrototype(Realm& realm) { } -void DurationPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> DurationPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -54,6 +54,8 @@ void DurationPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toJSON, to_json, 0, attr); define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); + + return {}; } // 7.3.3 get Temporal.Duration.prototype.years, https://tc39.es/proposal-temporal/#sec-get-temporal.duration.prototype.years diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h index 07996aa841..f7867c14d8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.h @@ -15,7 +15,7 @@ class DurationPrototype final : public PrototypeObject<DurationPrototype, Durati JS_PROTOTYPE_OBJECT(DurationPrototype, Duration, Temporal.Duration); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~DurationPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp index 4993f0be61..a886a9d812 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp @@ -18,9 +18,9 @@ InstantConstructor::InstantConstructor(Realm& realm) { } -void InstantConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> InstantConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -36,6 +36,8 @@ void InstantConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 8.1.1 Temporal.Instant ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h index f6a1844040..e66876ffcb 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.h @@ -14,7 +14,7 @@ class InstantConstructor final : public NativeFunction { JS_OBJECT(InstantConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~InstantConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index ab6416b03c..c0dce78669 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -24,9 +24,9 @@ InstantPrototype::InstantPrototype(Realm& realm) { } -void InstantPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> InstantPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -51,6 +51,8 @@ void InstantPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.valueOf, value_of, 0, attr); define_native_function(realm, vm.names.toZonedDateTime, to_zoned_date_time, 1, attr); define_native_function(realm, vm.names.toZonedDateTimeISO, to_zoned_date_time_iso, 1, attr); + + return {}; } // 8.3.3 get Temporal.Instant.prototype.epochSeconds, https://tc39.es/proposal-temporal/#sec-get-temporal.instant.prototype.epochseconds diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h index 80899bd45d..09dc79ed2d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h @@ -15,7 +15,7 @@ class InstantPrototype final : public PrototypeObject<InstantPrototype, Instant> JS_PROTOTYPE_OBJECT(InstantPrototype, Instant, Temporal.Instant); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~InstantPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 2000515553..8f7504623e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -26,9 +26,9 @@ Now::Now(Realm& realm) { } -void Now::initialize(Realm& realm) +ThrowCompletionOr<void> Now::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -45,6 +45,8 @@ void Now::initialize(Realm& realm) define_native_function(realm, vm.names.plainDate, plain_date, 1, attr); define_native_function(realm, vm.names.plainDateISO, plain_date_iso, 0, attr); define_native_function(realm, vm.names.plainTimeISO, plain_time_iso, 0, attr); + + return {}; } // 2.2.1 Temporal.Now.timeZone ( ), https://tc39.es/proposal-temporal/#sec-temporal.now.timezone diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h index c6821b5c43..3413ff8be0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.h @@ -15,7 +15,7 @@ class Now final : public Object { JS_OBJECT(Now, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~Now() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp index 3a3c017ae9..85e3f9f4be 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp @@ -20,9 +20,9 @@ PlainDateConstructor::PlainDateConstructor(Realm& realm) { } -void PlainDateConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PlainDateConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -34,6 +34,8 @@ void PlainDateConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(3), Attribute::Configurable); + + return {}; } // 3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h index e6f13118a7..58945ffb39 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.h @@ -14,7 +14,7 @@ class PlainDateConstructor final : public NativeFunction { JS_OBJECT(PlainDateConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainDateConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index 1fd6ceac4d..8a3eedb9e6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -25,9 +25,9 @@ PlainDatePrototype::PlainDatePrototype(Realm& realm) { } -void PlainDatePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PlainDatePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -68,6 +68,8 @@ void PlainDatePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr); define_native_function(realm, vm.names.toJSON, to_json, 0, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); + + return {}; } // 3.3.3 get Temporal.PlainDate.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h index dd3d45c837..5048f300bd 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.h @@ -15,7 +15,7 @@ class PlainDatePrototype final : public PrototypeObject<PlainDatePrototype, Plai JS_PROTOTYPE_OBJECT(PlainDatePrototype, PlainDate, Temporal.PlainDate); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainDatePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp index 5c5225f3bb..0bb6b9340a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp @@ -20,9 +20,9 @@ PlainDateTimeConstructor::PlainDateTimeConstructor(Realm& realm) { } -void PlainDateTimeConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PlainDateTimeConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -34,6 +34,8 @@ void PlainDateTimeConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(3), Attribute::Configurable); + + return {}; } // 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h index d1f5bd67e5..80e760fa20 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.h @@ -14,7 +14,7 @@ class PlainDateTimeConstructor final : public NativeFunction { JS_OBJECT(PlainDateTimeConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainDateTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index 34ba681080..cd010724be 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -26,9 +26,9 @@ PlainDateTimePrototype::PlainDateTimePrototype(Realm& realm) { } -void PlainDateTimePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PlainDateTimePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -79,6 +79,8 @@ void PlainDateTimePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toPlainMonthDay, to_plain_month_day, 0, attr); define_native_function(realm, vm.names.toPlainTime, to_plain_time, 0, attr); define_native_function(realm, vm.names.getISOFields, get_iso_fields, 0, attr); + + return {}; } // 5.3.3 get Temporal.PlainDateTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h index b657fa55e4..6afc8dbee4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.h @@ -15,7 +15,7 @@ class PlainDateTimePrototype final : public PrototypeObject<PlainDateTimePrototy JS_PROTOTYPE_OBJECT(PlainDateTimePrototype, PlainDateTime, Temporal.PlainDateTime); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainDateTimePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp index f2f9a35111..169ca0ee36 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp @@ -19,9 +19,9 @@ PlainMonthDayConstructor::PlainMonthDayConstructor(Realm& realm) { } -void PlainMonthDayConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PlainMonthDayConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -32,6 +32,8 @@ void PlainMonthDayConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.from, from, 1, attr); + + return {}; } // 10.1.1 Temporal.PlainMonthDay ( isoMonth, isoDay [ , calendarLike [ , referenceISOYear ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h index 136c7d1526..e16d9de2af 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.h @@ -14,7 +14,7 @@ class PlainMonthDayConstructor final : public NativeFunction { JS_OBJECT(PlainMonthDayConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainMonthDayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index d57e2f0c51..7f08e3a499 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -20,9 +20,9 @@ PlainMonthDayPrototype::PlainMonthDayPrototype(Realm& realm) { } -void PlainMonthDayPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PlainMonthDayPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -42,6 +42,8 @@ void PlainMonthDayPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.valueOf, value_of, 0, attr); define_native_function(realm, vm.names.toPlainDate, to_plain_date, 1, attr); define_native_function(realm, vm.names.getISOFields, get_iso_fields, 0, attr); + + return {}; } // 10.3.3 get Temporal.PlainMonthDay.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plainmonthday.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h index c20cf81468..5559350c2d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.h @@ -15,7 +15,7 @@ class PlainMonthDayPrototype final : public PrototypeObject<PlainMonthDayPrototy JS_PROTOTYPE_OBJECT(PlainMonthDayPrototype, PlainMonthDay, Temporal.PlainMonthDay); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainMonthDayPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp index a45acaf43a..162d0e7f08 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp @@ -18,9 +18,9 @@ PlainTimeConstructor::PlainTimeConstructor(Realm& realm) { } -void PlainTimeConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PlainTimeConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -32,6 +32,8 @@ void PlainTimeConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 4.1.1 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h index 0f03dec2db..4a8c4b1e8b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h @@ -14,7 +14,7 @@ class PlainTimeConstructor final : public NativeFunction { JS_OBJECT(PlainTimeConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 7d28371fe3..3ddc7e48d2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -25,9 +25,9 @@ PlainTimePrototype::PlainTimePrototype(Realm& realm) { } -void PlainTimePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PlainTimePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -57,6 +57,8 @@ void PlainTimePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toLocaleString, to_locale_string, 0, attr); define_native_function(realm, vm.names.toJSON, to_json, 0, attr); define_native_function(realm, vm.names.valueOf, value_of, 0, attr); + + return {}; } // 4.3.3 get Temporal.PlainTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h index 00bdbf5423..3b6c29fee5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h @@ -15,7 +15,7 @@ class PlainTimePrototype final : public PrototypeObject<PlainTimePrototype, Plai JS_PROTOTYPE_OBJECT(PlainTimePrototype, PlainTime, Temporal.PlainTime); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainTimePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp index 1e65ade25d..33bf3dadc1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp @@ -20,9 +20,9 @@ PlainYearMonthConstructor::PlainYearMonthConstructor(Realm& realm) { } -void PlainYearMonthConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> PlainYearMonthConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -34,6 +34,8 @@ void PlainYearMonthConstructor::initialize(Realm& realm) u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.from, from, 1, attr); define_native_function(realm, vm.names.compare, compare, 2, attr); + + return {}; } // 9.1.1 Temporal.PlainYearMonth ( isoYear, isoMonth [ , calendarLike [ , referenceISODay ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h index 1f51297e27..2a5f389f27 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.h @@ -14,7 +14,7 @@ class PlainYearMonthConstructor final : public NativeFunction { JS_OBJECT(PlainYearMonthConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainYearMonthConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 5a23cd4757..7c5ea0b074 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -22,9 +22,9 @@ PlainYearMonthPrototype::PlainYearMonthPrototype(Realm& realm) { } -void PlainYearMonthPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> PlainYearMonthPrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -55,6 +55,8 @@ void PlainYearMonthPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.valueOf, value_of, 0, attr); define_native_function(realm, vm.names.toPlainDate, to_plain_date, 1, attr); define_native_function(realm, vm.names.getISOFields, get_iso_fields, 0, attr); + + return {}; } // 9.3.3 get Temporal.PlainYearMonth.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h index 3e987a077d..33fbdbfb2f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.h @@ -15,7 +15,7 @@ class PlainYearMonthPrototype final : public PrototypeObject<PlainYearMonthProto JS_PROTOTYPE_OBJECT(PlainYearMonthPrototype, PlainYearMonth, Temporal.PlainYearMonth); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~PlainYearMonthPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp index 75c468d8b2..82fe3dc23a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp @@ -26,9 +26,9 @@ Temporal::Temporal(Realm& realm) { } -void Temporal::initialize(Realm& realm) +ThrowCompletionOr<void> Temporal::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -47,6 +47,8 @@ void Temporal::initialize(Realm& realm) define_intrinsic_accessor(vm.names.PlainYearMonth, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_plain_year_month_constructor(); }); define_intrinsic_accessor(vm.names.TimeZone, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_time_zone_constructor(); }); define_intrinsic_accessor(vm.names.ZonedDateTime, attr, [](auto& realm) -> Value { return realm.intrinsics().temporal_zoned_date_time_constructor(); }); + + return {}; } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h index 90c6a45251..57fcae6fd6 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h @@ -14,7 +14,7 @@ class Temporal final : public Object { JS_OBJECT(Temporal, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~Temporal() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp index d97bcc8375..10c4656d02 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp @@ -17,9 +17,9 @@ TimeZoneConstructor::TimeZoneConstructor(Realm& realm) { } -void TimeZoneConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> TimeZoneConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -30,6 +30,8 @@ void TimeZoneConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.from, from, 1, attr); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 11.2.1 Temporal.TimeZone ( identifier ), https://tc39.es/proposal-temporal/#sec-temporal.timezone diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h index 5de3ea1e26..9c49f169fe 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.h @@ -14,7 +14,7 @@ class TimeZoneConstructor final : public NativeFunction { JS_OBJECT(TimeZoneConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~TimeZoneConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index c74b02b187..7ae03d25d9 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -23,9 +23,9 @@ TimeZonePrototype::TimeZonePrototype(Realm& realm) { } -void TimeZonePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> TimeZonePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -43,6 +43,8 @@ void TimeZonePrototype::initialize(Realm& realm) // 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.TimeZone"), Attribute::Configurable); + + return {}; } // 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h index a1fb7f9103..3c3e362ca1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.h @@ -15,7 +15,7 @@ class TimeZonePrototype final : public PrototypeObject<TimeZonePrototype, TimeZo JS_PROTOTYPE_OBJECT(TimeZonePrototype, TimeZone, Temporal.TimeZone); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~TimeZonePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index 0efa6616f3..6ec6dbaeac 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -21,9 +21,9 @@ ZonedDateTimeConstructor::ZonedDateTimeConstructor(Realm& realm) { } -void ZonedDateTimeConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> ZonedDateTimeConstructor::initialize(Realm& realm) { - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); auto& vm = this->vm(); @@ -35,6 +35,8 @@ void ZonedDateTimeConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(2), Attribute::Configurable); + + return {}; } // 6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h index b1779d8206..20445838ec 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h @@ -14,7 +14,7 @@ class ZonedDateTimeConstructor final : public NativeFunction { JS_OBJECT(ZonedDateTimeConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ZonedDateTimeConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index fba6badfff..a71630d620 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -26,9 +26,9 @@ ZonedDateTimePrototype::ZonedDateTimePrototype(Realm& realm) { } -void ZonedDateTimePrototype::initialize(Realm& realm) +ThrowCompletionOr<void> ZonedDateTimePrototype::initialize(Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); auto& vm = this->vm(); @@ -90,6 +90,8 @@ void ZonedDateTimePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.toPlainYearMonth, to_plain_year_month, 0, attr); define_native_function(realm, vm.names.toPlainMonthDay, to_plain_month_day, 0, attr); define_native_function(realm, vm.names.getISOFields, get_iso_fields, 0, attr); + + return {}; } // 6.3.3 get Temporal.ZonedDateTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.calendar diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h index 4e92877448..2fc873dc49 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.h @@ -15,7 +15,7 @@ class ZonedDateTimePrototype final : public PrototypeObject<ZonedDateTimePrototy JS_PROTOTYPE_OBJECT(ZonedDateTimePrototype, ZonedDateTime, Temporal.ZonedDateTime); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~ZonedDateTimePrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index b1ef270f05..148a61bab3 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -467,11 +467,13 @@ void TypedArrayBase::visit_edges(Visitor& visitor) { \ } \ \ - void PrototypeName::initialize(Realm& realm) \ + ThrowCompletionOr<void> PrototypeName::initialize(Realm& realm) \ { \ auto& vm = this->vm(); \ - Object::initialize(realm); \ + 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) \ @@ -483,10 +485,10 @@ void TypedArrayBase::visit_edges(Visitor& visitor) { \ } \ \ - void ConstructorName::initialize(Realm& realm) \ + ThrowCompletionOr<void> ConstructorName::initialize(Realm& realm) \ { \ auto& vm = this->vm(); \ - NativeFunction::initialize(realm); \ + 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); \ @@ -495,6 +497,8 @@ void TypedArrayBase::visit_edges(Visitor& visitor) 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 */ \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.h b/Userland/Libraries/LibJS/Runtime/TypedArray.h index 7096bfc019..60f5396694 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.h @@ -479,7 +479,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(VM&, Value x, Value y, Fu JS_OBJECT(PrototypeName, Object); \ \ public: \ - virtual void initialize(Realm&) override; \ + virtual ThrowCompletionOr<void> initialize(Realm&) override; \ virtual ~PrototypeName() override; \ \ private: \ @@ -489,7 +489,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(VM&, Value x, Value y, Fu JS_OBJECT(ConstructorName, TypedArrayConstructor); \ \ public: \ - virtual void initialize(Realm&) override; \ + virtual ThrowCompletionOr<void> initialize(Realm&) override; \ virtual ~ConstructorName() override; \ \ virtual ThrowCompletionOr<Value> call() override; \ diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index 14748455d0..aa5df341fe 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -21,10 +21,10 @@ TypedArrayConstructor::TypedArrayConstructor(Realm& realm) { } -void TypedArrayConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> TypedArrayConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 23.2.2.3 %TypedArray%.prototype, https://tc39.es/ecma262/#sec-%typedarray%.prototype define_direct_property(vm.names.prototype, realm.intrinsics().typed_array_prototype(), 0); @@ -36,6 +36,8 @@ void TypedArrayConstructor::initialize(Realm& realm) define_native_accessor(realm, *vm.well_known_symbol_species(), symbol_species_getter, {}, Attribute::Configurable); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray% diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h index 3d9ae5a08e..9a9d3bf2fd 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.h @@ -15,7 +15,7 @@ class TypedArrayConstructor : public NativeFunction { public: explicit TypedArrayConstructor(Realm&); - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~TypedArrayConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index 1ad0b3bc16..685fcd85a9 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -21,10 +21,10 @@ TypedArrayPrototype::TypedArrayPrototype(Realm& realm) { } -void TypedArrayPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> TypedArrayPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_accessor(realm, vm.names.buffer, buffer_getter, nullptr, Attribute::Configurable); @@ -70,6 +70,8 @@ void TypedArrayPrototype::initialize(Realm& realm) // 23.2.3.34 %TypedArray%.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr); + + return {}; } static ThrowCompletionOr<TypedArrayBase*> typed_array_from_this(VM& vm) diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h index cb73efd9eb..3087a4343c 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.h @@ -15,7 +15,7 @@ class TypedArrayPrototype final : public Object { JS_OBJECT(TypedArrayPrototype, Object); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~TypedArrayPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index 031e3a7f2d..7ae0efeaa3 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -18,15 +18,17 @@ WeakMapConstructor::WeakMapConstructor(Realm& realm) { } -void WeakMapConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> WeakMapConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 24.3.2.1 WeakMap.prototype, https://tc39.es/ecma262/#sec-weakmap.prototype define_direct_property(vm.names.prototype, realm.intrinsics().weak_map_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h index 57810ad481..f090f628eb 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.h @@ -14,7 +14,7 @@ class WeakMapConstructor final : public NativeFunction { JS_OBJECT(WeakMapConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakMapConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp index abbcd24a12..6e33921c82 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp @@ -16,10 +16,10 @@ WeakMapPrototype::WeakMapPrototype(Realm& realm) { } -void WeakMapPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> WeakMapPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.delete_, delete_, 1, attr); @@ -29,6 +29,8 @@ void WeakMapPrototype::initialize(Realm& realm) // 24.3.3.6 WeakMap.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakmap.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakMap.as_string()), Attribute::Configurable); + + return {}; } // 24.3.3.2 WeakMap.prototype.delete ( key ), https://tc39.es/ecma262/#sec-weakmap.prototype.delete diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h index 32aec28120..edeb27b137 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.h @@ -15,7 +15,7 @@ class WeakMapPrototype final : public PrototypeObject<WeakMapPrototype, WeakMap> JS_PROTOTYPE_OBJECT(WeakMapPrototype, WeakMap, WeakMap); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakMapPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index 1379313c05..5be04068ea 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -17,15 +17,17 @@ WeakRefConstructor::WeakRefConstructor(Realm& realm) { } -void WeakRefConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> WeakRefConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 26.1.2.1 WeakRef.prototype, https://tc39.es/ecma262/#sec-weak-ref.prototype define_direct_property(vm.names.prototype, realm.intrinsics().weak_ref_prototype(), 0); define_direct_property(vm.names.length, Value(1), Attribute::Configurable); + + return {}; } // 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h index a3afbf755f..976c1d62af 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.h @@ -14,7 +14,7 @@ class WeakRefConstructor final : public NativeFunction { JS_OBJECT(WeakRefConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakRefConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp index 437c9ec30a..90e9422727 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.cpp @@ -14,14 +14,16 @@ WeakRefPrototype::WeakRefPrototype(Realm& realm) { } -void WeakRefPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> WeakRefPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_function(realm, vm.names.deref, deref, 0, Attribute::Writable | Attribute::Configurable); define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakRef.as_string()), Attribute::Configurable); + + return {}; } // 26.1.3.2 WeakRef.prototype.deref ( ), https://tc39.es/ecma262/#sec-weak-ref.prototype.deref diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h index 3dbe323a7d..ac72169745 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakRefPrototype.h @@ -15,7 +15,7 @@ class WeakRefPrototype final : public PrototypeObject<WeakRefPrototype, WeakRef> JS_PROTOTYPE_OBJECT(WeakRefPrototype, WeakRef, WeakRef); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakRefPrototype() override = default; private: diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index f48baadb11..48040f7f55 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -18,15 +18,17 @@ WeakSetConstructor::WeakSetConstructor(Realm& realm) { } -void WeakSetConstructor::initialize(Realm& realm) +ThrowCompletionOr<void> WeakSetConstructor::initialize(Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); // 24.4.2.1 WeakSet.prototype, https://tc39.es/ecma262/#sec-weakset.prototype define_direct_property(vm.names.prototype, realm.intrinsics().weak_set_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); + + return {}; } // 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h index 7e423630d0..b05db7ece7 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.h @@ -14,7 +14,7 @@ class WeakSetConstructor final : public NativeFunction { JS_OBJECT(WeakSetConstructor, NativeFunction); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakSetConstructor() override = default; virtual ThrowCompletionOr<Value> call() override; diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index d779963ca1..d5373e124e 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -16,10 +16,10 @@ WeakSetPrototype::WeakSetPrototype(Realm& realm) { } -void WeakSetPrototype::initialize(Realm& realm) +ThrowCompletionOr<void> WeakSetPrototype::initialize(Realm& realm) { auto& vm = this->vm(); - Object::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.add, add, 1, attr); @@ -28,6 +28,8 @@ void WeakSetPrototype::initialize(Realm& realm) // 24.4.3.5 WeakSet.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-weakset.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, vm.names.WeakSet.as_string()), Attribute::Configurable); + + return {}; } // 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h index 2a01447bef..720addeb27 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h @@ -15,7 +15,7 @@ class WeakSetPrototype final : public PrototypeObject<WeakSetPrototype, WeakSet> JS_PROTOTYPE_OBJECT(WeakSetPrototype, WeakSet, WeakSet); public: - virtual void initialize(Realm&) override; + virtual ThrowCompletionOr<void> initialize(Realm&) override; virtual ~WeakSetPrototype() override = default; private: diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index baa0e99da7..9f39623e74 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -194,13 +194,13 @@ public: : JS::GlobalObject(realm) { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~TestRunnerGlobalObject() override = default; }; -inline void TestRunnerGlobalObject::initialize(JS::Realm& realm) +inline JS::ThrowCompletionOr<void> TestRunnerGlobalObject::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property("global", this, JS::Attribute::Enumerable); for (auto& entry : s_exposed_global_functions) { @@ -211,6 +211,8 @@ inline void TestRunnerGlobalObject::initialize(JS::Realm& realm) }, entry.value.length, JS::default_attributes); } + + return {}; } inline ByteBuffer load_entire_file(StringView path) diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp index 0c2fdfe3dd..96d8ca6340 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.cpp @@ -18,13 +18,15 @@ AudioConstructor::AudioConstructor(JS::Realm& realm) { } -void AudioConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> AudioConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &ensure_web_prototype<Bindings::HTMLAudioElementPrototype>(realm, "HTMLAudioElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); + + return {}; } JS::ThrowCompletionOr<JS::Value> AudioConstructor::call() diff --git a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h index 85f464da7b..3f58eb5e54 100644 --- a/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/AudioConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class AudioConstructor final : public JS::NativeFunction { public: explicit AudioConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~AudioConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp index 816662d2ab..9327c6aa6f 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.cpp @@ -18,12 +18,14 @@ CSSNamespace::CSSNamespace(JS::Realm& realm) { } -void CSSNamespace::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSNamespace::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); u8 attr = JS::Attribute::Enumerable; define_native_function(realm, "escape", escape, 1, attr); define_native_function(realm, "supports", supports, 2, attr); + + return {}; } // https://www.w3.org/TR/cssom-1/#dom-css-escape diff --git a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h index cdd92bdc9a..2466ed9c6b 100644 --- a/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h +++ b/Userland/Libraries/LibWeb/Bindings/CSSNamespace.h @@ -17,7 +17,7 @@ class CSSNamespace final : public JS::Object { public: explicit CSSNamespace(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~CSSNamespace() override = default; private: diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index 42410d7510..424b64e0cc 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -18,13 +18,15 @@ ImageConstructor::ImageConstructor(JS::Realm& realm) { } -void ImageConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ImageConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &ensure_web_prototype<Bindings::HTMLImageElementPrototype>(realm, "HTMLImageElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); + + return {}; } JS::ThrowCompletionOr<JS::Value> ImageConstructor::call() diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h index a5b5f058d9..c38477d6c5 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class ImageConstructor final : public JS::NativeFunction { public: explicit ImageConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~ImageConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp index 8202db37b3..17c86fdab5 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.cpp @@ -20,13 +20,15 @@ OptionConstructor::OptionConstructor(JS::Realm& realm) { } -void OptionConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> OptionConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &ensure_web_prototype<Bindings::HTMLOptionElementPrototype>(realm, "HTMLOptionElement"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); + + return {}; } JS::ThrowCompletionOr<JS::Value> OptionConstructor::call() diff --git a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h index a212ddb398..bbb6b2fe11 100644 --- a/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/OptionConstructor.h @@ -14,7 +14,7 @@ namespace Web::Bindings { class OptionConstructor final : public JS::NativeFunction { public: explicit OptionConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~OptionConstructor() override = default; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp index f392e07969..95935409d0 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.cpp @@ -27,13 +27,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WindowConstructor::construct return vm().throw_completion<JS::TypeError>(JS::ErrorType::NotAConstructor, "Window"); } -void WindowConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WindowConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &ensure_web_prototype<Bindings::WindowPrototype>(realm, "Window"), 0); define_direct_property(vm.names.length, JS::Value(0), JS::Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h index b287c8ffe3..07f39ebf07 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowConstructor.h @@ -15,7 +15,7 @@ class WindowConstructor : public JS::NativeFunction { public: explicit WindowConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WindowConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp index 23c88d7f26..49f419a02b 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.cpp @@ -14,10 +14,12 @@ WindowPrototype::WindowPrototype(JS::Realm& realm) { } -void WindowPrototype::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WindowPrototype::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::EventTargetPrototype>(realm, "EventTarget")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h index e26ad57d4c..ec58070287 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h +++ b/Userland/Libraries/LibWeb/Bindings/WindowPrototype.h @@ -19,7 +19,7 @@ public: explicit WindowPrototype(JS::Realm& realm); private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp index d3d416fd2c..5e4be880de 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.cpp @@ -22,10 +22,12 @@ void CSSConditionRule::for_each_effective_style_rule(Function<void(CSSStyleRule CSSGroupingRule::for_each_effective_style_rule(callback); } -void CSSConditionRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSConditionRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSConditionRulePrototype>(realm, "CSSConditionRule")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h index 34b8013d9b..825106bb38 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSConditionRule.h @@ -27,7 +27,7 @@ public: protected: CSSConditionRule(JS::Realm&, CSSRuleList&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index 11dba3358f..ba8e669468 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -23,10 +23,12 @@ CSSFontFaceRule::CSSFontFaceRule(JS::Realm& realm, FontFace&& font_face) { } -void CSSFontFaceRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSFontFaceRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSFontFaceRulePrototype>(realm, "CSSFontFaceRule")); + + return {}; } CSSStyleDeclaration* CSSFontFaceRule::style() diff --git a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h index 03e9fcb92b..fe08427d46 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -28,7 +28,7 @@ public: private: CSSFontFaceRule(JS::Realm&, FontFace&&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual DeprecatedString serialized() const override; FontFace m_font_face; diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp index 01d9ef8643..1b7c18b0ec 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp @@ -22,10 +22,12 @@ CSSGroupingRule::CSSGroupingRule(JS::Realm& realm, CSSRuleList& rules) rule.set_parent_rule(this); } -void CSSGroupingRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSGroupingRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSGroupingRulePrototype>(realm, "CSSGroupingRule")); + + return {}; } void CSSGroupingRule::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h index 3b77a75457..2e888bf09a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h @@ -33,7 +33,7 @@ public: protected: CSSGroupingRule(JS::Realm&, CSSRuleList&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 965cc450d3..3aaa7a4c37 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -39,10 +39,12 @@ CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document) set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request)); } -void CSSImportRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSImportRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSImportRulePrototype>(realm, "CSSImportRule")); + + return {}; } void CSSImportRule::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h index 68b87938fd..c17b0c2332 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.h @@ -40,7 +40,7 @@ public: private: CSSImportRule(AK::URL, DOM::Document&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual DeprecatedString serialized() const override; diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp index 7f8ce6afc9..1bdd9c4a04 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.cpp @@ -23,10 +23,12 @@ CSSMediaRule::CSSMediaRule(JS::Realm& realm, MediaList& media, CSSRuleList& rule { } -void CSSMediaRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSMediaRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSMediaRulePrototype>(realm, "CSSMediaRule")); + + return {}; } void CSSMediaRule::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h index 75b4d66857..6ec7a4df68 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSMediaRule.h @@ -35,7 +35,7 @@ public: private: CSSMediaRule(JS::Realm&, MediaList&, CSSRuleList&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual DeprecatedString serialized() const override; diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index 9451b6aef1..c44e6cd39b 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -35,10 +35,12 @@ CSSRuleList* CSSRuleList::create_empty(JS::Realm& realm) return realm.heap().allocate<CSSRuleList>(realm, realm); } -void CSSRuleList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSRuleList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSRuleListPrototype>(realm, "CSSRuleList")); + + return {}; } void CSSRuleList::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h index af8de394c2..726a7c5f9e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h @@ -66,7 +66,7 @@ public: private: explicit CSSRuleList(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; Vector<CSSRule&> m_rules; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index ec597f12d6..b09449fe1d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -23,10 +23,12 @@ CSSStyleRule::CSSStyleRule(JS::Realm& realm, NonnullRefPtrVector<Selector>&& sel { } -void CSSStyleRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSStyleRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleRulePrototype>(realm, "CSSStyleRule")); + + return {}; } void CSSStyleRule::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index 21b800f4ca..d6f7680570 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -36,7 +36,7 @@ public: private: CSSStyleRule(JS::Realm&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual DeprecatedString serialized() const override; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index fd4eec4155..becd498153 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -30,10 +30,12 @@ CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& me rule.set_parent_style_sheet(this); } -void CSSStyleSheet::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSStyleSheet::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSStyleSheetPrototype>(realm, "CSSStyleSheet")); + + return {}; } void CSSStyleSheet::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 747f2549f3..d08e9035c2 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -52,7 +52,7 @@ public: private: CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; CSSRuleList* m_rules { nullptr }; diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp index ffcbd1057e..9214d4f03a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.cpp @@ -22,10 +22,12 @@ CSSSupportsRule::CSSSupportsRule(JS::Realm& realm, NonnullRefPtr<Supports>&& sup { } -void CSSSupportsRule::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CSSSupportsRule::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSSupportsRulePrototype>(realm, "CSSSupportsRule")); + + return {}; } DeprecatedString CSSSupportsRule::condition_text() const diff --git a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h index fc91a0af16..0c03187869 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSSupportsRule.h @@ -33,7 +33,7 @@ public: private: CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual DeprecatedString serialized() const override; NonnullRefPtr<Supports> m_supports; diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp index ab25824513..b3fbb7b59d 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp @@ -23,10 +23,12 @@ MediaList::MediaList(JS::Realm& realm, NonnullRefPtrVector<MediaQuery>&& media) { } -void MediaList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MediaList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaListPrototype>(realm, "MediaList")); + + return {}; } // https://www.w3.org/TR/cssom-1/#dom-medialist-mediatext diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.h b/Userland/Libraries/LibWeb/CSS/MediaList.h index 1f42ba0298..2650f6a555 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaList.h @@ -39,7 +39,7 @@ public: private: MediaList(JS::Realm&, NonnullRefPtrVector<MediaQuery>&&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; NonnullRefPtrVector<MediaQuery> m_media; }; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp index be77857aab..90f8192674 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp @@ -28,10 +28,12 @@ MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<Medi evaluate(); } -void MediaQueryList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MediaQueryList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListPrototype>(realm, "MediaQueryList")); + + return {}; } void MediaQueryList::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h index 12382afe51..6c40fd2be4 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h @@ -34,7 +34,7 @@ public: private: MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<DOM::Document> m_document; diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp index 212790f537..e5f20af1dc 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.cpp @@ -24,10 +24,12 @@ MediaQueryListEvent::MediaQueryListEvent(JS::Realm& realm, DeprecatedFlyString c MediaQueryListEvent::~MediaQueryListEvent() = default; -void MediaQueryListEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MediaQueryListEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MediaQueryListEventPrototype>(realm, "MediaQueryListEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h index 395f7bf099..9dd511afd1 100644 --- a/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h +++ b/Userland/Libraries/LibWeb/CSS/MediaQueryListEvent.h @@ -29,7 +29,7 @@ public: private: MediaQueryListEvent(JS::Realm&, DeprecatedFlyString const& event_name, MediaQueryListEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_media; bool m_matches; diff --git a/Userland/Libraries/LibWeb/CSS/Screen.cpp b/Userland/Libraries/LibWeb/CSS/Screen.cpp index f51e5d51e0..577cc97ca5 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.cpp +++ b/Userland/Libraries/LibWeb/CSS/Screen.cpp @@ -24,10 +24,12 @@ Screen::Screen(HTML::Window& window) { } -void Screen::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Screen::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ScreenPrototype>(realm, "Screen")); + + return {}; } void Screen::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/Screen.h b/Userland/Libraries/LibWeb/CSS/Screen.h index c0ef644c41..35e3a3c913 100644 --- a/Userland/Libraries/LibWeb/CSS/Screen.h +++ b/Userland/Libraries/LibWeb/CSS/Screen.h @@ -29,7 +29,7 @@ public: private: explicit Screen(HTML::Window&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; HTML::Window const& window() const { return *m_window; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp index c31d1b30a2..0ac2d9a788 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -57,10 +57,12 @@ StyleSheetList::StyleSheetList(DOM::Document& document) { } -void StyleSheetList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> StyleSheetList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::StyleSheetListPrototype>(realm, "StyleSheetList")); + + return {}; } void StyleSheetList::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index ec09052ac3..b80226af15 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -41,7 +41,7 @@ public: private: explicit StyleSheetList(DOM::Document&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; void sort_sheets(); diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 453287a78e..4d06755e9f 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -26,11 +26,13 @@ Crypto::Crypto(JS::Realm& realm) Crypto::~Crypto() = default; -void Crypto::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Crypto::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CryptoPrototype>(realm, "Crypto")); m_subtle = SubtleCrypto::create(realm); + + return {}; } JS::NonnullGCPtr<SubtleCrypto> Crypto::subtle() const diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h index 29a4e313e9..2573bbb344 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.h +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h @@ -26,7 +26,7 @@ public: DeprecatedString random_uuid() const; protected: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index a525d8200e..382000a712 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -26,10 +26,12 @@ SubtleCrypto::SubtleCrypto(JS::Realm& realm) SubtleCrypto::~SubtleCrypto() = default; -void SubtleCrypto::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SubtleCrypto::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SubtleCryptoPrototype>(realm, "SubtleCrypto")); + + return {}; } // https://w3c.github.io/webcrypto/#dfn-SubtleCrypto-method-digest diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h index 23a07eb649..bf13e9f723 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.h @@ -23,7 +23,7 @@ public: private: explicit SubtleCrypto(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.cpp b/Userland/Libraries/LibWeb/DOM/AbortController.cpp index 3152d92b72..f306c85cfa 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortController.cpp @@ -25,10 +25,12 @@ AbortController::AbortController(JS::Realm& realm, JS::NonnullGCPtr<AbortSignal> AbortController::~AbortController() = default; -void AbortController::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> AbortController::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::AbortControllerPrototype>(realm, "AbortController")); + + return {}; } void AbortController::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.h b/Userland/Libraries/LibWeb/DOM/AbortController.h index b02bbca182..9ede4bab2e 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.h +++ b/Userland/Libraries/LibWeb/DOM/AbortController.h @@ -28,7 +28,7 @@ public: private: AbortController(JS::Realm&, JS::NonnullGCPtr<AbortSignal>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://dom.spec.whatwg.org/#abortcontroller-signal diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index d49254aa15..709b4f2a32 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -22,10 +22,12 @@ AbortSignal::AbortSignal(JS::Realm& realm) { } -void AbortSignal::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> AbortSignal::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::AbortSignalPrototype>(realm, "AbortSignal")); + + return {}; } // https://dom.spec.whatwg.org/#abortsignal-add diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.h b/Userland/Libraries/LibWeb/DOM/AbortSignal.h index e25557e4df..87552982c0 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.h +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.h @@ -43,7 +43,7 @@ public: private: explicit AbortSignal(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; // https://dom.spec.whatwg.org/#abortsignal-abort-reason diff --git a/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp b/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp index 8c22be6b1a..f4f6632269 100644 --- a/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbstractRange.cpp @@ -21,10 +21,12 @@ AbstractRange::AbstractRange(Node& start_container, u32 start_offset, Node& end_ AbstractRange::~AbstractRange() = default; -void AbstractRange::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> AbstractRange::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::AbstractRangePrototype>(realm, "AbstractRange")); + + return {}; } void AbstractRange::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/AbstractRange.h b/Userland/Libraries/LibWeb/DOM/AbstractRange.h index af8b04bad3..2490a39ac8 100644 --- a/Userland/Libraries/LibWeb/DOM/AbstractRange.h +++ b/Userland/Libraries/LibWeb/DOM/AbstractRange.h @@ -36,7 +36,7 @@ public: protected: AbstractRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<Node> m_start_container; diff --git a/Userland/Libraries/LibWeb/DOM/Attr.cpp b/Userland/Libraries/LibWeb/DOM/Attr.cpp index c09031cb08..e171b68b78 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.cpp +++ b/Userland/Libraries/LibWeb/DOM/Attr.cpp @@ -31,10 +31,12 @@ Attr::Attr(Document& document, QualifiedName qualified_name, DeprecatedString va { } -void Attr::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Attr::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::AttrPrototype>(realm, "Attr")); + + return {}; } void Attr::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Attr.h b/Userland/Libraries/LibWeb/DOM/Attr.h index ddc8133614..fcf07bf5fa 100644 --- a/Userland/Libraries/LibWeb/DOM/Attr.h +++ b/Userland/Libraries/LibWeb/DOM/Attr.h @@ -45,7 +45,7 @@ public: private: Attr(Document&, QualifiedName, DeprecatedString value, Element const*); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; QualifiedName m_qualified_name; diff --git a/Userland/Libraries/LibWeb/DOM/CDATASection.cpp b/Userland/Libraries/LibWeb/DOM/CDATASection.cpp index d738f2fd4e..6ced5bd51e 100644 --- a/Userland/Libraries/LibWeb/DOM/CDATASection.cpp +++ b/Userland/Libraries/LibWeb/DOM/CDATASection.cpp @@ -16,10 +16,12 @@ CDATASection::CDATASection(Document& document, DeprecatedString const& data) CDATASection::~CDATASection() = default; -void CDATASection::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CDATASection::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CDATASectionPrototype>(realm, "CDATASection")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/DOM/CDATASection.h b/Userland/Libraries/LibWeb/DOM/CDATASection.h index 148dad1c8d..e56aeac0f6 100644 --- a/Userland/Libraries/LibWeb/DOM/CDATASection.h +++ b/Userland/Libraries/LibWeb/DOM/CDATASection.h @@ -23,7 +23,7 @@ public: private: CDATASection(Document&, DeprecatedString const&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; template<> diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index 1a5a6712c7..a346b8111f 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -19,10 +19,12 @@ CharacterData::CharacterData(Document& document, NodeType type, DeprecatedString { } -void CharacterData::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CharacterData::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CharacterDataPrototype>(realm, "CharacterData")); + + return {}; } // https://dom.spec.whatwg.org/#dom-characterdata-data diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.h b/Userland/Libraries/LibWeb/DOM/CharacterData.h index 328a14a0db..6b1b992d77 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.h +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.h @@ -36,7 +36,7 @@ public: protected: CharacterData(Document&, NodeType, DeprecatedString const&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: DeprecatedString m_data; diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp index be20d60880..62632b4187 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.cpp @@ -29,10 +29,12 @@ CustomEvent::CustomEvent(JS::Realm& realm, DeprecatedFlyString const& event_name CustomEvent::~CustomEvent() = default; -void CustomEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CustomEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CustomEventPrototype>(realm, "CustomEvent")); + + return {}; } void CustomEvent::visit_edges(JS::Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.h b/Userland/Libraries/LibWeb/DOM/CustomEvent.h index adab99322e..3e4f6610cb 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.h +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.h @@ -28,7 +28,7 @@ public: // https://dom.spec.whatwg.org/#dom-customevent-detail JS::Value detail() const { return m_detail; } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; void init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index acd7a7c398..79bed545ed 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -31,10 +31,12 @@ DOMImplementation::DOMImplementation(Document& document) DOMImplementation::~DOMImplementation() = default; -void DOMImplementation::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMImplementation::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMImplementationPrototype>(realm, "DOMImplementation")); + + return {}; } void DOMImplementation::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 569f650f17..e785fe373c 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -30,7 +30,7 @@ public: private: explicit DOMImplementation(Document&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; Document& document() { return m_document; } diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 56ba3e5b6e..5cac3fa188 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -68,10 +68,12 @@ DOMTokenList::DOMTokenList(Element const& associated_element, DeprecatedFlyStrin associated_attribute_changed(value); } -void DOMTokenList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMTokenList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMTokenListPrototype>(realm, "DOMTokenList")); + + return {}; } void DOMTokenList::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index 62c9c6a6c7..60dda71782 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -45,7 +45,7 @@ public: private: DOMTokenList(Element const& associated_element, DeprecatedFlyString associated_attribute); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr<void> validate_token(StringView token) const; diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index d575117498..9a78695bdf 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -314,10 +314,12 @@ Document::~Document() HTML::main_thread_event_loop().unregister_document({}, *this); } -void Document::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Document::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentPrototype>(realm, "Document")); + + return {}; } void Document::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index ddf48874a6..bb45b04d1d 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -450,7 +450,7 @@ public: DeprecatedString dump_accessibility_tree_as_json(); protected: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp index 44bb492e8a..2853d58945 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -14,10 +14,12 @@ DocumentFragment::DocumentFragment(Document& document) { } -void DocumentFragment::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DocumentFragment::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentFragmentPrototype>(realm, "DocumentFragment")); + + return {}; } void DocumentFragment::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.h b/Userland/Libraries/LibWeb/DOM/DocumentFragment.h index 0d5aa5e4c3..a73b91252c 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.h @@ -33,7 +33,7 @@ public: protected: explicit DocumentFragment(Document& document); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp index 567ff1eca0..02161ac44d 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.cpp @@ -19,10 +19,12 @@ DocumentType::DocumentType(Document& document) { } -void DocumentType::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DocumentType::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DocumentTypePrototype>(realm, "DocumentType")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/DOM/DocumentType.h b/Userland/Libraries/LibWeb/DOM/DocumentType.h index 44e0f1d7f5..fb2e511926 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentType.h +++ b/Userland/Libraries/LibWeb/DOM/DocumentType.h @@ -36,7 +36,7 @@ public: private: explicit DocumentType(Document&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_name; DeprecatedString m_public_id; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index f965b5241d..144836204f 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -61,12 +61,14 @@ Element::Element(Document& document, DOM::QualifiedName qualified_name) Element::~Element() = default; -void Element::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Element::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ElementPrototype>(realm, "Element")); m_attributes = NamedNodeMap::create(*this); + + return {}; } void Element::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index ed95dda952..3cf48c80cc 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -251,7 +251,7 @@ public: protected: Element(Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void children_changed() override; virtual i32 default_tab_index_value() const; diff --git a/Userland/Libraries/LibWeb/DOM/Event.cpp b/Userland/Libraries/LibWeb/DOM/Event.cpp index ae6e12692a..4ee2e8f1be 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.cpp +++ b/Userland/Libraries/LibWeb/DOM/Event.cpp @@ -41,10 +41,12 @@ Event::Event(JS::Realm& realm, DeprecatedFlyString const& type, EventInit const& { } -void Event::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Event::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::EventPrototype>(realm, "Event")); + + return {}; } void Event::visit_edges(Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index 027ebc7c1f..e05d93945a 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -146,7 +146,7 @@ public: protected: void initialize_event(DeprecatedString const&, bool, bool); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp index 59715879aa..1035dd3097 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.cpp @@ -27,10 +27,12 @@ HTMLCollection::HTMLCollection(ParentNode& root, Function<bool(Element const&)> HTMLCollection::~HTMLCollection() = default; -void HTMLCollection::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLCollection::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLCollectionPrototype>(realm, "HTMLCollection")); + + return {}; } void HTMLCollection::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h index 909c8c18f1..78998f2f4b 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.h +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.h @@ -47,7 +47,7 @@ public: protected: HTMLCollection(ParentNode& root, Function<bool(Element const&)> filter); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; JS::NonnullGCPtr<ParentNode> root() { return *m_root; } diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index 7f01b98f76..fc2c9be5b0 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -31,10 +31,12 @@ MutationObserver::MutationObserver(JS::Realm& realm, JS::GCPtr<WebIDL::CallbackT MutationObserver::~MutationObserver() = default; -void MutationObserver::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MutationObserver::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MutationObserverPrototype>(realm, "MutationObserver")); + + return {}; } void MutationObserver::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.h b/Userland/Libraries/LibWeb/DOM/MutationObserver.h index edc5722394..f12d1b4c48 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.h +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.h @@ -52,7 +52,7 @@ public: private: MutationObserver(JS::Realm&, JS::GCPtr<WebIDL::CallbackType>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://dom.spec.whatwg.org/#concept-mo-callback diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index 8765e832ee..2e80f18180 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -33,10 +33,12 @@ MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type MutationRecord::~MutationRecord() = default; -void MutationRecord::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MutationRecord::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MutationRecordPrototype>(realm, "MutationRecord")); + + return {}; } void MutationRecord::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h index 76a5f747b9..2b7a3d82f5 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.h +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h @@ -32,7 +32,7 @@ public: private: 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); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedFlyString m_type; diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 2c7ef4fb23..c834d7943a 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -25,10 +25,12 @@ NamedNodeMap::NamedNodeMap(Element& element) { } -void NamedNodeMap::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> NamedNodeMap::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::NamedNodeMapPrototype>(realm, "NamedNodeMap")); + + return {}; } void NamedNodeMap::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index 6c64c6ca43..655f298a5e 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -56,7 +56,7 @@ public: private: explicit NamedNodeMap(Element&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; Element& associated_element() { return *m_element; } diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp index 5018918f55..78d833c620 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -21,10 +21,12 @@ NodeIterator::NodeIterator(Node& root) NodeIterator::~NodeIterator() = default; -void NodeIterator::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> NodeIterator::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::NodeIteratorPrototype>(realm, "NodeIterator")); + + return {}; } void NodeIterator::finalize() diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.h b/Userland/Libraries/LibWeb/DOM/NodeIterator.h index 0186bc78a0..2a9c242f95 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.h +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.h @@ -37,7 +37,7 @@ public: private: explicit NodeIterator(Node& root); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void finalize() override; diff --git a/Userland/Libraries/LibWeb/DOM/NodeList.cpp b/Userland/Libraries/LibWeb/DOM/NodeList.cpp index b1a5c6bb97..245418ff3d 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeList.cpp @@ -17,10 +17,12 @@ NodeList::NodeList(JS::Realm& realm) NodeList::~NodeList() = default; -void NodeList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> NodeList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::NodeListPrototype>(realm, "NodeList")); + + return {}; } JS::Value NodeList::item_value(size_t index) const diff --git a/Userland/Libraries/LibWeb/DOM/NodeList.h b/Userland/Libraries/LibWeb/DOM/NodeList.h index 70c87a270f..eb891603e0 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeList.h +++ b/Userland/Libraries/LibWeb/DOM/NodeList.h @@ -27,7 +27,7 @@ public: protected: explicit NodeList(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp index 791d8eede7..52796dbd2b 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.cpp @@ -17,10 +17,12 @@ ProcessingInstruction::ProcessingInstruction(Document& document, DeprecatedStrin { } -void ProcessingInstruction::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ProcessingInstruction::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ProcessingInstructionPrototype>(realm, "ProcessingInstruction")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h index ad5e448468..e4321ad65c 100644 --- a/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h +++ b/Userland/Libraries/LibWeb/DOM/ProcessingInstruction.h @@ -24,7 +24,7 @@ public: private: ProcessingInstruction(Document&, DeprecatedString const& data, DeprecatedString const& target); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_target; }; diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index d8cfe26de4..2192cea2ba 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -66,10 +66,12 @@ Range::~Range() live_ranges().remove(this); } -void Range::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Range::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::RangePrototype>(realm, "Range")); + + return {}; } void Range::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index 52c1eeab0e..480cdb3a4e 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -93,7 +93,7 @@ private: explicit Range(Document&); Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; Node& root(); diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index f86bf5204d..13a73fe821 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -35,10 +35,12 @@ WebIDL::ExceptionOr<StaticRange*> StaticRange::construct_impl(JS::Realm& realm, return realm.heap().allocate<StaticRange>(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset).ptr(); } -void StaticRange::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> StaticRange::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::StaticRangePrototype>(realm, "StaticRange")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.h b/Userland/Libraries/LibWeb/DOM/StaticRange.h index 012714423d..60a06597d2 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.h +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.h @@ -29,7 +29,7 @@ public: StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); virtual ~StaticRange() override; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 33fe4b7d83..9b99b19365 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -24,10 +24,12 @@ Text::Text(Document& document, NodeType type, DeprecatedString const& data) { } -void Text::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Text::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::TextPrototype>(realm, "Text")); + + return {}; } void Text::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/Text.h b/Userland/Libraries/LibWeb/DOM/Text.h index aed9f5f0fc..b0fe498bc7 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.h +++ b/Userland/Libraries/LibWeb/DOM/Text.h @@ -38,7 +38,7 @@ protected: Text(Document&, DeprecatedString const&); Text(Document&, NodeType, DeprecatedString const&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; private: diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp index e86a8a50b3..d9a5c83f4d 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -22,10 +22,12 @@ TreeWalker::TreeWalker(Node& root) TreeWalker::~TreeWalker() = default; -void TreeWalker::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> TreeWalker::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::TreeWalkerPrototype>(realm, "TreeWalker")); + + return {}; } void TreeWalker::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.h b/Userland/Libraries/LibWeb/DOM/TreeWalker.h index 6281bfc108..96b84cae68 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.h +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.h @@ -39,7 +39,7 @@ public: private: explicit TreeWalker(Node& root); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; enum class ChildTraversalType { diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index 262fa0dcb3..3066f16798 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -32,10 +32,12 @@ XMLSerializer::XMLSerializer(JS::Realm& realm) XMLSerializer::~XMLSerializer() = default; -void XMLSerializer::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> XMLSerializer::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::XMLSerializerPrototype>(realm, "XMLSerializer")); + + return {}; } // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h index ee5e311d99..e616d5a6c9 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h @@ -23,7 +23,7 @@ public: private: explicit XMLSerializer(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; enum class RequireWellFormed { diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index 0a300d6f42..63289d0152 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -33,10 +33,12 @@ TextDecoder::TextDecoder(JS::Realm& realm, TextCodec::Decoder& decoder, Deprecat TextDecoder::~TextDecoder() = default; -void TextDecoder::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> TextDecoder::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::TextDecoderPrototype>(realm, "TextDecoder")); + + return {}; } // https://encoding.spec.whatwg.org/#dom-textdecoder-decode diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h index c68447d078..02210830ae 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h @@ -35,7 +35,7 @@ private: // https://encoding.spec.whatwg.org/#dom-textdecoder TextDecoder(JS::Realm&, TextCodec::Decoder&, DeprecatedFlyString encoding, bool fatal, bool ignore_bom); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; TextCodec::Decoder& m_decoder; DeprecatedFlyString m_encoding; diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp index 78fbd0b131..174b976cda 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.cpp @@ -23,10 +23,12 @@ TextEncoder::TextEncoder(JS::Realm& realm) TextEncoder::~TextEncoder() = default; -void TextEncoder::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> TextEncoder::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::TextEncoderPrototype>(realm, "TextEncoder")); + + return {}; } // https://encoding.spec.whatwg.org/#dom-textencoder-encode diff --git a/Userland/Libraries/LibWeb/Encoding/TextEncoder.h b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h index 2da540f5d5..9d8b6e41bf 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextEncoder.h +++ b/Userland/Libraries/LibWeb/Encoding/TextEncoder.h @@ -32,7 +32,7 @@ protected: // https://encoding.spec.whatwg.org/#dom-textencoder explicit TextEncoder(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index 7db1bb3691..f6daf4340c 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -37,10 +37,12 @@ Headers::Headers(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::HeaderList> Headers::~Headers() = default; -void Headers::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Headers::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersPrototype>(realm, "Headers")); + + return {}; } void Headers::visit_edges(JS::Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.h b/Userland/Libraries/LibWeb/Fetch/Headers.h index 2a9b6b5474..d3a582863a 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.h +++ b/Userland/Libraries/LibWeb/Fetch/Headers.h @@ -60,7 +60,7 @@ private: Headers(JS::Realm&, JS::NonnullGCPtr<Infrastructure::HeaderList>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; WebIDL::ExceptionOr<bool> validate(Infrastructure::Header const&) const; diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp index 9a1f682dfa..48b5cfa3ad 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.cpp @@ -37,10 +37,12 @@ HeadersIterator::HeadersIterator(Headers const& headers, JS::Object::PropertyKin HeadersIterator::~HeadersIterator() = default; -void HeadersIterator::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HeadersIterator::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HeadersIteratorPrototype>(realm, "HeadersIterator")); + + return {}; } void HeadersIterator::visit_edges(JS::Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h index 68771b4134..e72eba71c3 100644 --- a/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h +++ b/Userland/Libraries/LibWeb/Fetch/HeadersIterator.h @@ -22,7 +22,7 @@ public: JS::ThrowCompletionOr<JS::Object*> next(); private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; HeadersIterator(Headers const&, JS::Object::PropertyKind iteration_kind); diff --git a/Userland/Libraries/LibWeb/Fetch/Request.cpp b/Userland/Libraries/LibWeb/Fetch/Request.cpp index bb46a039c5..9134ba018b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Request.cpp @@ -29,10 +29,12 @@ Request::Request(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Request> req Request::~Request() = default; -void Request::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Request::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::RequestPrototype>(realm, "Request")); + + return {}; } void Request::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Fetch/Request.h b/Userland/Libraries/LibWeb/Fetch/Request.h index 1a4ff6d914..429ad1be9c 100644 --- a/Userland/Libraries/LibWeb/Fetch/Request.h +++ b/Userland/Libraries/LibWeb/Fetch/Request.h @@ -98,7 +98,7 @@ public: private: Request(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Request>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://fetch.spec.whatwg.org/#concept-request-request diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 92bf6188e4..1348afac88 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -26,10 +26,12 @@ Response::Response(JS::Realm& realm, JS::NonnullGCPtr<Infrastructure::Response> Response::~Response() = default; -void Response::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Response::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ResponsePrototype>(realm, "Response")); + + return {}; } void Response::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Fetch/Response.h b/Userland/Libraries/LibWeb/Fetch/Response.h index 7487911108..01376d618b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.h +++ b/Userland/Libraries/LibWeb/Fetch/Response.h @@ -62,7 +62,7 @@ public: private: Response(JS::Realm&, JS::NonnullGCPtr<Infrastructure::Response>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; WebIDL::ExceptionOr<void> initialize_response(ResponseInit const&, Optional<Infrastructure::BodyWithType> const&); diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index 6a76a7cbd4..673ff7cc17 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -132,10 +132,12 @@ Blob::Blob(JS::Realm& realm, ByteBuffer byte_buffer) Blob::~Blob() = default; -void Blob::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Blob::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::BlobPrototype>(realm, "Blob")); + + return {}; } // https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index f3d482eb0a..9abbf258c8 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -53,7 +53,7 @@ protected: Blob(JS::Realm&, ByteBuffer, DeprecatedString type); Blob(JS::Realm&, ByteBuffer); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: explicit Blob(JS::Realm&); diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index bd1c68ba9b..4b569d22e5 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -18,10 +18,12 @@ File::File(JS::Realm& realm, ByteBuffer byte_buffer, DeprecatedString file_name, { } -void File::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> File::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::FilePrototype>(realm, "File")); + + return {}; } File::~File() = default; diff --git a/Userland/Libraries/LibWeb/FileAPI/File.h b/Userland/Libraries/LibWeb/FileAPI/File.h index 143f61ac3d..902e5bff91 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.h +++ b/Userland/Libraries/LibWeb/FileAPI/File.h @@ -31,7 +31,7 @@ public: private: File(JS::Realm&, ByteBuffer, DeprecatedString file_name, DeprecatedString type, i64 last_modified); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_name; i64 m_last_modified { 0 }; diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp index d0eb3bad21..96f4973a62 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.cpp @@ -24,10 +24,12 @@ FileList::FileList(JS::Realm& realm, Vector<JS::NonnullGCPtr<File>>&& files) FileList::~FileList() = default; -void FileList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> FileList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::FileListPrototype>(realm, "FileList")); + + return {}; } // https://w3c.github.io/FileAPI/#dfn-item diff --git a/Userland/Libraries/LibWeb/FileAPI/FileList.h b/Userland/Libraries/LibWeb/FileAPI/FileList.h index 8b049dc791..66c882daa3 100644 --- a/Userland/Libraries/LibWeb/FileAPI/FileList.h +++ b/Userland/Libraries/LibWeb/FileAPI/FileList.h @@ -35,7 +35,7 @@ public: private: FileList(JS::Realm&, Vector<JS::NonnullGCPtr<File>>&&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; Vector<JS::NonnullGCPtr<File>> m_files; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp index cd2a160629..20a091c77e 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.cpp @@ -29,10 +29,12 @@ JS::NonnullGCPtr<DOMPoint> DOMPoint::from_point(JS::VM& vm, DOMPointInit const& DOMPoint::~DOMPoint() = default; -void DOMPoint::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMPoint::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointPrototype>(realm, "DOMPoint")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h index 8d9bdc4c9e..57999c4402 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPoint.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPoint.h @@ -35,7 +35,7 @@ public: private: DOMPoint(JS::Realm&, double x, double y, double z, double w); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp index 0b43b00f38..bbef19a0dd 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.cpp @@ -33,10 +33,12 @@ JS::NonnullGCPtr<DOMPointReadOnly> DOMPointReadOnly::from_point(JS::VM& vm, DOMP DOMPointReadOnly::~DOMPointReadOnly() = default; -void DOMPointReadOnly::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMPointReadOnly::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMPointReadOnlyPrototype>(realm, "DOMPointReadOnly")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h index be5819b57f..c52bc75bee 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMPointReadOnly.h @@ -39,7 +39,7 @@ public: protected: DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; double m_x; double m_y; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp index f74c4c74f3..54415fa7f0 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.cpp @@ -26,10 +26,12 @@ DOMRect::DOMRect(JS::Realm& realm, double x, double y, double width, double heig DOMRect::~DOMRect() = default; -void DOMRect::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMRect::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectPrototype>(realm, "DOMRect")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRect.h b/Userland/Libraries/LibWeb/Geometry/DOMRect.h index b8398102d8..0eb93c1d54 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRect.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRect.h @@ -33,7 +33,7 @@ public: private: DOMRect(JS::Realm&, double x, double y, double width, double height); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp index ece3ce8a06..14e5bc4e57 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.cpp @@ -27,10 +27,12 @@ DOMRectList::DOMRectList(JS::Realm& realm, Vector<JS::NonnullGCPtr<DOMRect>> rec DOMRectList::~DOMRectList() = default; -void DOMRectList::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMRectList::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectListPrototype>(realm, "DOMRectList")); + + return {}; } // https://drafts.fxtf.org/geometry-1/#dom-domrectlist-length diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectList.h b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h index cc98b0e284..cf43ff88c0 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectList.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectList.h @@ -30,7 +30,7 @@ public: private: DOMRectList(JS::Realm&, Vector<JS::NonnullGCPtr<DOMRect>>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Vector<JS::NonnullGCPtr<DOMRect>> m_rects; }; diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp index c6a3286aef..a583d500fc 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.cpp @@ -22,10 +22,12 @@ DOMRectReadOnly::DOMRectReadOnly(JS::Realm& realm, double x, double y, double wi DOMRectReadOnly::~DOMRectReadOnly() = default; -void DOMRectReadOnly::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMRectReadOnly::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMRectReadOnlyPrototype>(realm, "DOMRectReadOnly")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h index f0abdf72c5..0fd39aa462 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h +++ b/Userland/Libraries/LibWeb/Geometry/DOMRectReadOnly.h @@ -34,7 +34,7 @@ public: protected: DOMRectReadOnly(JS::Realm&, double x, double y, double width, double height); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Gfx::FloatRect m_rect; }; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index 0c9a431430..c7d07f7849 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -47,10 +47,12 @@ CanvasGradient::CanvasGradient(JS::Realm& realm, Gfx::GradientPaintStyle& gradie CanvasGradient::~CanvasGradient() = default; -void CanvasGradient::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CanvasGradient::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CanvasGradientPrototype>(realm, "CanvasGradient")); + + return {}; } // https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h index c0ad7a78af..e9f23636ac 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h @@ -29,7 +29,7 @@ public: private: CanvasGradient(JS::Realm&, Gfx::GradientPaintStyle& gradient); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; NonnullRefPtr<Gfx::GradientPaintStyle> m_gradient; }; diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 662df94c8b..ae0018375c 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -38,10 +38,12 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(JS::Realm& realm, HTMLCanvasE CanvasRenderingContext2D::~CanvasRenderingContext2D() = default; -void CanvasRenderingContext2D::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CanvasRenderingContext2D::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CanvasRenderingContext2DPrototype>(realm, "CanvasRenderingContext2D")); + + return {}; } void CanvasRenderingContext2D::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 66fe651176..4567b4e451 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -86,7 +86,7 @@ public: private: explicit CanvasRenderingContext2D(JS::Realm&, HTMLCanvasElement&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; struct PreparedTextGlyph { diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp index d74105da24..866fd6cf9f 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.cpp @@ -29,10 +29,12 @@ CloseEvent::CloseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, CloseEvent::~CloseEvent() = default; -void CloseEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> CloseEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::CloseEventPrototype>(realm, "CloseEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/CloseEvent.h b/Userland/Libraries/LibWeb/HTML/CloseEvent.h index 548f4d489d..fb2886bc8b 100644 --- a/Userland/Libraries/LibWeb/HTML/CloseEvent.h +++ b/Userland/Libraries/LibWeb/HTML/CloseEvent.h @@ -33,7 +33,7 @@ public: private: CloseEvent(JS::Realm&, DeprecatedFlyString const& event_name, CloseEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; bool m_was_clean { false }; u16 m_code { 0 }; diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index bb40b3574c..a89e927b11 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -25,10 +25,12 @@ DOMParser::DOMParser(JS::Realm& realm) DOMParser::~DOMParser() = default; -void DOMParser::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMParser::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMParserPrototype>(realm, "DOMParser")); + + return {}; } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.h b/Userland/Libraries/LibWeb/HTML/DOMParser.h index 85f696e46b..ff03c9d710 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.h +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.h @@ -28,7 +28,7 @@ public: private: explicit DOMParser(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 271ba6160a..19729c5d66 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -26,10 +26,12 @@ DOMStringMap::DOMStringMap(DOM::Element& element) DOMStringMap::~DOMStringMap() = default; -void DOMStringMap::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMStringMap::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMStringMapPrototype>(realm, "DOMStringMap")); + + return {}; } void DOMStringMap::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h index 5b77c072f0..9752706283 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h @@ -31,7 +31,7 @@ public: private: explicit DOMStringMap(DOM::Element&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // ^LegacyPlatformObject diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp index 2e83004d95..8e2f4669df 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp @@ -31,10 +31,12 @@ ErrorEvent::ErrorEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEvent::~ErrorEvent() = default; -void ErrorEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ErrorEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ErrorEventPrototype>(realm, "ErrorEvent")); + + return {}; } void ErrorEvent::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h index c34b6cf430..ef8d2d6cdc 100644 --- a/Userland/Libraries/LibWeb/HTML/ErrorEvent.h +++ b/Userland/Libraries/LibWeb/HTML/ErrorEvent.h @@ -47,7 +47,7 @@ public: private: ErrorEvent(JS::Realm&, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedString m_message { "" }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 3a62420849..3ad875c00d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -20,10 +20,12 @@ HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, DOM::QualifiedName HTMLAnchorElement::~HTMLAnchorElement() = default; -void HTMLAnchorElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLAnchorElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAnchorElementPrototype>(realm, "HTMLAnchorElement")); + + return {}; } void HTMLAnchorElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 2f01af5187..0f6d9d864b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -32,7 +32,7 @@ public: private: HTMLAnchorElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void run_activation_behavior(Web::DOM::Event const&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp index 9618a11f6f..accb0eb3ee 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.cpp @@ -17,10 +17,12 @@ HTMLAreaElement::HTMLAreaElement(DOM::Document& document, DOM::QualifiedName qua HTMLAreaElement::~HTMLAreaElement() = default; -void HTMLAreaElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLAreaElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAreaElementPrototype>(realm, "HTMLAreaElement")); + + return {}; } void HTMLAreaElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h index b12b7df404..2f52e7d8e7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAreaElement.h @@ -23,7 +23,7 @@ public: private: HTMLAreaElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; // ^DOM::Element virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp index f480581aa2..ea3e83e1e8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.cpp @@ -16,10 +16,12 @@ HTMLAudioElement::HTMLAudioElement(DOM::Document& document, DOM::QualifiedName q HTMLAudioElement::~HTMLAudioElement() = default; -void HTMLAudioElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLAudioElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLAudioElementPrototype>(realm, "HTMLAudioElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h index 4d32b7e9b3..4dadc6c15e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAudioElement.h @@ -19,7 +19,7 @@ public: private: HTMLAudioElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp index a13ae96957..8499debff0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -17,10 +17,12 @@ HTMLBRElement::HTMLBRElement(DOM::Document& document, DOM::QualifiedName qualifi HTMLBRElement::~HTMLBRElement() = default; -void HTMLBRElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLBRElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBRElementPrototype>(realm, "HTMLBRElement")); + + return {}; } JS::GCPtr<Layout::Node> HTMLBRElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h index f6b1cf2f7e..9a70829cdb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -21,7 +21,7 @@ public: private: HTMLBRElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp index 7b515c87b1..08a40b5cb0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.cpp @@ -16,10 +16,12 @@ HTMLBaseElement::HTMLBaseElement(DOM::Document& document, DOM::QualifiedName qua HTMLBaseElement::~HTMLBaseElement() = default; -void HTMLBaseElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLBaseElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBaseElementPrototype>(realm, "HTMLBaseElement")); + + return {}; } void HTMLBaseElement::inserted() diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h index 2a69da35ef..986c2a810e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h @@ -28,7 +28,7 @@ public: private: HTMLBaseElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual bool is_html_base_element() const override { return true; } // https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 4edc01ca4c..817fe91dd3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -19,10 +19,12 @@ HTMLBodyElement::HTMLBodyElement(DOM::Document& document, DOM::QualifiedName qua HTMLBodyElement::~HTMLBodyElement() = default; -void HTMLBodyElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLBodyElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLBodyElementPrototype>(realm, "HTMLBodyElement")); + + return {}; } void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h index 4b437268fb..39bf51605f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -29,7 +29,7 @@ public: private: HTMLBodyElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; // ^HTML::GlobalEventHandlers virtual EventTarget& global_event_handlers_to_event_target(DeprecatedFlyString const& event_name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp index 6705b3e5fb..6dacc24ac6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.cpp @@ -51,10 +51,12 @@ HTMLButtonElement::HTMLButtonElement(DOM::Document& document, DOM::QualifiedName HTMLButtonElement::~HTMLButtonElement() = default; -void HTMLButtonElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLButtonElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLButtonElementPrototype>(realm, "HTMLButtonElement")); + + return {}; } DeprecatedString HTMLButtonElement::type() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h index 8e49feba52..3cd9499f86 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLButtonElement.h @@ -26,7 +26,7 @@ class HTMLButtonElement final public: virtual ~HTMLButtonElement() override; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; enum class TypeAttributeState { #define __ENUMERATE_HTML_BUTTON_TYPE_ATTRIBUTE(_, state) state, diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index cc373053a3..360ecfd79e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -25,10 +25,12 @@ HTMLCanvasElement::HTMLCanvasElement(DOM::Document& document, DOM::QualifiedName HTMLCanvasElement::~HTMLCanvasElement() = default; -void HTMLCanvasElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLCanvasElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLCanvasElementPrototype>(realm, "HTMLCanvasElement")); + + return {}; } void HTMLCanvasElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h index 51a0f11292..f723162843 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -40,7 +40,7 @@ public: private: HTMLCanvasElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp index eed2efc709..26aad40aa1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.cpp @@ -16,10 +16,12 @@ HTMLDListElement::HTMLDListElement(DOM::Document& document, DOM::QualifiedName q HTMLDListElement::~HTMLDListElement() = default; -void HTMLDListElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDListElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDListElementPrototype>(realm, "HTMLDListElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h index d0c1dbdd8e..3dc20a0008 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDListElement.h @@ -19,7 +19,7 @@ public: private: HTMLDListElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp index 0ec6a42b80..bfcb8d483a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.cpp @@ -16,10 +16,12 @@ HTMLDataElement::HTMLDataElement(DOM::Document& document, DOM::QualifiedName qua HTMLDataElement::~HTMLDataElement() = default; -void HTMLDataElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDataElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDataElementPrototype>(realm, "HTMLDataElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h index 5708963291..3266bfc9a1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataElement.h @@ -23,7 +23,7 @@ public: private: HTMLDataElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp index 7c3f9619ca..62fba41c78 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.cpp @@ -16,10 +16,12 @@ HTMLDataListElement::HTMLDataListElement(DOM::Document& document, DOM::Qualified HTMLDataListElement::~HTMLDataListElement() = default; -void HTMLDataListElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDataListElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDataListElementPrototype>(realm, "HTMLDataListElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h index d71383912e..db0cf827ae 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDataListElement.h @@ -22,7 +22,7 @@ public: private: HTMLDataListElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp index a6f6401ae3..fceef86285 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.cpp @@ -16,10 +16,12 @@ HTMLDetailsElement::HTMLDetailsElement(DOM::Document& document, DOM::QualifiedNa HTMLDetailsElement::~HTMLDetailsElement() = default; -void HTMLDetailsElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDetailsElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDetailsElementPrototype>(realm, "HTMLDetailsElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h index 2a09a57b64..112e362ed3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h @@ -23,7 +23,7 @@ public: private: HTMLDetailsElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp index f283602cc6..6791fb1ae9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.cpp @@ -16,10 +16,12 @@ HTMLDialogElement::HTMLDialogElement(DOM::Document& document, DOM::QualifiedName HTMLDialogElement::~HTMLDialogElement() = default; -void HTMLDialogElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDialogElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDialogElementPrototype>(realm, "HTMLDialogElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h index d54332c872..78a24fd469 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDialogElement.h @@ -23,7 +23,7 @@ public: private: HTMLDialogElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp index 7e76c9ee3c..1ea6e17034 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.cpp @@ -16,10 +16,12 @@ HTMLDirectoryElement::HTMLDirectoryElement(DOM::Document& document, DOM::Qualifi HTMLDirectoryElement::~HTMLDirectoryElement() = default; -void HTMLDirectoryElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDirectoryElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDirectoryElementPrototype>(realm, "HTMLDirectoryElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h index fd53d1dc37..0bd8337a55 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDirectoryElement.h @@ -20,7 +20,7 @@ public: private: HTMLDirectoryElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp index 050187c916..3ebd7580b6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.cpp @@ -16,10 +16,12 @@ HTMLDivElement::HTMLDivElement(DOM::Document& document, DOM::QualifiedName quali HTMLDivElement::~HTMLDivElement() = default; -void HTMLDivElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLDivElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLDivElementPrototype>(realm, "HTMLDivElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h index a94635fe1a..37348a32e2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLDivElement.h @@ -23,7 +23,7 @@ public: private: HTMLDivElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 1fdc7a5e77..3924eff662 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -40,12 +40,14 @@ HTMLElement::HTMLElement(DOM::Document& document, DOM::QualifiedName qualified_n HTMLElement::~HTMLElement() = default; -void HTMLElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLElementPrototype>(realm, "HTMLElement")); m_dataset = DOMStringMap::create(*this); + + return {}; } void HTMLElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h index 6f8e774f74..24808802aa 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h @@ -64,7 +64,7 @@ public: protected: HTMLElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp index 7ba220f5c1..d6242daef2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.cpp @@ -16,10 +16,12 @@ HTMLEmbedElement::HTMLEmbedElement(DOM::Document& document, DOM::QualifiedName q HTMLEmbedElement::~HTMLEmbedElement() = default; -void HTMLEmbedElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLEmbedElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLEmbedElementPrototype>(realm, "HTMLEmbedElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h index 311ad16d3a..1e67977b1e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLEmbedElement.h @@ -19,7 +19,7 @@ public: private: HTMLEmbedElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp index 59297ca6cc..cf6423d3d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.cpp @@ -17,10 +17,12 @@ HTMLFieldSetElement::HTMLFieldSetElement(DOM::Document& document, DOM::Qualified HTMLFieldSetElement::~HTMLFieldSetElement() = default; -void HTMLFieldSetElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLFieldSetElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFieldSetElementPrototype>(realm, "HTMLFieldSetElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/form-elements.html#concept-fieldset-disabled diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h index ecb9eb522b..2c3af63ed5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFieldSetElement.h @@ -41,7 +41,7 @@ public: private: HTMLFieldSetElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp index 75243d89c4..ad8fad5fb7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.cpp @@ -18,10 +18,12 @@ HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qua HTMLFontElement::~HTMLFontElement() = default; -void HTMLFontElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLFontElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFontElementPrototype>(realm, "HTMLFontElement")); + + return {}; } void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h index 89a3b0783d..13c5bd3c04 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFontElement.h @@ -21,7 +21,7 @@ public: private: HTMLFontElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 54c13cbea7..a40da14126 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -30,10 +30,12 @@ HTMLFormElement::HTMLFormElement(DOM::Document& document, DOM::QualifiedName qua HTMLFormElement::~HTMLFormElement() = default; -void HTMLFormElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLFormElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFormElementPrototype>(realm, "HTMLFormElement")); + + return {}; } void HTMLFormElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index 41ec186c01..de93f3629d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -43,7 +43,7 @@ public: private: HTMLFormElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; bool m_firing_submission_events { false }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp index 3256104e30..e5d2099e79 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.cpp @@ -16,10 +16,12 @@ HTMLFrameElement::HTMLFrameElement(DOM::Document& document, DOM::QualifiedName q HTMLFrameElement::~HTMLFrameElement() = default; -void HTMLFrameElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLFrameElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameElementPrototype>(realm, "HTMLFrameElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h index ab36507102..f0cbfeb0ab 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameElement.h @@ -20,7 +20,7 @@ public: private: HTMLFrameElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; // ^DOM::Element virtual i32 default_tab_index_value() const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp index b36b77f494..7a5c11644d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.cpp @@ -17,10 +17,12 @@ HTMLFrameSetElement::HTMLFrameSetElement(DOM::Document& document, DOM::Qualified HTMLFrameSetElement::~HTMLFrameSetElement() = default; -void HTMLFrameSetElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLFrameSetElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLFrameSetElementPrototype>(realm, "HTMLFrameSetElement")); + + return {}; } void HTMLFrameSetElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h index 24a4c295c9..60dc9ae5e4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFrameSetElement.h @@ -23,7 +23,7 @@ public: private: HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void parse_attribute(DeprecatedFlyString const&, DeprecatedString const&) override; // ^HTML::GlobalEventHandlers diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp index f97a7814f8..0286bdf7a2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -16,10 +16,12 @@ HTMLHRElement::HTMLHRElement(DOM::Document& document, DOM::QualifiedName qualifi HTMLHRElement::~HTMLHRElement() = default; -void HTMLHRElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLHRElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHRElementPrototype>(realm, "HTMLHRElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h index 97827985ea..ad58320baa 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHRElement.h @@ -23,7 +23,7 @@ public: private: HTMLHRElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp index ff17191036..d961e7a72a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.cpp @@ -16,10 +16,12 @@ HTMLHeadElement::HTMLHeadElement(DOM::Document& document, DOM::QualifiedName qua HTMLHeadElement::~HTMLHeadElement() = default; -void HTMLHeadElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLHeadElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHeadElementPrototype>(realm, "HTMLHeadElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h index 6d88ab8034..be4ab44aa7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadElement.h @@ -19,7 +19,7 @@ public: private: HTMLHeadElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index e6fe3dddfc..83b2b7f90a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -16,10 +16,12 @@ HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, DOM::QualifiedNa HTMLHeadingElement::~HTMLHeadingElement() = default; -void HTMLHeadingElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLHeadingElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHeadingElementPrototype>(realm, "HTMLHeadingElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h index 599975c046..9f02839b29 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -31,7 +31,7 @@ public: private: HTMLHeadingElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp index f2758c9c67..606519ac02 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp @@ -16,10 +16,12 @@ HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, DOM::QualifiedName qua HTMLHtmlElement::~HTMLHtmlElement() = default; -void HTMLHtmlElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLHtmlElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLHtmlElementPrototype>(realm, "HTMLHtmlElement")); + + return {}; } bool HTMLHtmlElement::should_use_body_background_properties() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h index 454d260a29..a11c54da5e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHtmlElement.h @@ -25,7 +25,7 @@ public: private: HTMLHtmlElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual bool is_html_html_element() const override { return true; } }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 98131a22a1..1b7f15ea83 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -21,10 +21,12 @@ HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, DOM::QualifiedName HTMLIFrameElement::~HTMLIFrameElement() = default; -void HTMLIFrameElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLIFrameElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLIFrameElementPrototype>(realm, "HTMLIFrameElement")); + + return {}; } JS::GCPtr<Layout::Node> HTMLIFrameElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h index e0a5f897e1..cc194cc369 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -28,7 +28,7 @@ public: private: HTMLIFrameElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; // ^DOM::Element virtual void inserted() override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index fd992c48ec..aadcf6b51d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -48,10 +48,12 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q HTMLImageElement::~HTMLImageElement() = default; -void HTMLImageElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLImageElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLImageElementPrototype>(realm, "HTMLImageElement")); + + return {}; } void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h index 9c79421a4d..d300fb4291 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -48,7 +48,7 @@ public: private: HTMLImageElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4592b97a29..4cbcf333c4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -41,10 +41,12 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q HTMLInputElement::~HTMLInputElement() = default; -void HTMLInputElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLInputElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLInputElementPrototype>(realm, "HTMLInputElement")); + + return {}; } void HTMLInputElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 893696a0fb..cc1dd564e4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -134,7 +134,7 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; static TypeAttributeState parse_type_attribute(StringView); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp index 41cf0533e6..980775cf8b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.cpp @@ -16,10 +16,12 @@ HTMLLIElement::HTMLLIElement(DOM::Document& document, DOM::QualifiedName qualifi HTMLLIElement::~HTMLLIElement() = default; -void HTMLLIElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLLIElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLIElementPrototype>(realm, "HTMLLIElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h index 491001b714..1295619c3e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLIElement.h @@ -23,7 +23,7 @@ public: private: HTMLLIElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index 6d8372bf23..94f9e56454 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -17,10 +17,12 @@ HTMLLabelElement::HTMLLabelElement(DOM::Document& document, DOM::QualifiedName q HTMLLabelElement::~HTMLLabelElement() = default; -void HTMLLabelElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLLabelElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLabelElementPrototype>(realm, "HTMLLabelElement")); + + return {}; } JS::GCPtr<Layout::Node> HTMLLabelElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h index 489ab4db4b..44f28e9aa9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.h @@ -23,7 +23,7 @@ public: private: HTMLLabelElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp index dd004bc08d..8313f82dcd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.cpp @@ -16,10 +16,12 @@ HTMLLegendElement::HTMLLegendElement(DOM::Document& document, DOM::QualifiedName HTMLLegendElement::~HTMLLegendElement() = default; -void HTMLLegendElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLLegendElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLegendElementPrototype>(realm, "HTMLLegendElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h index dc10820eda..23c5cd8173 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLegendElement.h @@ -19,7 +19,7 @@ public: private: HTMLLegendElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 7787da4572..294f5ee67b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -26,10 +26,12 @@ HTMLLinkElement::HTMLLinkElement(DOM::Document& document, DOM::QualifiedName qua HTMLLinkElement::~HTMLLinkElement() = default; -void HTMLLinkElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLLinkElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLLinkElementPrototype>(realm, "HTMLLinkElement")); + + return {}; } void HTMLLinkElement::inserted() diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h index bb8cdfbc34..ee78861ec6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -33,7 +33,7 @@ public: private: HTMLLinkElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void parse_attribute(DeprecatedFlyString const&, DeprecatedString const&) override; // ^ResourceClient diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp index ebcfa407b3..318c5658a4 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.cpp @@ -16,10 +16,12 @@ HTMLMapElement::HTMLMapElement(DOM::Document& document, DOM::QualifiedName quali HTMLMapElement::~HTMLMapElement() = default; -void HTMLMapElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMapElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMapElementPrototype>(realm, "HTMLMapElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h index c862ba7cc1..30b2a0df26 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMapElement.h @@ -19,7 +19,7 @@ public: private: HTMLMapElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp index 194f9e9cb7..31f6e8df48 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.cpp @@ -16,10 +16,12 @@ HTMLMarqueeElement::HTMLMarqueeElement(DOM::Document& document, DOM::QualifiedNa HTMLMarqueeElement::~HTMLMarqueeElement() = default; -void HTMLMarqueeElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMarqueeElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMarqueeElementPrototype>(realm, "HTMLMarqueeElement")); + + return {}; } void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h index 3c85d41bc2..cb345a54c6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMarqueeElement.h @@ -20,7 +20,7 @@ public: private: HTMLMarqueeElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index a1325ce359..2fea46c39a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -17,10 +17,12 @@ HTMLMediaElement::HTMLMediaElement(DOM::Document& document, DOM::QualifiedName q HTMLMediaElement::~HTMLMediaElement() = default; -void HTMLMediaElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMediaElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMediaElementPrototype>(realm, "HTMLMediaElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/media.html#dom-navigator-canplaytype diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index d1f3139bb6..126c24299c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -24,7 +24,7 @@ public: protected: HTMLMediaElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp index b4b7575005..6507d52179 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.cpp @@ -16,10 +16,12 @@ HTMLMenuElement::HTMLMenuElement(DOM::Document& document, DOM::QualifiedName qua HTMLMenuElement::~HTMLMenuElement() = default; -void HTMLMenuElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMenuElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMenuElementPrototype>(realm, "HTMLMenuElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h index 2af2ebff78..feb831fd67 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMenuElement.h @@ -23,7 +23,7 @@ public: private: HTMLMenuElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp index b40bb5507e..c32581290d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.cpp @@ -16,10 +16,12 @@ HTMLMetaElement::HTMLMetaElement(DOM::Document& document, DOM::QualifiedName qua HTMLMetaElement::~HTMLMetaElement() = default; -void HTMLMetaElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMetaElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMetaElementPrototype>(realm, "HTMLMetaElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h index bd21f42c14..dc81eaff21 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMetaElement.h @@ -19,7 +19,7 @@ public: private: HTMLMetaElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp index 6f8ce5e8fa..61c2245ab7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.cpp @@ -16,10 +16,12 @@ HTMLMeterElement::HTMLMeterElement(DOM::Document& document, DOM::QualifiedName q HTMLMeterElement::~HTMLMeterElement() = default; -void HTMLMeterElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLMeterElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLMeterElementPrototype>(realm, "HTMLMeterElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h index 5040a5589a..50d5c0613f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMeterElement.h @@ -28,7 +28,7 @@ public: private: HTMLMeterElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp index a1a4778828..98f2f967f6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLModElement.cpp @@ -17,10 +17,12 @@ HTMLModElement::HTMLModElement(DOM::Document& document, DOM::QualifiedName quali HTMLModElement::~HTMLModElement() = default; -void HTMLModElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLModElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLModElementPrototype>(realm, "HTMLModElement")); + + return {}; } Optional<DOM::ARIARoles::Role> HTMLModElement::default_role() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLModElement.h b/Userland/Libraries/LibWeb/HTML/HTMLModElement.h index 47aa99d641..b710d0936c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLModElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLModElement.h @@ -22,7 +22,7 @@ public: private: HTMLModElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp index 74de79aa2b..ae12c71934 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.cpp @@ -16,10 +16,12 @@ HTMLOListElement::HTMLOListElement(DOM::Document& document, DOM::QualifiedName q HTMLOListElement::~HTMLOListElement() = default; -void HTMLOListElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLOListElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOListElementPrototype>(realm, "HTMLOListElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h index 7df7b0b08b..423251be5d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOListElement.h @@ -23,7 +23,7 @@ public: private: HTMLOListElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index dbbfada928..77662c57c7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -30,10 +30,12 @@ HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName HTMLObjectElement::~HTMLObjectElement() = default; -void HTMLObjectElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLObjectElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLObjectElementPrototype>(realm, "HTMLObjectElement")); + + return {}; } void HTMLObjectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h index 46567c275e..e3fff897bf 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -46,7 +46,7 @@ public: private: HTMLObjectElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp index 77c433c961..0acb8d000e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.cpp @@ -16,10 +16,12 @@ HTMLOptGroupElement::HTMLOptGroupElement(DOM::Document& document, DOM::Qualified HTMLOptGroupElement::~HTMLOptGroupElement() = default; -void HTMLOptGroupElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLOptGroupElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptGroupElementPrototype>(realm, "HTMLOptGroupElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h index 3b3971442d..7e78eb6811 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptGroupElement.h @@ -23,7 +23,7 @@ public: private: HTMLOptGroupElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp index f70d7dffb9..1f4f64b0f1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.cpp @@ -25,10 +25,12 @@ HTMLOptionElement::HTMLOptionElement(DOM::Document& document, DOM::QualifiedName HTMLOptionElement::~HTMLOptionElement() = default; -void HTMLOptionElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLOptionElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionElementPrototype>(realm, "HTMLOptionElement")); + + return {}; } void HTMLOptionElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h index c6d8228c92..fd71690c33 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionElement.h @@ -38,7 +38,7 @@ private: HTMLOptionElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; void did_remove_attribute(DeprecatedFlyString const& name) override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index 61fd922053..c832827131 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -25,10 +25,12 @@ HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<boo HTMLOptionsCollection::~HTMLOptionsCollection() = default; -void HTMLOptionsCollection::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLOptionsCollection::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOptionsCollectionPrototype>(realm, "HTMLOptionsCollection")); + + return {}; } // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h index ee3d7ff5a0..46686fd223 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h @@ -27,7 +27,7 @@ public: private: HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp index 99a9d89ba9..1d5063c1d5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.cpp @@ -16,10 +16,12 @@ HTMLOutputElement::HTMLOutputElement(DOM::Document& document, DOM::QualifiedName HTMLOutputElement::~HTMLOutputElement() = default; -void HTMLOutputElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLOutputElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLOutputElementPrototype>(realm, "HTMLOutputElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/form-elements.html#the-output-element:concept-form-reset-control diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h index d8c22cb5c6..12a19e8820 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOutputElement.h @@ -50,7 +50,7 @@ public: private: HTMLOutputElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp index 72a77736ef..6010a77800 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp @@ -16,10 +16,12 @@ HTMLParagraphElement::HTMLParagraphElement(DOM::Document& document, DOM::Qualifi HTMLParagraphElement::~HTMLParagraphElement() = default; -void HTMLParagraphElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLParagraphElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLParagraphElementPrototype>(realm, "HTMLParagraphElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h index e0f4153047..519dd7cd83 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h @@ -25,7 +25,7 @@ public: private: HTMLParagraphElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp index b71bdbaed9..1dd89c3c17 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.cpp @@ -16,10 +16,12 @@ HTMLParamElement::HTMLParamElement(DOM::Document& document, DOM::QualifiedName q HTMLParamElement::~HTMLParamElement() = default; -void HTMLParamElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLParamElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLParamElementPrototype>(realm, "HTMLParamElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h index 8ae224061a..f32fc146fe 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLParamElement.h @@ -19,7 +19,7 @@ public: private: HTMLParamElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp index d9e4bb99a5..f6f5d1abec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.cpp @@ -16,10 +16,12 @@ HTMLPictureElement::HTMLPictureElement(DOM::Document& document, DOM::QualifiedNa HTMLPictureElement::~HTMLPictureElement() = default; -void HTMLPictureElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLPictureElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPictureElementPrototype>(realm, "HTMLPictureElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h index c27e99ee34..33d9d3d02f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLPictureElement.h @@ -19,7 +19,7 @@ public: private: HTMLPictureElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp index 684e4e49f1..15feeca06a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp @@ -16,10 +16,12 @@ HTMLPreElement::HTMLPreElement(DOM::Document& document, DOM::QualifiedName quali HTMLPreElement::~HTMLPreElement() = default; -void HTMLPreElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLPreElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLPreElementPrototype>(realm, "HTMLPreElement")); + + return {}; } void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h index b1caeff7f6..db7fd5c8da 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h @@ -23,7 +23,7 @@ public: private: HTMLPreElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp index cde41d2594..a92512aaeb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.cpp @@ -21,10 +21,12 @@ HTMLProgressElement::HTMLProgressElement(DOM::Document& document, DOM::Qualified HTMLProgressElement::~HTMLProgressElement() = default; -void HTMLProgressElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLProgressElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLProgressElementPrototype>(realm, "HTMLProgressElement")); + + return {}; } JS::GCPtr<Layout::Node> HTMLProgressElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h index e8bac3b42d..9ff233211c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLProgressElement.h @@ -39,7 +39,7 @@ public: private: HTMLProgressElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void progress_position_updated(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp index a1113a00a7..21dad595a1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.cpp @@ -18,10 +18,12 @@ HTMLQuoteElement::HTMLQuoteElement(DOM::Document& document, DOM::QualifiedName q HTMLQuoteElement::~HTMLQuoteElement() = default; -void HTMLQuoteElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLQuoteElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLQuoteElementPrototype>(realm, "HTMLQuoteElement")); + + return {}; } Optional<DOM::ARIARoles::Role> HTMLQuoteElement::default_role() const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h index 9791dda4d7..ccc80188f9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLQuoteElement.h @@ -21,7 +21,7 @@ public: private: HTMLQuoteElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index 0af9dd888d..2438d1da96 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -30,10 +30,12 @@ HTMLScriptElement::HTMLScriptElement(DOM::Document& document, DOM::QualifiedName HTMLScriptElement::~HTMLScriptElement() = default; -void HTMLScriptElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLScriptElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLScriptElementPrototype>(realm, "HTMLScriptElement")); + + return {}; } void HTMLScriptElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h index 049e5aa994..df06764ac2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -57,7 +57,7 @@ public: virtual void resource_did_load() override; virtual void resource_did_fail() override; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index bef9062115..60d11670f8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -20,10 +20,12 @@ HTMLSelectElement::HTMLSelectElement(DOM::Document& document, DOM::QualifiedName HTMLSelectElement::~HTMLSelectElement() = default; -void HTMLSelectElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLSelectElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSelectElementPrototype>(realm, "HTMLSelectElement")); + + return {}; } void HTMLSelectElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h index 29996d74d4..2746422ec5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -65,7 +65,7 @@ public: private: HTMLSelectElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // ^DOM::Element diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp index 7a43cb4ee1..e1570f44e1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.cpp @@ -16,10 +16,12 @@ HTMLSlotElement::HTMLSlotElement(DOM::Document& document, DOM::QualifiedName qua HTMLSlotElement::~HTMLSlotElement() = default; -void HTMLSlotElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLSlotElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSlotElementPrototype>(realm, "HTMLSlotElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h index 9f7cc04950..3167f98f2a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSlotElement.h @@ -19,7 +19,7 @@ public: private: HTMLSlotElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp index 5031b6b25b..afb877a308 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.cpp @@ -16,10 +16,12 @@ HTMLSourceElement::HTMLSourceElement(DOM::Document& document, DOM::QualifiedName HTMLSourceElement::~HTMLSourceElement() = default; -void HTMLSourceElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLSourceElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSourceElementPrototype>(realm, "HTMLSourceElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h index 98c98a4e05..d3673f6a68 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSourceElement.h @@ -19,7 +19,7 @@ public: private: HTMLSourceElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp index dd5559e20c..db14bb9402 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.cpp @@ -16,10 +16,12 @@ HTMLSpanElement::HTMLSpanElement(DOM::Document& document, DOM::QualifiedName qua HTMLSpanElement::~HTMLSpanElement() = default; -void HTMLSpanElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLSpanElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLSpanElementPrototype>(realm, "HTMLSpanElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h index 493e2effe6..97d7e7f023 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSpanElement.h @@ -23,7 +23,7 @@ public: private: HTMLSpanElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp index cf42ecc56a..457e33c913 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.cpp @@ -18,10 +18,12 @@ HTMLStyleElement::HTMLStyleElement(DOM::Document& document, DOM::QualifiedName q HTMLStyleElement::~HTMLStyleElement() = default; -void HTMLStyleElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLStyleElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLStyleElementPrototype>(realm, "HTMLStyleElement")); + + return {}; } void HTMLStyleElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h index 522390128b..2b9d2e871c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLStyleElement.h @@ -29,7 +29,7 @@ public: private: HTMLStyleElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://www.w3.org/TR/cssom/#associated-css-style-sheet diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp index 25354fdb42..3b24428da8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp @@ -16,10 +16,12 @@ HTMLTableCaptionElement::HTMLTableCaptionElement(DOM::Document& document, DOM::Q HTMLTableCaptionElement::~HTMLTableCaptionElement() = default; -void HTMLTableCaptionElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableCaptionElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableCaptionElementPrototype>(realm, "HTMLTableCaptionElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/rendering.html#tables-2 diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h index 4de44131a4..e8e24d1e6c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h @@ -25,7 +25,7 @@ public: private: HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index dbfbe9b62e..1204a56f9c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -18,10 +18,12 @@ HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, DOM::Qualifi HTMLTableCellElement::~HTMLTableCellElement() = default; -void HTMLTableCellElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableCellElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableCellElementPrototype>(realm, "HTMLTableCellElement")); + + return {}; } void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h index b30c0900f0..b671a7e29b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.h @@ -27,7 +27,7 @@ public: private: HTMLTableCellElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp index 06e94dd8b6..35e8dab791 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.cpp @@ -16,10 +16,12 @@ HTMLTableColElement::HTMLTableColElement(DOM::Document& document, DOM::Qualified HTMLTableColElement::~HTMLTableColElement() = default; -void HTMLTableColElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableColElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableColElementPrototype>(realm, "HTMLTableColElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h index 6b4a0f1da9..4a69c978bd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableColElement.h @@ -19,7 +19,7 @@ public: private: HTMLTableColElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 821d0e684f..a6747dcd13 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -24,10 +24,12 @@ HTMLTableElement::HTMLTableElement(DOM::Document& document, DOM::QualifiedName q HTMLTableElement::~HTMLTableElement() = default; -void HTMLTableElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableElementPrototype>(realm, "HTMLTableElement")); + + return {}; } void HTMLTableElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h index 6f897b41d4..2120927207 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -48,7 +48,7 @@ public: private: HTMLTableElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index 16be11e4b2..db02190d93 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -22,10 +22,12 @@ HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, DOM::Qualified HTMLTableRowElement::~HTMLTableRowElement() = default; -void HTMLTableRowElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableRowElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableRowElementPrototype>(realm, "HTMLTableRowElement")); + + return {}; } void HTMLTableRowElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h index 9332f86d38..f5cf0b9320 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.h @@ -30,7 +30,7 @@ public: private: HTMLTableRowElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<DOM::HTMLCollection> mutable m_cells; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index 146a0197b8..5c469839c3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -21,10 +21,12 @@ HTMLTableSectionElement::HTMLTableSectionElement(DOM::Document& document, DOM::Q HTMLTableSectionElement::~HTMLTableSectionElement() = default; -void HTMLTableSectionElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTableSectionElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableSectionElementPrototype>(realm, "HTMLTableSectionElement")); + + return {}; } void HTMLTableSectionElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h index a09fb90123..a695de1f61 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h @@ -30,7 +30,7 @@ public: private: HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<DOM::HTMLCollection> mutable m_rows; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp index 9712909d70..47df82e552 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.cpp @@ -17,13 +17,15 @@ HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, DOM::Qualified HTMLTemplateElement::~HTMLTemplateElement() = default; -void HTMLTemplateElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTemplateElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTemplateElementPrototype>(realm, "HTMLTemplateElement")); m_content = heap().allocate<DOM::DocumentFragment>(realm, m_document->appropriate_template_contents_owner_document()); m_content->set_host(this); + + return {}; } void HTMLTemplateElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h index 2c22e19480..6a6a0a42bd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTemplateElement.h @@ -28,7 +28,7 @@ private: virtual bool is_html_template_element() const final { return true; } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<DOM::DocumentFragment> m_content; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index ac1443b100..3e49ad145d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -16,10 +16,12 @@ HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::Qualified HTMLTextAreaElement::~HTMLTextAreaElement() = default; -void HTMLTextAreaElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTextAreaElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTextAreaElementPrototype>(realm, "HTMLTextAreaElement")); + + return {}; } // https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h index e7e323cfa7..dccef8e876 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h @@ -57,7 +57,7 @@ public: private: HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; // ^DOM::Element virtual i32 default_tab_index_value() const override; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp index 77692b083d..d0a14e5909 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.cpp @@ -14,10 +14,12 @@ HTMLTimeElement::HTMLTimeElement(DOM::Document& document, DOM::QualifiedName qua { } -void HTMLTimeElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTimeElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTimeElementPrototype>(realm, "HTMLTimeElement")); + + return {}; } HTMLTimeElement::~HTMLTimeElement() = default; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h index f6e9fefc72..573faa6118 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTimeElement.h @@ -23,7 +23,7 @@ public: private: HTMLTimeElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index 998a4b5b24..94a663a01b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -17,10 +17,12 @@ HTMLTitleElement::HTMLTitleElement(DOM::Document& document, DOM::QualifiedName q HTMLTitleElement::~HTMLTitleElement() = default; -void HTMLTitleElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTitleElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTitleElementPrototype>(realm, "HTMLTitleElement")); + + return {}; } void HTMLTitleElement::children_changed() diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h index 545b24b6f3..e2dbccb9e7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.h @@ -19,7 +19,7 @@ public: private: HTMLTitleElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void children_changed() override; }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp index 286d94b73a..74796453bb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.cpp @@ -16,10 +16,12 @@ HTMLTrackElement::HTMLTrackElement(DOM::Document& document, DOM::QualifiedName q HTMLTrackElement::~HTMLTrackElement() = default; -void HTMLTrackElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLTrackElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTrackElementPrototype>(realm, "HTMLTrackElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h index 17be218974..804dcdd107 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTrackElement.h @@ -19,7 +19,7 @@ public: private: HTMLTrackElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp index 04e1fd451c..deb8651ac1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.cpp @@ -16,10 +16,12 @@ HTMLUListElement::HTMLUListElement(DOM::Document& document, DOM::QualifiedName q HTMLUListElement::~HTMLUListElement() = default; -void HTMLUListElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLUListElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLUListElementPrototype>(realm, "HTMLUListElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h index f1f4585ad4..52b5fa6c58 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLUListElement.h @@ -23,7 +23,7 @@ public: private: HTMLUListElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp index ae683a1b35..0b88dc1709 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.cpp @@ -16,10 +16,12 @@ HTMLUnknownElement::HTMLUnknownElement(DOM::Document& document, DOM::QualifiedNa HTMLUnknownElement::~HTMLUnknownElement() = default; -void HTMLUnknownElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLUnknownElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLUnknownElementPrototype>(realm, "HTMLUnknownElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h index 9e46892771..769bc6a7a3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLUnknownElement.h @@ -19,7 +19,7 @@ public: private: HTMLUnknownElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp index eea5bfd1d5..97d73d2aa1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.cpp @@ -16,10 +16,12 @@ HTMLVideoElement::HTMLVideoElement(DOM::Document& document, DOM::QualifiedName q HTMLVideoElement::~HTMLVideoElement() = default; -void HTMLVideoElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> HTMLVideoElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLVideoElementPrototype>(realm, "HTMLVideoElement")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h index 0d4470a583..41bb73e3de 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLVideoElement.h @@ -19,7 +19,7 @@ public: private: HTMLVideoElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 7034c04ea5..36817a6969 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -23,10 +23,12 @@ History::History(JS::Realm& realm, DOM::Document& document) History::~History() = default; -void History::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> History::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::HistoryPrototype>(realm, "History")); + + return {}; } void History::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index c20902b1fe..044d947adc 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -30,7 +30,7 @@ public: private: History(JS::Realm&, DOM::Document&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; enum class IsPush { diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.cpp b/Userland/Libraries/LibWeb/HTML/ImageData.cpp index 04ab5b549e..7b2df06eac 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Userland/Libraries/LibWeb/HTML/ImageData.cpp @@ -40,10 +40,12 @@ ImageData::ImageData(JS::Realm& realm, NonnullRefPtr<Gfx::Bitmap> bitmap, JS::No ImageData::~ImageData() = default; -void ImageData::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ImageData::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ImageDataPrototype>(realm, "ImageData")); + + return {}; } void ImageData::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/ImageData.h b/Userland/Libraries/LibWeb/HTML/ImageData.h index 86c25ce578..e3ffc55490 100644 --- a/Userland/Libraries/LibWeb/HTML/ImageData.h +++ b/Userland/Libraries/LibWeb/HTML/ImageData.h @@ -31,7 +31,7 @@ public: private: ImageData(JS::Realm&, NonnullRefPtr<Gfx::Bitmap>, JS::NonnullGCPtr<JS::Uint8ClampedArray>); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; NonnullRefPtr<Gfx::Bitmap> m_bitmap; diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp index 04714e5e52..d9d6ccaddb 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -35,9 +35,9 @@ void Location::visit_edges(Cell::Visitor& visitor) visitor.visit(property); } -void Location::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Location::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::LocationPrototype>(realm, "Location")); // FIXME: Implement steps 2.-4. @@ -45,6 +45,8 @@ void Location::initialize(JS::Realm& realm) // 5. Set the value of the [[DefaultProperties]] internal slot of location to location.[[OwnPropertyKeys]](). // NOTE: In LibWeb this happens before the ESO is set up, so we must avoid location's custom [[OwnPropertyKeys]]. m_default_properties.extend(MUST(Object::internal_own_property_keys())); + + return {}; } // https://html.spec.whatwg.org/multipage/history.html#relevant-document diff --git a/Userland/Libraries/LibWeb/HTML/Location.h b/Userland/Libraries/LibWeb/HTML/Location.h index a2f9fc48c9..0d79ea70c0 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.h +++ b/Userland/Libraries/LibWeb/HTML/Location.h @@ -68,7 +68,7 @@ public: private: explicit Location(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DOM::Document const* relevant_document() const; diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp index 069564c3e2..a027cb0f95 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.cpp @@ -38,10 +38,12 @@ void MessageChannel::visit_edges(Cell::Visitor& visitor) visitor.visit(m_port2.ptr()); } -void MessageChannel::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MessageChannel::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MessageChannelPrototype>(realm, "MessageChannel")); + + return {}; } MessagePort* MessageChannel::port1() diff --git a/Userland/Libraries/LibWeb/HTML/MessageChannel.h b/Userland/Libraries/LibWeb/HTML/MessageChannel.h index 1dfe15520c..ac472971cb 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageChannel.h +++ b/Userland/Libraries/LibWeb/HTML/MessageChannel.h @@ -28,7 +28,7 @@ public: private: explicit MessageChannel(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<MessagePort> m_port1; diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp index 910a94b5ae..455b84b8d1 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.cpp @@ -29,10 +29,12 @@ MessageEvent::MessageEvent(JS::Realm& realm, DeprecatedFlyString const& event_na MessageEvent::~MessageEvent() = default; -void MessageEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MessageEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MessageEventPrototype>(realm, "MessageEvent")); + + return {}; } void MessageEvent::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/MessageEvent.h b/Userland/Libraries/LibWeb/HTML/MessageEvent.h index 73cd28d29c..3a62c071aa 100644 --- a/Userland/Libraries/LibWeb/HTML/MessageEvent.h +++ b/Userland/Libraries/LibWeb/HTML/MessageEvent.h @@ -32,7 +32,7 @@ public: DeprecatedString const& last_event_id() const { return m_last_event_id; } private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::Value m_data; diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp index 52159660e0..65eb830882 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.cpp +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.cpp @@ -26,10 +26,12 @@ MessagePort::MessagePort(JS::Realm& realm) MessagePort::~MessagePort() = default; -void MessagePort::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MessagePort::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MessagePortPrototype>(realm, "MessagePort")); + + return {}; } void MessagePort::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/MessagePort.h b/Userland/Libraries/LibWeb/HTML/MessagePort.h index 84de2b7288..855aaf38b8 100644 --- a/Userland/Libraries/LibWeb/HTML/MessagePort.h +++ b/Userland/Libraries/LibWeb/HTML/MessagePort.h @@ -46,7 +46,7 @@ public: private: explicit MessagePort(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; bool is_entangled() const { return m_remote_port; } diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.cpp b/Userland/Libraries/LibWeb/HTML/Navigator.cpp index b53263418b..d862e63d45 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigator.cpp @@ -27,10 +27,12 @@ Navigator::Navigator(JS::Realm& realm) Navigator::~Navigator() = default; -void Navigator::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Navigator::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::NavigatorPrototype>(realm, "Navigator")); + + return {}; } // https://w3c.github.io/webdriver/#dfn-webdriver diff --git a/Userland/Libraries/LibWeb/HTML/Navigator.h b/Userland/Libraries/LibWeb/HTML/Navigator.h index a6447ed749..54026d53ae 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigator.h +++ b/Userland/Libraries/LibWeb/HTML/Navigator.h @@ -46,7 +46,7 @@ public: private: explicit Navigator(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp index 33393346db..7b46fb9a60 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp @@ -27,10 +27,12 @@ PageTransitionEvent::PageTransitionEvent(JS::Realm& realm, DeprecatedFlyString c PageTransitionEvent::~PageTransitionEvent() = default; -void PageTransitionEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> PageTransitionEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::PageTransitionEventPrototype>(realm, "PageTransitionEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h index 6409d141c8..ffee7bc592 100644 --- a/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PageTransitionEvent.h @@ -28,7 +28,7 @@ public: bool persisted() const { return m_persisted; } private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; bool m_persisted { false }; }; diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.cpp b/Userland/Libraries/LibWeb/HTML/Path2D.cpp index 3803c7f019..f4910ad59e 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/Path2D.cpp @@ -54,10 +54,12 @@ Path2D::Path2D(JS::Realm& realm, Optional<Variant<JS::Handle<Path2D>, Deprecated Path2D::~Path2D() = default; -void Path2D::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Path2D::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::Path2DPrototype>(realm, "Path2D")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/Path2D.h b/Userland/Libraries/LibWeb/HTML/Path2D.h index db3d781d09..2805a60c8f 100644 --- a/Userland/Libraries/LibWeb/HTML/Path2D.h +++ b/Userland/Libraries/LibWeb/HTML/Path2D.h @@ -28,7 +28,7 @@ public: private: Path2D(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, DeprecatedString>> const&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp index b27adcc40d..96faaab3a2 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp @@ -35,10 +35,12 @@ void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor) visitor.visit(m_reason); } -void PromiseRejectionEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> PromiseRejectionEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::PromiseRejectionEventPrototype>(realm, "PromiseRejectionEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h index 6b4f4e01ee..3cd0ef2f1c 100644 --- a/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h +++ b/Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.h @@ -35,7 +35,7 @@ public: private: PromiseRejectionEvent(JS::Realm&, DeprecatedFlyString const& event_name, PromiseRejectionEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::Promise* m_promise { nullptr }; diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index e826eb44b7..ca325205c8 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -22,10 +22,12 @@ Storage::Storage(JS::Realm& realm) Storage::~Storage() = default; -void Storage::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Storage::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::StoragePrototype>(realm, "Storage")); + + return {}; } // https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-length diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index 6b3323bc81..2fc749ee88 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -35,7 +35,7 @@ public: private: explicit Storage(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void reorder(); void broadcast(DeprecatedString const& key, DeprecatedString const& old_value, DeprecatedString const& new_value); diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp index ee1a535447..f25bdcbccc 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp @@ -27,10 +27,12 @@ SubmitEvent::SubmitEvent(JS::Realm& realm, DeprecatedFlyString const& event_name SubmitEvent::~SubmitEvent() = default; -void SubmitEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SubmitEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SubmitEventPrototype>(realm, "SubmitEvent")); + + return {}; } void SubmitEvent::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h index 51398d9a46..a7cece8c14 100644 --- a/Userland/Libraries/LibWeb/HTML/SubmitEvent.h +++ b/Userland/Libraries/LibWeb/HTML/SubmitEvent.h @@ -29,7 +29,7 @@ public: private: SubmitEvent(JS::Realm&, DeprecatedFlyString const& event_name, SubmitEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTMLElement> m_submitter; diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp index fda88cba77..acd6002399 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.cpp @@ -21,10 +21,12 @@ TextMetrics::TextMetrics(JS::Realm& realm) TextMetrics::~TextMetrics() = default; -void TextMetrics::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> TextMetrics::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::TextMetricsPrototype>(realm, "TextMetrics")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/TextMetrics.h b/Userland/Libraries/LibWeb/HTML/TextMetrics.h index 8c969a2545..47df236a57 100644 --- a/Userland/Libraries/LibWeb/HTML/TextMetrics.h +++ b/Userland/Libraries/LibWeb/HTML/TextMetrics.h @@ -47,7 +47,7 @@ public: private: explicit TextMetrics(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; double m_width { 0 }; double m_actual_bounding_box_left { 0 }; diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index cf5179dc6a..8581c58c47 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -30,10 +30,12 @@ Worker::Worker(DeprecatedFlyString const& script_url, WorkerOptions const option { } -void Worker::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Worker::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WorkerPrototype>(realm, "Worker")); + + return {}; } void Worker::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index 9650cd39ea..218a0b7383 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -68,7 +68,7 @@ private: return static_cast<Bindings::WebEngineCustomData*>(target_vm.custom_data())->event_loop; } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; DeprecatedFlyString m_script_url; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp index 24c01bab54..c7b8973c4f 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp @@ -30,10 +30,12 @@ WorkerGlobalScope::WorkerGlobalScope(JS::Realm& realm) WorkerGlobalScope::~WorkerGlobalScope() = default; -void WorkerGlobalScope::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WorkerGlobalScope::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); m_navigator = WorkerNavigator::create(*this); + + return {}; } void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index 9a1106cd32..c6bf3d6c1e 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -73,7 +73,7 @@ protected: explicit WorkerGlobalScope(JS::Realm&); private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp index 2585f260b4..0eadfd0fd8 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.cpp @@ -23,10 +23,12 @@ WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) WorkerNavigator::~WorkerNavigator() = default; -void WorkerNavigator::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WorkerNavigator::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WorkerNavigatorPrototype>(realm, "WorkerNavigator")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h index 54fdb2b263..d111884375 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerNavigator.h @@ -29,7 +29,7 @@ public: private: explicit WorkerNavigator(WorkerGlobalScope&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 633ab366d8..6cd4f31b68 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -22,10 +22,12 @@ Performance::Performance(HTML::Window& window) Performance::~Performance() = default; -void Performance::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Performance::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformancePrototype>(realm, "Performance")); + + return {}; } void Performance::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h index 817b8087c1..77acba9900 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.h @@ -25,7 +25,7 @@ public: private: explicit Performance(HTML::Window&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp index e14bf17609..1458414f92 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.cpp @@ -27,10 +27,12 @@ IntersectionObserver::IntersectionObserver(JS::Realm& realm) IntersectionObserver::~IntersectionObserver() = default; -void IntersectionObserver::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> IntersectionObserver::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::IntersectionObserverPrototype>(realm, "IntersectionObserver")); + + return {}; } // https://w3c.github.io/IntersectionObserver/#dom-intersectionobserver-observe diff --git a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h index 326385ed1e..cb10036bec 100644 --- a/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h +++ b/Userland/Libraries/LibWeb/IntersectionObserver/IntersectionObserver.h @@ -33,7 +33,7 @@ public: private: explicit IntersectionObserver(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp index a2d53b5ac9..efd2c964ec 100644 --- a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp +++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.cpp @@ -16,10 +16,12 @@ PerformanceTiming::PerformanceTiming(HTML::Window& window) PerformanceTiming::~PerformanceTiming() = default; -void PerformanceTiming::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> PerformanceTiming::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::PerformanceTimingPrototype>(realm, "PerformanceTiming")); + + return {}; } void PerformanceTiming::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h index fa711fb634..0c564dea3a 100644 --- a/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h +++ b/Userland/Libraries/LibWeb/NavigationTiming/PerformanceTiming.h @@ -43,7 +43,7 @@ public: private: explicit PerformanceTiming(HTML::Window&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index b0d6fb123d..0d79753c58 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -23,10 +23,12 @@ IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) { } -void IdleDeadline::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> IdleDeadline::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::IdleDeadlinePrototype>(realm, "IdleDeadline")); + + return {}; } IdleDeadline::~IdleDeadline() = default; diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h index d703a9c620..d977fffb97 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h @@ -24,7 +24,7 @@ public: private: IdleDeadline(JS::Realm&, bool did_timeout); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; bool m_did_timeout { false }; }; diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp index 0112c34fd6..4e6e692908 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp @@ -25,10 +25,12 @@ ResizeObserver::ResizeObserver(JS::Realm& realm) ResizeObserver::~ResizeObserver() = default; -void ResizeObserver::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ResizeObserver::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ResizeObserverPrototype>(realm, "ResizeObserver")); + + return {}; } // https://drafts.csswg.org/resize-observer/#dom-resizeobserver-observe diff --git a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h index a9cd4aa3cf..722e3b9e2e 100644 --- a/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h +++ b/Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h @@ -30,7 +30,7 @@ public: private: explicit ResizeObserver(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp index 124e2ed960..93e84234bc 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.cpp @@ -25,10 +25,12 @@ SVGAnimatedLength::SVGAnimatedLength(JS::Realm& realm, JS::NonnullGCPtr<SVGLengt SVGAnimatedLength::~SVGAnimatedLength() = default; -void SVGAnimatedLength::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGAnimatedLength::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGAnimatedLengthPrototype>(realm, "SVGAnimatedLength")); + + return {}; } void SVGAnimatedLength::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h index cb96977d03..e0517f08f7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAnimatedLength.h @@ -25,7 +25,7 @@ public: private: SVGAnimatedLength(JS::Realm&, JS::NonnullGCPtr<SVGLength> base_val, JS::NonnullGCPtr<SVGLength> anim_val); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<SVGLength> m_base_val; diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp index cb7ca7177b..68ae712ecf 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.cpp @@ -16,10 +16,12 @@ SVGCircleElement::SVGCircleElement(DOM::Document& document, DOM::QualifiedName q { } -void SVGCircleElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGCircleElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement")); + + return {}; } void SVGCircleElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h index 376002299c..d22c679aa2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGCircleElement.h @@ -28,7 +28,7 @@ public: private: SVGCircleElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp index 4ded39d8c9..be5ecfa64c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.cpp @@ -18,10 +18,12 @@ SVGClipPathElement::~SVGClipPathElement() { } -void SVGClipPathElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGClipPathElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGClipPathElementPrototype>(realm, "SVGClipPathElement")); + + return {}; } JS::GCPtr<Layout::Node> SVGClipPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>) diff --git a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h index e5d562eba6..c055bd9ae9 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h @@ -21,7 +21,7 @@ public: private: SVGClipPathElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp index 1403ed8380..0bf340706c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.cpp @@ -18,10 +18,12 @@ SVGDefsElement::~SVGDefsElement() { } -void SVGDefsElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGDefsElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGDefsElementPrototype>(realm, "SVGDefsElement")); + + return {}; } JS::GCPtr<Layout::Node> SVGDefsElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties>) diff --git a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h index a875239cca..700a9bde4c 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDefsElement.h @@ -21,7 +21,7 @@ public: private: SVGDefsElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp index 6fd8c1c605..4777cd33af 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.cpp @@ -16,10 +16,12 @@ SVGElement::SVGElement(DOM::Document& document, DOM::QualifiedName qualified_nam { } -void SVGElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGElementPrototype>(realm, "SVGElement")); + + return {}; } void SVGElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGElement.h index 5cfca6517f..7ffff6f812 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGElement.h @@ -22,7 +22,7 @@ public: protected: SVGElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::DOMStringMap> m_dataset; diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index d062616c6a..40399ae507 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -16,10 +16,12 @@ SVGEllipseElement::SVGEllipseElement(DOM::Document& document, DOM::QualifiedName { } -void SVGEllipseElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGEllipseElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement")); + + return {}; } void SVGEllipseElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h index 72e179896e..a05665c37e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGEllipseElement.h @@ -29,7 +29,7 @@ public: private: SVGEllipseElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index d2297e9730..40f100a221 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -21,9 +21,9 @@ SVGForeignObjectElement::SVGForeignObjectElement(DOM::Document& document, DOM::Q SVGForeignObjectElement::~SVGForeignObjectElement() = default; -void SVGForeignObjectElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGForeignObjectElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGForeignObjectElementPrototype>(realm, "SVGForeignObjectElement")); // FIXME: These never actually get updated! @@ -31,6 +31,8 @@ void SVGForeignObjectElement::initialize(JS::Realm& realm) m_y = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); m_width = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); m_height = SVGAnimatedLength::create(realm, SVGLength::create(realm, 0, 0), SVGLength::create(realm, 0, 0)); + + return {}; } void SVGForeignObjectElement::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h index 4c7b2f12f0..7dc94e1917 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.h @@ -27,7 +27,7 @@ public: private: SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual void apply_presentational_hints(CSS::StyleProperties&) const override; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index 6e3979d736..5af78482e8 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -15,10 +15,12 @@ SVGGeometryElement::SVGGeometryElement(DOM::Document& document, DOM::QualifiedNa { } -void SVGGeometryElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGGeometryElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGeometryElementPrototype>(realm, "SVGGeometryElement")); + + return {}; } JS::GCPtr<Layout::Node> SVGGeometryElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h index 3a32b82e1c..86a5573f6b 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -26,7 +26,7 @@ public: protected: SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 9714587c71..649d7bfdc6 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -18,10 +18,12 @@ SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, DOM::QualifiedNa { } -void SVGGraphicsElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGGraphicsElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement")); + + return {}; } void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style) const diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h index b62703ca94..e225a6526a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -27,7 +27,7 @@ public: protected: SVGGraphicsElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index ae53ce61e0..acd2e386fd 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -21,10 +21,12 @@ SVGLength::SVGLength(JS::Realm& realm, u8 unit_type, float value) { } -void SVGLength::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGLength::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLengthPrototype>(realm, "SVGLength")); + + return {}; } SVGLength::~SVGLength() = default; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.h b/Userland/Libraries/LibWeb/SVG/SVGLength.h index 02e129d748..400fb7ae41 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.h @@ -27,7 +27,7 @@ public: private: SVGLength(JS::Realm&, u8 unit_type, float value); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; u8 m_unit_type { 0 }; float m_value { 0 }; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp index 3e79cf16a9..7fb9e7ce63 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.cpp @@ -16,10 +16,12 @@ SVGLineElement::SVGLineElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGLineElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGLineElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement")); + + return {}; } void SVGLineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h index 01ed6b136c..e2865c1c1f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLineElement.h @@ -29,7 +29,7 @@ public: private: SVGLineElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp index 2e30643663..d542dc0ff7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -89,10 +89,12 @@ SVGPathElement::SVGPathElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGPathElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGPathElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement")); + + return {}; } void SVGPathElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h index 93b06bb340..ab1df776c3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPathElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPathElement.h @@ -26,7 +26,7 @@ public: private: SVGPathElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Vector<PathInstruction> m_instructions; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp index a17630bae6..0602454970 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.cpp @@ -16,10 +16,12 @@ SVGPolygonElement::SVGPolygonElement(DOM::Document& document, DOM::QualifiedName { } -void SVGPolygonElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGPolygonElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement")); + + return {}; } void SVGPolygonElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h index 021392c743..3a3c7f8dba 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolygonElement.h @@ -23,7 +23,7 @@ public: private: SVGPolygonElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp index 5275fcd606..83ccb98e27 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.cpp @@ -16,10 +16,12 @@ SVGPolylineElement::SVGPolylineElement(DOM::Document& document, DOM::QualifiedNa { } -void SVGPolylineElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGPolylineElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement")); + + return {}; } void SVGPolylineElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h index 8ad2a9da82..c21121f3cb 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGPolylineElement.h @@ -23,7 +23,7 @@ public: private: SVGPolylineElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Optional<Gfx::Path> m_path; diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp index c14c1be515..e6ac9adab7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -18,10 +18,12 @@ SVGRectElement::SVGRectElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGRectElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGRectElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement")); + + return {}; } void SVGRectElement::parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) diff --git a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h index eea648ae1d..aca0ce65dd 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGRectElement.h @@ -31,7 +31,7 @@ public: private: SVGRectElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; Gfx::FloatPoint calculate_used_corner_radius_values(); diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index cf1caff20a..621c084c38 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -22,10 +22,12 @@ SVGSVGElement::SVGSVGElement(DOM::Document& document, DOM::QualifiedName qualifi { } -void SVGSVGElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGSVGElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGSVGElementPrototype>(realm, "SVGSVGElement")); + + return {}; } JS::GCPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h index 7834df2154..7f03fda104 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.h @@ -28,7 +28,7 @@ public: private: SVGSVGElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual bool is_svg_svg_element() const override { return true; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp index 1cb956395f..df66953ebc 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.cpp @@ -17,10 +17,12 @@ SVGTextContentElement::SVGTextContentElement(DOM::Document& document, DOM::Quali { } -void SVGTextContentElement::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> SVGTextContentElement::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextContentElementPrototype>(realm, "SVGTextContentElement")); + + return {}; } // https://svgwg.org/svg2-draft/text.html#__svg__SVGTextContentElement__getNumberOfChars diff --git a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h index 719ee102f3..1f68e6d7f5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGTextContentElement.h @@ -21,7 +21,7 @@ public: protected: SVGTextContentElement(DOM::Document&, DOM::QualifiedName); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 72aa62b0e6..2d7695d6b4 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -24,10 +24,12 @@ Selection::Selection(JS::NonnullGCPtr<JS::Realm> realm, JS::NonnullGCPtr<DOM::Do Selection::~Selection() = default; -void Selection::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> Selection::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::SelectionPrototype>(realm, "Selection")); + + return {}; } // https://w3c.github.io/selection-api/#dfn-empty diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h index 581336e39b..e1dc383343 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.h +++ b/Userland/Libraries/LibWeb/Selection/Selection.h @@ -61,7 +61,7 @@ private: [[nodiscard]] bool is_empty() const; - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; void set_range(JS::GCPtr<DOM::Range>); diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index ae898e4c5b..9da7c0cd84 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -24,10 +24,12 @@ ReadableStream::ReadableStream(JS::Realm& realm) ReadableStream::~ReadableStream() = default; -void ReadableStream::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ReadableStream::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ReadableStreamPrototype>(realm, "ReadableStream")); + + return {}; } void ReadableStream::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.h b/Userland/Libraries/LibWeb/Streams/ReadableStream.h index f8db6d1c56..b0d351d93c 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.h +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.h @@ -41,7 +41,7 @@ public: private: explicit ReadableStream(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; // https://streams.spec.whatwg.org/#readablestream-controller diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp index 3799d472eb..10e05fb181 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.cpp @@ -22,10 +22,12 @@ FocusEvent::FocusEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, FocusEvent::~FocusEvent() = default; -void FocusEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> FocusEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::FocusEventPrototype>(realm, "FocusEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h index f11b84918b..1ef560ca9a 100644 --- a/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/FocusEvent.h @@ -25,7 +25,7 @@ public: private: FocusEvent(JS::Realm&, DeprecatedFlyString const& event_name, FocusEventInit const&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; }; } diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp index 7bc89ddbb6..37b0f642cb 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.cpp @@ -132,10 +132,12 @@ KeyboardEvent::KeyboardEvent(JS::Realm& realm, DeprecatedFlyString const& event_ KeyboardEvent::~KeyboardEvent() = default; -void KeyboardEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> KeyboardEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::KeyboardEventPrototype>(realm, "KeyboardEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h index 0ce603b9e5..6b355792a2 100644 --- a/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/KeyboardEvent.h @@ -56,7 +56,7 @@ public: private: KeyboardEvent(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_key; DeprecatedString m_code; diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp index 2c4138f4fd..0f9a593841 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.cpp @@ -29,10 +29,12 @@ MouseEvent::MouseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, MouseEvent::~MouseEvent() = default; -void MouseEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> MouseEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::MouseEventPrototype>(realm, "MouseEvent")); + + return {}; } // https://www.w3.org/TR/uievents/#dom-mouseevent-button diff --git a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h index 03d0f1b8bd..839e01a37b 100644 --- a/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h @@ -58,7 +58,7 @@ public: protected: MouseEvent(JS::Realm&, DeprecatedFlyString const& event_name, MouseEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: void set_event_characteristics(); diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp index e5781a8422..06bbf93b0d 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.cpp @@ -33,10 +33,12 @@ UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEven UIEvent::~UIEvent() = default; -void UIEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> UIEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::UIEventPrototype>(realm, "UIEvent")); + + return {}; } void UIEvent::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h index 97e7b1cd84..cf7ff0c106 100644 --- a/Userland/Libraries/LibWeb/UIEvents/UIEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/UIEvent.h @@ -41,7 +41,7 @@ protected: UIEvent(JS::Realm&, DeprecatedFlyString const& event_name); UIEvent(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::GCPtr<HTML::Window> m_view; diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp index 46152ce8dd..5001070427 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.cpp @@ -22,10 +22,12 @@ WheelEvent::WheelEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEvent::~WheelEvent() = default; -void WheelEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WheelEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WheelEventPrototype>(realm, "WheelEvent")); + + return {}; } WheelEvent* WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init) diff --git a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h index 43a3c80f61..30d62ff020 100644 --- a/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h +++ b/Userland/Libraries/LibWeb/UIEvents/WheelEvent.h @@ -42,7 +42,7 @@ public: private: WheelEvent(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; void set_event_characteristics(); diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 49cfc3f906..5aefd55fa3 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -61,10 +61,12 @@ URL::URL(JS::Realm& realm, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query) URL::~URL() = default; -void URL::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> URL::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::URLPrototype>(realm, "URL")); + + return {}; } void URL::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index d691f0ec08..389241b24b 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -65,7 +65,7 @@ public: private: URL(JS::Realm&, AK::URL, JS::NonnullGCPtr<URLSearchParams> query); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; AK::URL m_url; diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index ddf08690a6..c31e068ae5 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -21,10 +21,12 @@ URLSearchParams::URLSearchParams(JS::Realm& realm, Vector<QueryParam> list) URLSearchParams::~URLSearchParams() = default; -void URLSearchParams::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> URLSearchParams::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::URLSearchParamsPrototype>(realm, "URLSearchParams")); + + return {}; } void URLSearchParams::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index 9456c83030..afe56d02d4 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -48,7 +48,7 @@ private: URLSearchParams(JS::Realm&, Vector<QueryParam> list); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; void update(); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp index 66ebc57ee9..2ac44893fe 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.cpp @@ -37,10 +37,12 @@ URLSearchParamsIterator::URLSearchParamsIterator(URLSearchParams const& url_sear URLSearchParamsIterator::~URLSearchParamsIterator() = default; -void URLSearchParamsIterator::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> URLSearchParamsIterator::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::URLSearchParamsIteratorPrototype>(realm, "URLSearchParamsIterator")); + + return {}; } void URLSearchParamsIterator::visit_edges(JS::Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h index 7a2714d22a..324c55253b 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParamsIterator.h @@ -24,7 +24,7 @@ public: private: URLSearchParamsIterator(URLSearchParams const&, JS::Object::PropertyKind iteration_kind); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; URLSearchParams const& m_url_search_params; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp index d5ce97272e..373b5425d5 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.cpp @@ -39,13 +39,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyInstanceConstruct return heap().allocate<WebAssemblyInstanceObject>(realm, realm, result); } -void WebAssemblyInstanceConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyInstanceConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyInstancePrototype>(realm, "WebAssembly.Instance"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h index 52c2849a9d..e5b7341110 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyInstanceConstructor : public JS::NativeFunction { public: explicit WebAssemblyInstanceConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyInstanceConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp index f32989e89d..66782bc1d5 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.cpp @@ -24,9 +24,9 @@ WebAssemblyInstanceObject::WebAssemblyInstanceObject(JS::Realm& realm, size_t in { } -void WebAssemblyInstanceObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyInstanceObject::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); auto& vm = this->vm(); @@ -66,6 +66,8 @@ void WebAssemblyInstanceObject::initialize(JS::Realm& realm) } MUST(m_exports_object->set_integrity_level(IntegrityLevel::Frozen)); + + return {}; } void WebAssemblyInstanceObject::visit_edges(Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h index d39b3dd8bb..f6a05660e6 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObject.h @@ -20,7 +20,7 @@ class WebAssemblyInstanceObject final : public JS::Object { public: explicit WebAssemblyInstanceObject(JS::Realm&, size_t index); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyInstanceObject() override = default; size_t index() const { return m_index; } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp index 8f19145e58..bc322e7a24 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.cpp @@ -10,10 +10,12 @@ namespace Web::Bindings { -void WebAssemblyInstancePrototype::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyInstancePrototype::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); define_native_accessor(realm, "exports", exports_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); + + return {}; } JS_DEFINE_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h index 76606d3295..19b9b3eb01 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyInstanceObjectPrototype.h @@ -22,7 +22,7 @@ public: { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(exports_getter); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp index 30ebd209a5..69d111b9a6 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.cpp @@ -49,13 +49,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyMemoryConstructor return vm.heap().allocate<WebAssemblyMemoryObject>(realm, realm, *address); } -void WebAssemblyMemoryConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyMemoryConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyMemoryPrototype>(realm, "WebAssembly.Memory"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h index 4fa79fd3cb..ec9c6f2559 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyMemoryConstructor : public JS::NativeFunction { public: explicit WebAssemblyMemoryConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyMemoryConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp index 854852f096..daf80668c3 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.cpp @@ -11,11 +11,13 @@ namespace Web::Bindings { -void WebAssemblyMemoryPrototype::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyMemoryPrototype::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); define_native_accessor(realm, "buffer", buffer_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function(realm, "grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); + + return {}; } JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h index 927758bd68..7cdc717faf 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyMemoryPrototype.h @@ -22,7 +22,7 @@ public: { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(grow); diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp index 1a0ed6802d..b859445833 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.cpp @@ -36,13 +36,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyModuleConstructor return heap().allocate<WebAssemblyModuleObject>(realm, realm, result); } -void WebAssemblyModuleConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyModuleConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyModulePrototype>(realm, "WebAssembly.Module"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h index 54a2a3d4b1..cfdfe0412f 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyModuleConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyModuleConstructor : public JS::NativeFunction { public: explicit WebAssemblyModuleConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyModuleConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp index 6e3858fddd..d7d1bd37cf 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.cpp @@ -32,9 +32,9 @@ WebAssemblyObject::WebAssemblyObject(JS::Realm& realm) s_abstract_machine.enable_instruction_count_limit(); } -void WebAssemblyObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyObject::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function(realm, "validate", validate, 1, attr); @@ -52,6 +52,8 @@ void WebAssemblyObject::initialize(JS::Realm& realm) auto& table_constructor = Bindings::ensure_web_constructor<WebAssemblyTablePrototype>(realm, "WebAssembly.Table"sv); define_direct_property("Table", &table_constructor, JS::Attribute::Writable | JS::Attribute::Configurable); + + return {}; } NonnullOwnPtrVector<WebAssemblyObject::CompiledWebAssemblyModule> WebAssemblyObject::s_compiled_modules; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h index 174b06956a..c3c2f23a32 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyObject.h @@ -25,7 +25,7 @@ class WebAssemblyObject final : public JS::Object { public: explicit WebAssemblyObject(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyObject() override = default; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp index 15b50e9d65..bc9717ff95 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.cpp @@ -80,13 +80,15 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> WebAssemblyTableConstructor: return vm.heap().allocate<WebAssemblyTableObject>(realm, realm, *address); } -void WebAssemblyTableConstructor::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyTableConstructor::initialize(JS::Realm& realm) { auto& vm = this->vm(); - NativeFunction::initialize(realm); + MUST_OR_THROW_OOM(NativeFunction::initialize(realm)); define_direct_property(vm.names.prototype, &Bindings::ensure_web_prototype<WebAssemblyTablePrototype>(realm, "WebAssembly.Table"), 0); define_direct_property(vm.names.length, JS::Value(1), JS::Attribute::Configurable); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h index 3896baee24..1d054bc982 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTableConstructor.h @@ -15,7 +15,7 @@ class WebAssemblyTableConstructor : public JS::NativeFunction { public: explicit WebAssemblyTableConstructor(JS::Realm&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~WebAssemblyTableConstructor() override; virtual JS::ThrowCompletionOr<JS::Value> call() override; diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp index 3b570891e3..3309a1f7f7 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.cpp @@ -11,13 +11,15 @@ namespace Web::Bindings { -void WebAssemblyTablePrototype::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebAssemblyTablePrototype::initialize(JS::Realm& realm) { - Object::initialize(realm); + MUST_OR_THROW_OOM(Object::initialize(realm)); define_native_accessor(realm, "length", length_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function(realm, "grow", grow, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function(realm, "get", get, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); define_native_function(realm, "set", set, 1, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable); + + return {}; } JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::grow) diff --git a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h index 09e29be2b0..cda4c7fce9 100644 --- a/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h +++ b/Userland/Libraries/LibWeb/WebAssembly/WebAssemblyTablePrototype.h @@ -22,7 +22,7 @@ public: { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: JS_DECLARE_NATIVE_FUNCTION(grow); diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp index 54d850fc61..92f913e016 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp @@ -27,10 +27,12 @@ WebGLContextEvent::WebGLContextEvent(JS::Realm& realm, DeprecatedFlyString const WebGLContextEvent::~WebGLContextEvent() = default; -void WebGLContextEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebGLContextEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WebGLContextEventPrototype>(realm, "WebGLContextEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h index a42fb8f224..08f3f67676 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h +++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h @@ -29,7 +29,7 @@ public: private: WebGLContextEvent(JS::Realm&, DeprecatedFlyString const& type, WebGLContextEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; DeprecatedString m_status_message { DeprecatedString::empty() }; }; diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp index 44d7fb1bd3..9c9d4fe731 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp @@ -56,10 +56,12 @@ WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasE WebGLRenderingContext::~WebGLRenderingContext() = default; -void WebGLRenderingContext::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebGLRenderingContext::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WebGLRenderingContextPrototype>(realm, "WebGLRenderingContext")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h index b31a6742ee..6eba5402a4 100644 --- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h +++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h @@ -21,7 +21,7 @@ public: virtual ~WebGLRenderingContext() override; private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; WebGLRenderingContext(JS::Realm&, HTML::HTMLCanvasElement&, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters); }; diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp index baaeac3a3f..ccbcdbfaf0 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -28,10 +28,12 @@ DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, De DOMException::~DOMException() = default; -void DOMException::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> DOMException::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::DOMExceptionPrototype>(realm, "DOMException")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.h b/Userland/Libraries/LibWeb/WebIDL/DOMException.h index 2e92283d94..0c9c48a573 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.h +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.h @@ -109,7 +109,7 @@ public: protected: DOMException(JS::Realm&, DeprecatedFlyString const& name, DeprecatedFlyString const& message); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; private: DeprecatedFlyString m_name; diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index c9f1284666..84e2eac861 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -95,10 +95,12 @@ WebSocket::WebSocket(HTML::Window& window, AK::URL& url) WebSocket::~WebSocket() = default; -void WebSocket::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> WebSocket::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::WebSocketPrototype>(realm, "WebSocket")); + + return {}; } void WebSocket::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index 59e8738945..96b6fb55ea 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -68,7 +68,7 @@ private: WebSocket(HTML::Window&, AK::URL&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr<HTML::Window> m_window; diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp index f8332a2556..ccc3e52ec0 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.cpp @@ -29,10 +29,12 @@ ProgressEvent::ProgressEvent(JS::Realm& realm, DeprecatedFlyString const& event_ ProgressEvent::~ProgressEvent() = default; -void ProgressEvent::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ProgressEvent::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::ProgressEventPrototype>(realm, "ProgressEvent")); + + return {}; } } diff --git a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h index abc7305fa9..47f0b353ee 100644 --- a/Userland/Libraries/LibWeb/XHR/ProgressEvent.h +++ b/Userland/Libraries/LibWeb/XHR/ProgressEvent.h @@ -35,7 +35,7 @@ public: private: ProgressEvent(JS::Realm&, DeprecatedFlyString const& event_name, ProgressEventInit const& event_init); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; bool m_length_computable { false }; u64 m_loaded { 0 }; diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index eda2f78fbe..d9dac15961 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -59,10 +59,12 @@ XMLHttpRequest::XMLHttpRequest(HTML::Window& window, Fetch::Infrastructure::Head XMLHttpRequest::~XMLHttpRequest() = default; -void XMLHttpRequest::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> XMLHttpRequest::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); set_prototype(&Bindings::ensure_web_prototype<Bindings::XMLHttpRequestPrototype>(realm, "XMLHttpRequest")); + + return {}; } void XMLHttpRequest::visit_edges(Cell::Visitor& visitor) diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index ca29cede33..396c2cfd59 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -72,7 +72,7 @@ public: void abort(); private: - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; virtual bool must_survive_garbage_collection() const override; diff --git a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp index e9c1e63a8f..33a82dbc8c 100644 --- a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.cpp @@ -21,14 +21,16 @@ ConsoleGlobalEnvironmentExtensions::ConsoleGlobalEnvironmentExtensions(JS::Realm { } -void ConsoleGlobalEnvironmentExtensions::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ConsoleGlobalEnvironmentExtensions::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_native_accessor(realm, "$0", $0_getter, nullptr, 0); define_native_accessor(realm, "$_", $__getter, nullptr, 0); define_native_function(realm, "$", $_function, 2, JS::default_attributes); define_native_function(realm, "$$", $$_function, 2, JS::default_attributes); + + return {}; } void ConsoleGlobalEnvironmentExtensions::visit_edges(Visitor& visitor) diff --git a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h index 476000ad85..fc9d5e74b9 100644 --- a/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h +++ b/Userland/Services/WebContent/ConsoleGlobalEnvironmentExtensions.h @@ -18,7 +18,7 @@ class ConsoleGlobalEnvironmentExtensions final : public JS::Object { public: ConsoleGlobalEnvironmentExtensions(JS::Realm&, Web::HTML::Window&); - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~ConsoleGlobalEnvironmentExtensions() override = default; void set_most_recent_result(JS::Value result) { m_most_recent_result = move(result); } diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 1a358fcad1..c0f1c86607 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -42,7 +42,7 @@ public: : GlobalObject(realm) { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~ReplObject() override = default; private: @@ -63,7 +63,7 @@ public: : JS::GlobalObject(realm) { } - virtual void initialize(JS::Realm&) override; + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual ~ScriptObject() override = default; private: @@ -381,9 +381,9 @@ static JS::ThrowCompletionOr<JS::Value> load_json_impl(JS::VM& vm) return JS::JSONObject::parse_json_value(vm, json.value()); } -void ReplObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ReplObject::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property("global", this, JS::Attribute::Enumerable); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; @@ -413,6 +413,8 @@ void ReplObject::initialize(JS::Realm& realm) return value; }, attr); + + return {}; } JS_DEFINE_NATIVE_FUNCTION(ReplObject::save_to_file) @@ -466,15 +468,17 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::print) return JS::js_undefined(); } -void ScriptObject::initialize(JS::Realm& realm) +JS::ThrowCompletionOr<void> ScriptObject::initialize(JS::Realm& realm) { - Base::initialize(realm); + MUST_OR_THROW_OOM(Base::initialize(realm)); define_direct_property("global", this, JS::Attribute::Enumerable); u8 attr = JS::Attribute::Configurable | JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_function(realm, "loadINI", load_ini, 1, attr); define_native_function(realm, "loadJSON", load_json, 1, attr); define_native_function(realm, "print", print, 1, attr); + + return {}; } JS_DEFINE_NATIVE_FUNCTION(ScriptObject::load_ini) |