1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:28:11 +00:00

LibWeb: Move ExceptionOr from DOM/ to WebIDL/

This is a concept fully defined in the Web IDL spec and doesn't belong
in the DOM directory/namespace - not even DOMException, despite the name
:^)
This commit is contained in:
Linus Groh 2022-09-25 17:03:42 +01:00
parent c0eda77928
commit ad04d7ac9b
107 changed files with 441 additions and 440 deletions

View file

@ -9,7 +9,7 @@
#include <AK/Optional.h> #include <AK/Optional.h>
#include <AK/StdLibExtras.h> #include <AK/StdLibExtras.h>
#include <LibJS/Runtime/VM.h> #include <LibJS/Runtime/VM.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Bindings { namespace Web::Bindings {
@ -17,7 +17,7 @@ template<typename>
constexpr bool IsExceptionOr = false; constexpr bool IsExceptionOr = false;
template<typename T> template<typename T>
constexpr bool IsExceptionOr<DOM::ExceptionOr<T>> = true; constexpr bool IsExceptionOr<WebIDL::ExceptionOr<T>> = true;
template<typename> template<typename>
constexpr bool IsThrowCompletionOr = false; constexpr bool IsThrowCompletionOr = false;
@ -33,7 +33,7 @@ struct ExtractExceptionOrValueType {
}; };
template<typename T> template<typename T>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<T>> { struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<T>> {
using Type = T; using Type = T;
}; };
@ -48,22 +48,22 @@ struct ExtractExceptionOrValueType<void> {
}; };
template<> template<>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<Empty>> { struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<Empty>> {
using Type = JS::Value; using Type = JS::Value;
}; };
template<> template<>
struct ExtractExceptionOrValueType<DOM::ExceptionOr<void>> { struct ExtractExceptionOrValueType<WebIDL::ExceptionOr<void>> {
using Type = JS::Value; using Type = JS::Value;
}; };
ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(auto&& vm, auto&& exception) ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(auto&& vm, auto&& exception)
{ {
return exception.visit( return exception.visit(
[&](DOM::SimpleException const& exception) { [&](WebIDL::SimpleException const& exception) {
switch (exception.type) { switch (exception.type) {
#define E(x) \ #define E(x) \
case DOM::SimpleExceptionType::x: \ case WebIDL::SimpleExceptionType::x: \
return vm.template throw_completion<JS::x>(exception.message); return vm.template throw_completion<JS::x>(exception.message);
ENUMERATE_SIMPLE_WEBIDL_EXCEPTION_TYPES(E) ENUMERATE_SIMPLE_WEBIDL_EXCEPTION_TYPES(E)

View file

@ -27,7 +27,7 @@ void CSSGroupingRule::visit_edges(Cell::Visitor& visitor)
visitor.visit(&m_rules); visitor.visit(&m_rules);
} }
DOM::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index) WebIDL::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
{ {
TRY(m_rules.insert_a_css_rule(rule, index)); TRY(m_rules.insert_a_css_rule(rule, index));
// NOTE: The spec doesn't say where to set the parent rule, so we'll do it here. // NOTE: The spec doesn't say where to set the parent rule, so we'll do it here.
@ -35,7 +35,7 @@ DOM::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
return index; return index;
} }
DOM::ExceptionOr<void> CSSGroupingRule::delete_rule(u32 index) WebIDL::ExceptionOr<void> CSSGroupingRule::delete_rule(u32 index)
{ {
return m_rules.remove_a_css_rule(index); return m_rules.remove_a_css_rule(index);
} }

View file

@ -23,8 +23,8 @@ public:
CSSRuleList const& css_rules() const { return m_rules; } CSSRuleList const& css_rules() const { return m_rules; }
CSSRuleList& css_rules() { return m_rules; } CSSRuleList& css_rules() { return m_rules; }
CSSRuleList* css_rules_for_bindings() { return &m_rules; } CSSRuleList* css_rules_for_bindings() { return &m_rules; }
DOM::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0); WebIDL::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
DOM::ExceptionOr<void> delete_rule(u32 index); WebIDL::ExceptionOr<void> delete_rule(u32 index);
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const; virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;

View file

@ -48,7 +48,7 @@ bool CSSRuleList::is_supported_property_index(u32 index) const
} }
// https://www.w3.org/TR/cssom/#insert-a-css-rule // https://www.w3.org/TR/cssom/#insert-a-css-rule
DOM::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CSSRule*> rule, u32 index) WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CSSRule*> rule, u32 index)
{ {
// 1. Set length to the number of items in list. // 1. Set length to the number of items in list.
auto length = m_rules.size(); auto length = m_rules.size();
@ -86,7 +86,7 @@ DOM::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView, CS
} }
// https://www.w3.org/TR/cssom/#remove-a-css-rule // https://www.w3.org/TR/cssom/#remove-a-css-rule
DOM::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index) WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
{ {
// 1. Set length to the number of items in list. // 1. Set length to the number of items in list.
auto length = m_rules.size(); auto length = m_rules.size();

View file

@ -13,8 +13,8 @@
#include <AK/RefPtr.h> #include <AK/RefPtr.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h> #include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/CSS/CSSRule.h> #include <LibWeb/CSS/CSSRule.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS { namespace Web::CSS {
@ -57,8 +57,8 @@ public:
virtual bool is_supported_property_index(u32 index) const override; virtual bool is_supported_property_index(u32 index) const override;
virtual JS::Value item_value(size_t index) const override; virtual JS::Value item_value(size_t index) const override;
DOM::ExceptionOr<void> remove_a_css_rule(u32 index); WebIDL::ExceptionOr<void> remove_a_css_rule(u32 index);
DOM::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, CSSRule*>, u32 index); WebIDL::ExceptionOr<unsigned> insert_a_css_rule(Variant<StringView, CSSRule*>, u32 index);
void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const; void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
// Returns whether the match state of any media queries changed after evaluation. // Returns whether the match state of any media queries changed after evaluation.

View file

@ -69,7 +69,7 @@ Optional<StyleProperty> PropertyOwningCSSStyleDeclaration::property(PropertyID p
} }
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
DOM::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority) WebIDL::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority)
{ {
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
// NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration. // NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration.
@ -117,7 +117,7 @@ DOM::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(PropertyI
} }
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
DOM::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id) WebIDL::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id)
{ {
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
// NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration. // NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration.
@ -214,7 +214,7 @@ String CSSStyleDeclaration::get_property_priority(StringView property_name) cons
return maybe_property->important == Important::Yes ? "important" : ""; return maybe_property->important == Important::Yes ? "important" : "";
} }
DOM::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority) WebIDL::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority)
{ {
auto property_id = property_id_from_string(property_name); auto property_id = property_id_from_string(property_name);
if (property_id == CSS::PropertyID::Invalid) if (property_id == CSS::PropertyID::Invalid)
@ -222,7 +222,7 @@ DOM::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_nam
return set_property(property_id, css_text, priority); return set_property(property_id, css_text, priority);
} }
DOM::ExceptionOr<String> CSSStyleDeclaration::remove_property(StringView property_name) WebIDL::ExceptionOr<String> CSSStyleDeclaration::remove_property(StringView property_name)
{ {
auto property_id = property_id_from_string(property_name); auto property_id = property_id_from_string(property_name);
if (property_id == CSS::PropertyID::Invalid) if (property_id == CSS::PropertyID::Invalid)

View file

@ -36,11 +36,11 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const = 0; virtual Optional<StyleProperty> property(PropertyID) const = 0;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0; virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) = 0; virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) = 0;
DOM::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority); WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority);
DOM::ExceptionOr<String> remove_property(StringView property_name); WebIDL::ExceptionOr<String> remove_property(StringView property_name);
String get_property_value(StringView property) const; String get_property_value(StringView property) const;
String get_property_priority(StringView property) const; String get_property_priority(StringView property) const;
@ -72,8 +72,8 @@ public:
virtual Optional<StyleProperty> property(PropertyID) const override; virtual Optional<StyleProperty> property(PropertyID) const override;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override; virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) override; virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
Vector<StyleProperty> const& properties() const { return m_properties; } Vector<StyleProperty> const& properties() const { return m_properties; }
HashMap<String, StyleProperty> const& custom_properties() const { return m_custom_properties; } HashMap<String, StyleProperty> const& custom_properties() const { return m_custom_properties; }

View file

@ -8,7 +8,7 @@
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleSheetList.h> #include <LibWeb/CSS/StyleSheetList.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::CSS { namespace Web::CSS {
@ -39,7 +39,7 @@ void CSSStyleSheet::visit_edges(Cell::Visitor& visitor)
} }
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-insertrule // https://www.w3.org/TR/cssom/#dom-cssstylesheet-insertrule
DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned index) WebIDL::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned index)
{ {
// FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception. // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
@ -71,7 +71,7 @@ DOM::ExceptionOr<unsigned> CSSStyleSheet::insert_rule(StringView rule, unsigned
} }
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-deleterule // https://www.w3.org/TR/cssom/#dom-cssstylesheet-deleterule
DOM::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index) WebIDL::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
{ {
// FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception. // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception.
@ -89,7 +89,7 @@ DOM::ExceptionOr<void> CSSStyleSheet::delete_rule(unsigned index)
} }
// https://www.w3.org/TR/cssom/#dom-cssstylesheet-removerule // https://www.w3.org/TR/cssom/#dom-cssstylesheet-removerule
DOM::ExceptionOr<void> CSSStyleSheet::remove_rule(unsigned index) WebIDL::ExceptionOr<void> CSSStyleSheet::remove_rule(unsigned index)
{ {
// The removeRule(index) method must run the same steps as deleteRule(). // The removeRule(index) method must run the same steps as deleteRule().
return delete_rule(index); return delete_rule(index);

View file

@ -40,9 +40,9 @@ public:
CSSRuleList* css_rules() { return m_rules; } CSSRuleList* css_rules() { return m_rules; }
CSSRuleList const* css_rules() const { return m_rules; } CSSRuleList const* css_rules() const { return m_rules; }
DOM::ExceptionOr<unsigned> insert_rule(StringView rule, unsigned index); WebIDL::ExceptionOr<unsigned> insert_rule(StringView rule, unsigned index);
DOM::ExceptionOr<void> remove_rule(unsigned index); WebIDL::ExceptionOr<void> remove_rule(unsigned index);
DOM::ExceptionOr<void> delete_rule(unsigned index); WebIDL::ExceptionOr<void> delete_rule(unsigned index);
void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const; void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
// Returns whether the match state of any media queries changed after evaluation. // Returns whether the match state of any media queries changed after evaluation.

View file

@ -535,14 +535,14 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
} }
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
DOM::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView) WebIDL::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView)
{ {
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create(global_object(), "Cannot modify properties in result of getComputedStyle()"); return DOM::NoModificationAllowedError::create(global_object(), "Cannot modify properties in result of getComputedStyle()");
} }
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
DOM::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID) WebIDL::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
{ {
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return DOM::NoModificationAllowedError::create(global_object(), "Cannot remove properties from result of getComputedStyle()"); return DOM::NoModificationAllowedError::create(global_object(), "Cannot remove properties from result of getComputedStyle()");

View file

@ -22,8 +22,8 @@ public:
virtual size_t length() const override; virtual size_t length() const override;
virtual String item(size_t index) const override; virtual String item(size_t index) const override;
virtual Optional<StyleProperty> property(PropertyID) const override; virtual Optional<StyleProperty> property(PropertyID) const override;
virtual DOM::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override; virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual DOM::ExceptionOr<String> remove_property(PropertyID) override; virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
virtual String serialized() const override; virtual String serialized() const override;

View file

@ -39,7 +39,7 @@ JS::NonnullGCPtr<SubtleCrypto> Crypto::subtle() const
} }
// https://w3c.github.io/webcrypto/#dfn-Crypto-method-getRandomValues // https://w3c.github.io/webcrypto/#dfn-Crypto-method-getRandomValues
DOM::ExceptionOr<JS::Value> Crypto::get_random_values(JS::Value array) const WebIDL::ExceptionOr<JS::Value> Crypto::get_random_values(JS::Value array) const
{ {
// 1. If array is not an Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array, then throw a TypeMismatchError and terminate the algorithm. // 1. If array is not an Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array, then throw a TypeMismatchError and terminate the algorithm.
if (!array.is_object() || !(is<JS::Int8Array>(array.as_object()) || is<JS::Uint8Array>(array.as_object()) || is<JS::Uint8ClampedArray>(array.as_object()) || is<JS::Int16Array>(array.as_object()) || is<JS::Uint16Array>(array.as_object()) || is<JS::Int32Array>(array.as_object()) || is<JS::Uint32Array>(array.as_object()) || is<JS::BigInt64Array>(array.as_object()) || is<JS::BigUint64Array>(array.as_object()))) if (!array.is_object() || !(is<JS::Int8Array>(array.as_object()) || is<JS::Uint8Array>(array.as_object()) || is<JS::Uint8ClampedArray>(array.as_object()) || is<JS::Int16Array>(array.as_object()) || is<JS::Uint16Array>(array.as_object()) || is<JS::Int32Array>(array.as_object()) || is<JS::Uint32Array>(array.as_object()) || is<JS::BigInt64Array>(array.as_object()) || is<JS::BigUint64Array>(array.as_object())))

View file

@ -8,7 +8,7 @@
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/Crypto/SubtleCrypto.h> #include <LibWeb/Crypto/SubtleCrypto.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Crypto { namespace Web::Crypto {
@ -22,7 +22,7 @@ public:
JS::NonnullGCPtr<SubtleCrypto> subtle() const; JS::NonnullGCPtr<SubtleCrypto> subtle() const;
DOM::ExceptionOr<JS::Value> get_random_values(JS::Value array) const; WebIDL::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
String random_uuid() const; String random_uuid() const;
protected: protected:

View file

@ -31,7 +31,7 @@ void CharacterData::set_data(String data)
} }
// https://dom.spec.whatwg.org/#concept-cd-substring // https://dom.spec.whatwg.org/#concept-cd-substring
ExceptionOr<String> CharacterData::substring_data(size_t offset, size_t count) const WebIDL::ExceptionOr<String> CharacterData::substring_data(size_t offset, size_t count) const
{ {
// 1. Let length be nodes length. // 1. Let length be nodes length.
auto length = this->length(); auto length = this->length();
@ -50,7 +50,7 @@ ExceptionOr<String> CharacterData::substring_data(size_t offset, size_t count) c
} }
// https://dom.spec.whatwg.org/#concept-cd-replace // https://dom.spec.whatwg.org/#concept-cd-replace
ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, String const& data) WebIDL::ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, String const& data)
{ {
// 1. Let length be nodes length. // 1. Let length be nodes length.
auto length = this->length(); auto length = this->length();
@ -109,21 +109,21 @@ ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, Strin
} }
// https://dom.spec.whatwg.org/#dom-characterdata-appenddata // https://dom.spec.whatwg.org/#dom-characterdata-appenddata
ExceptionOr<void> CharacterData::append_data(String const& data) WebIDL::ExceptionOr<void> CharacterData::append_data(String const& data)
{ {
// The appendData(data) method steps are to replace data with node this, offset thiss length, count 0, and data data. // The appendData(data) method steps are to replace data with node this, offset thiss length, count 0, and data data.
return replace_data(m_data.length(), 0, data); return replace_data(m_data.length(), 0, data);
} }
// https://dom.spec.whatwg.org/#dom-characterdata-insertdata // https://dom.spec.whatwg.org/#dom-characterdata-insertdata
ExceptionOr<void> CharacterData::insert_data(size_t offset, String const& data) WebIDL::ExceptionOr<void> CharacterData::insert_data(size_t offset, String const& data)
{ {
// The insertData(offset, data) method steps are to replace data with node this, offset offset, count 0, and data data. // The insertData(offset, data) method steps are to replace data with node this, offset offset, count 0, and data data.
return replace_data(offset, 0, data); return replace_data(offset, 0, data);
} }
// https://dom.spec.whatwg.org/#dom-characterdata-deletedata // https://dom.spec.whatwg.org/#dom-characterdata-deletedata
ExceptionOr<void> CharacterData::delete_data(size_t offset, size_t count) WebIDL::ExceptionOr<void> CharacterData::delete_data(size_t offset, size_t count)
{ {
// The deleteData(offset, count) method steps are to replace data with node this, offset offset, count count, and data the empty string. // The deleteData(offset, count) method steps are to replace data with node this, offset offset, count count, and data the empty string.
return replace_data(offset, count, String::empty()); return replace_data(offset, count, String::empty());

View file

@ -27,11 +27,11 @@ public:
unsigned length() const { return m_data.length(); } unsigned length() const { return m_data.length(); }
ExceptionOr<String> substring_data(size_t offset, size_t count) const; WebIDL::ExceptionOr<String> substring_data(size_t offset, size_t count) const;
ExceptionOr<void> append_data(String const&); WebIDL::ExceptionOr<void> append_data(String const&);
ExceptionOr<void> insert_data(size_t offset, String const&); WebIDL::ExceptionOr<void> insert_data(size_t offset, String const&);
ExceptionOr<void> delete_data(size_t offset, size_t count); WebIDL::ExceptionOr<void> delete_data(size_t offset, size_t count);
ExceptionOr<void> replace_data(size_t offset, size_t count, String const&); WebIDL::ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
protected: protected:
explicit CharacterData(Document&, NodeType, String const&); explicit CharacterData(Document&, NodeType, String const&);

View file

@ -6,8 +6,8 @@
#pragma once #pragma once
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/NodeOperations.h> #include <LibWeb/DOM/NodeOperations.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -16,7 +16,7 @@ template<typename NodeType>
class ChildNode { class ChildNode {
public: public:
// https://dom.spec.whatwg.org/#dom-childnode-before // https://dom.spec.whatwg.org/#dom-childnode-before
ExceptionOr<void> before(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> before(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
auto* node = static_cast<NodeType*>(this); auto* node = static_cast<NodeType*>(this);
@ -46,7 +46,7 @@ public:
} }
// https://dom.spec.whatwg.org/#dom-childnode-after // https://dom.spec.whatwg.org/#dom-childnode-after
ExceptionOr<void> after(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> after(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
auto* node = static_cast<NodeType*>(this); auto* node = static_cast<NodeType*>(this);
@ -70,7 +70,7 @@ public:
} }
// https://dom.spec.whatwg.org/#dom-childnode-replacewith // https://dom.spec.whatwg.org/#dom-childnode-replacewith
ExceptionOr<void> replace_with(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> replace_with(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
auto* node = static_cast<NodeType*>(this); auto* node = static_cast<NodeType*>(this);

View file

@ -38,7 +38,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor)
} }
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, JS::GCPtr<DocumentType> doctype) const WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, JS::GCPtr<DocumentType> doctype) const
{ {
// FIXME: This should specifically be an XML document. // FIXME: This should specifically be an XML document.
auto xml_document = Document::create(Bindings::main_thread_internal_window_object()); auto xml_document = Document::create(Bindings::main_thread_internal_window_object());
@ -103,7 +103,7 @@ JS::NonnullGCPtr<Document> DOMImplementation::create_html_document(String const&
} }
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype // https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype
ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id) WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id)
{ {
TRY(Document::validate_qualified_name(global_object(), qualified_name)); TRY(Document::validate_qualified_name(global_object(), qualified_name));
auto document_type = DocumentType::create(document()); auto document_type = DocumentType::create(document());

View file

@ -20,9 +20,9 @@ public:
static JS::NonnullGCPtr<DOMImplementation> create(Document&); static JS::NonnullGCPtr<DOMImplementation> create(Document&);
virtual ~DOMImplementation(); virtual ~DOMImplementation();
ExceptionOr<JS::NonnullGCPtr<Document>> create_document(String const&, String const&, JS::GCPtr<DocumentType>) const; WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_document(String const&, String const&, JS::GCPtr<DocumentType>) const;
JS::NonnullGCPtr<Document> create_html_document(String const& title) const; JS::NonnullGCPtr<Document> create_html_document(String const& title) const;
ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentType>> create_document_type(String const& qualified_name, String const& public_id, String const& system_id);
// https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
bool has_feature() const { return true; } bool has_feature() const { return true; }

View file

@ -108,7 +108,7 @@ bool DOMTokenList::contains(StringView token)
} }
// https://dom.spec.whatwg.org/#dom-domtokenlist-add // https://dom.spec.whatwg.org/#dom-domtokenlist-add
ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens) WebIDL::ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens)
{ {
// 1. For each token in tokens: // 1. For each token in tokens:
for (auto const& token : tokens) { for (auto const& token : tokens) {
@ -126,7 +126,7 @@ ExceptionOr<void> DOMTokenList::add(Vector<String> const& tokens)
} }
// https://dom.spec.whatwg.org/#dom-domtokenlist-remove // https://dom.spec.whatwg.org/#dom-domtokenlist-remove
ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens) WebIDL::ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens)
{ {
// 1. For each token in tokens: // 1. For each token in tokens:
for (auto const& token : tokens) { for (auto const& token : tokens) {
@ -144,7 +144,7 @@ ExceptionOr<void> DOMTokenList::remove(Vector<String> const& tokens)
} }
// https://dom.spec.whatwg.org/#dom-domtokenlist-toggle // https://dom.spec.whatwg.org/#dom-domtokenlist-toggle
ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<bool> force) WebIDL::ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<bool> force)
{ {
// 1. If token is the empty string, then throw a "SyntaxError" DOMException. // 1. If token is the empty string, then throw a "SyntaxError" DOMException.
// 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException. // 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
@ -175,7 +175,7 @@ ExceptionOr<bool> DOMTokenList::toggle(String const& token, Optional<bool> force
} }
// https://dom.spec.whatwg.org/#dom-domtokenlist-replace // https://dom.spec.whatwg.org/#dom-domtokenlist-replace
ExceptionOr<bool> DOMTokenList::replace(String const& token, String const& new_token) WebIDL::ExceptionOr<bool> DOMTokenList::replace(String const& token, String const& new_token)
{ {
// 1. If either token or newToken is the empty string, then throw a "SyntaxError" DOMException. // 1. If either token or newToken is the empty string, then throw a "SyntaxError" DOMException.
// 2. If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException. // 2. If either token or newToken contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException.
@ -198,13 +198,13 @@ ExceptionOr<bool> DOMTokenList::replace(String const& token, String const& new_t
// https://dom.spec.whatwg.org/#dom-domtokenlist-supports // https://dom.spec.whatwg.org/#dom-domtokenlist-supports
// https://dom.spec.whatwg.org/#concept-domtokenlist-validation // https://dom.spec.whatwg.org/#concept-domtokenlist-validation
ExceptionOr<bool> DOMTokenList::supports([[maybe_unused]] StringView token) WebIDL::ExceptionOr<bool> DOMTokenList::supports([[maybe_unused]] StringView token)
{ {
// FIXME: Implement this fully when any use case defines supported tokens. // FIXME: Implement this fully when any use case defines supported tokens.
// 1. If the associated attributes local name does not define supported tokens, throw a TypeError. // 1. If the associated attributes local name does not define supported tokens, throw a TypeError.
return DOM::SimpleException { return WebIDL::SimpleException {
DOM::SimpleExceptionType::TypeError, WebIDL::SimpleExceptionType::TypeError,
String::formatted("Attribute {} does not define any supported tokens", m_associated_attribute) String::formatted("Attribute {} does not define any supported tokens", m_associated_attribute)
}; };
@ -231,7 +231,7 @@ void DOMTokenList::set_value(String value)
associated_element->set_attribute(m_associated_attribute, move(value)); associated_element->set_attribute(m_associated_attribute, move(value));
} }
ExceptionOr<void> DOMTokenList::validate_token(StringView token) const WebIDL::ExceptionOr<void> DOMTokenList::validate_token(StringView token) const
{ {
if (token.is_empty()) if (token.is_empty())
return SyntaxError::create(global_object(), "Non-empty DOM tokens are not allowed"); return SyntaxError::create(global_object(), "Non-empty DOM tokens are not allowed");

View file

@ -13,8 +13,8 @@
#include <AK/StringView.h> #include <AK/StringView.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h> #include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -34,18 +34,18 @@ public:
size_t length() const { return m_token_set.size(); } size_t length() const { return m_token_set.size(); }
String const& item(size_t index) const; String const& item(size_t index) const;
bool contains(StringView token); bool contains(StringView token);
ExceptionOr<void> add(Vector<String> const& tokens); WebIDL::ExceptionOr<void> add(Vector<String> const& tokens);
ExceptionOr<void> remove(Vector<String> const& tokens); WebIDL::ExceptionOr<void> remove(Vector<String> const& tokens);
ExceptionOr<bool> toggle(String const& token, Optional<bool> force); WebIDL::ExceptionOr<bool> toggle(String const& token, Optional<bool> force);
ExceptionOr<bool> replace(String const& token, String const& new_token); WebIDL::ExceptionOr<bool> replace(String const& token, String const& new_token);
ExceptionOr<bool> supports(StringView token); WebIDL::ExceptionOr<bool> supports(StringView token);
String value() const; String value() const;
void set_value(String value); void set_value(String value);
private: private:
DOMTokenList(Element const& associated_element, FlyString associated_attribute); DOMTokenList(Element const& associated_element, FlyString associated_attribute);
ExceptionOr<void> validate_token(StringView token) const; WebIDL::ExceptionOr<void> validate_token(StringView token) const;
void run_update_steps(); void run_update_steps();
WeakPtr<Element> m_associated_element; WeakPtr<Element> m_associated_element;

View file

@ -28,7 +28,6 @@
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ElementFactory.h> #include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/HTMLCollection.h> #include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/DOM/NodeIterator.h> #include <LibWeb/DOM/NodeIterator.h>
#include <LibWeb/DOM/Range.h> #include <LibWeb/DOM/Range.h>
@ -73,6 +72,7 @@
#include <LibWeb/UIEvents/FocusEvent.h> #include <LibWeb/UIEvents/FocusEvent.h>
#include <LibWeb/UIEvents/KeyboardEvent.h> #include <LibWeb/UIEvents/KeyboardEvent.h>
#include <LibWeb/UIEvents/MouseEvent.h> #include <LibWeb/UIEvents/MouseEvent.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -351,7 +351,7 @@ void Document::visit_edges(Cell::Visitor& visitor)
} }
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-write
ExceptionOr<void> Document::write(Vector<String> const& strings) WebIDL::ExceptionOr<void> Document::write(Vector<String> const& strings)
{ {
StringBuilder builder; StringBuilder builder;
builder.join(""sv, strings); builder.join(""sv, strings);
@ -360,7 +360,7 @@ ExceptionOr<void> Document::write(Vector<String> const& strings)
} }
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln
ExceptionOr<void> Document::writeln(Vector<String> const& strings) WebIDL::ExceptionOr<void> Document::writeln(Vector<String> const& strings)
{ {
StringBuilder builder; StringBuilder builder;
builder.join(""sv, strings); builder.join(""sv, strings);
@ -370,7 +370,7 @@ ExceptionOr<void> Document::writeln(Vector<String> const& strings)
} }
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-write-steps // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-write-steps
ExceptionOr<void> Document::run_the_document_write_steps(String input) WebIDL::ExceptionOr<void> Document::run_the_document_write_steps(String input)
{ {
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException. // 1. If document is an XML document, then throw an "InvalidStateError" DOMException.
if (m_type == Type::XML) if (m_type == Type::XML)
@ -405,7 +405,7 @@ ExceptionOr<void> Document::run_the_document_write_steps(String input)
} }
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open
ExceptionOr<Document*> Document::open(String const&, String const&) WebIDL::ExceptionOr<Document*> Document::open(String const&, String const&)
{ {
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception.
if (m_type == Type::XML) if (m_type == Type::XML)
@ -476,7 +476,7 @@ ExceptionOr<Document*> Document::open(String const&, String const&)
} }
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#closing-the-input-stream // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#closing-the-input-stream
ExceptionOr<void> Document::close() WebIDL::ExceptionOr<void> Document::close()
{ {
// 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception.
if (m_type == Type::XML) if (m_type == Type::XML)
@ -585,7 +585,7 @@ HTML::HTMLElement* Document::body()
} }
// https://html.spec.whatwg.org/multipage/dom.html#dom-document-body // https://html.spec.whatwg.org/multipage/dom.html#dom-document-body
ExceptionOr<void> Document::set_body(HTML::HTMLElement* new_body) WebIDL::ExceptionOr<void> Document::set_body(HTML::HTMLElement* new_body)
{ {
if (!is<HTML::HTMLBodyElement>(new_body) && !is<HTML::HTMLFrameSetElement>(new_body)) if (!is<HTML::HTMLBodyElement>(new_body) && !is<HTML::HTMLFrameSetElement>(new_body))
return DOM::HierarchyRequestError::create(global_object(), "Invalid document body element, must be 'body' or 'frameset'"); return DOM::HierarchyRequestError::create(global_object(), "Invalid document body element, must be 'body' or 'frameset'");
@ -1108,7 +1108,7 @@ JS::Value Document::run_javascript(StringView source, StringView filename)
} }
// https://dom.spec.whatwg.org/#dom-document-createelement // https://dom.spec.whatwg.org/#dom-document-createelement
DOM::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(FlyString const& a_local_name) WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(FlyString const& a_local_name)
{ {
auto local_name = a_local_name; auto local_name = a_local_name;
@ -1135,7 +1135,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element(FlyString c
// https://dom.spec.whatwg.org/#dom-document-createelementns // https://dom.spec.whatwg.org/#dom-document-createelementns
// https://dom.spec.whatwg.org/#internal-createelementns-steps // https://dom.spec.whatwg.org/#internal-createelementns-steps
// FIXME: This only implements step 4 of the algorithm and does not take in options. // FIXME: This only implements step 4 of the algorithm and does not take in options.
DOM::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(String const& namespace_, String const& qualified_name) WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> Document::create_element_ns(String const& namespace_, String const& qualified_name)
{ {
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract. // 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name)); auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name));
@ -1168,7 +1168,7 @@ JS::NonnullGCPtr<Range> Document::create_range()
} }
// https://dom.spec.whatwg.org/#dom-document-createevent // https://dom.spec.whatwg.org/#dom-document-createevent
DOM::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(String const& interface) WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(String const& interface)
{ {
auto& window_object = window(); auto& window_object = window();
@ -1285,7 +1285,7 @@ Vector<JS::Handle<HTML::HTMLScriptElement>> Document::take_scripts_to_execute_in
} }
// https://dom.spec.whatwg.org/#dom-document-importnode // https://dom.spec.whatwg.org/#dom-document-importnode
ExceptionOr<JS::NonnullGCPtr<Node>> Document::import_node(JS::NonnullGCPtr<Node> node, bool deep) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Document::import_node(JS::NonnullGCPtr<Node> node, bool deep)
{ {
// 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException. // 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException.
if (is<Document>(*node) || is<ShadowRoot>(*node)) if (is<Document>(*node) || is<ShadowRoot>(*node))
@ -1333,7 +1333,7 @@ void Document::adopt_node(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-document-adoptnode // https://dom.spec.whatwg.org/#dom-document-adoptnode
ExceptionOr<JS::NonnullGCPtr<Node>> Document::adopt_node_binding(JS::NonnullGCPtr<Node> node) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Document::adopt_node_binding(JS::NonnullGCPtr<Node> node)
{ {
if (is<Document>(*node)) if (is<Document>(*node))
return DOM::NotSupportedError::create(global_object(), "Cannot adopt a document into a document"); return DOM::NotSupportedError::create(global_object(), "Cannot adopt a document into a document");
@ -1798,7 +1798,7 @@ bool Document::is_valid_name(String const& name)
} }
// https://dom.spec.whatwg.org/#validate // https://dom.spec.whatwg.org/#validate
ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(JS::Object& global_object, String const& qualified_name) WebIDL::ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(JS::Object& global_object, String const& qualified_name)
{ {
if (qualified_name.is_empty()) if (qualified_name.is_empty())
return InvalidCharacterError::create(global_object, "Empty string is not a valid qualified name."); return InvalidCharacterError::create(global_object, "Empty string is not a valid qualified name.");

View file

@ -21,7 +21,6 @@
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/CSS/StyleSheetList.h> #include <LibWeb/CSS/StyleSheetList.h>
#include <LibWeb/Cookie/Cookie.h> #include <LibWeb/Cookie/Cookie.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/NonElementParentNode.h> #include <LibWeb/DOM/NonElementParentNode.h>
#include <LibWeb/DOM/ParentNode.h> #include <LibWeb/DOM/ParentNode.h>
#include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h> #include <LibWeb/HTML/CrossOrigin/CrossOriginOpenerPolicy.h>
@ -33,6 +32,7 @@
#include <LibWeb/HTML/Scripting/Environments.h> #include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/VisibilityState.h> #include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -156,7 +156,7 @@ public:
return const_cast<Document*>(this)->body(); return const_cast<Document*>(this)->body();
} }
ExceptionOr<void> set_body(HTML::HTMLElement* new_body); WebIDL::ExceptionOr<void> set_body(HTML::HTMLElement* new_body);
String title() const; String title() const;
void set_title(String const&); void set_title(String const&);
@ -219,12 +219,12 @@ public:
JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv); JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv);
ExceptionOr<JS::NonnullGCPtr<Element>> create_element(FlyString const& local_name); WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(FlyString const& local_name);
ExceptionOr<JS::NonnullGCPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name); WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element_ns(String const& namespace_, String const& qualified_name);
JS::NonnullGCPtr<DocumentFragment> create_document_fragment(); JS::NonnullGCPtr<DocumentFragment> create_document_fragment();
JS::NonnullGCPtr<Text> create_text_node(String const& data); JS::NonnullGCPtr<Text> create_text_node(String const& data);
JS::NonnullGCPtr<Comment> create_comment(String const& data); JS::NonnullGCPtr<Comment> create_comment(String const& data);
ExceptionOr<JS::NonnullGCPtr<Event>> create_event(String const& interface); WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create_event(String const& interface);
JS::NonnullGCPtr<Range> create_range(); JS::NonnullGCPtr<Range> create_range();
void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*); void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*);
@ -253,9 +253,9 @@ public:
// https://dom.spec.whatwg.org/#xml-document // https://dom.spec.whatwg.org/#xml-document
bool is_xml_document() const { return m_type == Type::XML; } bool is_xml_document() const { return m_type == Type::XML; }
ExceptionOr<JS::NonnullGCPtr<Node>> import_node(JS::NonnullGCPtr<Node> node, bool deep); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> import_node(JS::NonnullGCPtr<Node> node, bool deep);
void adopt_node(Node&); void adopt_node(Node&);
ExceptionOr<JS::NonnullGCPtr<Node>> adopt_node_binding(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> adopt_node_binding(JS::NonnullGCPtr<Node>);
DocumentType const* doctype() const; DocumentType const* doctype() const;
String const& compat_mode() const; String const& compat_mode() const;
@ -286,11 +286,11 @@ public:
void set_window(Badge<HTML::BrowsingContext>, HTML::Window&); void set_window(Badge<HTML::BrowsingContext>, HTML::Window&);
ExceptionOr<void> write(Vector<String> const& strings); WebIDL::ExceptionOr<void> write(Vector<String> const& strings);
ExceptionOr<void> writeln(Vector<String> const& strings); WebIDL::ExceptionOr<void> writeln(Vector<String> const& strings);
ExceptionOr<Document*> open(String const& = "", String const& = ""); WebIDL::ExceptionOr<Document*> open(String const& = "", String const& = "");
ExceptionOr<void> close(); WebIDL::ExceptionOr<void> close();
HTML::Window* default_view() { return m_window.ptr(); } HTML::Window* default_view() { return m_window.ptr(); }
@ -367,7 +367,7 @@ public:
FlyString prefix; FlyString prefix;
FlyString tag_name; FlyString tag_name;
}; };
static ExceptionOr<PrefixAndTagName> validate_qualified_name(JS::Object& global_object, String const& qualified_name); static WebIDL::ExceptionOr<PrefixAndTagName> validate_qualified_name(JS::Object& global_object, String const& qualified_name);
JS::NonnullGCPtr<NodeIterator> create_node_iterator(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>); JS::NonnullGCPtr<NodeIterator> create_node_iterator(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
JS::NonnullGCPtr<TreeWalker> create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>); JS::NonnullGCPtr<TreeWalker> create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr<NodeFilter>);
@ -449,7 +449,7 @@ private:
void evaluate_media_rules(); void evaluate_media_rules();
ExceptionOr<void> run_the_document_write_steps(String); WebIDL::ExceptionOr<void> run_the_document_write_steps(String);
size_t m_next_layout_node_serial_id { 0 }; size_t m_next_layout_node_serial_id { 0 };

View file

@ -16,7 +16,6 @@
#include <LibWeb/DOM/DOMTokenList.h> #include <LibWeb/DOM/DOMTokenList.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/HTMLCollection.h> #include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/DOM/ShadowRoot.h> #include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOM/Text.h> #include <LibWeb/DOM/Text.h>
@ -39,6 +38,7 @@
#include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -82,7 +82,7 @@ String Element::get_attribute(FlyString const& name) const
} }
// https://dom.spec.whatwg.org/#dom-element-setattribute // https://dom.spec.whatwg.org/#dom-element-setattribute
ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value) WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
{ {
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
// FIXME: Proper name validation // FIXME: Proper name validation
@ -118,7 +118,7 @@ ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& va
} }
// https://dom.spec.whatwg.org/#validate-and-extract // https://dom.spec.whatwg.org/#validate-and-extract
ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name) WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name)
{ {
// 1. If namespace is the empty string, then set it to null. // 1. If namespace is the empty string, then set it to null.
if (namespace_.is_empty()) if (namespace_.is_empty())
@ -161,7 +161,7 @@ ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlySt
} }
// https://dom.spec.whatwg.org/#dom-element-setattributens // https://dom.spec.whatwg.org/#dom-element-setattributens
ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value) WebIDL::ExceptionOr<void> Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value)
{ {
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract. // 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name)); auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name));
@ -190,7 +190,7 @@ bool Element::has_attribute(FlyString const& name) const
} }
// https://dom.spec.whatwg.org/#dom-element-toggleattribute // https://dom.spec.whatwg.org/#dom-element-toggleattribute
DOM::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force) WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
{ {
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
// FIXME: Proper name validation // FIXME: Proper name validation
@ -439,7 +439,7 @@ DOMTokenList* Element::class_list()
} }
// https://dom.spec.whatwg.org/#dom-element-matches // https://dom.spec.whatwg.org/#dom-element-matches
DOM::ExceptionOr<bool> Element::matches(StringView selectors) const WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
{ {
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors); auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
if (!maybe_selectors.has_value()) if (!maybe_selectors.has_value())
@ -454,7 +454,7 @@ DOM::ExceptionOr<bool> Element::matches(StringView selectors) const
} }
// https://dom.spec.whatwg.org/#dom-element-closest // https://dom.spec.whatwg.org/#dom-element-closest
DOM::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const
{ {
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors); auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
if (!maybe_selectors.has_value()) if (!maybe_selectors.has_value())
@ -479,7 +479,7 @@ DOM::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) con
return nullptr; return nullptr;
} }
ExceptionOr<void> Element::set_inner_html(String const& markup) WebIDL::ExceptionOr<void> Element::set_inner_html(String const& markup)
{ {
TRY(DOMParsing::inner_html_setter(*this, markup)); TRY(DOMParsing::inner_html_setter(*this, markup));
@ -729,7 +729,7 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
} }
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml // https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
DOM::ExceptionOr<void> Element::insert_adjacent_html(String position, String text) WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String position, String text)
{ {
JS::GCPtr<Node> context; JS::GCPtr<Node> context;
// 1. Use the first matching item from this list: // 1. Use the first matching item from this list:

View file

@ -12,7 +12,6 @@
#include <LibWeb/CSS/StyleComputer.h> #include <LibWeb/CSS/StyleComputer.h>
#include <LibWeb/DOM/Attr.h> #include <LibWeb/DOM/Attr.h>
#include <LibWeb/DOM/ChildNode.h> #include <LibWeb/DOM/ChildNode.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/NamedNodeMap.h> #include <LibWeb/DOM/NamedNodeMap.h>
#include <LibWeb/DOM/NonDocumentTypeChildNode.h> #include <LibWeb/DOM/NonDocumentTypeChildNode.h>
#include <LibWeb/DOM/ParentNode.h> #include <LibWeb/DOM/ParentNode.h>
@ -22,6 +21,7 @@
#include <LibWeb/HTML/TagNames.h> #include <LibWeb/HTML/TagNames.h>
#include <LibWeb/Layout/Node.h> #include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/TreeBuilder.h> #include <LibWeb/Layout/TreeBuilder.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -52,18 +52,18 @@ public:
bool has_attributes() const { return !m_attributes->is_empty(); } bool has_attributes() const { return !m_attributes->is_empty(); }
String attribute(FlyString const& name) const { return get_attribute(name); } String attribute(FlyString const& name) const { return get_attribute(name); }
String get_attribute(FlyString const& name) const; String get_attribute(FlyString const& name) const;
ExceptionOr<void> set_attribute(FlyString const& name, String const& value); WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, String const& value);
ExceptionOr<void> set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value); WebIDL::ExceptionOr<void> set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value);
void remove_attribute(FlyString const& name); void remove_attribute(FlyString const& name);
DOM::ExceptionOr<bool> toggle_attribute(FlyString const& name, Optional<bool> force); WebIDL::ExceptionOr<bool> toggle_attribute(FlyString const& name, Optional<bool> force);
size_t attribute_list_size() const { return m_attributes->length(); } size_t attribute_list_size() const { return m_attributes->length(); }
NamedNodeMap const* attributes() const { return m_attributes.ptr(); } NamedNodeMap const* attributes() const { return m_attributes.ptr(); }
Vector<String> get_attribute_names() const; Vector<String> get_attribute_names() const;
DOMTokenList* class_list(); DOMTokenList* class_list();
DOM::ExceptionOr<bool> matches(StringView selectors) const; WebIDL::ExceptionOr<bool> matches(StringView selectors) const;
DOM::ExceptionOr<DOM::Element const*> closest(StringView selectors) const; WebIDL::ExceptionOr<DOM::Element const*> closest(StringView selectors) const;
int client_top() const; int client_top() const;
int client_left() const; int client_left() const;
@ -106,9 +106,9 @@ public:
CSS::CSSStyleDeclaration* style_for_bindings(); CSS::CSSStyleDeclaration* style_for_bindings();
String inner_html() const; String inner_html() const;
ExceptionOr<void> set_inner_html(String const&); WebIDL::ExceptionOr<void> set_inner_html(String const&);
ExceptionOr<void> insert_adjacent_html(String position, String text); WebIDL::ExceptionOr<void> insert_adjacent_html(String position, String text);
bool is_focused() const; bool is_focused() const;
bool is_active() const; bool is_active() const;
@ -172,6 +172,6 @@ private:
template<> template<>
inline bool Node::fast_is<Element>() const { return is_element(); } inline bool Node::fast_is<Element>() const { return is_element(); }
ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name); WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name);
} }

View file

@ -223,7 +223,7 @@ void EventTarget::remove_from_event_listener_list(DOMEventListener& listener)
} }
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent // https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
ExceptionOr<bool> EventTarget::dispatch_event_binding(Event& event) WebIDL::ExceptionOr<bool> EventTarget::dispatch_event_binding(Event& event)
{ {
// 1. If events dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException. // 1. If events dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException.
if (event.dispatched()) if (event.dispatched())

View file

@ -12,9 +12,9 @@
#include <LibJS/Forward.h> #include <LibJS/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/DOMEventListener.h> #include <LibWeb/DOM/DOMEventListener.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/HTML/EventHandler.h> #include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -34,7 +34,7 @@ public:
void remove_event_listener_without_options(FlyString const& type, IDLEventListener& callback); void remove_event_listener_without_options(FlyString const& type, IDLEventListener& callback);
virtual bool dispatch_event(Event&); virtual bool dispatch_event(Event&);
ExceptionOr<bool> dispatch_event_binding(Event&); WebIDL::ExceptionOr<bool> dispatch_event_binding(Event&);
virtual EventTarget* get_parent(Event const&) { return nullptr; } virtual EventTarget* get_parent(Event const&) { return nullptr; }

View file

@ -41,7 +41,7 @@ void MutationObserver::visit_edges(Cell::Visitor& visitor)
} }
// https://dom.spec.whatwg.org/#dom-mutationobserver-observe // https://dom.spec.whatwg.org/#dom-mutationobserver-observe
ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserverInit options) WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserverInit options)
{ {
// 1. If either options["attributeOldValue"] or options["attributeFilter"] exists, and options["attributes"] does not exist, then set options["attributes"] to true. // 1. If either options["attributeOldValue"] or options["attributeFilter"] exists, and options["attributes"] does not exist, then set options["attributes"] to true.
if ((options.attribute_old_value.has_value() || options.attribute_filter.has_value()) && !options.attributes.has_value()) if ((options.attribute_old_value.has_value() || options.attribute_filter.has_value()) && !options.attributes.has_value())
@ -53,22 +53,22 @@ ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserverInit o
// 3. If none of options["childList"], options["attributes"], and options["characterData"] is true, then throw a TypeError. // 3. If none of options["childList"], options["attributes"], and options["characterData"] is true, then throw a TypeError.
if (!options.child_list && (!options.attributes.has_value() || !options.attributes.value()) && (!options.character_data.has_value() || !options.character_data.value())) if (!options.child_list && (!options.attributes.has_value() || !options.attributes.value()) && (!options.character_data.has_value() || !options.character_data.value()))
return SimpleException { SimpleExceptionType::TypeError, "Options must have one of childList, attributes or characterData set to true." }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Options must have one of childList, attributes or characterData set to true." };
// 4. If options["attributeOldValue"] is true and options["attributes"] is false, then throw a TypeError. // 4. If options["attributeOldValue"] is true and options["attributes"] is false, then throw a TypeError.
// NOTE: If attributeOldValue is present, attributes will be present because of step 1. // NOTE: If attributeOldValue is present, attributes will be present because of step 1.
if (options.attribute_old_value.has_value() && options.attribute_old_value.value() && !options.attributes.value()) if (options.attribute_old_value.has_value() && options.attribute_old_value.value() && !options.attributes.value())
return SimpleException { SimpleExceptionType::TypeError, "attributes must be true if attributeOldValue is true." }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "attributes must be true if attributeOldValue is true." };
// 5. If options["attributeFilter"] is present and options["attributes"] is false, then throw a TypeError. // 5. If options["attributeFilter"] is present and options["attributes"] is false, then throw a TypeError.
// NOTE: If attributeFilter is present, attributes will be present because of step 1. // NOTE: If attributeFilter is present, attributes will be present because of step 1.
if (options.attribute_filter.has_value() && !options.attributes.value()) if (options.attribute_filter.has_value() && !options.attributes.value())
return SimpleException { SimpleExceptionType::TypeError, "attributes must be true if attributeFilter is present." }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "attributes must be true if attributeFilter is present." };
// 6. If options["characterDataOldValue"] is true and options["characterData"] is false, then throw a TypeError. // 6. If options["characterDataOldValue"] is true and options["characterData"] is false, then throw a TypeError.
// NOTE: If characterDataOldValue is present, characterData will be present because of step 2. // NOTE: If characterDataOldValue is present, characterData will be present because of step 2.
if (options.character_data_old_value.has_value() && options.character_data_old_value.value() && !options.character_data.value()) if (options.character_data_old_value.has_value() && options.character_data_old_value.value() && !options.character_data.value())
return SimpleException { SimpleExceptionType::TypeError, "characterData must be true if characterDataOldValue is true." }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "characterData must be true if characterDataOldValue is true." };
// 7. For each registered of targets registered observer list, if registereds observer is this: // 7. For each registered of targets registered observer list, if registereds observer is this:
bool updated_existing_observer = false; bool updated_existing_observer = false;

View file

@ -10,9 +10,9 @@
#include <AK/NonnullRefPtrVector.h> #include <AK/NonnullRefPtrVector.h>
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <LibJS/Heap/Handle.h> #include <LibJS/Heap/Handle.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/MutationRecord.h> #include <LibWeb/DOM/MutationRecord.h>
#include <LibWeb/WebIDL/CallbackType.h> #include <LibWeb/WebIDL/CallbackType.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -35,7 +35,7 @@ public:
static JS::NonnullGCPtr<MutationObserver> create_with_global_object(HTML::Window&, JS::GCPtr<WebIDL::CallbackType>); static JS::NonnullGCPtr<MutationObserver> create_with_global_object(HTML::Window&, JS::GCPtr<WebIDL::CallbackType>);
virtual ~MutationObserver() override; virtual ~MutationObserver() override;
ExceptionOr<void> observe(Node& target, MutationObserverInit options = {}); WebIDL::ExceptionOr<void> observe(Node& target, MutationObserverInit options = {});
void disconnect(); void disconnect();
Vector<JS::Handle<MutationRecord>> take_records(); Vector<JS::Handle<MutationRecord>> take_records();

View file

@ -80,13 +80,13 @@ Attr const* NamedNodeMap::get_named_item(StringView qualified_name) const
} }
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem // https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem
ExceptionOr<Attr const*> NamedNodeMap::set_named_item(Attr& attribute) WebIDL::ExceptionOr<Attr const*> NamedNodeMap::set_named_item(Attr& attribute)
{ {
return set_attribute(attribute); return set_attribute(attribute);
} }
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem // https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
ExceptionOr<Attr const*> NamedNodeMap::remove_named_item(StringView qualified_name) WebIDL::ExceptionOr<Attr const*> NamedNodeMap::remove_named_item(StringView qualified_name)
{ {
// 1. Let attr be the result of removing an attribute given qualifiedName and element. // 1. Let attr be the result of removing an attribute given qualifiedName and element.
auto const* attribute = remove_attribute(qualified_name); auto const* attribute = remove_attribute(qualified_name);
@ -133,7 +133,7 @@ Attr const* NamedNodeMap::get_attribute(StringView qualified_name, size_t* item_
} }
// https://dom.spec.whatwg.org/#concept-element-attributes-set // https://dom.spec.whatwg.org/#concept-element-attributes-set
ExceptionOr<Attr const*> NamedNodeMap::set_attribute(Attr& attribute) WebIDL::ExceptionOr<Attr const*> NamedNodeMap::set_attribute(Attr& attribute)
{ {
// 1. If attrs element is neither null nor element, throw an "InUseAttributeError" DOMException. // 1. If attrs element is neither null nor element, throw an "InUseAttributeError" DOMException.
if ((attribute.owner_element() != nullptr) && (attribute.owner_element() != &associated_element())) if ((attribute.owner_element() != nullptr) && (attribute.owner_element() != &associated_element()))

View file

@ -11,8 +11,8 @@
#include <AK/String.h> #include <AK/String.h>
#include <AK/StringView.h> #include <AK/StringView.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h> #include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -35,13 +35,13 @@ public:
// Methods defined by the spec for JavaScript: // Methods defined by the spec for JavaScript:
Attr const* item(u32 index) const; Attr const* item(u32 index) const;
Attr const* get_named_item(StringView qualified_name) const; Attr const* get_named_item(StringView qualified_name) const;
ExceptionOr<Attr const*> set_named_item(Attr& attribute); WebIDL::ExceptionOr<Attr const*> set_named_item(Attr& attribute);
ExceptionOr<Attr const*> remove_named_item(StringView qualified_name); WebIDL::ExceptionOr<Attr const*> remove_named_item(StringView qualified_name);
// Methods defined by the spec for internal use: // Methods defined by the spec for internal use:
Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr); Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr);
Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const; Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const;
ExceptionOr<Attr const*> set_attribute(Attr& attribute); WebIDL::ExceptionOr<Attr const*> set_attribute(Attr& attribute);
void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index); void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index);
void append_attribute(Attr& attribute); void append_attribute(Attr& attribute);
Attr const* remove_attribute(StringView qualified_name); Attr const* remove_attribute(StringView qualified_name);

View file

@ -311,7 +311,7 @@ Element const* Node::parent_element() const
} }
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity // https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const
{ {
// 1. If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. // 1. If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this)) if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this))
@ -456,7 +456,7 @@ void Node::insert_before(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child, boo
} }
// https://dom.spec.whatwg.org/#concept-node-pre-insert // https://dom.spec.whatwg.org/#concept-node-pre-insert
ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_insert(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_insert(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child)
{ {
// 1. Ensure pre-insertion validity of node into parent before child. // 1. Ensure pre-insertion validity of node into parent before child.
TRY(ensure_pre_insertion_validity(node, child)); TRY(ensure_pre_insertion_validity(node, child));
@ -476,14 +476,14 @@ ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_insert(JS::NonnullGCPtr<Node> node
} }
// https://dom.spec.whatwg.org/#dom-node-removechild // https://dom.spec.whatwg.org/#dom-node-removechild
ExceptionOr<JS::NonnullGCPtr<Node>> Node::remove_child(JS::NonnullGCPtr<Node> child) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::remove_child(JS::NonnullGCPtr<Node> child)
{ {
// The removeChild(child) method steps are to return the result of pre-removing child from this. // The removeChild(child) method steps are to return the result of pre-removing child from this.
return pre_remove(child); return pre_remove(child);
} }
// https://dom.spec.whatwg.org/#concept-node-pre-remove // https://dom.spec.whatwg.org/#concept-node-pre-remove
ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_remove(JS::NonnullGCPtr<Node> child) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_remove(JS::NonnullGCPtr<Node> child)
{ {
// 1. If childs parent is not parent, then throw a "NotFoundError" DOMException. // 1. If childs parent is not parent, then throw a "NotFoundError" DOMException.
if (child->parent() != this) if (child->parent() != this)
@ -497,7 +497,7 @@ ExceptionOr<JS::NonnullGCPtr<Node>> Node::pre_remove(JS::NonnullGCPtr<Node> chil
} }
// https://dom.spec.whatwg.org/#concept-node-append // https://dom.spec.whatwg.org/#concept-node-append
ExceptionOr<JS::NonnullGCPtr<Node>> Node::append_child(JS::NonnullGCPtr<Node> node) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::append_child(JS::NonnullGCPtr<Node> node)
{ {
// To append a node to a parent, pre-insert node into parent before null. // To append a node to a parent, pre-insert node into parent before null.
return pre_insert(node, nullptr); return pre_insert(node, nullptr);
@ -608,7 +608,7 @@ void Node::remove(bool suppress_observers)
} }
// https://dom.spec.whatwg.org/#concept-node-replace // https://dom.spec.whatwg.org/#concept-node-replace
ExceptionOr<JS::NonnullGCPtr<Node>> Node::replace_child(JS::NonnullGCPtr<Node> node, JS::NonnullGCPtr<Node> child) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::replace_child(JS::NonnullGCPtr<Node> node, JS::NonnullGCPtr<Node> child)
{ {
// If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. // If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this)) if (!is<Document>(this) && !is<DocumentFragment>(this) && !is<Element>(this))
@ -792,7 +792,7 @@ JS::NonnullGCPtr<Node> Node::clone_node(Document* document, bool clone_children)
} }
// https://dom.spec.whatwg.org/#dom-node-clonenode // https://dom.spec.whatwg.org/#dom-node-clonenode
ExceptionOr<JS::NonnullGCPtr<Node>> Node::clone_node_binding(bool deep) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> Node::clone_node_binding(bool deep)
{ {
// 1. If this is a shadow root, then throw a "NotSupportedError" DOMException. // 1. If this is a shadow root, then throw a "NotSupportedError" DOMException.
if (is<ShadowRoot>(*this)) if (is<ShadowRoot>(*this))

View file

@ -13,7 +13,7 @@
#include <AK/TypeCasts.h> #include <AK/TypeCasts.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -81,21 +81,21 @@ public:
virtual bool is_html_template_element() const { return false; } virtual bool is_html_template_element() const { return false; }
virtual bool is_browsing_context_container() const { return false; } virtual bool is_browsing_context_container() const { return false; }
ExceptionOr<JS::NonnullGCPtr<Node>> pre_insert(JS::NonnullGCPtr<Node>, JS::GCPtr<Node>); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_insert(JS::NonnullGCPtr<Node>, JS::GCPtr<Node>);
ExceptionOr<JS::NonnullGCPtr<Node>> pre_remove(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> pre_remove(JS::NonnullGCPtr<Node>);
ExceptionOr<JS::NonnullGCPtr<Node>> append_child(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> append_child(JS::NonnullGCPtr<Node>);
ExceptionOr<JS::NonnullGCPtr<Node>> remove_child(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> remove_child(JS::NonnullGCPtr<Node>);
void insert_before(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child, bool suppress_observers = false); void insert_before(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child, bool suppress_observers = false);
void remove(bool suppress_observers = false); void remove(bool suppress_observers = false);
void remove_all_children(bool suppress_observers = false); void remove_all_children(bool suppress_observers = false);
u16 compare_document_position(JS::GCPtr<Node> other); u16 compare_document_position(JS::GCPtr<Node> other);
ExceptionOr<JS::NonnullGCPtr<Node>> replace_child(JS::NonnullGCPtr<Node> node, JS::NonnullGCPtr<Node> child); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> replace_child(JS::NonnullGCPtr<Node> node, JS::NonnullGCPtr<Node> child);
JS::NonnullGCPtr<Node> clone_node(Document* document = nullptr, bool clone_children = false); JS::NonnullGCPtr<Node> clone_node(Document* document = nullptr, bool clone_children = false);
ExceptionOr<JS::NonnullGCPtr<Node>> clone_node_binding(bool deep); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> clone_node_binding(bool deep);
// NOTE: This is intended for the JS bindings. // NOTE: This is intended for the JS bindings.
bool has_child_nodes() const { return has_children(); } bool has_child_nodes() const { return has_children(); }
@ -177,7 +177,7 @@ public:
template<typename T> template<typename T>
bool fast_is() const = delete; bool fast_is() const = delete;
ExceptionOr<void> ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const; WebIDL::ExceptionOr<void> ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const;
bool is_host_including_inclusive_ancestor_of(Node const&) const; bool is_host_including_inclusive_ancestor_of(Node const&) const;

View file

@ -14,7 +14,7 @@
namespace Web::DOM { namespace Web::DOM {
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node // https://dom.spec.whatwg.org/#converting-nodes-into-a-node
ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document) WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document)
{ {
// 1. Let node be null. // 1. Let node be null.
// 2. Replace each string in nodes with a new Text node whose data is the string and node document is document. // 2. Replace each string in nodes with a new Text node whose data is the string and node document is document.

View file

@ -12,6 +12,6 @@
namespace Web::DOM { namespace Web::DOM {
ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document); WebIDL::ExceptionOr<JS::NonnullGCPtr<Node>> convert_nodes_to_single_node(Vector<Variant<JS::Handle<Node>, String>> const& nodes, DOM::Document& document);
} }

View file

@ -18,7 +18,7 @@
namespace Web::DOM { namespace Web::DOM {
ExceptionOr<JS::GCPtr<Element>> ParentNode::query_selector(StringView selector_text) WebIDL::ExceptionOr<JS::GCPtr<Element>> ParentNode::query_selector(StringView selector_text)
{ {
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text); auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text);
if (!maybe_selectors.has_value()) if (!maybe_selectors.has_value())
@ -41,7 +41,7 @@ ExceptionOr<JS::GCPtr<Element>> ParentNode::query_selector(StringView selector_t
return result; return result;
} }
ExceptionOr<JS::NonnullGCPtr<NodeList>> ParentNode::query_selector_all(StringView selector_text) WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> ParentNode::query_selector_all(StringView selector_text)
{ {
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text); auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text);
if (!maybe_selectors.has_value()) if (!maybe_selectors.has_value())
@ -168,7 +168,7 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name_ns(FlyStri
} }
// https://dom.spec.whatwg.org/#dom-parentnode-prepend // https://dom.spec.whatwg.org/#dom-parentnode-prepend
ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document. // 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document())); auto node = TRY(convert_nodes_to_single_node(nodes, document()));
@ -179,7 +179,7 @@ ExceptionOr<void> ParentNode::prepend(Vector<Variant<JS::Handle<Node>, String>>
return {}; return {};
} }
ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document. // 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document())); auto node = TRY(convert_nodes_to_single_node(nodes, document()));
@ -190,7 +190,7 @@ ExceptionOr<void> ParentNode::append(Vector<Variant<JS::Handle<Node>, String>> c
return {}; return {};
} }
ExceptionOr<void> ParentNode::replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes) WebIDL::ExceptionOr<void> ParentNode::replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes)
{ {
// 1. Let node be the result of converting nodes into a node given nodes and thiss node document. // 1. Let node be the result of converting nodes into a node given nodes and thiss node document.
auto node = TRY(convert_nodes_to_single_node(nodes, document())); auto node = TRY(convert_nodes_to_single_node(nodes, document()));

View file

@ -23,17 +23,17 @@ public:
JS::GCPtr<Element> last_element_child(); JS::GCPtr<Element> last_element_child();
u32 child_element_count() const; u32 child_element_count() const;
ExceptionOr<JS::GCPtr<Element>> query_selector(StringView); WebIDL::ExceptionOr<JS::GCPtr<Element>> query_selector(StringView);
ExceptionOr<JS::NonnullGCPtr<NodeList>> query_selector_all(StringView); WebIDL::ExceptionOr<JS::NonnullGCPtr<NodeList>> query_selector_all(StringView);
JS::NonnullGCPtr<HTMLCollection> children(); JS::NonnullGCPtr<HTMLCollection> children();
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name(FlyString const&); JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name(FlyString const&);
JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name_ns(FlyString const&, FlyString const&); JS::NonnullGCPtr<HTMLCollection> get_elements_by_tag_name_ns(FlyString const&, FlyString const&);
ExceptionOr<void> prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes); WebIDL::ExceptionOr<void> prepend(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
ExceptionOr<void> append(Vector<Variant<JS::Handle<Node>, String>> const& nodes); WebIDL::ExceptionOr<void> append(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
ExceptionOr<void> replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes); WebIDL::ExceptionOr<void> replace_children(Vector<Variant<JS::Handle<Node>, String>> const& nodes);
protected: protected:
ParentNode(JS::Realm& realm, Document& document, NodeType type) ParentNode(JS::Realm& realm, Document& document, NodeType type)

View file

@ -131,7 +131,7 @@ static RelativeBoundaryPointPosition position_of_boundary_point_relative_to_othe
return RelativeBoundaryPointPosition::Before; return RelativeBoundaryPointPosition::Before;
} }
ExceptionOr<void> Range::set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end) WebIDL::ExceptionOr<void> Range::set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end)
{ {
// To set the start or end of a range to a boundary point (node, offset), run these steps: // To set the start or end of a range to a boundary point (node, offset), run these steps:
@ -176,20 +176,20 @@ ExceptionOr<void> Range::set_start_or_end(Node& node, u32 offset, StartOrEnd sta
} }
// https://dom.spec.whatwg.org/#concept-range-bp-set // https://dom.spec.whatwg.org/#concept-range-bp-set
ExceptionOr<void> Range::set_start(Node& node, u32 offset) WebIDL::ExceptionOr<void> Range::set_start(Node& node, u32 offset)
{ {
// The setStart(node, offset) method steps are to set the start of this to boundary point (node, offset). // The setStart(node, offset) method steps are to set the start of this to boundary point (node, offset).
return set_start_or_end(node, offset, StartOrEnd::Start); return set_start_or_end(node, offset, StartOrEnd::Start);
} }
ExceptionOr<void> Range::set_end(Node& node, u32 offset) WebIDL::ExceptionOr<void> Range::set_end(Node& node, u32 offset)
{ {
// The setEnd(node, offset) method steps are to set the end of this to boundary point (node, offset). // The setEnd(node, offset) method steps are to set the end of this to boundary point (node, offset).
return set_start_or_end(node, offset, StartOrEnd::End); return set_start_or_end(node, offset, StartOrEnd::End);
} }
// https://dom.spec.whatwg.org/#dom-range-setstartbefore // https://dom.spec.whatwg.org/#dom-range-setstartbefore
ExceptionOr<void> Range::set_start_before(Node& node) WebIDL::ExceptionOr<void> Range::set_start_before(Node& node)
{ {
// 1. Let parent be nodes parent. // 1. Let parent be nodes parent.
auto* parent = node.parent(); auto* parent = node.parent();
@ -203,7 +203,7 @@ ExceptionOr<void> Range::set_start_before(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-range-setstartafter // https://dom.spec.whatwg.org/#dom-range-setstartafter
ExceptionOr<void> Range::set_start_after(Node& node) WebIDL::ExceptionOr<void> Range::set_start_after(Node& node)
{ {
// 1. Let parent be nodes parent. // 1. Let parent be nodes parent.
auto* parent = node.parent(); auto* parent = node.parent();
@ -217,7 +217,7 @@ ExceptionOr<void> Range::set_start_after(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-range-setendbefore // https://dom.spec.whatwg.org/#dom-range-setendbefore
ExceptionOr<void> Range::set_end_before(Node& node) WebIDL::ExceptionOr<void> Range::set_end_before(Node& node)
{ {
// 1. Let parent be nodes parent. // 1. Let parent be nodes parent.
auto* parent = node.parent(); auto* parent = node.parent();
@ -231,7 +231,7 @@ ExceptionOr<void> Range::set_end_before(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-range-setendafter // https://dom.spec.whatwg.org/#dom-range-setendafter
ExceptionOr<void> Range::set_end_after(Node& node) WebIDL::ExceptionOr<void> Range::set_end_after(Node& node)
{ {
// 1. Let parent be nodes parent. // 1. Let parent be nodes parent.
auto* parent = node.parent(); auto* parent = node.parent();
@ -245,7 +245,7 @@ ExceptionOr<void> Range::set_end_after(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-range-compareboundarypoints // https://dom.spec.whatwg.org/#dom-range-compareboundarypoints
ExceptionOr<i16> Range::compare_boundary_points(u16 how, Range const& source_range) const WebIDL::ExceptionOr<i16> Range::compare_boundary_points(u16 how, Range const& source_range) const
{ {
// 1. If how is not one of // 1. If how is not one of
// - START_TO_START, // - START_TO_START,
@ -332,7 +332,7 @@ ExceptionOr<i16> Range::compare_boundary_points(u16 how, Range const& source_ran
} }
// https://dom.spec.whatwg.org/#concept-range-select // https://dom.spec.whatwg.org/#concept-range-select
ExceptionOr<void> Range::select(Node& node) WebIDL::ExceptionOr<void> Range::select(Node& node)
{ {
// 1. Let parent be nodes parent. // 1. Let parent be nodes parent.
auto* parent = node.parent(); auto* parent = node.parent();
@ -356,7 +356,7 @@ ExceptionOr<void> Range::select(Node& node)
} }
// https://dom.spec.whatwg.org/#dom-range-selectnode // https://dom.spec.whatwg.org/#dom-range-selectnode
ExceptionOr<void> Range::select_node(Node& node) WebIDL::ExceptionOr<void> Range::select_node(Node& node)
{ {
// The selectNode(node) method steps are to select node within this. // The selectNode(node) method steps are to select node within this.
return select(node); return select(node);
@ -377,7 +377,7 @@ void Range::collapse(bool to_start)
} }
// https://dom.spec.whatwg.org/#dom-range-selectnodecontents // https://dom.spec.whatwg.org/#dom-range-selectnodecontents
ExceptionOr<void> Range::select_node_contents(Node const& node) WebIDL::ExceptionOr<void> Range::select_node_contents(Node const& node)
{ {
// 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException. // 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(node)) if (is<DocumentType>(node))
@ -466,7 +466,7 @@ bool Range::intersects_node(Node const& node) const
} }
// https://dom.spec.whatwg.org/#dom-range-ispointinrange // https://dom.spec.whatwg.org/#dom-range-ispointinrange
ExceptionOr<bool> Range::is_point_in_range(Node const& node, u32 offset) const WebIDL::ExceptionOr<bool> Range::is_point_in_range(Node const& node, u32 offset) const
{ {
// 1. If nodes root is different from thiss root, return false. // 1. If nodes root is different from thiss root, return false.
if (&node.root() != &root()) if (&node.root() != &root())
@ -491,7 +491,7 @@ ExceptionOr<bool> Range::is_point_in_range(Node const& node, u32 offset) const
} }
// https://dom.spec.whatwg.org/#dom-range-comparepoint // https://dom.spec.whatwg.org/#dom-range-comparepoint
ExceptionOr<i16> Range::compare_point(Node const& node, u32 offset) const WebIDL::ExceptionOr<i16> Range::compare_point(Node const& node, u32 offset) const
{ {
// 1. If nodes root is different from thiss root, then throw a "WrongDocumentError" DOMException. // 1. If nodes root is different from thiss root, then throw a "WrongDocumentError" DOMException.
if (&node.root() != &root()) if (&node.root() != &root())
@ -549,13 +549,13 @@ String Range::to_string() const
} }
// https://dom.spec.whatwg.org/#dom-range-extractcontents // https://dom.spec.whatwg.org/#dom-range-extractcontents
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract_contents() WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract_contents()
{ {
return extract(); return extract();
} }
// https://dom.spec.whatwg.org/#concept-range-extract // https://dom.spec.whatwg.org/#concept-range-extract
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract() WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::extract()
{ {
// 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document. // 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document.
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document())); auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
@ -771,13 +771,13 @@ bool Range::partially_contains_node(Node const& node) const
} }
// https://dom.spec.whatwg.org/#dom-range-insertnode // https://dom.spec.whatwg.org/#dom-range-insertnode
ExceptionOr<void> Range::insert_node(JS::NonnullGCPtr<Node> node) WebIDL::ExceptionOr<void> Range::insert_node(JS::NonnullGCPtr<Node> node)
{ {
return insert(node); return insert(node);
} }
// https://dom.spec.whatwg.org/#concept-range-insert // https://dom.spec.whatwg.org/#concept-range-insert
ExceptionOr<void> Range::insert(JS::NonnullGCPtr<Node> node) WebIDL::ExceptionOr<void> Range::insert(JS::NonnullGCPtr<Node> node)
{ {
// 1. If ranges start node is a ProcessingInstruction or Comment node, is a Text node whose parent is null, or is node, then throw a "HierarchyRequestError" DOMException. // 1. If ranges start node is a ProcessingInstruction or Comment node, is a Text node whose parent is null, or is node, then throw a "HierarchyRequestError" DOMException.
if ((is<ProcessingInstruction>(*m_start_container) || is<Comment>(*m_start_container)) if ((is<ProcessingInstruction>(*m_start_container) || is<Comment>(*m_start_container))
@ -844,7 +844,7 @@ ExceptionOr<void> Range::insert(JS::NonnullGCPtr<Node> node)
} }
// https://dom.spec.whatwg.org/#dom-range-surroundcontents // https://dom.spec.whatwg.org/#dom-range-surroundcontents
ExceptionOr<void> Range::surround_contents(JS::NonnullGCPtr<Node> new_parent) WebIDL::ExceptionOr<void> Range::surround_contents(JS::NonnullGCPtr<Node> new_parent)
{ {
// 1. If a non-Text node is partially contained in this, then throw an "InvalidStateError" DOMException. // 1. If a non-Text node is partially contained in this, then throw an "InvalidStateError" DOMException.
Node* start_non_text_node = start_container(); Node* start_non_text_node = start_container();
@ -878,13 +878,13 @@ ExceptionOr<void> Range::surround_contents(JS::NonnullGCPtr<Node> new_parent)
} }
// https://dom.spec.whatwg.org/#dom-range-clonecontents // https://dom.spec.whatwg.org/#dom-range-clonecontents
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_contents() WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_contents()
{ {
return clone_the_contents(); return clone_the_contents();
} }
// https://dom.spec.whatwg.org/#concept-range-clone // https://dom.spec.whatwg.org/#concept-range-clone
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_contents() WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_contents()
{ {
// 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document. // 1. Let fragment be a new DocumentFragment node whose node document is ranges start nodes node document.
auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document())); auto* fragment = heap().allocate<DOM::DocumentFragment>(realm(), const_cast<Document&>(start_container()->document()));
@ -1040,7 +1040,7 @@ ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> Range::clone_the_contents()
} }
// https://dom.spec.whatwg.org/#dom-range-deletecontents // https://dom.spec.whatwg.org/#dom-range-deletecontents
ExceptionOr<void> Range::delete_contents() WebIDL::ExceptionOr<void> Range::delete_contents()
{ {
// 1. If this is collapsed, then return. // 1. If this is collapsed, then return.
if (collapsed()) if (collapsed())

View file

@ -27,15 +27,15 @@ public:
// FIXME: There are a ton of methods missing here. // FIXME: There are a ton of methods missing here.
ExceptionOr<void> set_start(Node& node, u32 offset); WebIDL::ExceptionOr<void> set_start(Node& node, u32 offset);
ExceptionOr<void> set_end(Node& node, u32 offset); WebIDL::ExceptionOr<void> set_end(Node& node, u32 offset);
ExceptionOr<void> set_start_before(Node& node); WebIDL::ExceptionOr<void> set_start_before(Node& node);
ExceptionOr<void> set_start_after(Node& node); WebIDL::ExceptionOr<void> set_start_after(Node& node);
ExceptionOr<void> set_end_before(Node& node); WebIDL::ExceptionOr<void> set_end_before(Node& node);
ExceptionOr<void> set_end_after(Node& node); WebIDL::ExceptionOr<void> set_end_after(Node& node);
ExceptionOr<void> select_node(Node& node); WebIDL::ExceptionOr<void> select_node(Node& node);
void collapse(bool to_start); void collapse(bool to_start);
ExceptionOr<void> select_node_contents(Node const&); WebIDL::ExceptionOr<void> select_node_contents(Node const&);
// https://dom.spec.whatwg.org/#dom-range-start_to_start // https://dom.spec.whatwg.org/#dom-range-start_to_start
enum HowToCompareBoundaryPoints : u16 { enum HowToCompareBoundaryPoints : u16 {
@ -45,7 +45,7 @@ public:
END_TO_START = 3, END_TO_START = 3,
}; };
ExceptionOr<i16> compare_boundary_points(u16 how, Range const& source_range) const; WebIDL::ExceptionOr<i16> compare_boundary_points(u16 how, Range const& source_range) const;
JS::NonnullGCPtr<Range> inverted() const; JS::NonnullGCPtr<Range> inverted() const;
JS::NonnullGCPtr<Range> normalized() const; JS::NonnullGCPtr<Range> normalized() const;
@ -61,15 +61,15 @@ public:
} }
bool intersects_node(Node const&) const; bool intersects_node(Node const&) const;
ExceptionOr<bool> is_point_in_range(Node const&, u32 offset) const; WebIDL::ExceptionOr<bool> is_point_in_range(Node const&, u32 offset) const;
ExceptionOr<i16> compare_point(Node const&, u32 offset) const; WebIDL::ExceptionOr<i16> compare_point(Node const&, u32 offset) const;
ExceptionOr<void> delete_contents(); WebIDL::ExceptionOr<void> delete_contents();
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> extract_contents(); WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> extract_contents();
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> clone_contents(); WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> clone_contents();
ExceptionOr<void> insert_node(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<void> insert_node(JS::NonnullGCPtr<Node>);
ExceptionOr<void> surround_contents(JS::NonnullGCPtr<Node> new_parent); WebIDL::ExceptionOr<void> surround_contents(JS::NonnullGCPtr<Node> new_parent);
String to_string() const; String to_string() const;
@ -84,12 +84,12 @@ private:
End, End,
}; };
ExceptionOr<void> set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end); WebIDL::ExceptionOr<void> set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end);
ExceptionOr<void> select(Node& node); WebIDL::ExceptionOr<void> select(Node& node);
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> extract(); WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> extract();
ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> clone_the_contents(); WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> clone_the_contents();
ExceptionOr<void> insert(JS::NonnullGCPtr<Node>); WebIDL::ExceptionOr<void> insert(JS::NonnullGCPtr<Node>);
bool contains_node(Node const&) const; bool contains_node(Node const&) const;
bool partially_contains_node(Node const&) const; bool partially_contains_node(Node const&) const;

View file

@ -37,7 +37,7 @@ String ShadowRoot::inner_html() const
} }
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
ExceptionOr<void> ShadowRoot::set_inner_html(String const& markup) WebIDL::ExceptionOr<void> ShadowRoot::set_inner_html(String const& markup)
{ {
TRY(DOMParsing::inner_html_setter(*this, markup)); TRY(DOMParsing::inner_html_setter(*this, markup));

View file

@ -29,7 +29,7 @@ public:
String mode() const { return m_closed ? "closed" : "open"; } String mode() const { return m_closed ? "closed" : "open"; }
String inner_html() const; String inner_html() const;
ExceptionOr<void> set_inner_html(String const&); WebIDL::ExceptionOr<void> set_inner_html(String const&);
private: private:
ShadowRoot(Document&, Element&); ShadowRoot(Document&, Element&);

View file

@ -9,8 +9,8 @@
#include <LibWeb/DOM/Attr.h> #include <LibWeb/DOM/Attr.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentType.h> #include <LibWeb/DOM/DocumentType.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/StaticRange.h> #include <LibWeb/DOM/StaticRange.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM { namespace Web::DOM {
@ -23,7 +23,7 @@ StaticRange::StaticRange(Node& start_container, u32 start_offset, Node& end_cont
StaticRange::~StaticRange() = default; StaticRange::~StaticRange() = default;
// https://dom.spec.whatwg.org/#dom-staticrange-staticrange // https://dom.spec.whatwg.org/#dom-staticrange-staticrange
ExceptionOr<StaticRange*> StaticRange::create_with_global_object(HTML::Window& window, StaticRangeInit& init) WebIDL::ExceptionOr<StaticRange*> StaticRange::create_with_global_object(HTML::Window& window, StaticRangeInit& init)
{ {
// 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException. // 1. If init["startContainer"] or init["endContainer"] is a DocumentType or Attr node, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(*init.start_container) || is<Attr>(*init.start_container)) if (is<DocumentType>(*init.start_container) || is<Attr>(*init.start_container))

View file

@ -24,7 +24,7 @@ class StaticRange final : public AbstractRange {
WEB_PLATFORM_OBJECT(StaticRange, JS::Object); WEB_PLATFORM_OBJECT(StaticRange, JS::Object);
public: public:
static ExceptionOr<StaticRange*> create_with_global_object(HTML::Window&, StaticRangeInit& init); static WebIDL::ExceptionOr<StaticRange*> create_with_global_object(HTML::Window&, StaticRangeInit& init);
StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
virtual ~StaticRange() override; virtual ~StaticRange() override;

View file

@ -43,7 +43,7 @@ void Text::set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInpu
// https://dom.spec.whatwg.org/#dom-text-splittext // https://dom.spec.whatwg.org/#dom-text-splittext
// https://dom.spec.whatwg.org/#concept-text-split // https://dom.spec.whatwg.org/#concept-text-split
ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset) WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> Text::split_text(size_t offset)
{ {
// 1. Let length be nodes length. // 1. Let length be nodes length.
auto length = this->length(); auto length = this->length();

View file

@ -29,7 +29,7 @@ public:
void set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement&); void set_owner_input_element(Badge<HTML::HTMLInputElement>, HTML::HTMLInputElement&);
HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element.ptr(); } HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element.ptr(); }
ExceptionOr<JS::NonnullGCPtr<Text>> split_text(size_t offset); WebIDL::ExceptionOr<JS::NonnullGCPtr<Text>> split_text(size_t offset);
protected: protected:
explicit Text(Document&, String const&); explicit Text(Document&, String const&);

View file

@ -5,14 +5,14 @@
*/ */
#include <LibWeb/DOM/DocumentFragment.h> #include <LibWeb/DOM/DocumentFragment.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOMParsing/InnerHTML.h> #include <LibWeb/DOMParsing/InnerHTML.h>
#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOMParsing { namespace Web::DOMParsing {
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm // https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm
DOM::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(String const& markup, DOM::Element& context_element) WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(String const& markup, DOM::Element& context_element)
{ {
// FIXME: Handle XML documents. // FIXME: Handle XML documents.
@ -30,7 +30,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(String
} }
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
DOM::ExceptionOr<void> inner_html_setter(JS::NonnullGCPtr<DOM::Node> context_object, String const& value) WebIDL::ExceptionOr<void> inner_html_setter(JS::NonnullGCPtr<DOM::Node> context_object, String const& value)
{ {
// 1. Let context element be the context object's host if the context object is a ShadowRoot object, or the context object otherwise. // 1. Let context element be the context object's host if the context object is a ShadowRoot object, or the context object otherwise.
// (This is handled in Element and ShadowRoot) // (This is handled in Element and ShadowRoot)

View file

@ -7,15 +7,15 @@
#pragma once #pragma once
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/ShadowRoot.h> #include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/HTML/HTMLTemplateElement.h> #include <LibWeb/HTML/HTMLTemplateElement.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOMParsing { namespace Web::DOMParsing {
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
DOM::ExceptionOr<void> inner_html_setter(JS::NonnullGCPtr<DOM::Node> context_object, String const& value); WebIDL::ExceptionOr<void> inner_html_setter(JS::NonnullGCPtr<DOM::Node> context_object, String const& value);
DOM::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(String const& markup, DOM::Element& context_element); WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::DocumentFragment>> parse_fragment(String const& markup, DOM::Element& context_element);
} }

View file

@ -10,13 +10,13 @@
#include <LibWeb/DOM/DocumentFragment.h> #include <LibWeb/DOM/DocumentFragment.h>
#include <LibWeb/DOM/DocumentType.h> #include <LibWeb/DOM/DocumentType.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/Node.h> #include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/ProcessingInstruction.h> #include <LibWeb/DOM/ProcessingInstruction.h>
#include <LibWeb/DOM/Text.h> #include <LibWeb/DOM/Text.h>
#include <LibWeb/DOMParsing/XMLSerializer.h> #include <LibWeb/DOMParsing/XMLSerializer.h>
#include <LibWeb/HTML/HTMLTemplateElement.h> #include <LibWeb/HTML/HTMLTemplateElement.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOMParsing { namespace Web::DOMParsing {
@ -34,7 +34,7 @@ XMLSerializer::XMLSerializer(HTML::Window& window)
XMLSerializer::~XMLSerializer() = default; XMLSerializer::~XMLSerializer() = default;
// https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring
DOM::ExceptionOr<String> XMLSerializer::serialize_to_string(JS::NonnullGCPtr<DOM::Node> root) WebIDL::ExceptionOr<String> XMLSerializer::serialize_to_string(JS::NonnullGCPtr<DOM::Node> root)
{ {
// The serializeToString(root) method must produce an XML serialization of root passing a value of false for the require well-formed parameter, and return the result. // The serializeToString(root) method must produce an XML serialization of root passing a value of false for the require well-formed parameter, and return the result.
return serialize_node_to_xml_string(root, RequireWellFormed::No); return serialize_node_to_xml_string(root, RequireWellFormed::No);
@ -113,10 +113,10 @@ static bool prefix_is_in_prefix_map(String const& prefix, HashMap<FlyString, Vec
return candidates_list_iterator->value.contains_slow(prefix); return candidates_list_iterator->value.contains_slow(prefix);
} }
DOM::ExceptionOr<String> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); WebIDL::ExceptionOr<String> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed);
// https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization
DOM::ExceptionOr<String> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed) WebIDL::ExceptionOr<String> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed)
{ {
// 1. Let namespace be a context namespace with value null. The context namespace tracks the XML serialization algorithm's current default namespace. // 1. Let namespace be a context namespace with value null. The context namespace tracks the XML serialization algorithm's current default namespace.
// The context namespace is changed when either an Element Node has a default namespace declaration, or the algorithm generates a default namespace declaration // The context namespace is changed when either an Element Node has a default namespace declaration, or the algorithm generates a default namespace declaration
@ -140,16 +140,16 @@ DOM::ExceptionOr<String> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node
return serialize_node_to_xml_string_impl(root, namespace_, prefix_map, prefix_index, require_well_formed); return serialize_node_to_xml_string_impl(root, namespace_, prefix_map, prefix_index, require_well_formed);
} }
static DOM::ExceptionOr<String> serialize_element(DOM::Element const& element, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_element(DOM::Element const& element, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_document(DOM::Document const& document, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_document(DOM::Document const& document, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_text(DOM::Text const& text, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_text(DOM::Text const& text, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed);
static DOM::ExceptionOr<String> serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed); static WebIDL::ExceptionOr<String> serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed);
// https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-algorithm // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-algorithm
DOM::ExceptionOr<String> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) WebIDL::ExceptionOr<String> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM::Node> root, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed)
{ {
// Each of the following algorithms for producing an XML serialization of a DOM node take as input a node to serialize and the following arguments: // Each of the following algorithms for producing an XML serialization of a DOM node take as input a node to serialize and the following arguments:
// - A context namespace namespace // - A context namespace namespace
@ -212,7 +212,7 @@ DOM::ExceptionOr<String> serialize_node_to_xml_string_impl(JS::NonnullGCPtr<DOM:
// -> Anything else // -> Anything else
// Throw a TypeError. Only Nodes and Attr objects can be serialized by this algorithm. // Throw a TypeError. Only Nodes and Attr objects can be serialized by this algorithm.
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Can only serialize Nodes or Attributes." }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Can only serialize Nodes or Attributes." };
} }
// https://w3c.github.io/DOM-Parsing/#dfn-recording-the-namespace-information // https://w3c.github.io/DOM-Parsing/#dfn-recording-the-namespace-information
@ -273,7 +273,7 @@ static Optional<String> record_namespace_information(DOM::Element const& element
} }
// https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value // https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
static DOM::ExceptionOr<String> serialize_an_attribute_value(String const& attribute_value, [[maybe_unused]] RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_an_attribute_value(String const& attribute_value, [[maybe_unused]] RequireWellFormed require_well_formed)
{ {
// FIXME: 1. If the require well-formed flag is set (its value is true), and attribute value contains characters that are not matched by the XML Char production, // FIXME: 1. If the require well-formed flag is set (its value is true), and attribute value contains characters that are not matched by the XML Char production,
// then throw an exception; the serialization of this attribute value would fail to produce a well-formed element serialization. // then throw an exception; the serialization of this attribute value would fail to produce a well-formed element serialization.
@ -306,7 +306,7 @@ struct LocalNameSetEntry {
}; };
// https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-of-the-attributes // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-of-the-attributes
static DOM::ExceptionOr<String> serialize_element_attributes(DOM::Element const& element, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, HashMap<String, String> const& local_prefixes_map, bool ignore_namespace_definition_attribute, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_element_attributes(DOM::Element const& element, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, HashMap<String, String> const& local_prefixes_map, bool ignore_namespace_definition_attribute, RequireWellFormed require_well_formed)
{ {
auto& global_object = element.global_object(); auto& global_object = element.global_object();
@ -459,7 +459,7 @@ static DOM::ExceptionOr<String> serialize_element_attributes(DOM::Element const&
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node
static DOM::ExceptionOr<String> serialize_element(DOM::Element const& element, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_element(DOM::Element const& element, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed)
{ {
auto& global_object = element.global_object(); auto& global_object = element.global_object();
@ -701,7 +701,7 @@ static DOM::ExceptionOr<String> serialize_element(DOM::Element const& element, O
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
static DOM::ExceptionOr<String> serialize_document(DOM::Document const& document, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_document(DOM::Document const& document, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed)
{ {
// If the require well-formed flag is set (its value is true), and this node has no documentElement (the documentElement attribute's value is null), // If the require well-formed flag is set (its value is true), and this node has no documentElement (the documentElement attribute's value is null),
// then throw an exception; the serialization of this node would not be a well-formed document. // then throw an exception; the serialization of this node would not be a well-formed document.
@ -721,7 +721,7 @@ static DOM::ExceptionOr<String> serialize_document(DOM::Document const& document
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-comment-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-comment-node
static DOM::ExceptionOr<String> serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed)
{ {
// If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production // If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production
// or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; // or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception;
@ -741,7 +741,7 @@ static DOM::ExceptionOr<String> serialize_comment(DOM::Comment const& comment, R
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
static DOM::ExceptionOr<String> serialize_text(DOM::Text const& text, [[maybe_unused]] RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_text(DOM::Text const& text, [[maybe_unused]] RequireWellFormed require_well_formed)
{ {
// FIXME: 1. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production, // FIXME: 1. If the require well-formed flag is set (its value is true), and node's data contains characters that are not matched by the XML Char production,
// then throw an exception; the serialization of this node's data would not be well-formed. // then throw an exception; the serialization of this node's data would not be well-formed.
@ -763,7 +763,7 @@ static DOM::ExceptionOr<String> serialize_text(DOM::Text const& text, [[maybe_un
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documentfragment-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documentfragment-node
static DOM::ExceptionOr<String> serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional<FlyString>& namespace_, HashMap<FlyString, Vector<String>>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed)
{ {
// 1. Let markup the empty string. // 1. Let markup the empty string.
StringBuilder markup; StringBuilder markup;
@ -778,7 +778,7 @@ static DOM::ExceptionOr<String> serialize_document_fragment(DOM::DocumentFragmen
} }
// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documenttype-node // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documenttype-node
static DOM::ExceptionOr<String> serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed)
{ {
if (require_well_formed == RequireWellFormed::Yes) { if (require_well_formed == RequireWellFormed::Yes) {
// FIXME: 1. If the require well-formed flag is true and the node's publicId attribute contains characters that are not matched by the XML PubidChar production, // FIXME: 1. If the require well-formed flag is true and the node's publicId attribute contains characters that are not matched by the XML PubidChar production,
@ -844,7 +844,7 @@ static DOM::ExceptionOr<String> serialize_document_type(DOM::DocumentType const&
} }
// https://w3c.github.io/DOM-Parsing/#dfn-xml-serializing-a-processinginstruction-node // https://w3c.github.io/DOM-Parsing/#dfn-xml-serializing-a-processinginstruction-node
static DOM::ExceptionOr<String> serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed) static WebIDL::ExceptionOr<String> serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed)
{ {
if (require_well_formed == RequireWellFormed::Yes) { if (require_well_formed == RequireWellFormed::Yes) {
// 1. If the require well-formed flag is set (its value is true), and node's target contains a ":" (U+003A COLON) character // 1. If the require well-formed flag is set (its value is true), and node's target contains a ":" (U+003A COLON) character

View file

@ -18,7 +18,7 @@ public:
virtual ~XMLSerializer() override; virtual ~XMLSerializer() override;
DOM::ExceptionOr<String> serialize_to_string(JS::NonnullGCPtr<DOM::Node> root); WebIDL::ExceptionOr<String> serialize_to_string(JS::NonnullGCPtr<DOM::Node> root);
private: private:
explicit XMLSerializer(HTML::Window&); explicit XMLSerializer(HTML::Window&);
@ -29,6 +29,6 @@ enum class RequireWellFormed {
Yes, Yes,
}; };
DOM::ExceptionOr<String> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed); WebIDL::ExceptionOr<String> serialize_node_to_xml_string(JS::NonnullGCPtr<DOM::Node> root, RequireWellFormed require_well_formed);
} }

View file

@ -12,11 +12,11 @@
namespace Web::Encoding { namespace Web::Encoding {
DOM::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::create_with_global_object(HTML::Window& window, FlyString encoding) WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> TextDecoder::create_with_global_object(HTML::Window& window, FlyString encoding)
{ {
auto decoder = TextCodec::decoder_for(encoding); auto decoder = TextCodec::decoder_for(encoding);
if (!decoder) if (!decoder)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, String::formatted("Invalid encoding {}", encoding) }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Invalid encoding {}", encoding) };
return JS::NonnullGCPtr(*window.heap().allocate<TextDecoder>(window.realm(), window, *decoder, move(encoding), false, false)); return JS::NonnullGCPtr(*window.heap().allocate<TextDecoder>(window.realm(), window, *decoder, move(encoding), false, false));
} }
@ -35,7 +35,7 @@ TextDecoder::TextDecoder(HTML::Window& window, TextCodec::Decoder& decoder, FlyS
TextDecoder::~TextDecoder() = default; TextDecoder::~TextDecoder() = default;
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode // https://encoding.spec.whatwg.org/#dom-textdecoder-decode
DOM::ExceptionOr<String> TextDecoder::decode(JS::Handle<JS::Object> const& input) const WebIDL::ExceptionOr<String> TextDecoder::decode(JS::Handle<JS::Object> const& input) const
{ {
// FIXME: Implement the streaming stuff. // FIXME: Implement the streaming stuff.

View file

@ -11,8 +11,8 @@
#include <LibJS/Forward.h> #include <LibJS/Forward.h>
#include <LibTextCodec/Decoder.h> #include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Encoding { namespace Web::Encoding {
@ -21,11 +21,11 @@ class TextDecoder : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject); WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject);
public: public:
static DOM::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> create_with_global_object(HTML::Window&, FlyString encoding); static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextDecoder>> create_with_global_object(HTML::Window&, FlyString encoding);
virtual ~TextDecoder() override; virtual ~TextDecoder() override;
DOM::ExceptionOr<String> decode(JS::Handle<JS::Object> const&) const; WebIDL::ExceptionOr<String> decode(JS::Handle<JS::Object> const&) const;
FlyString const& encoding() const { return m_encoding; } FlyString const& encoding() const { return m_encoding; }
bool fatal() const { return m_fatal; } bool fatal() const { return m_fatal; }

View file

@ -5,17 +5,17 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Fetch/BodyInit.h> #include <LibWeb/Fetch/BodyInit.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h> #include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/URL/URLSearchParams.h> #include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/WebIDL/AbstractOperations.h> #include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Fetch { namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract // https://fetch.spec.whatwg.org/#concept-bodyinit-extract
DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive)
{ {
auto& window = verify_cast<HTML::Window>(realm.global_object()); auto& window = verify_cast<HTML::Window>(realm.global_object());
@ -38,7 +38,7 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo
// 6. Switch on object. // 6. Switch on object.
// FIXME: Still need to support BufferSource and FormData // FIXME: Still need to support BufferSource and FormData
TRY(object.visit( TRY(object.visit(
[&](JS::Handle<FileAPI::Blob> const& blob) -> DOM::ExceptionOr<void> { [&](JS::Handle<FileAPI::Blob> const& blob) -> WebIDL::ExceptionOr<void> {
// FIXME: Set action to this step: read object. // FIXME: Set action to this step: read object.
// Set source to object. // Set source to object.
source = blob; source = blob;
@ -49,19 +49,19 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo
type = blob->type().to_byte_buffer(); type = blob->type().to_byte_buffer();
return {}; return {};
}, },
[&](JS::Handle<JS::Object> const& buffer_source) -> DOM::ExceptionOr<void> { [&](JS::Handle<JS::Object> const& buffer_source) -> WebIDL::ExceptionOr<void> {
// Set source to a copy of the bytes held by object. // Set source to a copy of the bytes held by object.
source = TRY_OR_RETURN_OOM(window, WebIDL::get_buffer_source_copy(*buffer_source.cell())); source = TRY_OR_RETURN_OOM(window, WebIDL::get_buffer_source_copy(*buffer_source.cell()));
return {}; return {};
}, },
[&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> DOM::ExceptionOr<void> { [&](JS::Handle<URL::URLSearchParams> const& url_search_params) -> WebIDL::ExceptionOr<void> {
// Set source to the result of running the application/x-www-form-urlencoded serializer with objects list. // Set source to the result of running the application/x-www-form-urlencoded serializer with objects list.
source = url_search_params->to_string().to_byte_buffer(); source = url_search_params->to_string().to_byte_buffer();
// Set type to `application/x-www-form-urlencoded;charset=UTF-8`. // Set type to `application/x-www-form-urlencoded;charset=UTF-8`.
type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("application/x-www-form-urlencoded;charset=UTF-8"sv.bytes())); type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("application/x-www-form-urlencoded;charset=UTF-8"sv.bytes()));
return {}; return {};
}, },
[&](String const& scalar_value_string) -> DOM::ExceptionOr<void> { [&](String const& scalar_value_string) -> WebIDL::ExceptionOr<void> {
// NOTE: AK::String is always UTF-8. // NOTE: AK::String is always UTF-8.
// Set source to the UTF-8 encoding of object. // Set source to the UTF-8 encoding of object.
source = scalar_value_string.to_byte_buffer(); source = scalar_value_string.to_byte_buffer();
@ -69,14 +69,14 @@ DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, Bo
type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("text/plain;charset=UTF-8"sv.bytes())); type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("text/plain;charset=UTF-8"sv.bytes()));
return {}; return {};
}, },
[&](JS::Handle<Streams::ReadableStream> const& stream) -> DOM::ExceptionOr<void> { [&](JS::Handle<Streams::ReadableStream> const& stream) -> WebIDL::ExceptionOr<void> {
// If keepalive is true, then throw a TypeError. // If keepalive is true, then throw a TypeError.
if (keepalive) if (keepalive)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Cannot extract body from stream when keepalive is set" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Cannot extract body from stream when keepalive is set" };
// If object is disturbed or locked, then throw a TypeError. // If object is disturbed or locked, then throw a TypeError.
if (stream->is_disturbed() || stream->is_locked()) if (stream->is_disturbed() || stream->is_locked())
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Cannot extract body from disturbed or locked stream" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Cannot extract body from disturbed or locked stream" };
return {}; return {};
})); }));

View file

@ -19,6 +19,6 @@ using XMLHttpRequestBodyInit = Variant<JS::Handle<FileAPI::Blob>, JS::Handle<JS:
// https://fetch.spec.whatwg.org/#bodyinit // https://fetch.spec.whatwg.org/#bodyinit
using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, String>; using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, String>;
DOM::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm&, BodyInit const&, bool keepalive = false); WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm&, BodyInit const&, bool keepalive = false);
} }

View file

@ -11,7 +11,7 @@
namespace Web::Fetch { namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#dom-headers // https://fetch.spec.whatwg.org/#dom-headers
DOM::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::create_with_global_object(HTML::Window& window, Optional<HeadersInit> const& init) WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> Headers::create_with_global_object(HTML::Window& window, Optional<HeadersInit> const& init)
{ {
// The new Headers(init) constructor steps are: // The new Headers(init) constructor steps are:
auto* headers = window.heap().allocate<Headers>(window.realm(), window); auto* headers = window.heap().allocate<Headers>(window.realm(), window);
@ -35,7 +35,7 @@ Headers::Headers(HTML::Window& window)
Headers::~Headers() = default; Headers::~Headers() = default;
// https://fetch.spec.whatwg.org/#dom-headers-append // https://fetch.spec.whatwg.org/#dom-headers-append
DOM::ExceptionOr<void> Headers::append(String const& name_string, String const& value_string) WebIDL::ExceptionOr<void> Headers::append(String const& name_string, String const& value_string)
{ {
// The append(name, value) method steps are to append (name, value) to this. // The append(name, value) method steps are to append (name, value) to this.
auto header = Infrastructure::Header { auto header = Infrastructure::Header {
@ -47,18 +47,18 @@ DOM::ExceptionOr<void> Headers::append(String const& name_string, String const&
} }
// https://fetch.spec.whatwg.org/#dom-headers-delete // https://fetch.spec.whatwg.org/#dom-headers-delete
DOM::ExceptionOr<void> Headers::delete_(String const& name_string) WebIDL::ExceptionOr<void> Headers::delete_(String const& name_string)
{ {
// The delete(name) method steps are: // The delete(name) method steps are:
auto name = name_string.bytes(); auto name = name_string.bytes();
// 1. If name is not a header name, then throw a TypeError. // 1. If name is not a header name, then throw a TypeError.
if (!Infrastructure::is_header_name(name)) if (!Infrastructure::is_header_name(name))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" };
// 2. If thiss guard is "immutable", then throw a TypeError. // 2. If thiss guard is "immutable", then throw a TypeError.
if (m_guard == Guard::Immutable) if (m_guard == Guard::Immutable)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Headers object is immutable" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Headers object is immutable" };
// 3. Otherwise, if thiss guard is "request" and name is a forbidden header name, return. // 3. Otherwise, if thiss guard is "request" and name is a forbidden header name, return.
if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name))
@ -87,14 +87,14 @@ DOM::ExceptionOr<void> Headers::delete_(String const& name_string)
} }
// https://fetch.spec.whatwg.org/#dom-headers-get // https://fetch.spec.whatwg.org/#dom-headers-get
DOM::ExceptionOr<String> Headers::get(String const& name_string) WebIDL::ExceptionOr<String> Headers::get(String const& name_string)
{ {
// The get(name) method steps are: // The get(name) method steps are:
auto name = name_string.bytes(); auto name = name_string.bytes();
// 1. If name is not a header name, then throw a TypeError. // 1. If name is not a header name, then throw a TypeError.
if (!Infrastructure::is_header_name(name)) if (!Infrastructure::is_header_name(name))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" };
// 2. Return the result of getting name from thiss header list. // 2. Return the result of getting name from thiss header list.
auto byte_buffer = TRY_OR_RETURN_OOM(global_object(), m_header_list.get(name)); auto byte_buffer = TRY_OR_RETURN_OOM(global_object(), m_header_list.get(name));
@ -103,21 +103,21 @@ DOM::ExceptionOr<String> Headers::get(String const& name_string)
} }
// https://fetch.spec.whatwg.org/#dom-headers-has // https://fetch.spec.whatwg.org/#dom-headers-has
DOM::ExceptionOr<bool> Headers::has(String const& name_string) WebIDL::ExceptionOr<bool> Headers::has(String const& name_string)
{ {
// The has(name) method steps are: // The has(name) method steps are:
auto name = name_string.bytes(); auto name = name_string.bytes();
// 1. If name is not a header name, then throw a TypeError. // 1. If name is not a header name, then throw a TypeError.
if (!Infrastructure::is_header_name(name)) if (!Infrastructure::is_header_name(name))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" };
// 2. Return true if thiss header list contains name; otherwise false. // 2. Return true if thiss header list contains name; otherwise false.
return m_header_list.contains(name); return m_header_list.contains(name);
} }
// https://fetch.spec.whatwg.org/#dom-headers-set // https://fetch.spec.whatwg.org/#dom-headers-set
DOM::ExceptionOr<void> Headers::set(String const& name_string, String const& value_string) WebIDL::ExceptionOr<void> Headers::set(String const& name_string, String const& value_string)
{ {
// The set(name, value) method steps are: // The set(name, value) method steps are:
auto name = name_string.bytes(); auto name = name_string.bytes();
@ -133,13 +133,13 @@ DOM::ExceptionOr<void> Headers::set(String const& name_string, String const& val
// 2. If name is not a header name or value is not a header value, then throw a TypeError. // 2. If name is not a header name or value is not a header value, then throw a TypeError.
if (!Infrastructure::is_header_name(name)) if (!Infrastructure::is_header_name(name))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" };
if (!Infrastructure::is_header_value(value)) if (!Infrastructure::is_header_value(value))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header value" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header value" };
// 3. If thiss guard is "immutable", then throw a TypeError. // 3. If thiss guard is "immutable", then throw a TypeError.
if (m_guard == Guard::Immutable) if (m_guard == Guard::Immutable)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Headers object is immutable" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Headers object is immutable" };
// 4. Otherwise, if thiss guard is "request" and name is a forbidden header name, return. // 4. Otherwise, if thiss guard is "request" and name is a forbidden header name, return.
if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name))
@ -201,7 +201,7 @@ JS::ThrowCompletionOr<void> Headers::for_each(ForEachCallback callback)
} }
// https://fetch.spec.whatwg.org/#concept-headers-append // https://fetch.spec.whatwg.org/#concept-headers-append
DOM::ExceptionOr<void> Headers::append(Infrastructure::Header header) WebIDL::ExceptionOr<void> Headers::append(Infrastructure::Header header)
{ {
// To append a header (name, value) to a Headers object headers, run these steps: // To append a header (name, value) to a Headers object headers, run these steps:
auto& [name, value] = header; auto& [name, value] = header;
@ -211,13 +211,13 @@ DOM::ExceptionOr<void> Headers::append(Infrastructure::Header header)
// 2. If name is not a header name or value is not a header value, then throw a TypeError. // 2. If name is not a header name or value is not a header value, then throw a TypeError.
if (!Infrastructure::is_header_name(name)) if (!Infrastructure::is_header_name(name))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" };
if (!Infrastructure::is_header_value(value)) if (!Infrastructure::is_header_value(value))
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header value" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header value" };
// 3. If headerss guard is "immutable", then throw a TypeError. // 3. If headerss guard is "immutable", then throw a TypeError.
if (m_guard == Guard::Immutable) if (m_guard == Guard::Immutable)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Headers object is immutable" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Headers object is immutable" };
// 4. Otherwise, if headerss guard is "request" and name is a forbidden header name, return. // 4. Otherwise, if headerss guard is "request" and name is a forbidden header name, return.
if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name))
@ -264,16 +264,16 @@ DOM::ExceptionOr<void> Headers::append(Infrastructure::Header header)
} }
// https://fetch.spec.whatwg.org/#concept-headers-fill // https://fetch.spec.whatwg.org/#concept-headers-fill
DOM::ExceptionOr<void> Headers::fill(HeadersInit const& object) WebIDL::ExceptionOr<void> Headers::fill(HeadersInit const& object)
{ {
// To fill a Headers object headers with a given object object, run these steps: // To fill a Headers object headers with a given object object, run these steps:
return object.visit( return object.visit(
// 1. If object is a sequence, then for each header in object: // 1. If object is a sequence, then for each header in object:
[this](Vector<Vector<String>> const& object) -> DOM::ExceptionOr<void> { [this](Vector<Vector<String>> const& object) -> WebIDL::ExceptionOr<void> {
for (auto const& entry : object) { for (auto const& entry : object) {
// 1. If header does not contain exactly two items, then throw a TypeError. // 1. If header does not contain exactly two items, then throw a TypeError.
if (entry.size() != 2) if (entry.size() != 2)
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Array must contain header key/value pair" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Array must contain header key/value pair" };
// 2. Append (headers first item, headers second item) to headers. // 2. Append (headers first item, headers second item) to headers.
auto header = Fetch::Infrastructure::Header { auto header = Fetch::Infrastructure::Header {
@ -285,7 +285,7 @@ DOM::ExceptionOr<void> Headers::fill(HeadersInit const& object)
return {}; return {};
}, },
// 2. Otherwise, object is a record, then for each key → value in object, append (key, value) to headers. // 2. Otherwise, object is a record, then for each key → value in object, append (key, value) to headers.
[this](OrderedHashMap<String, String> const& object) -> DOM::ExceptionOr<void> { [this](OrderedHashMap<String, String> const& object) -> WebIDL::ExceptionOr<void> {
for (auto const& entry : object) { for (auto const& entry : object) {
auto header = Fetch::Infrastructure::Header { auto header = Fetch::Infrastructure::Header {
.name = TRY_OR_RETURN_OOM(global_object(), ByteBuffer::copy(entry.key.bytes())), .name = TRY_OR_RETURN_OOM(global_object(), ByteBuffer::copy(entry.key.bytes())),

View file

@ -11,8 +11,8 @@
#include <AK/Variant.h> #include <AK/Variant.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h> #include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Fetch { namespace Web::Fetch {
@ -31,16 +31,16 @@ public:
None, None,
}; };
static DOM::ExceptionOr<JS::NonnullGCPtr<Headers>> create_with_global_object(HTML::Window& window, Optional<HeadersInit> const& init); static WebIDL::ExceptionOr<JS::NonnullGCPtr<Headers>> create_with_global_object(HTML::Window& window, Optional<HeadersInit> const& init);
virtual ~Headers() override; virtual ~Headers() override;
DOM::ExceptionOr<void> append(Infrastructure::Header); WebIDL::ExceptionOr<void> append(Infrastructure::Header);
DOM::ExceptionOr<void> append(String const& name, String const& value); WebIDL::ExceptionOr<void> append(String const& name, String const& value);
DOM::ExceptionOr<void> delete_(String const& name); WebIDL::ExceptionOr<void> delete_(String const& name);
DOM::ExceptionOr<String> get(String const& name); WebIDL::ExceptionOr<String> get(String const& name);
DOM::ExceptionOr<bool> has(String const& name); WebIDL::ExceptionOr<bool> has(String const& name);
DOM::ExceptionOr<void> set(String const& name, String const& value); WebIDL::ExceptionOr<void> set(String const& name, String const& value);
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(String const&, String const&)>; using ForEachCallback = Function<JS::ThrowCompletionOr<void>(String const&, String const&)>;
JS::ThrowCompletionOr<void> for_each(ForEachCallback); JS::ThrowCompletionOr<void> for_each(ForEachCallback);
@ -50,7 +50,7 @@ private:
explicit Headers(HTML::Window&); explicit Headers(HTML::Window&);
DOM::ExceptionOr<void> fill(HeadersInit const&); WebIDL::ExceptionOr<void> fill(HeadersInit const&);
void remove_privileged_no_cors_headers(); void remove_privileged_no_cors_headers();
// https://fetch.spec.whatwg.org/#concept-headers-header-list // https://fetch.spec.whatwg.org/#concept-headers-header-list

View file

@ -135,7 +135,7 @@ Blob::Blob(HTML::Window& window, ByteBuffer byte_buffer)
Blob::~Blob() = default; Blob::~Blob() = default;
// https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob // https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob
DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(HTML::Window& window, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options) WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(HTML::Window& window, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options)
{ {
// 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string. // 1. If invoked with zero parameters, return a new Blob object consisting of 0 bytes, with size set to 0, and with type set to the empty string.
if (!blob_parts.has_value() && !options.has_value()) if (!blob_parts.has_value() && !options.has_value())
@ -167,13 +167,13 @@ DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create(HTML::Window& window, Opti
return JS::NonnullGCPtr(*window.heap().allocate<Blob>(window.realm(), window, move(byte_buffer), move(type))); return JS::NonnullGCPtr(*window.heap().allocate<Blob>(window.realm(), window, move(byte_buffer), move(type)));
} }
DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create_with_global_object(HTML::Window& window, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options) WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::create_with_global_object(HTML::Window& window, Optional<Vector<BlobPart>> const& blob_parts, Optional<BlobPropertyBag> const& options)
{ {
return Blob::create(window, blob_parts, options); return Blob::create(window, blob_parts, options);
} }
// https://w3c.github.io/FileAPI/#dfn-slice // https://w3c.github.io/FileAPI/#dfn-slice
DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Optional<i64> end, Optional<String> const& content_type) WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Optional<i64> end, Optional<String> const& content_type)
{ {
// 1. The optional start parameter is a value for the start point of a slice() call, and must be treated as a byte-order position, with the zeroth position representing the first byte. // 1. The optional start parameter is a value for the start point of a slice() call, and must be treated as a byte-order position, with the zeroth position representing the first byte.
// User agents must process slice() with start normalized according to the following: // User agents must process slice() with start normalized according to the following:

View file

@ -11,8 +11,8 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibWeb/Bindings/BlobPrototype.h> #include <LibWeb/Bindings/BlobPrototype.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::FileAPI { namespace Web::FileAPI {
@ -34,15 +34,15 @@ public:
virtual ~Blob() override; virtual ~Blob() override;
static JS::NonnullGCPtr<Blob> create(HTML::Window&, ByteBuffer, String type); static JS::NonnullGCPtr<Blob> create(HTML::Window&, ByteBuffer, String type);
static DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> create(HTML::Window&, Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {}); static WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> create(HTML::Window&, Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {});
static DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> create_with_global_object(HTML::Window&, Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {}); static WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> create_with_global_object(HTML::Window&, Optional<Vector<BlobPart>> const& blob_parts = {}, Optional<BlobPropertyBag> const& options = {});
// https://w3c.github.io/FileAPI/#dfn-size // https://w3c.github.io/FileAPI/#dfn-size
u64 size() const { return m_byte_buffer.size(); } u64 size() const { return m_byte_buffer.size(); }
// https://w3c.github.io/FileAPI/#dfn-type // https://w3c.github.io/FileAPI/#dfn-type
String const& type() const { return m_type; } String const& type() const { return m_type; }
DOM::ExceptionOr<JS::NonnullGCPtr<Blob>> slice(Optional<i64> start = {}, Optional<i64> end = {}, Optional<String> const& content_type = {}); WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> slice(Optional<i64> start = {}, Optional<i64> end = {}, Optional<String> const& content_type = {});
JS::Promise* text(); JS::Promise* text();
JS::Promise* array_buffer(); JS::Promise* array_buffer();

View file

@ -20,7 +20,7 @@ File::File(HTML::Window& window, ByteBuffer byte_buffer, String file_name, Strin
File::~File() = default; File::~File() = default;
// https://w3c.github.io/FileAPI/#ref-for-dom-file-file // https://w3c.github.io/FileAPI/#ref-for-dom-file-file
DOM::ExceptionOr<JS::NonnullGCPtr<File>> File::create(HTML::Window& window, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options) WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create(HTML::Window& window, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
{ {
// 1. Let bytes be the result of processing blob parts given fileBits and options. // 1. Let bytes be the result of processing blob parts given fileBits and options.
auto bytes = TRY_OR_RETURN_OOM(window, process_blob_parts(file_bits, static_cast<Optional<BlobPropertyBag> const&>(*options))); auto bytes = TRY_OR_RETURN_OOM(window, process_blob_parts(file_bits, static_cast<Optional<BlobPropertyBag> const&>(*options)));
@ -60,7 +60,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<File>> File::create(HTML::Window& window, Vect
return JS::NonnullGCPtr(*window.heap().allocate<File>(window.realm(), window, move(bytes), move(name), move(type), last_modified)); return JS::NonnullGCPtr(*window.heap().allocate<File>(window.realm(), window, move(bytes), move(name), move(type), last_modified));
} }
DOM::ExceptionOr<JS::NonnullGCPtr<File>> File::create_with_global_object(HTML::Window& window, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options) WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> File::create_with_global_object(HTML::Window& window, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options)
{ {
return create(window, file_bits, file_name, options); return create(window, file_bits, file_name, options);
} }

View file

@ -19,8 +19,8 @@ class File : public Blob {
WEB_PLATFORM_OBJECT(File, Blob); WEB_PLATFORM_OBJECT(File, Blob);
public: public:
static DOM::ExceptionOr<JS::NonnullGCPtr<File>> create(HTML::Window&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {}); static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> create(HTML::Window&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
static DOM::ExceptionOr<JS::NonnullGCPtr<File>> create_with_global_object(HTML::Window&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {}); static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> create_with_global_object(HTML::Window&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
virtual ~File() override; virtual ~File() override;

View file

@ -170,9 +170,6 @@ class TreeWalker;
enum class QuirksMode; enum class QuirksMode;
struct EventListenerOptions; struct EventListenerOptions;
struct AddEventListenerOptions; struct AddEventListenerOptions;
template<typename ValueType>
class ExceptionOr;
} }
namespace Web::DOMParsing { namespace Web::DOMParsing {
@ -397,6 +394,9 @@ class SVGSVGElement;
namespace Web::WebIDL { namespace Web::WebIDL {
class CallbackType; class CallbackType;
template<typename ValueType>
class ExceptionOr;
} }
namespace Web::WebSockets { namespace Web::WebSockets {

View file

@ -859,7 +859,7 @@ void BrowsingContext::remove()
} }
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
DOM::ExceptionOr<void> BrowsingContext::navigate( WebIDL::ExceptionOr<void> BrowsingContext::navigate(
Fetch::Infrastructure::Request resource, Fetch::Infrastructure::Request resource,
BrowsingContext& source_browsing_context, BrowsingContext& source_browsing_context,
bool exceptions_enabled, bool exceptions_enabled,
@ -983,7 +983,7 @@ DOM::ExceptionOr<void> BrowsingContext::navigate(
} }
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid
DOM::ExceptionOr<void> BrowsingContext::navigate_to_a_fragment(AK::URL const& url, HistoryHandlingBehavior history_handling, String navigation_id) WebIDL::ExceptionOr<void> BrowsingContext::navigate_to_a_fragment(AK::URL const& url, HistoryHandlingBehavior history_handling, String navigation_id)
{ {
// 1. If historyHandling is not "replace", // 1. If historyHandling is not "replace",
if (history_handling != HistoryHandlingBehavior::Replace) { if (history_handling != HistoryHandlingBehavior::Replace) {
@ -1025,7 +1025,7 @@ DOM::ExceptionOr<void> BrowsingContext::navigate_to_a_fragment(AK::URL const& ur
} }
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history // https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history
DOM::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_index, HistoryHandlingBehavior history_handling, bool explicit_history_navigation) WebIDL::ExceptionOr<void> BrowsingContext::traverse_the_history(size_t entry_index, HistoryHandlingBehavior history_handling, bool explicit_history_navigation)
{ {
auto* entry = &m_session_history[entry_index]; auto* entry = &m_session_history[entry_index];

View file

@ -140,7 +140,7 @@ public:
bool is_allowed_to_navigate(BrowsingContext const&) const; bool is_allowed_to_navigate(BrowsingContext const&) const;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate
DOM::ExceptionOr<void> navigate( WebIDL::ExceptionOr<void> navigate(
Fetch::Infrastructure::Request resource, Fetch::Infrastructure::Request resource,
BrowsingContext& source_browsing_context, BrowsingContext& source_browsing_context,
bool exceptions_enabled = false, bool exceptions_enabled = false,
@ -151,13 +151,13 @@ public:
Function<void(NonnullOwnPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {}); Function<void(NonnullOwnPtr<Fetch::Infrastructure::Response>)> process_response_end_of_body = {});
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid
DOM::ExceptionOr<void> navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id); WebIDL::ExceptionOr<void> navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id);
// https://html.spec.whatwg.org/multipage/origin.html#one-permitted-sandboxed-navigator // https://html.spec.whatwg.org/multipage/origin.html#one-permitted-sandboxed-navigator
BrowsingContext const* the_one_permitted_sandboxed_navigator() const; BrowsingContext const* the_one_permitted_sandboxed_navigator() const;
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history // https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history
DOM::ExceptionOr<void> traverse_the_history(size_t entry_index, HistoryHandlingBehavior = HistoryHandlingBehavior::Default, bool explicit_history_navigation = false); WebIDL::ExceptionOr<void> traverse_the_history(size_t entry_index, HistoryHandlingBehavior = HistoryHandlingBehavior::Default, bool explicit_history_navigation = false);
Vector<JS::Handle<DOM::Document>> document_family() const; Vector<JS::Handle<DOM::Document>> document_family() const;
bool document_family_contains(DOM::Document const&) const; bool document_family_contains(DOM::Document const&) const;

View file

@ -21,7 +21,7 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi
}); });
} }
DOM::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y) WebIDL::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y)
{ {
// If not specified, the dw and dh arguments must default to the values of sw and sh, interpreted such that one CSS pixel in the image is treated as one unit in the output bitmap's coordinate space. // If not specified, the dw and dh arguments must default to the values of sw and sh, interpreted such that one CSS pixel in the image is treated as one unit in the output bitmap's coordinate space.
// If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively. // If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively.
@ -33,7 +33,7 @@ DOM::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource
return draw_image_internal(image, 0, 0, source_width, source_height, destination_x, destination_y, source_width, source_height); return draw_image_internal(image, 0, 0, source_width, source_height, destination_x, destination_y, source_width, source_height);
} }
DOM::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y, float destination_width, float destination_height) WebIDL::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y, float destination_width, float destination_height)
{ {
// If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively. // If the sx, sy, sw, and sh arguments are omitted, then they must default to 0, 0, the image's intrinsic width in image pixels, and the image's intrinsic height in image pixels, respectively.
// If the image has no intrinsic dimensions, then the concrete object size must be used instead, as determined using the CSS "Concrete Object Size Resolution" algorithm, with the specified size having // If the image has no intrinsic dimensions, then the concrete object size must be used instead, as determined using the CSS "Concrete Object Size Resolution" algorithm, with the specified size having
@ -44,7 +44,7 @@ DOM::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource
return draw_image_internal(image, 0, 0, source_width, source_height, destination_x, destination_y, destination_width, destination_height); return draw_image_internal(image, 0, 0, source_width, source_height, destination_x, destination_y, destination_width, destination_height);
} }
DOM::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) WebIDL::ExceptionOr<void> CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height)
{ {
return draw_image_internal(image, source_x, source_y, source_width, source_height, destination_x, destination_y, destination_width, destination_height); return draw_image_internal(image, source_x, source_y, source_width, source_height, destination_x, destination_y, destination_width, destination_height);
} }

View file

@ -7,9 +7,9 @@
#pragma once #pragma once
#include <AK/String.h> #include <AK/String.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/HTMLCanvasElement.h> #include <LibWeb/HTML/HTMLCanvasElement.h>
#include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -22,11 +22,11 @@ class CanvasDrawImage {
public: public:
virtual ~CanvasDrawImage() = default; virtual ~CanvasDrawImage() = default;
DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y); WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y);
DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height); WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height);
DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height); WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height);
virtual DOM::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) = 0; virtual WebIDL::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) = 0;
protected: protected:
CanvasDrawImage() = default; CanvasDrawImage() = default;

View file

@ -16,7 +16,7 @@ public:
virtual ~CanvasImageData() = default; virtual ~CanvasImageData() = default;
virtual JS::GCPtr<ImageData> create_image_data(int width, int height) const = 0; virtual JS::GCPtr<ImageData> create_image_data(int width, int height) const = 0;
virtual DOM::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height) const = 0; virtual WebIDL::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height) const = 0;
virtual void put_image_data(ImageData const&, float x, float y) = 0; virtual void put_image_data(ImageData const&, float x, float y) = 0;
protected: protected:

View file

@ -36,14 +36,14 @@ void CanvasPath::bezier_curve_to(double cp1x, double cp1y, double cp2x, double c
m_path.cubic_bezier_curve_to(Gfx::FloatPoint(cp1x, cp1y), Gfx::FloatPoint(cp2x, cp2y), Gfx::FloatPoint(x, y)); m_path.cubic_bezier_curve_to(Gfx::FloatPoint(cp1x, cp1y), Gfx::FloatPoint(cp2x, cp2y), Gfx::FloatPoint(x, y));
} }
DOM::ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise) WebIDL::ExceptionOr<void> CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise)
{ {
if (radius < 0) if (radius < 0)
return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The radius provided ({}) is negative.", radius)); return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The radius provided ({}) is negative.", radius));
return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise); return ellipse(x, y, radius, radius, 0, start_angle, end_angle, counter_clockwise);
} }
DOM::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise) WebIDL::ExceptionOr<void> CanvasPath::ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise)
{ {
if (radius_x < 0) if (radius_x < 0)
return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The major-axis radius provided ({}) is negative.", radius_x)); return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The major-axis radius provided ({}) is negative.", radius_x));

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <LibGfx/Path.h> #include <LibGfx/Path.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -23,8 +23,8 @@ public:
void quadratic_curve_to(float cx, float cy, float x, float y); void quadratic_curve_to(float cx, float cy, float x, float y);
void bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void bezier_curve_to(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
void rect(float x, float y, float width, float height); void rect(float x, float y, float width, float height);
DOM::ExceptionOr<void> arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise); WebIDL::ExceptionOr<void> arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise);
DOM::ExceptionOr<void> ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise); WebIDL::ExceptionOr<void> ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise);
Gfx::Path& path() { return m_path; } Gfx::Path& path() { return m_path; }
Gfx::Path const& path() const { return m_path; } Gfx::Path const& path() const { return m_path; }

View file

@ -5,9 +5,9 @@
*/ */
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/CanvasGradient.h> #include <LibWeb/HTML/CanvasGradient.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -49,7 +49,7 @@ CanvasGradient::CanvasGradient(HTML::Window& window, Type type)
CanvasGradient::~CanvasGradient() = default; CanvasGradient::~CanvasGradient() = default;
// https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop // https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop
DOM::ExceptionOr<void> CanvasGradient::add_color_stop(double offset, String const& color) WebIDL::ExceptionOr<void> CanvasGradient::add_color_stop(double offset, String const& color)
{ {
// 1. If the offset is less than 0 or greater than 1, then throw an "IndexSizeError" DOMException. // 1. If the offset is less than 0 or greater than 1, then throw an "IndexSizeError" DOMException.
if (offset < 0 || offset > 1) if (offset < 0 || offset > 1)

View file

@ -25,7 +25,7 @@ public:
static JS::NonnullGCPtr<CanvasGradient> create_linear(HTML::Window&, double x0, double y0, double x1, double y1); static JS::NonnullGCPtr<CanvasGradient> create_linear(HTML::Window&, double x0, double y0, double x1, double y1);
static JS::NonnullGCPtr<CanvasGradient> create_conic(HTML::Window&, double start_angle, double x, double y); static JS::NonnullGCPtr<CanvasGradient> create_conic(HTML::Window&, double start_angle, double x, double y);
DOM::ExceptionOr<void> add_color_stop(double offset, String const& color); WebIDL::ExceptionOr<void> add_color_stop(double offset, String const& color);
~CanvasGradient(); ~CanvasGradient();

View file

@ -10,7 +10,6 @@
#include <LibGfx/Painter.h> #include <LibGfx/Painter.h>
#include <LibGfx/Quad.h> #include <LibGfx/Quad.h>
#include <LibGfx/Rect.h> #include <LibGfx/Rect.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/CanvasRenderingContext2D.h> #include <LibWeb/HTML/CanvasRenderingContext2D.h>
#include <LibWeb/HTML/HTMLCanvasElement.h> #include <LibWeb/HTML/HTMLCanvasElement.h>
#include <LibWeb/HTML/HTMLImageElement.h> #include <LibWeb/HTML/HTMLImageElement.h>
@ -20,6 +19,7 @@
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Platform/FontPlugin.h> #include <LibWeb/Platform/FontPlugin.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -107,7 +107,7 @@ void CanvasRenderingContext2D::stroke_rect(float x, float y, float width, float
} }
// 4.12.5.1.14 Drawing images, https://html.spec.whatwg.org/multipage/canvas.html#drawing-images // 4.12.5.1.14 Drawing images, https://html.spec.whatwg.org/multipage/canvas.html#drawing-images
DOM::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasImageSource const& image, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasImageSource const& image, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height)
{ {
// 1. If any of the arguments are infinite or NaN, then return. // 1. If any of the arguments are infinite or NaN, then return.
if (!isfinite(source_x) || !isfinite(source_y) || !isfinite(source_width) || !isfinite(source_height) || !isfinite(destination_x) || !isfinite(destination_y) || !isfinite(destination_width) || !isfinite(destination_height)) if (!isfinite(source_x) || !isfinite(source_y) || !isfinite(source_width) || !isfinite(source_height) || !isfinite(destination_x) || !isfinite(destination_y) || !isfinite(destination_width) || !isfinite(destination_height))
@ -271,7 +271,7 @@ JS::GCPtr<ImageData> CanvasRenderingContext2D::create_image_data(int width, int
} }
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata
DOM::ExceptionOr<JS::GCPtr<ImageData>> CanvasRenderingContext2D::get_image_data(int x, int y, int width, int height) const WebIDL::ExceptionOr<JS::GCPtr<ImageData>> CanvasRenderingContext2D::get_image_data(int x, int y, int width, int height) const
{ {
// 1. If either the sw or sh arguments are zero, then throw an "IndexSizeError" DOMException. // 1. If either the sw or sh arguments are zero, then throw an "IndexSizeError" DOMException.
if (width == 0 || height == 0) if (width == 0 || height == 0)
@ -471,12 +471,12 @@ void CanvasRenderingContext2D::clip()
} }
// https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument // https://html.spec.whatwg.org/multipage/canvas.html#check-the-usability-of-the-image-argument
DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image) WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const& image)
{ {
// 1. Switch on image: // 1. Switch on image:
auto usability = TRY(image.visit( auto usability = TRY(image.visit(
// HTMLOrSVGImageElement // HTMLOrSVGImageElement
[](JS::Handle<HTMLImageElement> const& image_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> { [](JS::Handle<HTMLImageElement> const& image_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException. // FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
// If image is not fully decodable, then return bad. // If image is not fully decodable, then return bad.
@ -494,7 +494,7 @@ DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImag
// HTMLCanvasElement // HTMLCanvasElement
// FIXME: OffscreenCanvas // FIXME: OffscreenCanvas
[](JS::Handle<HTMLCanvasElement> const& canvas_element) -> DOM::ExceptionOr<Optional<CanvasImageSourceUsability>> { [](JS::Handle<HTMLCanvasElement> const& canvas_element) -> WebIDL::ExceptionOr<Optional<CanvasImageSourceUsability>> {
// If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException. // If image has either a horizontal dimension or a vertical dimension equal to zero, then throw an "InvalidStateError" DOMException.
if (canvas_element->width() == 0 || canvas_element->height() == 0) if (canvas_element->width() == 0 || canvas_element->height() == 0)
return DOM::InvalidStateError::create(canvas_element->global_object(), "Canvas width or height is zero"); return DOM::InvalidStateError::create(canvas_element->global_object(), "Canvas width or height is zero");

View file

@ -14,7 +14,6 @@
#include <LibGfx/Painter.h> #include <LibGfx/Painter.h>
#include <LibGfx/Path.h> #include <LibGfx/Path.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/Canvas/CanvasDrawImage.h> #include <LibWeb/HTML/Canvas/CanvasDrawImage.h>
#include <LibWeb/HTML/Canvas/CanvasDrawPath.h> #include <LibWeb/HTML/Canvas/CanvasDrawPath.h>
#include <LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h> #include <LibWeb/HTML/Canvas/CanvasFillStrokeStyles.h>
@ -28,6 +27,7 @@
#include <LibWeb/HTML/CanvasGradient.h> #include <LibWeb/HTML/CanvasGradient.h>
#include <LibWeb/Layout/InlineNode.h> #include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Layout/LineBox.h> #include <LibWeb/Layout/LineBox.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -58,7 +58,7 @@ public:
virtual void stroke_rect(float x, float y, float width, float height) override; virtual void stroke_rect(float x, float y, float width, float height) override;
virtual void clear_rect(float x, float y, float width, float height) override; virtual void clear_rect(float x, float y, float width, float height) override;
virtual DOM::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) override; virtual WebIDL::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) override;
virtual void begin_path() override; virtual void begin_path() override;
virtual void stroke() override; virtual void stroke() override;
@ -71,7 +71,7 @@ public:
virtual void fill(Path2D& path, String const& fill_rule) override; virtual void fill(Path2D& path, String const& fill_rule) override;
virtual JS::GCPtr<ImageData> create_image_data(int width, int height) const override; virtual JS::GCPtr<ImageData> create_image_data(int width, int height) const override;
virtual DOM::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height) const override; virtual WebIDL::ExceptionOr<JS::GCPtr<ImageData>> get_image_data(int x, int y, int width, int height) const override;
virtual void put_image_data(ImageData const&, float x, float y) override; virtual void put_image_data(ImageData const&, float x, float y) override;
virtual void reset_to_default_state() override; virtual void reset_to_default_state() override;
@ -120,7 +120,7 @@ enum class CanvasImageSourceUsability {
Good, Good,
}; };
DOM::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const&); WebIDL::ExceptionOr<CanvasImageSourceUsability> check_usability_of_image(CanvasImageSource const&);
bool image_is_not_origin_clean(CanvasImageSource const&); bool image_is_not_origin_clean(CanvasImageSource const&);
} }

View file

@ -13,7 +13,7 @@
namespace Web::HTML { namespace Web::HTML {
DOM::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::create_with_global_object(HTML::Window& window) WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> DOMParser::create_with_global_object(HTML::Window& window)
{ {
return JS::NonnullGCPtr(*window.heap().allocate<DOMParser>(window.realm(), window)); return JS::NonnullGCPtr(*window.heap().allocate<DOMParser>(window.realm(), window));
} }

View file

@ -8,8 +8,8 @@
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -18,7 +18,7 @@ class DOMParser final : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(DOMParser, Bindings::PlatformObject); WEB_PLATFORM_OBJECT(DOMParser, Bindings::PlatformObject);
public: public:
static DOM::ExceptionOr<JS::NonnullGCPtr<DOMParser>> create_with_global_object(HTML::Window&); static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMParser>> create_with_global_object(HTML::Window&);
virtual ~DOMParser() override; virtual ~DOMParser() override;

View file

@ -111,7 +111,7 @@ String DOMStringMap::determine_value_of_named_property(String const& name) const
} }
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem // https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem
DOM::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String const& name, String const& value) WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String const& name, String const& value)
{ {
AK::StringBuilder builder; AK::StringBuilder builder;
@ -150,7 +150,7 @@ DOM::ExceptionOr<void> DOMStringMap::set_value_of_new_named_property(String cons
} }
// https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem // https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem
DOM::ExceptionOr<void> DOMStringMap::set_value_of_existing_named_property(String const& name, String const& value) WebIDL::ExceptionOr<void> DOMStringMap::set_value_of_existing_named_property(String const& name, String const& value)
{ {
return set_value_of_new_named_property(name, value); return set_value_of_new_named_property(name, value);
} }

View file

@ -25,8 +25,8 @@ public:
String determine_value_of_named_property(String const&) const; String determine_value_of_named_property(String const&) const;
DOM::ExceptionOr<void> set_value_of_new_named_property(String const&, String const&); WebIDL::ExceptionOr<void> set_value_of_new_named_property(String const&, String const&);
DOM::ExceptionOr<void> set_value_of_existing_named_property(String const&, String const&); WebIDL::ExceptionOr<void> set_value_of_existing_named_property(String const&, String const&);
bool delete_existing_named_property(String const&); bool delete_existing_named_property(String const&);

View file

@ -9,7 +9,6 @@
#include <LibJS/Parser.h> #include <LibJS/Parser.h>
#include <LibWeb/DOM/DOMException.h> #include <LibWeb/DOM/DOMException.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/IDLEventListener.h> #include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/HTML/BrowsingContextContainer.h> #include <LibWeb/HTML/BrowsingContextContainer.h>
@ -25,6 +24,7 @@
#include <LibWeb/UIEvents/EventNames.h> #include <LibWeb/UIEvents/EventNames.h>
#include <LibWeb/UIEvents/FocusEvent.h> #include <LibWeb/UIEvents/FocusEvent.h>
#include <LibWeb/UIEvents/MouseEvent.h> #include <LibWeb/UIEvents/MouseEvent.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -90,7 +90,7 @@ String HTMLElement::content_editable() const
} }
// https://html.spec.whatwg.org/multipage/interaction.html#contenteditable // https://html.spec.whatwg.org/multipage/interaction.html#contenteditable
DOM::ExceptionOr<void> HTMLElement::set_content_editable(String const& content_editable) WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(String const& content_editable)
{ {
if (content_editable.equals_ignoring_case("inherit"sv)) { if (content_editable.equals_ignoring_case("inherit"sv)) {
remove_attribute(HTML::AttributeNames::contenteditable); remove_attribute(HTML::AttributeNames::contenteditable);

View file

@ -25,7 +25,7 @@ public:
virtual bool is_editable() const final; virtual bool is_editable() const final;
String content_editable() const; String content_editable() const;
DOM::ExceptionOr<void> set_content_editable(String const&); WebIDL::ExceptionOr<void> set_content_editable(String const&);
String inner_text(); String inner_text();
void set_inner_text(StringView); void set_inner_text(StringView);

View file

@ -27,7 +27,7 @@ HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function<boo
HTMLOptionsCollection::~HTMLOptionsCollection() = default; HTMLOptionsCollection::~HTMLOptionsCollection() = default;
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add // https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add
DOM::ExceptionOr<void> HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before) WebIDL::ExceptionOr<void> HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before)
{ {
auto resolved_element = element.visit( auto resolved_element = element.visit(
[](auto& e) -> JS::Handle<HTMLElement> { [](auto& e) -> JS::Handle<HTMLElement> {

View file

@ -7,8 +7,8 @@
#pragma once #pragma once
#include <AK/Variant.h> #include <AK/Variant.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/HTMLCollection.h> #include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -22,7 +22,7 @@ public:
static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter); static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
virtual ~HTMLOptionsCollection() override; virtual ~HTMLOptionsCollection() override;
DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {}); WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
private: private:
HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter); HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);

View file

@ -43,7 +43,7 @@ JS::GCPtr<HTMLOptionsCollection> const& HTMLSelectElement::options()
} }
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add
DOM::ExceptionOr<void> HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before) WebIDL::ExceptionOr<void> HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before)
{ {
// Similarly, the add(element, before) method must act like its namesake method on that same options collection. // Similarly, the add(element, before) method must act like its namesake method on that same options collection.
return const_cast<HTMLOptionsCollection&>(*options()).add(move(element), move(before)); return const_cast<HTMLOptionsCollection&>(*options()).add(move(element), move(before));

View file

@ -25,7 +25,7 @@ public:
JS::GCPtr<HTMLOptionsCollection> const& options(); JS::GCPtr<HTMLOptionsCollection> const& options();
DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {}); WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
int selected_index() const; int selected_index() const;
void set_selected_index(int); void set_selected_index(int);

View file

@ -97,7 +97,7 @@ JS::GCPtr<HTMLTableSectionElement> HTMLTableElement::t_head()
return nullptr; return nullptr;
} }
DOM::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement* thead) WebIDL::ExceptionOr<void> HTMLTableElement::set_t_head(HTMLTableSectionElement* thead)
{ {
// FIXME: This is not always the case, but this function is currently written in a way that assumes non-null. // FIXME: This is not always the case, but this function is currently written in a way that assumes non-null.
VERIFY(thead); VERIFY(thead);
@ -184,7 +184,7 @@ JS::GCPtr<HTMLTableSectionElement> HTMLTableElement::t_foot()
return nullptr; return nullptr;
} }
DOM::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement* tfoot) WebIDL::ExceptionOr<void> HTMLTableElement::set_t_foot(HTMLTableSectionElement* tfoot)
{ {
// FIXME: This is not always the case, but this function is currently written in a way that assumes non-null. // FIXME: This is not always the case, but this function is currently written in a way that assumes non-null.
VERIFY(tfoot); VERIFY(tfoot);
@ -280,7 +280,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableElement::rows()
}); });
} }
DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::insert_row(long index) WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::insert_row(long index)
{ {
auto rows = this->rows(); auto rows = this->rows();
auto rows_length = rows->length(); auto rows_length = rows->length();
@ -306,7 +306,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableElement::insert
} }
// https://html.spec.whatwg.org/multipage/tables.html#dom-table-deleterow // https://html.spec.whatwg.org/multipage/tables.html#dom-table-deleterow
DOM::ExceptionOr<void> HTMLTableElement::delete_row(long index) WebIDL::ExceptionOr<void> HTMLTableElement::delete_row(long index)
{ {
auto rows = this->rows(); auto rows = this->rows();
auto rows_length = rows->length(); auto rows_length = rows->length();

View file

@ -6,11 +6,11 @@
#pragma once #pragma once
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/HTMLElement.h> #include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/HTMLTableCaptionElement.h> #include <LibWeb/HTML/HTMLTableCaptionElement.h>
#include <LibWeb/HTML/HTMLTableRowElement.h> #include <LibWeb/HTML/HTMLTableRowElement.h>
#include <LibWeb/HTML/HTMLTableSectionElement.h> #include <LibWeb/HTML/HTMLTableSectionElement.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -26,12 +26,12 @@ public:
void delete_caption(); void delete_caption();
JS::GCPtr<HTMLTableSectionElement> t_head(); JS::GCPtr<HTMLTableSectionElement> t_head();
DOM::ExceptionOr<void> set_t_head(HTMLTableSectionElement* thead); WebIDL::ExceptionOr<void> set_t_head(HTMLTableSectionElement* thead);
JS::NonnullGCPtr<HTMLTableSectionElement> create_t_head(); JS::NonnullGCPtr<HTMLTableSectionElement> create_t_head();
void delete_t_head(); void delete_t_head();
JS::GCPtr<HTMLTableSectionElement> t_foot(); JS::GCPtr<HTMLTableSectionElement> t_foot();
DOM::ExceptionOr<void> set_t_foot(HTMLTableSectionElement* tfoot); WebIDL::ExceptionOr<void> set_t_foot(HTMLTableSectionElement* tfoot);
JS::NonnullGCPtr<HTMLTableSectionElement> create_t_foot(); JS::NonnullGCPtr<HTMLTableSectionElement> create_t_foot();
void delete_t_foot(); void delete_t_foot();
@ -39,8 +39,8 @@ public:
JS::NonnullGCPtr<HTMLTableSectionElement> create_t_body(); JS::NonnullGCPtr<HTMLTableSectionElement> create_t_body();
JS::NonnullGCPtr<DOM::HTMLCollection> rows(); JS::NonnullGCPtr<DOM::HTMLCollection> rows();
DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index); WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index);
DOM::ExceptionOr<void> delete_row(long index); WebIDL::ExceptionOr<void> delete_row(long index);
private: private:
HTMLTableElement(DOM::Document&, DOM::QualifiedName); HTMLTableElement(DOM::Document&, DOM::QualifiedName);

View file

@ -36,7 +36,7 @@ JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
} }
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-insertrow // https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-insertrow
DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableSectionElement::insert_row(long index) WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableSectionElement::insert_row(long index)
{ {
auto rows_collection = rows(); auto rows_collection = rows();
auto rows_collection_size = static_cast<long>(rows_collection->length()); auto rows_collection_size = static_cast<long>(rows_collection->length());
@ -60,7 +60,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> HTMLTableSectionElement:
} }
// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-deleterow // https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-deleterow
DOM::ExceptionOr<void> HTMLTableSectionElement::delete_row(long index) WebIDL::ExceptionOr<void> HTMLTableSectionElement::delete_row(long index)
{ {
auto rows_collection = rows(); auto rows_collection = rows();
auto rows_collection_size = static_cast<long>(rows_collection->length()); auto rows_collection_size = static_cast<long>(rows_collection->length());

View file

@ -18,8 +18,8 @@ public:
virtual ~HTMLTableSectionElement() override; virtual ~HTMLTableSectionElement() override;
JS::NonnullGCPtr<DOM::HTMLCollection> rows() const; JS::NonnullGCPtr<DOM::HTMLCollection> rows() const;
DOM::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index); WebIDL::ExceptionOr<JS::NonnullGCPtr<HTMLTableRowElement>> insert_row(long index);
DOM::ExceptionOr<void> delete_row(long index); WebIDL::ExceptionOr<void> delete_row(long index);
private: private:
HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName); HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName);

View file

@ -30,21 +30,21 @@ void History::visit_edges(Cell::Visitor& visitor)
} }
// https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate // https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate
DOM::ExceptionOr<void> History::push_state(JS::Value data, String const&, String const& url) WebIDL::ExceptionOr<void> History::push_state(JS::Value data, String const&, String const& url)
{ {
// NOTE: The second parameter of this function is intentionally unused. // NOTE: The second parameter of this function is intentionally unused.
return shared_history_push_replace_state(data, url, IsPush::Yes); return shared_history_push_replace_state(data, url, IsPush::Yes);
} }
// https://html.spec.whatwg.org/multipage/history.html#dom-history-replacestate // https://html.spec.whatwg.org/multipage/history.html#dom-history-replacestate
DOM::ExceptionOr<void> History::replace_state(JS::Value data, String const&, String const& url) WebIDL::ExceptionOr<void> History::replace_state(JS::Value data, String const&, String const& url)
{ {
// NOTE: The second parameter of this function is intentionally unused. // NOTE: The second parameter of this function is intentionally unused.
return shared_history_push_replace_state(data, url, IsPush::No); return shared_history_push_replace_state(data, url, IsPush::No);
} }
// https://html.spec.whatwg.org/multipage/history.html#shared-history-push/replace-state-steps // https://html.spec.whatwg.org/multipage/history.html#shared-history-push/replace-state-steps
DOM::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value, String const&, IsPush) WebIDL::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value, String const&, IsPush)
{ {
// 1. Let document be history's associated Document. (NOTE: Not necessary) // 1. Let document be history's associated Document. (NOTE: Not necessary)

View file

@ -9,7 +9,7 @@
#include <LibJS/Heap/Handle.h> #include <LibJS/Heap/Handle.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -21,8 +21,8 @@ public:
virtual ~History() override; virtual ~History() override;
DOM::ExceptionOr<void> push_state(JS::Value data, String const& unused, String const& url); WebIDL::ExceptionOr<void> push_state(JS::Value data, String const& unused, String const& url);
DOM::ExceptionOr<void> replace_state(JS::Value data, String const& unused, String const& url); WebIDL::ExceptionOr<void> replace_state(JS::Value data, String const& unused, String const& url);
private: private:
explicit History(HTML::Window&, DOM::Document&); explicit History(HTML::Window&, DOM::Document&);
@ -33,7 +33,7 @@ private:
No, No,
Yes, Yes,
}; };
DOM::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push); WebIDL::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push);
JS::NonnullGCPtr<DOM::Document> m_associated_document; JS::NonnullGCPtr<DOM::Document> m_associated_document;
}; };

View file

@ -57,7 +57,7 @@ String Storage::get_item(String const& key) const
} }
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem // https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem
DOM::ExceptionOr<void> Storage::set_item(String const& key, String const& value) WebIDL::ExceptionOr<void> Storage::set_item(String const& key, String const& value)
{ {
// 1. Let oldValue be null. // 1. Let oldValue be null.
String old_value; String old_value;

View file

@ -8,7 +8,7 @@
#include <AK/HashMap.h> #include <AK/HashMap.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -22,7 +22,7 @@ public:
size_t length() const; size_t length() const;
String key(size_t index); String key(size_t index);
String get_item(String const& key) const; String get_item(String const& key) const;
DOM::ExceptionOr<void> set_item(String const& key, String const& value); WebIDL::ExceptionOr<void> set_item(String const& key, String const& value);
void remove_item(String const& key); void remove_item(String const& key);
void clear(); void clear();

View file

@ -596,7 +596,7 @@ Window* Window::parent()
} }
// https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps // https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps
DOM::ExceptionOr<void> Window::post_message_impl(JS::Value message, String const&) WebIDL::ExceptionOr<void> Window::post_message_impl(JS::Value message, String const&)
{ {
// FIXME: This is an ad-hoc hack implementation instead, since we don't currently // FIXME: This is an ad-hoc hack implementation instead, since we don't currently
// have serialization and deserialization of messages. // have serialization and deserialization of messages.

View file

@ -108,7 +108,7 @@ public:
Window* parent(); Window* parent();
DOM::ExceptionOr<void> post_message_impl(JS::Value, String const& target_origin); WebIDL::ExceptionOr<void> post_message_impl(JS::Value, String const& target_origin);
String name() const; String name() const;
void set_name(String const&); void set_name(String const&);

View file

@ -8,10 +8,10 @@
#include <LibJS/Runtime/ConsoleObject.h> #include <LibJS/Runtime/ConsoleObject.h>
#include <LibJS/Runtime/Realm.h> #include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/HTML/Scripting/Environments.h> #include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Worker.h> #include <LibWeb/HTML/Worker.h>
#include <LibWeb/HTML/WorkerDebugConsoleClient.h> #include <LibWeb/HTML/WorkerDebugConsoleClient.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML { namespace Web::HTML {
@ -39,7 +39,7 @@ void Worker::visit_edges(Cell::Visitor& visitor)
} }
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker // https://html.spec.whatwg.org/multipage/workers.html#dom-worker
DOM::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document) WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document)
{ {
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url); dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url);
@ -312,7 +312,7 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
} }
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker-terminate // https://html.spec.whatwg.org/multipage/workers.html#dom-worker-terminate
DOM::ExceptionOr<void> Worker::terminate() WebIDL::ExceptionOr<void> Worker::terminate()
{ {
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Terminate"); dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Terminate");

View file

@ -36,13 +36,13 @@ class Worker : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(Worker, DOM::EventTarget); WEB_PLATFORM_OBJECT(Worker, DOM::EventTarget);
public: public:
static DOM::ExceptionOr<JS::NonnullGCPtr<Worker>> create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document); static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document);
static DOM::ExceptionOr<JS::NonnullGCPtr<Worker>> create_with_global_object(HTML::Window& window, FlyString const& script_url, WorkerOptions const options) static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> create_with_global_object(HTML::Window& window, FlyString const& script_url, WorkerOptions const options)
{ {
return Worker::create(script_url, options, window.associated_document()); return Worker::create(script_url, options, window.associated_document());
} }
DOM::ExceptionOr<void> terminate(); WebIDL::ExceptionOr<void> terminate();
void post_message(JS::Value message, JS::Value transfer); void post_message(JS::Value message, JS::Value transfer);

View file

@ -43,7 +43,7 @@ void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor)
} }
// https://html.spec.whatwg.org/multipage/workers.html#importing-scripts-and-libraries // https://html.spec.whatwg.org/multipage/workers.html#importing-scripts-and-libraries
DOM::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls) WebIDL::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls)
{ {
// The algorithm may optionally be customized by supplying custom perform the fetch hooks, // The algorithm may optionally be customized by supplying custom perform the fetch hooks,
// which if provided will be used when invoking fetch a classic worker-imported script. // which if provided will be used when invoking fetch a classic worker-imported script.
@ -121,7 +121,7 @@ bool WorkerGlobalScope::cross_origin_isolated() const
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa // https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa
DOM::ExceptionOr<String> WorkerGlobalScope::btoa(String const& data) const WebIDL::ExceptionOr<String> WorkerGlobalScope::btoa(String const& data) const
{ {
// FIXME: This is the same as the implementation in Bindings/WindowObject.cpp // FIXME: This is the same as the implementation in Bindings/WindowObject.cpp
// Find a way to share this implementation, since they come from the same mixin. // Find a way to share this implementation, since they come from the same mixin.
@ -141,7 +141,7 @@ DOM::ExceptionOr<String> WorkerGlobalScope::btoa(String const& data) const
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob // https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob
DOM::ExceptionOr<String> WorkerGlobalScope::atob(String const& data) const WebIDL::ExceptionOr<String> WorkerGlobalScope::atob(String const& data) const
{ {
// FIXME: This is the same as the implementation in Bindings/WindowObject.cpp // FIXME: This is the same as the implementation in Bindings/WindowObject.cpp
// Find a way to share this implementation, since they come from the same mixin. // Find a way to share this implementation, since they come from the same mixin.

View file

@ -10,10 +10,10 @@
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <AK/URL.h> #include <AK/URL.h>
#include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/HTML/WorkerLocation.h> #include <LibWeb/HTML/WorkerLocation.h>
#include <LibWeb/HTML/WorkerNavigator.h> #include <LibWeb/HTML/WorkerNavigator.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#define ENUMERATE_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \ #define ENUMERATE_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \
E(onerror, HTML::EventNames::error) \ E(onerror, HTML::EventNames::error) \
@ -42,7 +42,7 @@ public:
JS::NonnullGCPtr<WorkerLocation> location() const; JS::NonnullGCPtr<WorkerLocation> location() const;
JS::NonnullGCPtr<WorkerNavigator> navigator() const; JS::NonnullGCPtr<WorkerNavigator> navigator() const;
DOM::ExceptionOr<void> import_scripts(Vector<String> urls); WebIDL::ExceptionOr<void> import_scripts(Vector<String> urls);
#undef __ENUMERATE #undef __ENUMERATE
#define __ENUMERATE(attribute_name, event_name) \ #define __ENUMERATE(attribute_name, event_name) \
@ -57,8 +57,8 @@ public:
String origin() const; String origin() const;
bool is_secure_context() const; bool is_secure_context() const;
bool cross_origin_isolated() const; bool cross_origin_isolated() const;
DOM::ExceptionOr<String> btoa(String const& data) const; WebIDL::ExceptionOr<String> btoa(String const& data) const;
DOM::ExceptionOr<String> atob(String const& data) const; WebIDL::ExceptionOr<String> atob(String const& data) const;
// Non-IDL public methods // Non-IDL public methods

View file

@ -25,7 +25,7 @@ SVGLength::SVGLength(HTML::Window& window, u8 unit_type, float value)
SVGLength::~SVGLength() = default; SVGLength::~SVGLength() = default;
// https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value // https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value
DOM::ExceptionOr<void> SVGLength::set_value(float value) WebIDL::ExceptionOr<void> SVGLength::set_value(float value)
{ {
// FIXME: Raise an exception if this <length> is read-only. // FIXME: Raise an exception if this <length> is read-only.
m_value = value; m_value = value;

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h> #include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::SVG { namespace Web::SVG {
@ -22,7 +22,7 @@ public:
u8 unit_type() const { return m_unit_type; } u8 unit_type() const { return m_unit_type; }
float value() const { return m_value; } float value() const { return m_value; }
DOM::ExceptionOr<void> set_value(float value); WebIDL::ExceptionOr<void> set_value(float value);
private: private:
SVGLength(HTML::Window&, u8 unit_type, float value); SVGLength(HTML::Window&, u8 unit_type, float value);

View file

@ -11,7 +11,7 @@
namespace Web::Streams { namespace Web::Streams {
// https://streams.spec.whatwg.org/#rs-constructor // https://streams.spec.whatwg.org/#rs-constructor
DOM::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::create_with_global_object(HTML::Window& window) WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> ReadableStream::create_with_global_object(HTML::Window& window)
{ {
auto* readable_stream = window.heap().allocate<ReadableStream>(window.realm(), window); auto* readable_stream = window.heap().allocate<ReadableStream>(window.realm(), window);

View file

@ -24,7 +24,7 @@ public:
Errored, Errored,
}; };
static DOM::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> create_with_global_object(HTML::Window&); static WebIDL::ExceptionOr<JS::NonnullGCPtr<ReadableStream>> create_with_global_object(HTML::Window&);
virtual ~ReadableStream() override; virtual ~ReadableStream() override;

View file

@ -16,7 +16,7 @@ JS::NonnullGCPtr<URL> URL::create(HTML::Window& window, AK::URL url, JS::Nonnull
return *window.heap().allocate<URL>(window.realm(), window, move(url), move(query)); return *window.heap().allocate<URL>(window.realm(), window, move(url), move(query));
} }
DOM::ExceptionOr<JS::NonnullGCPtr<URL>> URL::create_with_global_object(HTML::Window& window, String const& url, String const& base) WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> URL::create_with_global_object(HTML::Window& window, String const& url, String const& base)
{ {
// 1. Let parsedBase be null. // 1. Let parsedBase be null.
Optional<AK::URL> parsed_base; Optional<AK::URL> parsed_base;
@ -26,7 +26,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<URL>> URL::create_with_global_object(HTML::Win
parsed_base = base; parsed_base = base;
// 2. If parsedBase is failure, then throw a TypeError. // 2. If parsedBase is failure, then throw a TypeError.
if (!parsed_base->is_valid()) if (!parsed_base->is_valid())
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid base URL" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid base URL" };
} }
// 3. Let parsedURL be the result of running the basic URL parser on url with parsedBase. // 3. Let parsedURL be the result of running the basic URL parser on url with parsedBase.
AK::URL parsed_url; AK::URL parsed_url;
@ -36,7 +36,7 @@ DOM::ExceptionOr<JS::NonnullGCPtr<URL>> URL::create_with_global_object(HTML::Win
parsed_url = url; parsed_url = url;
// 4. If parsedURL is failure, then throw a TypeError. // 4. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid()) if (!parsed_url.is_valid())
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid URL" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid URL" };
// 5. Let query be parsedURLs query, if that is non-null, and the empty string otherwise. // 5. Let query be parsedURLs query, if that is non-null, and the empty string otherwise.
auto& query = parsed_url.query().is_null() ? String::empty() : parsed_url.query(); auto& query = parsed_url.query().is_null() ? String::empty() : parsed_url.query();
// 6. Set thiss URL to parsedURL. // 6. Set thiss URL to parsedURL.
@ -78,13 +78,13 @@ String URL::to_json() const
return m_url.serialize(); return m_url.serialize();
} }
DOM::ExceptionOr<void> URL::set_href(String const& href) WebIDL::ExceptionOr<void> URL::set_href(String const& href)
{ {
// 1. Let parsedURL be the result of running the basic URL parser on the given value. // 1. Let parsedURL be the result of running the basic URL parser on the given value.
AK::URL parsed_url = href; AK::URL parsed_url = href;
// 2. If parsedURL is failure, then throw a TypeError. // 2. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid()) if (!parsed_url.is_valid())
return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid URL" }; return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid URL" };
// 3. Set thiss URL to parsedURL. // 3. Set thiss URL to parsedURL.
m_url = move(parsed_url); m_url = move(parsed_url);
// 4. Empty thiss query objects list. // 4. Empty thiss query objects list.

View file

@ -10,8 +10,8 @@
#include <AK/String.h> #include <AK/String.h>
#include <AK/URL.h> #include <AK/URL.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/URL/URLSearchParams.h> #include <LibWeb/URL/URLSearchParams.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::URL { namespace Web::URL {
@ -20,12 +20,12 @@ class URL : public Bindings::PlatformObject {
public: public:
static JS::NonnullGCPtr<URL> create(HTML::Window&, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query); static JS::NonnullGCPtr<URL> create(HTML::Window&, AK::URL url, JS::NonnullGCPtr<URLSearchParams> query);
static DOM::ExceptionOr<JS::NonnullGCPtr<URL>> create_with_global_object(HTML::Window&, String const& url, String const& base); static WebIDL::ExceptionOr<JS::NonnullGCPtr<URL>> create_with_global_object(HTML::Window&, String const& url, String const& base);
virtual ~URL() override; virtual ~URL() override;
String href() const; String href() const;
DOM::ExceptionOr<void> set_href(String const&); WebIDL::ExceptionOr<void> set_href(String const&);
String origin() const; String origin() const;

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