mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Bindings: Remove exception handling for named_item
We don't need this for any case, so just remove it to simplify handling in PlatformObject.
This commit is contained in:
parent
273593afba
commit
081c92bf3d
Notes:
github-actions[bot]
2024-07-26 12:27:29 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/081c92bf3dc Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/827
31 changed files with 32 additions and 33 deletions
|
@ -98,7 +98,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 = TRY(throw_dom_exception_if_needed(vm, [&] { return item_value(index); }));
|
||||
auto value item_value(index);
|
||||
|
||||
// 5. Let desc be a newly created Property Descriptor with no fields.
|
||||
JS::PropertyDescriptor descriptor;
|
||||
|
@ -483,7 +483,7 @@ WebIDL::ExceptionOr<PlatformObject::DidDeletionFail> PlatformObject::delete_valu
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> PlatformObject::item_value(size_t) const
|
||||
JS::Value PlatformObject::item_value(size_t) const
|
||||
{
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
};
|
||||
JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> legacy_platform_object_get_own_property(JS::PropertyKey const&, IgnoreNamedProps ignore_named_props) const;
|
||||
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const;
|
||||
virtual JS::Value item_value(size_t index) const;
|
||||
virtual WebIDL::ExceptionOr<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;
|
||||
|
|
|
@ -227,7 +227,7 @@ bool CSSRuleList::evaluate_media_queries(HTML::Window const& window)
|
|||
return any_media_queries_changed_match_state;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> CSSRuleList::item_value(size_t index) const
|
||||
JS::Value CSSRuleList::item_value(size_t index) const
|
||||
{
|
||||
return item(index);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
auto end() { return m_rules.end(); }
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
WebIDL::ExceptionOr<void> remove_a_css_rule(u32 index);
|
||||
WebIDL::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, CSSRule*>, u32 index);
|
||||
|
|
|
@ -116,7 +116,7 @@ bool MediaList::matches() const
|
|||
return false;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> MediaList::item_value(size_t index) const
|
||||
JS::Value MediaList::item_value(size_t index) const
|
||||
{
|
||||
if (index >= m_media.size())
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
void delete_medium(StringView);
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
bool evaluate(HTML::Window const&);
|
||||
bool matches() const;
|
||||
|
|
|
@ -164,7 +164,7 @@ bool StyleSheetList::is_supported_property_index(u32 index) const
|
|||
return index < m_sheets.size();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> StyleSheetList::item_value(size_t index) const
|
||||
JS::Value StyleSheetList::item_value(size_t index) const
|
||||
{
|
||||
if (index >= m_sheets.size())
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
size_t length() const { return m_sheets.size(); }
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
DOM::Document& document() { return m_document; }
|
||||
DOM::Document const& document() const { return m_document; }
|
||||
|
|
|
@ -302,7 +302,7 @@ void DOMTokenList::run_update_steps()
|
|||
MUST(associated_element->set_attribute(m_associated_attribute, serialize_ordered_set()));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> DOMTokenList::item_value(size_t index) const
|
||||
JS::Value DOMTokenList::item_value(size_t index) const
|
||||
{
|
||||
auto string = item(index);
|
||||
if (!string.has_value())
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
void associated_attribute_changed(StringView value);
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
size_t length() const { return m_token_set.size(); }
|
||||
Optional<String> item(size_t index) const;
|
||||
|
|
|
@ -169,7 +169,7 @@ bool HTMLCollection::is_supported_property_index(u32 index) const
|
|||
return index < length();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> HTMLCollection::item_value(size_t index) const
|
||||
JS::Value HTMLCollection::item_value(size_t index) const
|
||||
{
|
||||
auto* element = item(index);
|
||||
if (!element)
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
JS::MarkedVector<JS::NonnullGCPtr<Element>> collect_matching_elements() const;
|
||||
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 Vector<FlyString> supported_property_names() const override;
|
||||
virtual bool is_supported_property_name(FlyString const&) const override;
|
||||
|
|
|
@ -326,7 +326,7 @@ Attr const* NamedNodeMap::remove_attribute_ns(Optional<FlyString> const& namespa
|
|||
return attribute;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> NamedNodeMap::item_value(size_t index) const
|
||||
JS::Value NamedNodeMap::item_value(size_t index) const
|
||||
{
|
||||
auto const* node = item(index);
|
||||
if (!node)
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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;
|
||||
|
||||
size_t length() const { return m_attributes.size(); }
|
||||
|
|
|
@ -25,7 +25,7 @@ void NodeList::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(NodeList);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> NodeList::item_value(size_t index) const
|
||||
JS::Value NodeList::item_value(size_t index) const
|
||||
{
|
||||
auto* node = item(index);
|
||||
if (!node)
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual u32 length() const = 0;
|
||||
virtual Node const* item(u32 index) const = 0;
|
||||
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -56,7 +56,7 @@ bool FileList::is_supported_property_index(u32 index) const
|
|||
return index < m_files.size();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> FileList::item_value(size_t index) const
|
||||
JS::Value FileList::item_value(size_t index) const
|
||||
{
|
||||
if (index >= m_files.size())
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
}
|
||||
|
||||
virtual bool is_supported_property_index(u32 index) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
virtual StringView interface_name() const override { return "FileList"sv; }
|
||||
virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::SerializationRecord& serialized, bool for_storage, HTML::SerializationMemory&) override;
|
||||
|
|
|
@ -66,7 +66,7 @@ bool DOMRectList::is_supported_property_index(u32 index) const
|
|||
return index < m_rects.size();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> DOMRectList::item_value(size_t index) const
|
||||
JS::Value DOMRectList::item_value(size_t index) const
|
||||
{
|
||||
if (index >= m_rects.size())
|
||||
return JS::js_undefined();
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
DOMRect const* item(u32 index) const;
|
||||
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
|
||||
virtual JS::Value item_value(size_t index) const override;
|
||||
|
||||
private:
|
||||
DOMRectList(JS::Realm&, Vector<JS::NonnullGCPtr<DOMRect>>);
|
||||
|
|
|
@ -219,7 +219,7 @@ bool HTMLAllCollection::is_supported_property_index(u32 index) const
|
|||
return index < collect_matching_elements().size();
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> HTMLAllCollection::item_value(size_t index) const
|
||||
JS::Value HTMLAllCollection::item_value(size_t index) const
|
||||
{
|
||||
return get_the_all_indexed_element(index);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
JS::MarkedVector<JS::NonnullGCPtr<DOM::Element>> collect_matching_elements() const;
|
||||
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 Vector<FlyString> supported_property_names() const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
|
|
@ -935,7 +935,7 @@ bool HTMLFormElement::is_supported_property_index(u32 index) const
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-item
|
||||
WebIDL::ExceptionOr<JS::Value> HTMLFormElement::item_value(size_t index) const
|
||||
JS::Value HTMLFormElement::item_value(size_t index) const
|
||||
{
|
||||
// To determine the value of an indexed property for a form element, the user agent must return the value returned by
|
||||
// the item method on the elements collection, when invoked with the given index as its argument.
|
||||
|
|
|
@ -106,7 +106,7 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// ^PlatformObject
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 Vector<FlyString> supported_property_names() const override;
|
||||
virtual bool is_supported_property_index(u32) const override;
|
||||
|
|
|
@ -97,7 +97,7 @@ JS::GCPtr<MimeType> MimeTypeArray::named_item(FlyString const& name) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> MimeTypeArray::item_value(size_t index) const
|
||||
JS::Value MimeTypeArray::item_value(size_t index) const
|
||||
{
|
||||
auto return_value = item(index);
|
||||
if (!return_value)
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
|
||||
// ^Bindings::PlatformObject
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 bool is_supported_property_index(u32) const override;
|
||||
};
|
||||
|
|
|
@ -120,7 +120,7 @@ JS::GCPtr<MimeType> Plugin::named_item(FlyString const& name) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> Plugin::item_value(size_t index) const
|
||||
JS::Value Plugin::item_value(size_t index) const
|
||||
{
|
||||
auto return_value = item(index);
|
||||
if (!return_value)
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
|
||||
// ^Bindings::PlatformObject
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 bool is_supported_property_index(u32) const override;
|
||||
};
|
||||
|
|
|
@ -106,7 +106,7 @@ JS::GCPtr<Plugin> PluginArray::named_item(FlyString const& name) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> PluginArray::item_value(size_t index) const
|
||||
JS::Value PluginArray::item_value(size_t index) const
|
||||
{
|
||||
auto return_value = item(index);
|
||||
if (!return_value)
|
||||
|
|
|
@ -30,7 +30,7 @@ private:
|
|||
|
||||
// ^Bindings::PlatformObject
|
||||
virtual Vector<FlyString> supported_property_names() const override;
|
||||
virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) 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 bool is_supported_property_index(u32) const override;
|
||||
};
|
||||
|
|
|
@ -114,8 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalEnvironmentExtensions::$$_function)
|
|||
|
||||
auto array = TRY(JS::Array::create(*vm.current_realm(), node_list->length()));
|
||||
for (auto i = 0u; i < node_list->length(); ++i) {
|
||||
// NOTE: NodeList::item_value cannot fail.
|
||||
TRY(array->create_data_property_or_throw(i, MUST(node_list->item_value(i))));
|
||||
TRY(array->create_data_property_or_throw(i, node_list->item_value(i)));
|
||||
}
|
||||
|
||||
return array;
|
||||
|
|
Loading…
Add table
Reference in a new issue