Bindings: Remove exception handling for named_item_value

This commit is contained in:
Shannon Booth 2024-07-25 17:36:10 +12:00 committed by Andreas Kling
parent 081c92bf3d
commit 9b59dc5e8b
Notes: github-actions[bot] 2024-07-26 12:27:24 +00:00
27 changed files with 29 additions and 32 deletions

View file

@ -3015,7 +3015,6 @@ void @named_properties_class@::initialize(JS::Realm& realm)
// https://webidl.spec.whatwg.org/#named-properties-object-getownproperty
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> @named_properties_class@::internal_get_own_property(JS::PropertyKey const& property_name) const
{
auto& vm = this->vm();
auto& realm = this->realm();
// 1. Let A be the interface for the named properties object O.
@ -3033,7 +3032,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> @named_properties_class@
// 2. Let value be an uninitialized variable.
// 3. If operation was defined without an identifier, then set value to the result of performing the steps listed in the interface description to determine the value of a named property with P as the name.
// 4. Otherwise, operation was defined with an identifier. Set value to the result of performing the method steps of operation with « P » as the only argument value.
auto value = TRY(throw_dom_exception_if_needed(vm, [&] { return object.named_item_value(property_name_string); }));
auto value = object.named_item_value(property_name_string);
// 5. Let desc be a newly created Property Descriptor with no fields.
JS::PropertyDescriptor descriptor;

View file

@ -85,8 +85,6 @@ JS::ThrowCompletionOr<bool> PlatformObject::is_named_property_exposed_on_object(
// https://webidl.spec.whatwg.org/#PlatformObjectGetOwnProperty
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> PlatformObject::legacy_platform_object_get_own_property(JS::PropertyKey const& property_name, IgnoreNamedProps ignore_named_props) const
{
auto& vm = this->vm();
// 1. If O supports indexed properties and P is an array index, then:
if (m_legacy_platform_object_flags->supports_indexed_properties && property_name.is_number()) {
// 1. Let index be the result of calling ToUint32(P).
@ -98,7 +96,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> PlatformObject::legacy_p
// 2. Let value be an uninitialized variable.
// 3. If operation was defined without an identifier, then set value to the result of performing the steps listed in the interface description to determine the value of an indexed property with index as the index.
// 4. Otherwise, operation was defined with an identifier. Set value to the result of performing the method steps of operation with O as this and « index » as the argument values.
auto value item_value(index);
auto value = item_value(index);
// 5. Let desc be a newly created Property Descriptor with no fields.
JS::PropertyDescriptor descriptor;
@ -132,7 +130,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> PlatformObject::legacy_p
// 2. Let value be an uninitialized variable.
// 3. If operation was defined without an identifier, then set value to the result of performing the steps listed in the interface description to determine the value of a named property with P as the name.
// 4. Otherwise, operation was defined with an identifier. Set value to the result of performing the method steps of operation with O as this and « P » as the argument values.
auto value = TRY(throw_dom_exception_if_needed(vm, [&] { return named_item_value(property_name_string); }));
auto value = named_item_value(property_name_string);
// 5. Let desc be a newly created Property Descriptor with no fields.
JS::PropertyDescriptor descriptor;
@ -488,7 +486,7 @@ JS::Value PlatformObject::item_value(size_t) const
return JS::js_undefined();
}
WebIDL::ExceptionOr<JS::Value> PlatformObject::named_item_value(FlyString const&) const
JS::Value PlatformObject::named_item_value(FlyString const&) const
{
return JS::js_undefined();
}

View file

@ -73,7 +73,7 @@ protected:
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> legacy_platform_object_get_own_property(JS::PropertyKey const&, IgnoreNamedProps ignore_named_props) const;
virtual JS::Value item_value(size_t index) const;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const;
virtual JS::Value named_item_value(FlyString const& name) const;
virtual Vector<FlyString> supported_property_names() const;
virtual bool is_supported_property_name(FlyString const&) const;
virtual bool is_supported_property_index(u32) const;

View file

@ -4837,7 +4837,7 @@ static Vector<JS::NonnullGCPtr<DOM::Element>> named_elements_with_name(Document
}
// https://html.spec.whatwg.org/multipage/dom.html#dom-document-nameditem
WebIDL::ExceptionOr<JS::Value> Document::named_item_value(FlyString const& name) const
JS::Value Document::named_item_value(FlyString const& name) const
{
// 1. Let elements be the list of named elements with the name name that are in a document tree with the Document as their root.
// NOTE: There will be at least one such element, since the algorithm would otherwise not have been invoked by Web IDL.

View file

@ -646,7 +646,7 @@ public:
void set_needs_to_resolve_paint_only_properties() { m_needs_to_resolve_paint_only_properties = true; }
void set_needs_animated_style_update() { m_needs_animated_style_update = true; }
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual Vector<FlyString> supported_property_names() const override;
Vector<JS::NonnullGCPtr<DOM::Element>> const& potentially_named_elements() const { return m_potentially_named_elements; }

View file

@ -177,7 +177,7 @@ JS::Value HTMLCollection::item_value(size_t index) const
return element;
}
WebIDL::ExceptionOr<JS::Value> HTMLCollection::named_item_value(FlyString const& name) const
JS::Value HTMLCollection::named_item_value(FlyString const& name) const
{
auto* element = named_item(name);
if (!element)

View file

@ -41,7 +41,7 @@ public:
JS::MarkedVector<JS::NonnullGCPtr<Element>> collect_matching_elements() const;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual Vector<FlyString> supported_property_names() const override;
virtual bool is_supported_property_name(FlyString const&) const override;
virtual bool is_supported_property_index(u32) const override;

View file

@ -76,7 +76,7 @@ Variant<Empty, Element*, JS::Handle<RadioNodeList>> HTMLFormControlsCollection::
}));
}
WebIDL::ExceptionOr<JS::Value> HTMLFormControlsCollection::named_item_value(FlyString const& name) const
JS::Value HTMLFormControlsCollection::named_item_value(FlyString const& name) const
{
return named_item_or_radio_node_list(name).visit(
[](Empty) -> JS::Value { return JS::js_undefined(); },

View file

@ -25,7 +25,7 @@ public:
protected:
virtual void initialize(JS::Realm&) override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const final;
virtual JS::Value named_item_value(FlyString const& name) const final;
private:
HTMLFormControlsCollection(ParentNode& root, Scope, ESCAPING Function<bool(Element const&)> filter);

View file

@ -334,7 +334,7 @@ JS::Value NamedNodeMap::item_value(size_t index) const
return node;
}
WebIDL::ExceptionOr<JS::Value> NamedNodeMap::named_item_value(FlyString const& name) const
JS::Value NamedNodeMap::named_item_value(FlyString const& name) const
{
auto const* node = get_named_item(name);
if (!node)

View file

@ -27,7 +27,7 @@ public:
virtual bool is_supported_property_index(u32 index) const override;
virtual Vector<FlyString> supported_property_names() const override;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
size_t length() const { return m_attributes.size(); }
bool is_empty() const { return m_attributes.is_empty(); }

View file

@ -204,7 +204,7 @@ WebIDL::ExceptionOr<Bindings::PlatformObject::DidDeletionFail> DOMStringMap::del
return DidDeletionFail::No;
}
WebIDL::ExceptionOr<JS::Value> DOMStringMap::named_item_value(FlyString const& name) const
JS::Value DOMStringMap::named_item_value(FlyString const& name) const
{
return JS::PrimitiveString::create(vm(), determine_value_of_named_property(name));
}

View file

@ -36,7 +36,7 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
// ^PlatformObject
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
virtual JS::Value named_item_value(FlyString const&) const override;
virtual Vector<FlyString> supported_property_names() const override;
struct NameValuePair {

View file

@ -224,7 +224,7 @@ JS::Value HTMLAllCollection::item_value(size_t index) const
return get_the_all_indexed_element(index);
}
WebIDL::ExceptionOr<JS::Value> HTMLAllCollection::named_item_value(FlyString const& name) const
JS::Value HTMLAllCollection::named_item_value(FlyString const& name) const
{
return named_item(name).visit(
[](Empty) -> JS::Value { return JS::js_undefined(); },

View file

@ -35,7 +35,7 @@ public:
JS::MarkedVector<JS::NonnullGCPtr<DOM::Element>> collect_matching_elements() const;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual Vector<FlyString> supported_property_names() const override;
virtual bool is_supported_property_index(u32) const override;

View file

@ -1036,7 +1036,7 @@ Vector<FlyString> HTMLFormElement::supported_property_names() const
}
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-nameditem
WebIDL::ExceptionOr<JS::Value> HTMLFormElement::named_item_value(FlyString const& name) const
JS::Value HTMLFormElement::named_item_value(FlyString const& name) const
{
auto& realm = this->realm();
auto& root = verify_cast<ParentNode>(this->root());

View file

@ -107,7 +107,7 @@ private:
// ^PlatformObject
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual Vector<FlyString> supported_property_names() const override;
virtual bool is_supported_property_index(u32) const override;

View file

@ -105,7 +105,7 @@ JS::Value MimeTypeArray::item_value(size_t index) const
return return_value.ptr();
}
WebIDL::ExceptionOr<JS::Value> MimeTypeArray::named_item_value(FlyString const& name) const
JS::Value MimeTypeArray::named_item_value(FlyString const& name) const
{
auto return_value = named_item(name);
if (!return_value)

View file

@ -30,7 +30,7 @@ private:
// ^Bindings::PlatformObject
virtual Vector<FlyString> supported_property_names() const override;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual bool is_supported_property_index(u32) const override;
};

View file

@ -128,7 +128,7 @@ JS::Value Plugin::item_value(size_t index) const
return return_value.ptr();
}
WebIDL::ExceptionOr<JS::Value> Plugin::named_item_value(FlyString const& name) const
JS::Value Plugin::named_item_value(FlyString const& name) const
{
auto return_value = named_item(name);
if (!return_value)

View file

@ -36,7 +36,7 @@ private:
// ^Bindings::PlatformObject
virtual Vector<FlyString> supported_property_names() const override;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual bool is_supported_property_index(u32) const override;
};

View file

@ -114,7 +114,7 @@ JS::Value PluginArray::item_value(size_t index) const
return return_value.ptr();
}
WebIDL::ExceptionOr<JS::Value> PluginArray::named_item_value(FlyString const& name) const
JS::Value PluginArray::named_item_value(FlyString const& name) const
{
auto return_value = named_item(name);
if (!return_value)

View file

@ -31,7 +31,7 @@ private:
// ^Bindings::PlatformObject
virtual Vector<FlyString> supported_property_names() const override;
virtual JS::Value item_value(size_t index) const override;
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const& name) const override;
virtual JS::Value named_item_value(FlyString const& name) const override;
virtual bool is_supported_property_index(u32) const override;
};

View file

@ -168,7 +168,7 @@ Vector<FlyString> Storage::supported_property_names() const
return names;
}
WebIDL::ExceptionOr<JS::Value> Storage::named_item_value(FlyString const& name) const
JS::Value Storage::named_item_value(FlyString const& name) const
{
auto value = get_item(name);
if (!value.has_value())

View file

@ -38,7 +38,7 @@ private:
virtual void initialize(JS::Realm&) override;
// ^PlatformObject
virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
virtual JS::Value named_item_value(FlyString const&) const override;
virtual WebIDL::ExceptionOr<DidDeletionFail> delete_value(String const&) override;
virtual Vector<FlyString> supported_property_names() const override;
virtual WebIDL::ExceptionOr<void> set_value_of_named_property(String const& key, JS::Value value) override;

View file

@ -1635,7 +1635,7 @@ Vector<FlyString> Window::supported_property_names() const
}
// https://html.spec.whatwg.org/#named-access-on-the-window-object
WebIDL::ExceptionOr<JS::Value> Window::named_item_value(FlyString const& name) const
JS::Value Window::named_item_value(FlyString const& name) const
{
// FIXME: Make the const-correctness of the methods this method calls less cowboy.
auto& mutable_this = const_cast<Window&>(*this);

View file

@ -232,7 +232,7 @@ public:
[[nodiscard]] OrderedHashMap<FlyString, JS::NonnullGCPtr<Navigable>> document_tree_child_navigable_target_name_property_set();
[[nodiscard]] Vector<FlyString> supported_property_names() const override;
[[nodiscard]] WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
[[nodiscard]] JS::Value named_item_value(FlyString const&) const override;
bool find(String const& string);