diff --git a/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h b/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h index 3a44f87da8..3f9b5d67ac 100644 --- a/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h +++ b/Userland/Libraries/LibWeb/Bindings/ExceptionOrUtils.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace Web::Bindings { @@ -17,7 +17,7 @@ template constexpr bool IsExceptionOr = false; template -constexpr bool IsExceptionOr> = true; +constexpr bool IsExceptionOr> = true; template constexpr bool IsThrowCompletionOr = false; @@ -33,7 +33,7 @@ struct ExtractExceptionOrValueType { }; template -struct ExtractExceptionOrValueType> { +struct ExtractExceptionOrValueType> { using Type = T; }; @@ -48,22 +48,22 @@ struct ExtractExceptionOrValueType { }; template<> -struct ExtractExceptionOrValueType> { +struct ExtractExceptionOrValueType> { using Type = JS::Value; }; template<> -struct ExtractExceptionOrValueType> { +struct ExtractExceptionOrValueType> { using Type = JS::Value; }; ALWAYS_INLINE JS::Completion dom_exception_to_throw_completion(auto&& vm, auto&& exception) { return exception.visit( - [&](DOM::SimpleException const& exception) { + [&](WebIDL::SimpleException const& exception) { switch (exception.type) { -#define E(x) \ - case DOM::SimpleExceptionType::x: \ +#define E(x) \ + case WebIDL::SimpleExceptionType::x: \ return vm.template throw_completion(exception.message); ENUMERATE_SIMPLE_WEBIDL_EXCEPTION_TYPES(E) diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp index ef44d0fd03..8b835b2da6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp @@ -27,7 +27,7 @@ void CSSGroupingRule::visit_edges(Cell::Visitor& visitor) visitor.visit(&m_rules); } -DOM::ExceptionOr CSSGroupingRule::insert_rule(StringView rule, u32 index) +WebIDL::ExceptionOr CSSGroupingRule::insert_rule(StringView rule, u32 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. @@ -35,7 +35,7 @@ DOM::ExceptionOr CSSGroupingRule::insert_rule(StringView rule, u32 index) return index; } -DOM::ExceptionOr CSSGroupingRule::delete_rule(u32 index) +WebIDL::ExceptionOr CSSGroupingRule::delete_rule(u32 index) { return m_rules.remove_a_css_rule(index); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h index a4cd691821..9e220e3a8c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h @@ -23,8 +23,8 @@ public: CSSRuleList const& css_rules() const { return m_rules; } CSSRuleList& css_rules() { return m_rules; } CSSRuleList* css_rules_for_bindings() { return &m_rules; } - DOM::ExceptionOr insert_rule(StringView rule, u32 index = 0); - DOM::ExceptionOr delete_rule(u32 index); + WebIDL::ExceptionOr insert_rule(StringView rule, u32 index = 0); + WebIDL::ExceptionOr delete_rule(u32 index); virtual void for_each_effective_style_rule(Function const& callback) const; diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index bbd5f35b59..d8da0487a6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -48,7 +48,7 @@ bool CSSRuleList::is_supported_property_index(u32 index) const } // https://www.w3.org/TR/cssom/#insert-a-css-rule -DOM::ExceptionOr CSSRuleList::insert_a_css_rule(Variant rule, u32 index) +WebIDL::ExceptionOr CSSRuleList::insert_a_css_rule(Variant rule, u32 index) { // 1. Set length to the number of items in list. auto length = m_rules.size(); @@ -86,7 +86,7 @@ DOM::ExceptionOr CSSRuleList::insert_a_css_rule(Variant CSSRuleList::remove_a_css_rule(u32 index) +WebIDL::ExceptionOr CSSRuleList::remove_a_css_rule(u32 index) { // 1. Set length to the number of items in list. auto length = m_rules.size(); diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h index 8e471bb32b..17c9297505 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.h @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include namespace Web::CSS { @@ -57,8 +57,8 @@ public: virtual bool is_supported_property_index(u32 index) const override; virtual JS::Value item_value(size_t index) const override; - DOM::ExceptionOr remove_a_css_rule(u32 index); - DOM::ExceptionOr insert_a_css_rule(Variant, u32 index); + WebIDL::ExceptionOr remove_a_css_rule(u32 index); + WebIDL::ExceptionOr insert_a_css_rule(Variant, u32 index); void for_each_effective_style_rule(Function const& callback) const; // Returns whether the match state of any media queries changed after evaluation. diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 8620d761af..799218c30d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -69,7 +69,7 @@ Optional PropertyOwningCSSStyleDeclaration::property(PropertyID p } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty -DOM::ExceptionOr PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority) +WebIDL::ExceptionOr PropertyOwningCSSStyleDeclaration::set_property(PropertyID property_id, StringView value, StringView priority) { // 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration. @@ -117,7 +117,7 @@ DOM::ExceptionOr PropertyOwningCSSStyleDeclaration::set_property(PropertyI } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty -DOM::ExceptionOr PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id) +WebIDL::ExceptionOr PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id) { // 1. If the computed flag is set, then throw a NoModificationAllowedError exception. // 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" : ""; } -DOM::ExceptionOr CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority) +WebIDL::ExceptionOr CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority) { auto property_id = property_id_from_string(property_name); if (property_id == CSS::PropertyID::Invalid) @@ -222,7 +222,7 @@ DOM::ExceptionOr CSSStyleDeclaration::set_property(StringView property_nam return set_property(property_id, css_text, priority); } -DOM::ExceptionOr CSSStyleDeclaration::remove_property(StringView property_name) +WebIDL::ExceptionOr CSSStyleDeclaration::remove_property(StringView property_name) { auto property_id = property_id_from_string(property_name); if (property_id == CSS::PropertyID::Invalid) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 31c125406a..13dd3f7780 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -36,11 +36,11 @@ public: virtual Optional property(PropertyID) const = 0; - virtual DOM::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0; - virtual DOM::ExceptionOr remove_property(PropertyID) = 0; + virtual WebIDL::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0; + virtual WebIDL::ExceptionOr remove_property(PropertyID) = 0; - DOM::ExceptionOr set_property(StringView property_name, StringView css_text, StringView priority); - DOM::ExceptionOr remove_property(StringView property_name); + WebIDL::ExceptionOr set_property(StringView property_name, StringView css_text, StringView priority); + WebIDL::ExceptionOr remove_property(StringView property_name); String get_property_value(StringView property) const; String get_property_priority(StringView property) const; @@ -72,8 +72,8 @@ public: virtual Optional property(PropertyID) const override; - virtual DOM::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority) override; - virtual DOM::ExceptionOr remove_property(PropertyID) override; + virtual WebIDL::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority) override; + virtual WebIDL::ExceptionOr remove_property(PropertyID) override; Vector const& properties() const { return m_properties; } HashMap const& custom_properties() const { return m_custom_properties; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 3ba873d5e5..ef8a525728 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include namespace Web::CSS { @@ -39,7 +39,7 @@ void CSSStyleSheet::visit_edges(Cell::Visitor& visitor) } // https://www.w3.org/TR/cssom/#dom-cssstylesheet-insertrule -DOM::ExceptionOr CSSStyleSheet::insert_rule(StringView rule, unsigned index) +WebIDL::ExceptionOr CSSStyleSheet::insert_rule(StringView rule, unsigned index) { // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception. @@ -71,7 +71,7 @@ DOM::ExceptionOr CSSStyleSheet::insert_rule(StringView rule, unsigned } // https://www.w3.org/TR/cssom/#dom-cssstylesheet-deleterule -DOM::ExceptionOr CSSStyleSheet::delete_rule(unsigned index) +WebIDL::ExceptionOr CSSStyleSheet::delete_rule(unsigned index) { // FIXME: 1. If the origin-clean flag is unset, throw a SecurityError exception. @@ -89,7 +89,7 @@ DOM::ExceptionOr CSSStyleSheet::delete_rule(unsigned index) } // https://www.w3.org/TR/cssom/#dom-cssstylesheet-removerule -DOM::ExceptionOr CSSStyleSheet::remove_rule(unsigned index) +WebIDL::ExceptionOr CSSStyleSheet::remove_rule(unsigned index) { // The removeRule(index) method must run the same steps as deleteRule(). return delete_rule(index); diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 4672921f41..e462789496 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -40,9 +40,9 @@ public: CSSRuleList* css_rules() { return m_rules; } CSSRuleList const* css_rules() const { return m_rules; } - DOM::ExceptionOr insert_rule(StringView rule, unsigned index); - DOM::ExceptionOr remove_rule(unsigned index); - DOM::ExceptionOr delete_rule(unsigned index); + WebIDL::ExceptionOr insert_rule(StringView rule, unsigned index); + WebIDL::ExceptionOr remove_rule(unsigned index); + WebIDL::ExceptionOr delete_rule(unsigned index); void for_each_effective_style_rule(Function const& callback) const; // Returns whether the match state of any media queries changed after evaluation. diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 62430f7506..61b27774e0 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -535,14 +535,14 @@ Optional ResolvedCSSStyleDeclaration::property(PropertyID propert } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty -DOM::ExceptionOr ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView) +WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView) { // 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()"); } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty -DOM::ExceptionOr ResolvedCSSStyleDeclaration::remove_property(PropertyID) +WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::remove_property(PropertyID) { // 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()"); diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h index f1bd202117..2700f7dd8d 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h @@ -22,8 +22,8 @@ public: virtual size_t length() const override; virtual String item(size_t index) const override; virtual Optional property(PropertyID) const override; - virtual DOM::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority) override; - virtual DOM::ExceptionOr remove_property(PropertyID) override; + virtual WebIDL::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority) override; + virtual WebIDL::ExceptionOr remove_property(PropertyID) override; virtual String serialized() const override; diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index f4626ac331..aa35018314 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -39,7 +39,7 @@ JS::NonnullGCPtr Crypto::subtle() const } // https://w3c.github.io/webcrypto/#dfn-Crypto-method-getRandomValues -DOM::ExceptionOr Crypto::get_random_values(JS::Value array) const +WebIDL::ExceptionOr 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. if (!array.is_object() || !(is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()) || is(array.as_object()))) diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.h b/Userland/Libraries/LibWeb/Crypto/Crypto.h index f7f4a9475d..dececef8b5 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.h +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Web::Crypto { @@ -22,7 +22,7 @@ public: JS::NonnullGCPtr subtle() const; - DOM::ExceptionOr get_random_values(JS::Value array) const; + WebIDL::ExceptionOr get_random_values(JS::Value array) const; String random_uuid() const; protected: diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index 95a40568de..a1344ac18b 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -31,7 +31,7 @@ void CharacterData::set_data(String data) } // https://dom.spec.whatwg.org/#concept-cd-substring -ExceptionOr CharacterData::substring_data(size_t offset, size_t count) const +WebIDL::ExceptionOr CharacterData::substring_data(size_t offset, size_t count) const { // 1. Let length be node’s length. auto length = this->length(); @@ -50,7 +50,7 @@ ExceptionOr CharacterData::substring_data(size_t offset, size_t count) c } // https://dom.spec.whatwg.org/#concept-cd-replace -ExceptionOr CharacterData::replace_data(size_t offset, size_t count, String const& data) +WebIDL::ExceptionOr CharacterData::replace_data(size_t offset, size_t count, String const& data) { // 1. Let length be node’s length. auto length = this->length(); @@ -109,21 +109,21 @@ ExceptionOr CharacterData::replace_data(size_t offset, size_t count, Strin } // https://dom.spec.whatwg.org/#dom-characterdata-appenddata -ExceptionOr CharacterData::append_data(String const& data) +WebIDL::ExceptionOr CharacterData::append_data(String const& data) { // The appendData(data) method steps are to replace data with node this, offset this’s length, count 0, and data data. return replace_data(m_data.length(), 0, data); } // https://dom.spec.whatwg.org/#dom-characterdata-insertdata -ExceptionOr CharacterData::insert_data(size_t offset, String const& data) +WebIDL::ExceptionOr 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. return replace_data(offset, 0, data); } // https://dom.spec.whatwg.org/#dom-characterdata-deletedata -ExceptionOr CharacterData::delete_data(size_t offset, size_t count) +WebIDL::ExceptionOr 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. return replace_data(offset, count, String::empty()); diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.h b/Userland/Libraries/LibWeb/DOM/CharacterData.h index b57e1ebf21..a97ecad4b0 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.h +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.h @@ -27,11 +27,11 @@ public: unsigned length() const { return m_data.length(); } - ExceptionOr substring_data(size_t offset, size_t count) const; - ExceptionOr append_data(String const&); - ExceptionOr insert_data(size_t offset, String const&); - ExceptionOr delete_data(size_t offset, size_t count); - ExceptionOr replace_data(size_t offset, size_t count, String const&); + WebIDL::ExceptionOr substring_data(size_t offset, size_t count) const; + WebIDL::ExceptionOr append_data(String const&); + WebIDL::ExceptionOr insert_data(size_t offset, String const&); + WebIDL::ExceptionOr delete_data(size_t offset, size_t count); + WebIDL::ExceptionOr replace_data(size_t offset, size_t count, String const&); protected: explicit CharacterData(Document&, NodeType, String const&); diff --git a/Userland/Libraries/LibWeb/DOM/ChildNode.h b/Userland/Libraries/LibWeb/DOM/ChildNode.h index ca7b48ae1d..4a54f7d518 100644 --- a/Userland/Libraries/LibWeb/DOM/ChildNode.h +++ b/Userland/Libraries/LibWeb/DOM/ChildNode.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include namespace Web::DOM { @@ -16,7 +16,7 @@ template class ChildNode { public: // https://dom.spec.whatwg.org/#dom-childnode-before - ExceptionOr before(Vector, String>> const& nodes) + WebIDL::ExceptionOr before(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -46,7 +46,7 @@ public: } // https://dom.spec.whatwg.org/#dom-childnode-after - ExceptionOr after(Vector, String>> const& nodes) + WebIDL::ExceptionOr after(Vector, String>> const& nodes) { auto* node = static_cast(this); @@ -70,7 +70,7 @@ public: } // https://dom.spec.whatwg.org/#dom-childnode-replacewith - ExceptionOr replace_with(Vector, String>> const& nodes) + WebIDL::ExceptionOr replace_with(Vector, String>> const& nodes) { auto* node = static_cast(this); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp index d1cb97ff5e..69da598dcd 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.cpp @@ -38,7 +38,7 @@ void DOMImplementation::visit_edges(Cell::Visitor& visitor) } // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument -ExceptionOr> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, JS::GCPtr doctype) const +WebIDL::ExceptionOr> DOMImplementation::create_document(String const& namespace_, String const& qualified_name, JS::GCPtr doctype) const { // FIXME: This should specifically be an XML document. auto xml_document = Document::create(Bindings::main_thread_internal_window_object()); @@ -103,7 +103,7 @@ JS::NonnullGCPtr DOMImplementation::create_html_document(String const& } // https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype -ExceptionOr> DOMImplementation::create_document_type(String const& qualified_name, String const& public_id, String const& system_id) +WebIDL::ExceptionOr> 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)); auto document_type = DocumentType::create(document()); diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index 3aac381a78..b4776c727b 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -20,9 +20,9 @@ public: static JS::NonnullGCPtr create(Document&); virtual ~DOMImplementation(); - ExceptionOr> create_document(String const&, String const&, JS::GCPtr) const; + WebIDL::ExceptionOr> create_document(String const&, String const&, JS::GCPtr) const; JS::NonnullGCPtr create_html_document(String const& title) const; - ExceptionOr> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); + WebIDL::ExceptionOr> create_document_type(String const& qualified_name, String const& public_id, String const& system_id); // https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature bool has_feature() const { return true; } diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 82ef51ed99..f448000e9c 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -108,7 +108,7 @@ bool DOMTokenList::contains(StringView token) } // https://dom.spec.whatwg.org/#dom-domtokenlist-add -ExceptionOr DOMTokenList::add(Vector const& tokens) +WebIDL::ExceptionOr DOMTokenList::add(Vector const& tokens) { // 1. For each token in tokens: for (auto const& token : tokens) { @@ -126,7 +126,7 @@ ExceptionOr DOMTokenList::add(Vector const& tokens) } // https://dom.spec.whatwg.org/#dom-domtokenlist-remove -ExceptionOr DOMTokenList::remove(Vector const& tokens) +WebIDL::ExceptionOr DOMTokenList::remove(Vector const& tokens) { // 1. For each token in tokens: for (auto const& token : tokens) { @@ -144,7 +144,7 @@ ExceptionOr DOMTokenList::remove(Vector const& tokens) } // https://dom.spec.whatwg.org/#dom-domtokenlist-toggle -ExceptionOr DOMTokenList::toggle(String const& token, Optional force) +WebIDL::ExceptionOr DOMTokenList::toggle(String const& token, Optional force) { // 1. If token is the empty string, then throw a "SyntaxError" DOMException. // 2. If token contains any ASCII whitespace, then throw an "InvalidCharacterError" DOMException. @@ -175,7 +175,7 @@ ExceptionOr DOMTokenList::toggle(String const& token, Optional force } // https://dom.spec.whatwg.org/#dom-domtokenlist-replace -ExceptionOr DOMTokenList::replace(String const& token, String const& new_token) +WebIDL::ExceptionOr DOMTokenList::replace(String const& token, String const& new_token) { // 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. @@ -198,13 +198,13 @@ ExceptionOr DOMTokenList::replace(String const& token, String const& new_t // https://dom.spec.whatwg.org/#dom-domtokenlist-supports // https://dom.spec.whatwg.org/#concept-domtokenlist-validation -ExceptionOr DOMTokenList::supports([[maybe_unused]] StringView token) +WebIDL::ExceptionOr DOMTokenList::supports([[maybe_unused]] StringView token) { // FIXME: Implement this fully when any use case defines supported tokens. // 1. If the associated attribute’s local name does not define supported tokens, throw a TypeError. - return DOM::SimpleException { - DOM::SimpleExceptionType::TypeError, + return WebIDL::SimpleException { + WebIDL::SimpleExceptionType::TypeError, 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)); } -ExceptionOr DOMTokenList::validate_token(StringView token) const +WebIDL::ExceptionOr DOMTokenList::validate_token(StringView token) const { if (token.is_empty()) return SyntaxError::create(global_object(), "Non-empty DOM tokens are not allowed"); diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h index 4197a7697a..b281e7e2ec 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.h +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.h @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include namespace Web::DOM { @@ -34,18 +34,18 @@ public: size_t length() const { return m_token_set.size(); } String const& item(size_t index) const; bool contains(StringView token); - ExceptionOr add(Vector const& tokens); - ExceptionOr remove(Vector const& tokens); - ExceptionOr toggle(String const& token, Optional force); - ExceptionOr replace(String const& token, String const& new_token); - ExceptionOr supports(StringView token); + WebIDL::ExceptionOr add(Vector const& tokens); + WebIDL::ExceptionOr remove(Vector const& tokens); + WebIDL::ExceptionOr toggle(String const& token, Optional force); + WebIDL::ExceptionOr replace(String const& token, String const& new_token); + WebIDL::ExceptionOr supports(StringView token); String value() const; void set_value(String value); private: DOMTokenList(Element const& associated_element, FlyString associated_attribute); - ExceptionOr validate_token(StringView token) const; + WebIDL::ExceptionOr validate_token(StringView token) const; void run_update_steps(); WeakPtr m_associated_element; diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 6c383f7959..398675eef6 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -73,6 +72,7 @@ #include #include #include +#include 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 -ExceptionOr Document::write(Vector const& strings) +WebIDL::ExceptionOr Document::write(Vector const& strings) { StringBuilder builder; builder.join(""sv, strings); @@ -360,7 +360,7 @@ ExceptionOr Document::write(Vector const& strings) } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-writeln -ExceptionOr Document::writeln(Vector const& strings) +WebIDL::ExceptionOr Document::writeln(Vector const& strings) { StringBuilder builder; builder.join(""sv, strings); @@ -370,7 +370,7 @@ ExceptionOr Document::writeln(Vector const& strings) } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-write-steps -ExceptionOr Document::run_the_document_write_steps(String input) +WebIDL::ExceptionOr Document::run_the_document_write_steps(String input) { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException. if (m_type == Type::XML) @@ -405,7 +405,7 @@ ExceptionOr Document::run_the_document_write_steps(String input) } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open -ExceptionOr Document::open(String const&, String const&) +WebIDL::ExceptionOr Document::open(String const&, String const&) { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. if (m_type == Type::XML) @@ -476,7 +476,7 @@ ExceptionOr Document::open(String const&, String const&) } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#closing-the-input-stream -ExceptionOr Document::close() +WebIDL::ExceptionOr Document::close() { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. if (m_type == Type::XML) @@ -585,7 +585,7 @@ HTML::HTMLElement* Document::body() } // https://html.spec.whatwg.org/multipage/dom.html#dom-document-body -ExceptionOr Document::set_body(HTML::HTMLElement* new_body) +WebIDL::ExceptionOr Document::set_body(HTML::HTMLElement* new_body) { if (!is(new_body) && !is(new_body)) 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 -DOM::ExceptionOr> Document::create_element(FlyString const& a_local_name) +WebIDL::ExceptionOr> Document::create_element(FlyString const& a_local_name) { auto local_name = a_local_name; @@ -1135,7 +1135,7 @@ DOM::ExceptionOr> Document::create_element(FlyString c // https://dom.spec.whatwg.org/#dom-document-createelementns // https://dom.spec.whatwg.org/#internal-createelementns-steps // FIXME: This only implements step 4 of the algorithm and does not take in options. -DOM::ExceptionOr> Document::create_element_ns(String const& namespace_, String const& qualified_name) +WebIDL::ExceptionOr> 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. auto extracted_qualified_name = TRY(validate_and_extract(global_object(), namespace_, qualified_name)); @@ -1168,7 +1168,7 @@ JS::NonnullGCPtr Document::create_range() } // https://dom.spec.whatwg.org/#dom-document-createevent -DOM::ExceptionOr> Document::create_event(String const& interface) +WebIDL::ExceptionOr> Document::create_event(String const& interface) { auto& window_object = window(); @@ -1285,7 +1285,7 @@ Vector> Document::take_scripts_to_execute_in } // https://dom.spec.whatwg.org/#dom-document-importnode -ExceptionOr> Document::import_node(JS::NonnullGCPtr node, bool deep) +WebIDL::ExceptionOr> Document::import_node(JS::NonnullGCPtr node, bool deep) { // 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException. if (is(*node) || is(*node)) @@ -1333,7 +1333,7 @@ void Document::adopt_node(Node& node) } // https://dom.spec.whatwg.org/#dom-document-adoptnode -ExceptionOr> Document::adopt_node_binding(JS::NonnullGCPtr node) +WebIDL::ExceptionOr> Document::adopt_node_binding(JS::NonnullGCPtr node) { if (is(*node)) 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 -ExceptionOr Document::validate_qualified_name(JS::Object& global_object, String const& qualified_name) +WebIDL::ExceptionOr Document::validate_qualified_name(JS::Object& global_object, String const& qualified_name) { if (qualified_name.is_empty()) return InvalidCharacterError::create(global_object, "Empty string is not a valid qualified name."); diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 337690e629..5969a115ca 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include #include #include +#include namespace Web::DOM { @@ -156,7 +156,7 @@ public: return const_cast(this)->body(); } - ExceptionOr set_body(HTML::HTMLElement* new_body); + WebIDL::ExceptionOr set_body(HTML::HTMLElement* new_body); String title() const; void set_title(String const&); @@ -219,12 +219,12 @@ public: JS::Value run_javascript(StringView source, StringView filename = "(unknown)"sv); - ExceptionOr> create_element(FlyString const& local_name); - ExceptionOr> create_element_ns(String const& namespace_, String const& qualified_name); + WebIDL::ExceptionOr> create_element(FlyString const& local_name); + WebIDL::ExceptionOr> create_element_ns(String const& namespace_, String const& qualified_name); JS::NonnullGCPtr create_document_fragment(); JS::NonnullGCPtr create_text_node(String const& data); JS::NonnullGCPtr create_comment(String const& data); - ExceptionOr> create_event(String const& interface); + WebIDL::ExceptionOr> create_event(String const& interface); JS::NonnullGCPtr create_range(); void set_pending_parsing_blocking_script(Badge, HTML::HTMLScriptElement*); @@ -253,9 +253,9 @@ public: // https://dom.spec.whatwg.org/#xml-document bool is_xml_document() const { return m_type == Type::XML; } - ExceptionOr> import_node(JS::NonnullGCPtr node, bool deep); + WebIDL::ExceptionOr> import_node(JS::NonnullGCPtr node, bool deep); void adopt_node(Node&); - ExceptionOr> adopt_node_binding(JS::NonnullGCPtr); + WebIDL::ExceptionOr> adopt_node_binding(JS::NonnullGCPtr); DocumentType const* doctype() const; String const& compat_mode() const; @@ -286,11 +286,11 @@ public: void set_window(Badge, HTML::Window&); - ExceptionOr write(Vector const& strings); - ExceptionOr writeln(Vector const& strings); + WebIDL::ExceptionOr write(Vector const& strings); + WebIDL::ExceptionOr writeln(Vector const& strings); - ExceptionOr open(String const& = "", String const& = ""); - ExceptionOr close(); + WebIDL::ExceptionOr open(String const& = "", String const& = ""); + WebIDL::ExceptionOr close(); HTML::Window* default_view() { return m_window.ptr(); } @@ -367,7 +367,7 @@ public: FlyString prefix; FlyString tag_name; }; - static ExceptionOr validate_qualified_name(JS::Object& global_object, String const& qualified_name); + static WebIDL::ExceptionOr validate_qualified_name(JS::Object& global_object, String const& qualified_name); JS::NonnullGCPtr create_node_iterator(Node& root, unsigned what_to_show, JS::GCPtr); JS::NonnullGCPtr create_tree_walker(Node& root, unsigned what_to_show, JS::GCPtr); @@ -449,7 +449,7 @@ private: void evaluate_media_rules(); - ExceptionOr run_the_document_write_steps(String); + WebIDL::ExceptionOr run_the_document_write_steps(String); size_t m_next_layout_node_serial_id { 0 }; diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 5920b32ed8..14d2c5ef37 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -39,6 +38,7 @@ #include #include #include +#include namespace Web::DOM { @@ -82,7 +82,7 @@ String Element::get_attribute(FlyString const& name) const } // https://dom.spec.whatwg.org/#dom-element-setattribute -ExceptionOr Element::set_attribute(FlyString const& name, String const& value) +WebIDL::ExceptionOr 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. // FIXME: Proper name validation @@ -118,7 +118,7 @@ ExceptionOr Element::set_attribute(FlyString const& name, String const& va } // https://dom.spec.whatwg.org/#validate-and-extract -ExceptionOr validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name) +WebIDL::ExceptionOr validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name) { // 1. If namespace is the empty string, then set it to null. if (namespace_.is_empty()) @@ -161,7 +161,7 @@ ExceptionOr validate_and_extract(JS::Object& global_object, FlySt } // https://dom.spec.whatwg.org/#dom-element-setattributens -ExceptionOr Element::set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value) +WebIDL::ExceptionOr 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. 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 -DOM::ExceptionOr Element::toggle_attribute(FlyString const& name, Optional force) +WebIDL::ExceptionOr Element::toggle_attribute(FlyString const& name, Optional force) { // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // FIXME: Proper name validation @@ -439,7 +439,7 @@ DOMTokenList* Element::class_list() } // https://dom.spec.whatwg.org/#dom-element-matches -DOM::ExceptionOr Element::matches(StringView selectors) const +WebIDL::ExceptionOr Element::matches(StringView selectors) const { auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast(const_cast(*this))), selectors); if (!maybe_selectors.has_value()) @@ -454,7 +454,7 @@ DOM::ExceptionOr Element::matches(StringView selectors) const } // https://dom.spec.whatwg.org/#dom-element-closest -DOM::ExceptionOr Element::closest(StringView selectors) const +WebIDL::ExceptionOr Element::closest(StringView selectors) const { auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast(const_cast(*this))), selectors); if (!maybe_selectors.has_value()) @@ -479,7 +479,7 @@ DOM::ExceptionOr Element::closest(StringView selectors) con return nullptr; } -ExceptionOr Element::set_inner_html(String const& markup) +WebIDL::ExceptionOr Element::set_inner_html(String const& markup) { TRY(DOMParsing::inner_html_setter(*this, markup)); @@ -729,7 +729,7 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer Element::insert_adjacent_html(String position, String text) +WebIDL::ExceptionOr Element::insert_adjacent_html(String position, String text) { JS::GCPtr context; // 1. Use the first matching item from this list: diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 203f3fc50d..d7d77f2c4e 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include namespace Web::DOM { @@ -52,18 +52,18 @@ public: bool has_attributes() const { return !m_attributes->is_empty(); } String attribute(FlyString const& name) const { return get_attribute(name); } String get_attribute(FlyString const& name) const; - ExceptionOr set_attribute(FlyString const& name, String const& value); - ExceptionOr set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value); + WebIDL::ExceptionOr set_attribute(FlyString const& name, String const& value); + WebIDL::ExceptionOr set_attribute_ns(FlyString const& namespace_, FlyString const& qualified_name, String const& value); void remove_attribute(FlyString const& name); - DOM::ExceptionOr toggle_attribute(FlyString const& name, Optional force); + WebIDL::ExceptionOr toggle_attribute(FlyString const& name, Optional force); size_t attribute_list_size() const { return m_attributes->length(); } NamedNodeMap const* attributes() const { return m_attributes.ptr(); } Vector get_attribute_names() const; DOMTokenList* class_list(); - DOM::ExceptionOr matches(StringView selectors) const; - DOM::ExceptionOr closest(StringView selectors) const; + WebIDL::ExceptionOr matches(StringView selectors) const; + WebIDL::ExceptionOr closest(StringView selectors) const; int client_top() const; int client_left() const; @@ -106,9 +106,9 @@ public: CSS::CSSStyleDeclaration* style_for_bindings(); String inner_html() const; - ExceptionOr set_inner_html(String const&); + WebIDL::ExceptionOr set_inner_html(String const&); - ExceptionOr insert_adjacent_html(String position, String text); + WebIDL::ExceptionOr insert_adjacent_html(String position, String text); bool is_focused() const; bool is_active() const; @@ -172,6 +172,6 @@ private: template<> inline bool Node::fast_is() const { return is_element(); } -ExceptionOr validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name); +WebIDL::ExceptionOr validate_and_extract(JS::Object& global_object, FlyString namespace_, FlyString qualified_name); } diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index 50ecabbbb4..796015167d 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -223,7 +223,7 @@ void EventTarget::remove_from_event_listener_list(DOMEventListener& listener) } // https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent -ExceptionOr EventTarget::dispatch_event_binding(Event& event) +WebIDL::ExceptionOr EventTarget::dispatch_event_binding(Event& event) { // 1. If event’s dispatch flag is set, or if its initialized flag is not set, then throw an "InvalidStateError" DOMException. if (event.dispatched()) diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.h b/Userland/Libraries/LibWeb/DOM/EventTarget.h index 28c1bb18ad..63afbfd6e2 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.h +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.h @@ -12,9 +12,9 @@ #include #include #include -#include #include #include +#include namespace Web::DOM { @@ -34,7 +34,7 @@ public: void remove_event_listener_without_options(FlyString const& type, IDLEventListener& callback); virtual bool dispatch_event(Event&); - ExceptionOr dispatch_event_binding(Event&); + WebIDL::ExceptionOr dispatch_event_binding(Event&); virtual EventTarget* get_parent(Event const&) { return nullptr; } diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index 3d9520b5c0..3c5bd4f5ca 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -41,7 +41,7 @@ void MutationObserver::visit_edges(Cell::Visitor& visitor) } // https://dom.spec.whatwg.org/#dom-mutationobserver-observe -ExceptionOr MutationObserver::observe(Node& target, MutationObserverInit options) +WebIDL::ExceptionOr 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. if ((options.attribute_old_value.has_value() || options.attribute_filter.has_value()) && !options.attributes.has_value()) @@ -53,22 +53,22 @@ ExceptionOr MutationObserver::observe(Node& target, MutationObserverInit o // 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())) - 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. // 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()) - 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. // NOTE: If attributeFilter is present, attributes will be present because of step 1. 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. // 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()) - 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 target’s registered observer list, if registered’s observer is this: bool updated_existing_observer = false; diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.h b/Userland/Libraries/LibWeb/DOM/MutationObserver.h index 33437ed35f..b6f86d7b61 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.h +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.h @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include namespace Web::DOM { @@ -35,7 +35,7 @@ public: static JS::NonnullGCPtr create_with_global_object(HTML::Window&, JS::GCPtr); virtual ~MutationObserver() override; - ExceptionOr observe(Node& target, MutationObserverInit options = {}); + WebIDL::ExceptionOr observe(Node& target, MutationObserverInit options = {}); void disconnect(); Vector> take_records(); diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index 5241902184..07260e6475 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -80,13 +80,13 @@ Attr const* NamedNodeMap::get_named_item(StringView qualified_name) const } // https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem -ExceptionOr NamedNodeMap::set_named_item(Attr& attribute) +WebIDL::ExceptionOr NamedNodeMap::set_named_item(Attr& attribute) { return set_attribute(attribute); } // https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem -ExceptionOr NamedNodeMap::remove_named_item(StringView qualified_name) +WebIDL::ExceptionOr NamedNodeMap::remove_named_item(StringView qualified_name) { // 1. Let attr be the result of removing an attribute given qualifiedName and element. 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 -ExceptionOr NamedNodeMap::set_attribute(Attr& attribute) +WebIDL::ExceptionOr NamedNodeMap::set_attribute(Attr& attribute) { // 1. If attr’s element is neither null nor element, throw an "InUseAttributeError" DOMException. if ((attribute.owner_element() != nullptr) && (attribute.owner_element() != &associated_element())) diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h index d4487b61f4..89b1c422c2 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.h @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include namespace Web::DOM { @@ -35,13 +35,13 @@ public: // Methods defined by the spec for JavaScript: Attr const* item(u32 index) const; Attr const* get_named_item(StringView qualified_name) const; - ExceptionOr set_named_item(Attr& attribute); - ExceptionOr remove_named_item(StringView qualified_name); + WebIDL::ExceptionOr set_named_item(Attr& attribute); + WebIDL::ExceptionOr remove_named_item(StringView qualified_name); // Methods defined by the spec for internal use: Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr); Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const; - ExceptionOr set_attribute(Attr& attribute); + WebIDL::ExceptionOr set_attribute(Attr& attribute); void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index); void append_attribute(Attr& attribute); Attr const* remove_attribute(StringView qualified_name); diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index eac22f3f31..b2d171d2ab 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -311,7 +311,7 @@ Element const* Node::parent_element() const } // https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity -ExceptionOr Node::ensure_pre_insertion_validity(JS::NonnullGCPtr node, JS::GCPtr child) const +WebIDL::ExceptionOr Node::ensure_pre_insertion_validity(JS::NonnullGCPtr node, JS::GCPtr child) const { // 1. If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. if (!is(this) && !is(this) && !is(this)) @@ -456,7 +456,7 @@ void Node::insert_before(JS::NonnullGCPtr node, JS::GCPtr child, boo } // https://dom.spec.whatwg.org/#concept-node-pre-insert -ExceptionOr> Node::pre_insert(JS::NonnullGCPtr node, JS::GCPtr child) +WebIDL::ExceptionOr> Node::pre_insert(JS::NonnullGCPtr node, JS::GCPtr child) { // 1. Ensure pre-insertion validity of node into parent before child. TRY(ensure_pre_insertion_validity(node, child)); @@ -476,14 +476,14 @@ ExceptionOr> Node::pre_insert(JS::NonnullGCPtr node } // https://dom.spec.whatwg.org/#dom-node-removechild -ExceptionOr> Node::remove_child(JS::NonnullGCPtr child) +WebIDL::ExceptionOr> Node::remove_child(JS::NonnullGCPtr child) { // The removeChild(child) method steps are to return the result of pre-removing child from this. return pre_remove(child); } // https://dom.spec.whatwg.org/#concept-node-pre-remove -ExceptionOr> Node::pre_remove(JS::NonnullGCPtr child) +WebIDL::ExceptionOr> Node::pre_remove(JS::NonnullGCPtr child) { // 1. If child’s parent is not parent, then throw a "NotFoundError" DOMException. if (child->parent() != this) @@ -497,7 +497,7 @@ ExceptionOr> Node::pre_remove(JS::NonnullGCPtr chil } // https://dom.spec.whatwg.org/#concept-node-append -ExceptionOr> Node::append_child(JS::NonnullGCPtr node) +WebIDL::ExceptionOr> Node::append_child(JS::NonnullGCPtr node) { // To append a node to a parent, pre-insert node into parent before null. return pre_insert(node, nullptr); @@ -608,7 +608,7 @@ void Node::remove(bool suppress_observers) } // https://dom.spec.whatwg.org/#concept-node-replace -ExceptionOr> Node::replace_child(JS::NonnullGCPtr node, JS::NonnullGCPtr child) +WebIDL::ExceptionOr> Node::replace_child(JS::NonnullGCPtr node, JS::NonnullGCPtr child) { // If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. if (!is(this) && !is(this) && !is(this)) @@ -792,7 +792,7 @@ JS::NonnullGCPtr Node::clone_node(Document* document, bool clone_children) } // https://dom.spec.whatwg.org/#dom-node-clonenode -ExceptionOr> Node::clone_node_binding(bool deep) +WebIDL::ExceptionOr> Node::clone_node_binding(bool deep) { // 1. If this is a shadow root, then throw a "NotSupportedError" DOMException. if (is(*this)) diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 3a754a182b..16b627039b 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace Web::DOM { @@ -81,21 +81,21 @@ public: virtual bool is_html_template_element() const { return false; } virtual bool is_browsing_context_container() const { return false; } - ExceptionOr> pre_insert(JS::NonnullGCPtr, JS::GCPtr); - ExceptionOr> pre_remove(JS::NonnullGCPtr); + WebIDL::ExceptionOr> pre_insert(JS::NonnullGCPtr, JS::GCPtr); + WebIDL::ExceptionOr> pre_remove(JS::NonnullGCPtr); - ExceptionOr> append_child(JS::NonnullGCPtr); - ExceptionOr> remove_child(JS::NonnullGCPtr); + WebIDL::ExceptionOr> append_child(JS::NonnullGCPtr); + WebIDL::ExceptionOr> remove_child(JS::NonnullGCPtr); void insert_before(JS::NonnullGCPtr node, JS::GCPtr child, bool suppress_observers = false); void remove(bool suppress_observers = false); void remove_all_children(bool suppress_observers = false); u16 compare_document_position(JS::GCPtr other); - ExceptionOr> replace_child(JS::NonnullGCPtr node, JS::NonnullGCPtr child); + WebIDL::ExceptionOr> replace_child(JS::NonnullGCPtr node, JS::NonnullGCPtr child); JS::NonnullGCPtr clone_node(Document* document = nullptr, bool clone_children = false); - ExceptionOr> clone_node_binding(bool deep); + WebIDL::ExceptionOr> clone_node_binding(bool deep); // NOTE: This is intended for the JS bindings. bool has_child_nodes() const { return has_children(); } @@ -177,7 +177,7 @@ public: template bool fast_is() const = delete; - ExceptionOr ensure_pre_insertion_validity(JS::NonnullGCPtr node, JS::GCPtr child) const; + WebIDL::ExceptionOr ensure_pre_insertion_validity(JS::NonnullGCPtr node, JS::GCPtr child) const; bool is_host_including_inclusive_ancestor_of(Node const&) const; diff --git a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp index 0f36843943..04b3501945 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeOperations.cpp @@ -14,7 +14,7 @@ namespace Web::DOM { // https://dom.spec.whatwg.org/#converting-nodes-into-a-node -ExceptionOr> convert_nodes_to_single_node(Vector, String>> const& nodes, DOM::Document& document) +WebIDL::ExceptionOr> convert_nodes_to_single_node(Vector, String>> const& nodes, DOM::Document& document) { // 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. diff --git a/Userland/Libraries/LibWeb/DOM/NodeOperations.h b/Userland/Libraries/LibWeb/DOM/NodeOperations.h index fe9817e58e..275ec316f3 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeOperations.h +++ b/Userland/Libraries/LibWeb/DOM/NodeOperations.h @@ -12,6 +12,6 @@ namespace Web::DOM { -ExceptionOr> convert_nodes_to_single_node(Vector, String>> const& nodes, DOM::Document& document); +WebIDL::ExceptionOr> convert_nodes_to_single_node(Vector, String>> const& nodes, DOM::Document& document); } diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index 80bb214151..a388db88c1 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -18,7 +18,7 @@ namespace Web::DOM { -ExceptionOr> ParentNode::query_selector(StringView selector_text) +WebIDL::ExceptionOr> ParentNode::query_selector(StringView selector_text) { auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text); if (!maybe_selectors.has_value()) @@ -41,7 +41,7 @@ ExceptionOr> ParentNode::query_selector(StringView selector_t return result; } -ExceptionOr> ParentNode::query_selector_all(StringView selector_text) +WebIDL::ExceptionOr> ParentNode::query_selector_all(StringView selector_text) { auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(*this), selector_text); if (!maybe_selectors.has_value()) @@ -168,7 +168,7 @@ JS::NonnullGCPtr ParentNode::get_elements_by_tag_name_ns(FlyStri } // https://dom.spec.whatwg.org/#dom-parentnode-prepend -ExceptionOr ParentNode::prepend(Vector, String>> const& nodes) +WebIDL::ExceptionOr ParentNode::prepend(Vector, String>> const& nodes) { // 1. Let node be the result of converting nodes into a node given nodes and this’s node document. auto node = TRY(convert_nodes_to_single_node(nodes, document())); @@ -179,7 +179,7 @@ ExceptionOr ParentNode::prepend(Vector, String>> return {}; } -ExceptionOr ParentNode::append(Vector, String>> const& nodes) +WebIDL::ExceptionOr ParentNode::append(Vector, String>> const& nodes) { // 1. Let node be the result of converting nodes into a node given nodes and this’s node document. auto node = TRY(convert_nodes_to_single_node(nodes, document())); @@ -190,7 +190,7 @@ ExceptionOr ParentNode::append(Vector, String>> c return {}; } -ExceptionOr ParentNode::replace_children(Vector, String>> const& nodes) +WebIDL::ExceptionOr ParentNode::replace_children(Vector, String>> const& nodes) { // 1. Let node be the result of converting nodes into a node given nodes and this’s node document. auto node = TRY(convert_nodes_to_single_node(nodes, document())); diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.h b/Userland/Libraries/LibWeb/DOM/ParentNode.h index 276e710d18..99b8bda747 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.h +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.h @@ -23,17 +23,17 @@ public: JS::GCPtr last_element_child(); u32 child_element_count() const; - ExceptionOr> query_selector(StringView); - ExceptionOr> query_selector_all(StringView); + WebIDL::ExceptionOr> query_selector(StringView); + WebIDL::ExceptionOr> query_selector_all(StringView); JS::NonnullGCPtr children(); JS::NonnullGCPtr get_elements_by_tag_name(FlyString const&); JS::NonnullGCPtr get_elements_by_tag_name_ns(FlyString const&, FlyString const&); - ExceptionOr prepend(Vector, String>> const& nodes); - ExceptionOr append(Vector, String>> const& nodes); - ExceptionOr replace_children(Vector, String>> const& nodes); + WebIDL::ExceptionOr prepend(Vector, String>> const& nodes); + WebIDL::ExceptionOr append(Vector, String>> const& nodes); + WebIDL::ExceptionOr replace_children(Vector, String>> const& nodes); protected: ParentNode(JS::Realm& realm, Document& document, NodeType type) diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index c44ab7c25c..3853c92699 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -131,7 +131,7 @@ static RelativeBoundaryPointPosition position_of_boundary_point_relative_to_othe return RelativeBoundaryPointPosition::Before; } -ExceptionOr Range::set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end) +WebIDL::ExceptionOr 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: @@ -176,20 +176,20 @@ ExceptionOr Range::set_start_or_end(Node& node, u32 offset, StartOrEnd sta } // https://dom.spec.whatwg.org/#concept-range-bp-set -ExceptionOr Range::set_start(Node& node, u32 offset) +WebIDL::ExceptionOr 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). return set_start_or_end(node, offset, StartOrEnd::Start); } -ExceptionOr Range::set_end(Node& node, u32 offset) +WebIDL::ExceptionOr 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). return set_start_or_end(node, offset, StartOrEnd::End); } // https://dom.spec.whatwg.org/#dom-range-setstartbefore -ExceptionOr Range::set_start_before(Node& node) +WebIDL::ExceptionOr Range::set_start_before(Node& node) { // 1. Let parent be node’s parent. auto* parent = node.parent(); @@ -203,7 +203,7 @@ ExceptionOr Range::set_start_before(Node& node) } // https://dom.spec.whatwg.org/#dom-range-setstartafter -ExceptionOr Range::set_start_after(Node& node) +WebIDL::ExceptionOr Range::set_start_after(Node& node) { // 1. Let parent be node’s parent. auto* parent = node.parent(); @@ -217,7 +217,7 @@ ExceptionOr Range::set_start_after(Node& node) } // https://dom.spec.whatwg.org/#dom-range-setendbefore -ExceptionOr Range::set_end_before(Node& node) +WebIDL::ExceptionOr Range::set_end_before(Node& node) { // 1. Let parent be node’s parent. auto* parent = node.parent(); @@ -231,7 +231,7 @@ ExceptionOr Range::set_end_before(Node& node) } // https://dom.spec.whatwg.org/#dom-range-setendafter -ExceptionOr Range::set_end_after(Node& node) +WebIDL::ExceptionOr Range::set_end_after(Node& node) { // 1. Let parent be node’s parent. auto* parent = node.parent(); @@ -245,7 +245,7 @@ ExceptionOr Range::set_end_after(Node& node) } // https://dom.spec.whatwg.org/#dom-range-compareboundarypoints -ExceptionOr Range::compare_boundary_points(u16 how, Range const& source_range) const +WebIDL::ExceptionOr Range::compare_boundary_points(u16 how, Range const& source_range) const { // 1. If how is not one of // - START_TO_START, @@ -332,7 +332,7 @@ ExceptionOr Range::compare_boundary_points(u16 how, Range const& source_ran } // https://dom.spec.whatwg.org/#concept-range-select -ExceptionOr Range::select(Node& node) +WebIDL::ExceptionOr Range::select(Node& node) { // 1. Let parent be node’s parent. auto* parent = node.parent(); @@ -356,7 +356,7 @@ ExceptionOr Range::select(Node& node) } // https://dom.spec.whatwg.org/#dom-range-selectnode -ExceptionOr Range::select_node(Node& node) +WebIDL::ExceptionOr Range::select_node(Node& node) { // The selectNode(node) method steps are to select node within this. return select(node); @@ -377,7 +377,7 @@ void Range::collapse(bool to_start) } // https://dom.spec.whatwg.org/#dom-range-selectnodecontents -ExceptionOr Range::select_node_contents(Node const& node) +WebIDL::ExceptionOr Range::select_node_contents(Node const& node) { // 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException. if (is(node)) @@ -466,7 +466,7 @@ bool Range::intersects_node(Node const& node) const } // https://dom.spec.whatwg.org/#dom-range-ispointinrange -ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) const +WebIDL::ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) const { // 1. If node’s root is different from this’s root, return false. if (&node.root() != &root()) @@ -491,7 +491,7 @@ ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) const } // https://dom.spec.whatwg.org/#dom-range-comparepoint -ExceptionOr Range::compare_point(Node const& node, u32 offset) const +WebIDL::ExceptionOr Range::compare_point(Node const& node, u32 offset) const { // 1. If node’s root is different from this’s root, then throw a "WrongDocumentError" DOMException. if (&node.root() != &root()) @@ -549,13 +549,13 @@ String Range::to_string() const } // https://dom.spec.whatwg.org/#dom-range-extractcontents -ExceptionOr> Range::extract_contents() +WebIDL::ExceptionOr> Range::extract_contents() { return extract(); } // https://dom.spec.whatwg.org/#concept-range-extract -ExceptionOr> Range::extract() +WebIDL::ExceptionOr> Range::extract() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. auto* fragment = heap().allocate(realm(), const_cast(start_container()->document())); @@ -771,13 +771,13 @@ bool Range::partially_contains_node(Node const& node) const } // https://dom.spec.whatwg.org/#dom-range-insertnode -ExceptionOr Range::insert_node(JS::NonnullGCPtr node) +WebIDL::ExceptionOr Range::insert_node(JS::NonnullGCPtr node) { return insert(node); } // https://dom.spec.whatwg.org/#concept-range-insert -ExceptionOr Range::insert(JS::NonnullGCPtr node) +WebIDL::ExceptionOr Range::insert(JS::NonnullGCPtr node) { // 1. If range’s 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(*m_start_container) || is(*m_start_container)) @@ -844,7 +844,7 @@ ExceptionOr Range::insert(JS::NonnullGCPtr node) } // https://dom.spec.whatwg.org/#dom-range-surroundcontents -ExceptionOr Range::surround_contents(JS::NonnullGCPtr new_parent) +WebIDL::ExceptionOr Range::surround_contents(JS::NonnullGCPtr new_parent) { // 1. If a non-Text node is partially contained in this, then throw an "InvalidStateError" DOMException. Node* start_non_text_node = start_container(); @@ -878,13 +878,13 @@ ExceptionOr Range::surround_contents(JS::NonnullGCPtr new_parent) } // https://dom.spec.whatwg.org/#dom-range-clonecontents -ExceptionOr> Range::clone_contents() +WebIDL::ExceptionOr> Range::clone_contents() { return clone_the_contents(); } // https://dom.spec.whatwg.org/#concept-range-clone -ExceptionOr> Range::clone_the_contents() +WebIDL::ExceptionOr> Range::clone_the_contents() { // 1. Let fragment be a new DocumentFragment node whose node document is range’s start node’s node document. auto* fragment = heap().allocate(realm(), const_cast(start_container()->document())); @@ -1040,7 +1040,7 @@ ExceptionOr> Range::clone_the_contents() } // https://dom.spec.whatwg.org/#dom-range-deletecontents -ExceptionOr Range::delete_contents() +WebIDL::ExceptionOr Range::delete_contents() { // 1. If this is collapsed, then return. if (collapsed()) diff --git a/Userland/Libraries/LibWeb/DOM/Range.h b/Userland/Libraries/LibWeb/DOM/Range.h index fadc1dfc71..234c2bb810 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.h +++ b/Userland/Libraries/LibWeb/DOM/Range.h @@ -27,15 +27,15 @@ public: // FIXME: There are a ton of methods missing here. - ExceptionOr set_start(Node& node, u32 offset); - ExceptionOr set_end(Node& node, u32 offset); - ExceptionOr set_start_before(Node& node); - ExceptionOr set_start_after(Node& node); - ExceptionOr set_end_before(Node& node); - ExceptionOr set_end_after(Node& node); - ExceptionOr select_node(Node& node); + WebIDL::ExceptionOr set_start(Node& node, u32 offset); + WebIDL::ExceptionOr set_end(Node& node, u32 offset); + WebIDL::ExceptionOr set_start_before(Node& node); + WebIDL::ExceptionOr set_start_after(Node& node); + WebIDL::ExceptionOr set_end_before(Node& node); + WebIDL::ExceptionOr set_end_after(Node& node); + WebIDL::ExceptionOr select_node(Node& node); void collapse(bool to_start); - ExceptionOr select_node_contents(Node const&); + WebIDL::ExceptionOr select_node_contents(Node const&); // https://dom.spec.whatwg.org/#dom-range-start_to_start enum HowToCompareBoundaryPoints : u16 { @@ -45,7 +45,7 @@ public: END_TO_START = 3, }; - ExceptionOr compare_boundary_points(u16 how, Range const& source_range) const; + WebIDL::ExceptionOr compare_boundary_points(u16 how, Range const& source_range) const; JS::NonnullGCPtr inverted() const; JS::NonnullGCPtr normalized() const; @@ -61,15 +61,15 @@ public: } bool intersects_node(Node const&) const; - ExceptionOr is_point_in_range(Node const&, u32 offset) const; - ExceptionOr compare_point(Node const&, u32 offset) const; + WebIDL::ExceptionOr is_point_in_range(Node const&, u32 offset) const; + WebIDL::ExceptionOr compare_point(Node const&, u32 offset) const; - ExceptionOr delete_contents(); - ExceptionOr> extract_contents(); - ExceptionOr> clone_contents(); + WebIDL::ExceptionOr delete_contents(); + WebIDL::ExceptionOr> extract_contents(); + WebIDL::ExceptionOr> clone_contents(); - ExceptionOr insert_node(JS::NonnullGCPtr); - ExceptionOr surround_contents(JS::NonnullGCPtr new_parent); + WebIDL::ExceptionOr insert_node(JS::NonnullGCPtr); + WebIDL::ExceptionOr surround_contents(JS::NonnullGCPtr new_parent); String to_string() const; @@ -84,12 +84,12 @@ private: End, }; - ExceptionOr set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end); - ExceptionOr select(Node& node); + WebIDL::ExceptionOr set_start_or_end(Node& node, u32 offset, StartOrEnd start_or_end); + WebIDL::ExceptionOr select(Node& node); - ExceptionOr> extract(); - ExceptionOr> clone_the_contents(); - ExceptionOr insert(JS::NonnullGCPtr); + WebIDL::ExceptionOr> extract(); + WebIDL::ExceptionOr> clone_the_contents(); + WebIDL::ExceptionOr insert(JS::NonnullGCPtr); bool contains_node(Node const&) const; bool partially_contains_node(Node const&) const; diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp index 01a312ee65..19ba81c54f 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.cpp @@ -37,7 +37,7 @@ String ShadowRoot::inner_html() const } // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml -ExceptionOr ShadowRoot::set_inner_html(String const& markup) +WebIDL::ExceptionOr ShadowRoot::set_inner_html(String const& markup) { TRY(DOMParsing::inner_html_setter(*this, markup)); diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h index 800307c8b8..f15fe502fc 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h @@ -29,7 +29,7 @@ public: String mode() const { return m_closed ? "closed" : "open"; } String inner_html() const; - ExceptionOr set_inner_html(String const&); + WebIDL::ExceptionOr set_inner_html(String const&); private: ShadowRoot(Document&, Element&); diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index f5adac85ef..332007fda9 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include namespace Web::DOM { @@ -23,7 +23,7 @@ StaticRange::StaticRange(Node& start_container, u32 start_offset, Node& end_cont StaticRange::~StaticRange() = default; // https://dom.spec.whatwg.org/#dom-staticrange-staticrange -ExceptionOr StaticRange::create_with_global_object(HTML::Window& window, StaticRangeInit& init) +WebIDL::ExceptionOr 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. if (is(*init.start_container) || is(*init.start_container)) diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.h b/Userland/Libraries/LibWeb/DOM/StaticRange.h index 95546d7fea..ec98ba31b0 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.h +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.h @@ -24,7 +24,7 @@ class StaticRange final : public AbstractRange { WEB_PLATFORM_OBJECT(StaticRange, JS::Object); public: - static ExceptionOr create_with_global_object(HTML::Window&, StaticRangeInit& init); + static WebIDL::ExceptionOr create_with_global_object(HTML::Window&, StaticRangeInit& init); StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset); virtual ~StaticRange() override; diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 57398559e1..65bae6668e 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -43,7 +43,7 @@ void Text::set_owner_input_element(Badge, HTML::HTMLInpu // https://dom.spec.whatwg.org/#dom-text-splittext // https://dom.spec.whatwg.org/#concept-text-split -ExceptionOr> Text::split_text(size_t offset) +WebIDL::ExceptionOr> Text::split_text(size_t offset) { // 1. Let length be node’s length. auto length = this->length(); diff --git a/Userland/Libraries/LibWeb/DOM/Text.h b/Userland/Libraries/LibWeb/DOM/Text.h index f308462dab..7980275c72 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.h +++ b/Userland/Libraries/LibWeb/DOM/Text.h @@ -29,7 +29,7 @@ public: void set_owner_input_element(Badge, HTML::HTMLInputElement&); HTML::HTMLInputElement* owner_input_element() { return m_owner_input_element.ptr(); } - ExceptionOr> split_text(size_t offset); + WebIDL::ExceptionOr> split_text(size_t offset); protected: explicit Text(Document&, String const&); diff --git a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp index 245dbeb049..bacbcf35dd 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.cpp @@ -5,14 +5,14 @@ */ #include -#include #include #include +#include namespace Web::DOMParsing { // https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm -DOM::ExceptionOr> parse_fragment(String const& markup, DOM::Element& context_element) +WebIDL::ExceptionOr> parse_fragment(String const& markup, DOM::Element& context_element) { // FIXME: Handle XML documents. @@ -30,7 +30,7 @@ DOM::ExceptionOr> parse_fragment(String } // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml -DOM::ExceptionOr inner_html_setter(JS::NonnullGCPtr context_object, String const& value) +WebIDL::ExceptionOr inner_html_setter(JS::NonnullGCPtr 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. // (This is handled in Element and ShadowRoot) diff --git a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.h b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.h index 9619254e14..c9d6512d98 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.h +++ b/Userland/Libraries/LibWeb/DOMParsing/InnerHTML.h @@ -7,15 +7,15 @@ #pragma once #include -#include #include #include +#include namespace Web::DOMParsing { // https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml -DOM::ExceptionOr inner_html_setter(JS::NonnullGCPtr context_object, String const& value); +WebIDL::ExceptionOr inner_html_setter(JS::NonnullGCPtr context_object, String const& value); -DOM::ExceptionOr> parse_fragment(String const& markup, DOM::Element& context_element); +WebIDL::ExceptionOr> parse_fragment(String const& markup, DOM::Element& context_element); } diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index f2f8711472..52055c260f 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -10,13 +10,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include namespace Web::DOMParsing { @@ -34,7 +34,7 @@ XMLSerializer::XMLSerializer(HTML::Window& window) XMLSerializer::~XMLSerializer() = default; // https://w3c.github.io/DOM-Parsing/#dom-xmlserializer-serializetostring -DOM::ExceptionOr XMLSerializer::serialize_to_string(JS::NonnullGCPtr root) +WebIDL::ExceptionOr XMLSerializer::serialize_to_string(JS::NonnullGCPtr 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. return serialize_node_to_xml_string(root, RequireWellFormed::No); @@ -113,10 +113,10 @@ static bool prefix_is_in_prefix_map(String const& prefix, HashMapvalue.contains_slow(prefix); } -DOM::ExceptionOr serialize_node_to_xml_string_impl(JS::NonnullGCPtr root, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); +WebIDL::ExceptionOr serialize_node_to_xml_string_impl(JS::NonnullGCPtr root, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization -DOM::ExceptionOr serialize_node_to_xml_string(JS::NonnullGCPtr root, RequireWellFormed require_well_formed) +WebIDL::ExceptionOr serialize_node_to_xml_string(JS::NonnullGCPtr 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. // 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 serialize_node_to_xml_string(JS::NonnullGCPtr serialize_element(DOM::Element const& element, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_document(DOM::Document const& document, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_text(DOM::Text const& text, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed); -static DOM::ExceptionOr serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_element(DOM::Element const& element, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_document(DOM::Document const& document, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_text(DOM::Text const& text, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed); +static WebIDL::ExceptionOr serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed); // https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-algorithm -DOM::ExceptionOr serialize_node_to_xml_string_impl(JS::NonnullGCPtr root, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) +WebIDL::ExceptionOr serialize_node_to_xml_string_impl(JS::NonnullGCPtr root, Optional& namespace_, HashMap>& 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: // - A context namespace namespace @@ -212,7 +212,7 @@ DOM::ExceptionOr serialize_node_to_xml_string_impl(JS::NonnullGCPtr Anything else // 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 @@ -273,7 +273,7 @@ static Optional record_namespace_information(DOM::Element const& element } // https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value -static DOM::ExceptionOr serialize_an_attribute_value(String const& attribute_value, [[maybe_unused]] RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr 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, // 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 -static DOM::ExceptionOr serialize_element_attributes(DOM::Element const& element, HashMap>& namespace_prefix_map, u64& prefix_index, HashMap const& local_prefixes_map, bool ignore_namespace_definition_attribute, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_element_attributes(DOM::Element const& element, HashMap>& namespace_prefix_map, u64& prefix_index, HashMap const& local_prefixes_map, bool ignore_namespace_definition_attribute, RequireWellFormed require_well_formed) { auto& global_object = element.global_object(); @@ -459,7 +459,7 @@ static DOM::ExceptionOr serialize_element_attributes(DOM::Element const& } // https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node -static DOM::ExceptionOr serialize_element(DOM::Element const& element, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_element(DOM::Element const& element, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) { auto& global_object = element.global_object(); @@ -701,7 +701,7 @@ static DOM::ExceptionOr serialize_element(DOM::Element const& element, O } // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node -static DOM::ExceptionOr serialize_document(DOM::Document const& document, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_document(DOM::Document const& document, Optional& namespace_, HashMap>& 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), // then throw an exception; the serialization of this node would not be a well-formed document. @@ -721,7 +721,7 @@ static DOM::ExceptionOr serialize_document(DOM::Document const& document } // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-comment-node -static DOM::ExceptionOr serialize_comment(DOM::Comment const& comment, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr 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 // 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 serialize_comment(DOM::Comment const& comment, R } // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node -static DOM::ExceptionOr serialize_text(DOM::Text const& text, [[maybe_unused]] RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr 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, // then throw an exception; the serialization of this node's data would not be well-formed. @@ -763,7 +763,7 @@ static DOM::ExceptionOr serialize_text(DOM::Text const& text, [[maybe_un } // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documentfragment-node -static DOM::ExceptionOr serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_document_fragment(DOM::DocumentFragment const& document_fragment, Optional& namespace_, HashMap>& namespace_prefix_map, u64& prefix_index, RequireWellFormed require_well_formed) { // 1. Let markup the empty string. StringBuilder markup; @@ -778,7 +778,7 @@ static DOM::ExceptionOr serialize_document_fragment(DOM::DocumentFragmen } // https://w3c.github.io/DOM-Parsing/#xml-serializing-a-documenttype-node -static DOM::ExceptionOr serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_document_type(DOM::DocumentType const& document_type, RequireWellFormed require_well_formed) { 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, @@ -844,7 +844,7 @@ static DOM::ExceptionOr serialize_document_type(DOM::DocumentType const& } // https://w3c.github.io/DOM-Parsing/#dfn-xml-serializing-a-processinginstruction-node -static DOM::ExceptionOr serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed) +static WebIDL::ExceptionOr serialize_processing_instruction(DOM::ProcessingInstruction const& processing_instruction, RequireWellFormed require_well_formed) { 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 diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h index 3178e3569b..be14dbe6c3 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.h @@ -18,7 +18,7 @@ public: virtual ~XMLSerializer() override; - DOM::ExceptionOr serialize_to_string(JS::NonnullGCPtr root); + WebIDL::ExceptionOr serialize_to_string(JS::NonnullGCPtr root); private: explicit XMLSerializer(HTML::Window&); @@ -29,6 +29,6 @@ enum class RequireWellFormed { Yes, }; -DOM::ExceptionOr serialize_node_to_xml_string(JS::NonnullGCPtr root, RequireWellFormed require_well_formed); +WebIDL::ExceptionOr serialize_node_to_xml_string(JS::NonnullGCPtr root, RequireWellFormed require_well_formed); } diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index 7556094ead..99e9e896d2 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -12,11 +12,11 @@ namespace Web::Encoding { -DOM::ExceptionOr> TextDecoder::create_with_global_object(HTML::Window& window, FlyString encoding) +WebIDL::ExceptionOr> TextDecoder::create_with_global_object(HTML::Window& window, FlyString encoding) { auto decoder = TextCodec::decoder_for(encoding); 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(window.realm(), window, *decoder, move(encoding), false, false)); } @@ -35,7 +35,7 @@ TextDecoder::TextDecoder(HTML::Window& window, TextCodec::Decoder& decoder, FlyS TextDecoder::~TextDecoder() = default; // https://encoding.spec.whatwg.org/#dom-textdecoder-decode -DOM::ExceptionOr TextDecoder::decode(JS::Handle const& input) const +WebIDL::ExceptionOr TextDecoder::decode(JS::Handle const& input) const { // FIXME: Implement the streaming stuff. diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h index f5f52e508e..fe37ccec45 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.h +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.h @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include namespace Web::Encoding { @@ -21,11 +21,11 @@ class TextDecoder : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(TextDecoder, Bindings::PlatformObject); public: - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, FlyString encoding); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, FlyString encoding); virtual ~TextDecoder() override; - DOM::ExceptionOr decode(JS::Handle const&) const; + WebIDL::ExceptionOr decode(JS::Handle const&) const; FlyString const& encoding() const { return m_encoding; } bool fatal() const { return m_fatal; } diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index 6fb629d77a..8dae6b2a20 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -5,17 +5,17 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include #include #include +#include namespace Web::Fetch { // https://fetch.spec.whatwg.org/#concept-bodyinit-extract -DOM::ExceptionOr extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) +WebIDL::ExceptionOr extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) { auto& window = verify_cast(realm.global_object()); @@ -38,7 +38,7 @@ DOM::ExceptionOr extract_body(JS::Realm& realm, Bo // 6. Switch on object. // FIXME: Still need to support BufferSource and FormData TRY(object.visit( - [&](JS::Handle const& blob) -> DOM::ExceptionOr { + [&](JS::Handle const& blob) -> WebIDL::ExceptionOr { // FIXME: Set action to this step: read object. // Set source to object. source = blob; @@ -49,19 +49,19 @@ DOM::ExceptionOr extract_body(JS::Realm& realm, Bo type = blob->type().to_byte_buffer(); return {}; }, - [&](JS::Handle const& buffer_source) -> DOM::ExceptionOr { + [&](JS::Handle const& buffer_source) -> WebIDL::ExceptionOr { // 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())); return {}; }, - [&](JS::Handle const& url_search_params) -> DOM::ExceptionOr { + [&](JS::Handle const& url_search_params) -> WebIDL::ExceptionOr { // Set source to the result of running the application/x-www-form-urlencoded serializer with object’s list. source = url_search_params->to_string().to_byte_buffer(); // 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())); return {}; }, - [&](String const& scalar_value_string) -> DOM::ExceptionOr { + [&](String const& scalar_value_string) -> WebIDL::ExceptionOr { // NOTE: AK::String is always UTF-8. // Set source to the UTF-8 encoding of object. source = scalar_value_string.to_byte_buffer(); @@ -69,14 +69,14 @@ DOM::ExceptionOr extract_body(JS::Realm& realm, Bo type = TRY_OR_RETURN_OOM(window, ByteBuffer::copy("text/plain;charset=UTF-8"sv.bytes())); return {}; }, - [&](JS::Handle const& stream) -> DOM::ExceptionOr { + [&](JS::Handle const& stream) -> WebIDL::ExceptionOr { // If keepalive is true, then throw a TypeError. 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 (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 {}; })); diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.h b/Userland/Libraries/LibWeb/Fetch/BodyInit.h index f60d3ade2e..3955a44839 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.h +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.h @@ -19,6 +19,6 @@ using XMLHttpRequestBodyInit = Variant, JS::Handle, JS::Handle, JS::Handle, JS::Handle, String>; -DOM::ExceptionOr extract_body(JS::Realm&, BodyInit const&, bool keepalive = false); +WebIDL::ExceptionOr extract_body(JS::Realm&, BodyInit const&, bool keepalive = false); } diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.cpp b/Userland/Libraries/LibWeb/Fetch/Headers.cpp index 4195c98aa2..c921e54992 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Headers.cpp @@ -11,7 +11,7 @@ namespace Web::Fetch { // https://fetch.spec.whatwg.org/#dom-headers -DOM::ExceptionOr> Headers::create_with_global_object(HTML::Window& window, Optional const& init) +WebIDL::ExceptionOr> Headers::create_with_global_object(HTML::Window& window, Optional const& init) { // The new Headers(init) constructor steps are: auto* headers = window.heap().allocate(window.realm(), window); @@ -35,7 +35,7 @@ Headers::Headers(HTML::Window& window) Headers::~Headers() = default; // https://fetch.spec.whatwg.org/#dom-headers-append -DOM::ExceptionOr Headers::append(String const& name_string, String const& value_string) +WebIDL::ExceptionOr Headers::append(String const& name_string, String const& value_string) { // The append(name, value) method steps are to append (name, value) to this. auto header = Infrastructure::Header { @@ -47,18 +47,18 @@ DOM::ExceptionOr Headers::append(String const& name_string, String const& } // https://fetch.spec.whatwg.org/#dom-headers-delete -DOM::ExceptionOr Headers::delete_(String const& name_string) +WebIDL::ExceptionOr Headers::delete_(String const& name_string) { // The delete(name) method steps are: auto name = name_string.bytes(); // 1. If name is not a header name, then throw a TypeError. 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 this’s guard is "immutable", then throw a TypeError. 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 this’s guard is "request" and name is a forbidden header name, return. if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) @@ -87,14 +87,14 @@ DOM::ExceptionOr Headers::delete_(String const& name_string) } // https://fetch.spec.whatwg.org/#dom-headers-get -DOM::ExceptionOr Headers::get(String const& name_string) +WebIDL::ExceptionOr Headers::get(String const& name_string) { // The get(name) method steps are: auto name = name_string.bytes(); // 1. If name is not a header name, then throw a TypeError. 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 this’s header list. auto byte_buffer = TRY_OR_RETURN_OOM(global_object(), m_header_list.get(name)); @@ -103,21 +103,21 @@ DOM::ExceptionOr Headers::get(String const& name_string) } // https://fetch.spec.whatwg.org/#dom-headers-has -DOM::ExceptionOr Headers::has(String const& name_string) +WebIDL::ExceptionOr Headers::has(String const& name_string) { // The has(name) method steps are: auto name = name_string.bytes(); // 1. If name is not a header name, then throw a TypeError. 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 this’s header list contains name; otherwise false. return m_header_list.contains(name); } // https://fetch.spec.whatwg.org/#dom-headers-set -DOM::ExceptionOr Headers::set(String const& name_string, String const& value_string) +WebIDL::ExceptionOr Headers::set(String const& name_string, String const& value_string) { // The set(name, value) method steps are: auto name = name_string.bytes(); @@ -133,13 +133,13 @@ DOM::ExceptionOr 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. 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)) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header value" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header value" }; // 3. If this’s guard is "immutable", then throw a TypeError. 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 this’s guard is "request" and name is a forbidden header name, return. if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) @@ -201,7 +201,7 @@ JS::ThrowCompletionOr Headers::for_each(ForEachCallback callback) } // https://fetch.spec.whatwg.org/#concept-headers-append -DOM::ExceptionOr Headers::append(Infrastructure::Header header) +WebIDL::ExceptionOr Headers::append(Infrastructure::Header header) { // To append a header (name, value) to a Headers object headers, run these steps: auto& [name, value] = header; @@ -211,13 +211,13 @@ DOM::ExceptionOr Headers::append(Infrastructure::Header header) // 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)) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid header name" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid header name" }; 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 headers’s guard is "immutable", then throw a TypeError. 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 headers’s guard is "request" and name is a forbidden header name, return. if (m_guard == Guard::Request && Infrastructure::is_forbidden_header_name(name)) @@ -264,16 +264,16 @@ DOM::ExceptionOr Headers::append(Infrastructure::Header header) } // https://fetch.spec.whatwg.org/#concept-headers-fill -DOM::ExceptionOr Headers::fill(HeadersInit const& object) +WebIDL::ExceptionOr Headers::fill(HeadersInit const& object) { // To fill a Headers object headers with a given object object, run these steps: return object.visit( // 1. If object is a sequence, then for each header in object: - [this](Vector> const& object) -> DOM::ExceptionOr { + [this](Vector> const& object) -> WebIDL::ExceptionOr { for (auto const& entry : object) { // 1. If header does not contain exactly two items, then throw a TypeError. 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 (header’s first item, header’s second item) to headers. auto header = Fetch::Infrastructure::Header { @@ -285,7 +285,7 @@ DOM::ExceptionOr Headers::fill(HeadersInit const& object) return {}; }, // 2. Otherwise, object is a record, then for each key → value in object, append (key, value) to headers. - [this](OrderedHashMap const& object) -> DOM::ExceptionOr { + [this](OrderedHashMap const& object) -> WebIDL::ExceptionOr { for (auto const& entry : object) { auto header = Fetch::Infrastructure::Header { .name = TRY_OR_RETURN_OOM(global_object(), ByteBuffer::copy(entry.key.bytes())), diff --git a/Userland/Libraries/LibWeb/Fetch/Headers.h b/Userland/Libraries/LibWeb/Fetch/Headers.h index 84e99c61cb..e5c6cebcab 100644 --- a/Userland/Libraries/LibWeb/Fetch/Headers.h +++ b/Userland/Libraries/LibWeb/Fetch/Headers.h @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include namespace Web::Fetch { @@ -31,16 +31,16 @@ public: None, }; - static DOM::ExceptionOr> create_with_global_object(HTML::Window& window, Optional const& init); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window& window, Optional const& init); virtual ~Headers() override; - DOM::ExceptionOr append(Infrastructure::Header); - DOM::ExceptionOr append(String const& name, String const& value); - DOM::ExceptionOr delete_(String const& name); - DOM::ExceptionOr get(String const& name); - DOM::ExceptionOr has(String const& name); - DOM::ExceptionOr set(String const& name, String const& value); + WebIDL::ExceptionOr append(Infrastructure::Header); + WebIDL::ExceptionOr append(String const& name, String const& value); + WebIDL::ExceptionOr delete_(String const& name); + WebIDL::ExceptionOr get(String const& name); + WebIDL::ExceptionOr has(String const& name); + WebIDL::ExceptionOr set(String const& name, String const& value); using ForEachCallback = Function(String const&, String const&)>; JS::ThrowCompletionOr for_each(ForEachCallback); @@ -50,7 +50,7 @@ private: explicit Headers(HTML::Window&); - DOM::ExceptionOr fill(HeadersInit const&); + WebIDL::ExceptionOr fill(HeadersInit const&); void remove_privileged_no_cors_headers(); // https://fetch.spec.whatwg.org/#concept-headers-header-list diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp index 510be487f4..a1d721f7fc 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.cpp @@ -135,7 +135,7 @@ Blob::Blob(HTML::Window& window, ByteBuffer byte_buffer) Blob::~Blob() = default; // https://w3c.github.io/FileAPI/#ref-for-dom-blob-blob -DOM::ExceptionOr> Blob::create(HTML::Window& window, Optional> const& blob_parts, Optional const& options) +WebIDL::ExceptionOr> Blob::create(HTML::Window& window, Optional> const& blob_parts, Optional 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. if (!blob_parts.has_value() && !options.has_value()) @@ -167,13 +167,13 @@ DOM::ExceptionOr> Blob::create(HTML::Window& window, Opti return JS::NonnullGCPtr(*window.heap().allocate(window.realm(), window, move(byte_buffer), move(type))); } -DOM::ExceptionOr> Blob::create_with_global_object(HTML::Window& window, Optional> const& blob_parts, Optional const& options) +WebIDL::ExceptionOr> Blob::create_with_global_object(HTML::Window& window, Optional> const& blob_parts, Optional const& options) { return Blob::create(window, blob_parts, options); } // https://w3c.github.io/FileAPI/#dfn-slice -DOM::ExceptionOr> Blob::slice(Optional start, Optional end, Optional const& content_type) +WebIDL::ExceptionOr> Blob::slice(Optional start, Optional end, Optional 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. // User agents must process slice() with start normalized according to the following: diff --git a/Userland/Libraries/LibWeb/FileAPI/Blob.h b/Userland/Libraries/LibWeb/FileAPI/Blob.h index d85bc94cb2..26babfbd40 100644 --- a/Userland/Libraries/LibWeb/FileAPI/Blob.h +++ b/Userland/Libraries/LibWeb/FileAPI/Blob.h @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include namespace Web::FileAPI { @@ -34,15 +34,15 @@ public: virtual ~Blob() override; static JS::NonnullGCPtr create(HTML::Window&, ByteBuffer, String type); - static DOM::ExceptionOr> create(HTML::Window&, Optional> const& blob_parts = {}, Optional const& options = {}); - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, Optional> const& blob_parts = {}, Optional const& options = {}); + static WebIDL::ExceptionOr> create(HTML::Window&, Optional> const& blob_parts = {}, Optional const& options = {}); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, Optional> const& blob_parts = {}, Optional const& options = {}); // https://w3c.github.io/FileAPI/#dfn-size u64 size() const { return m_byte_buffer.size(); } // https://w3c.github.io/FileAPI/#dfn-type String const& type() const { return m_type; } - DOM::ExceptionOr> slice(Optional start = {}, Optional end = {}, Optional const& content_type = {}); + WebIDL::ExceptionOr> slice(Optional start = {}, Optional end = {}, Optional const& content_type = {}); JS::Promise* text(); JS::Promise* array_buffer(); diff --git a/Userland/Libraries/LibWeb/FileAPI/File.cpp b/Userland/Libraries/LibWeb/FileAPI/File.cpp index f431134bca..7f8e0f4e45 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.cpp +++ b/Userland/Libraries/LibWeb/FileAPI/File.cpp @@ -20,7 +20,7 @@ File::File(HTML::Window& window, ByteBuffer byte_buffer, String file_name, Strin File::~File() = default; // https://w3c.github.io/FileAPI/#ref-for-dom-file-file -DOM::ExceptionOr> File::create(HTML::Window& window, Vector const& file_bits, String const& file_name, Optional const& options) +WebIDL::ExceptionOr> File::create(HTML::Window& window, Vector const& file_bits, String const& file_name, Optional const& 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 const&>(*options))); @@ -60,7 +60,7 @@ DOM::ExceptionOr> File::create(HTML::Window& window, Vect return JS::NonnullGCPtr(*window.heap().allocate(window.realm(), window, move(bytes), move(name), move(type), last_modified)); } -DOM::ExceptionOr> File::create_with_global_object(HTML::Window& window, Vector const& file_bits, String const& file_name, Optional const& options) +WebIDL::ExceptionOr> File::create_with_global_object(HTML::Window& window, Vector const& file_bits, String const& file_name, Optional const& options) { return create(window, file_bits, file_name, options); } diff --git a/Userland/Libraries/LibWeb/FileAPI/File.h b/Userland/Libraries/LibWeb/FileAPI/File.h index 82f2817722..0ad1238d1c 100644 --- a/Userland/Libraries/LibWeb/FileAPI/File.h +++ b/Userland/Libraries/LibWeb/FileAPI/File.h @@ -19,8 +19,8 @@ class File : public Blob { WEB_PLATFORM_OBJECT(File, Blob); public: - static DOM::ExceptionOr> create(HTML::Window&, Vector const& file_bits, String const& file_name, Optional const& options = {}); - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, Vector const& file_bits, String const& file_name, Optional const& options = {}); + static WebIDL::ExceptionOr> create(HTML::Window&, Vector const& file_bits, String const& file_name, Optional const& options = {}); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, Vector const& file_bits, String const& file_name, Optional const& options = {}); virtual ~File() override; diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index d9f9510f71..465a9343bb 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -170,9 +170,6 @@ class TreeWalker; enum class QuirksMode; struct EventListenerOptions; struct AddEventListenerOptions; - -template -class ExceptionOr; } namespace Web::DOMParsing { @@ -397,6 +394,9 @@ class SVGSVGElement; namespace Web::WebIDL { class CallbackType; + +template +class ExceptionOr; } namespace Web::WebSockets { diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 5e2e9da965..416ca237be 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -859,7 +859,7 @@ void BrowsingContext::remove() } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate -DOM::ExceptionOr BrowsingContext::navigate( +WebIDL::ExceptionOr BrowsingContext::navigate( Fetch::Infrastructure::Request resource, BrowsingContext& source_browsing_context, bool exceptions_enabled, @@ -983,7 +983,7 @@ DOM::ExceptionOr BrowsingContext::navigate( } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid -DOM::ExceptionOr BrowsingContext::navigate_to_a_fragment(AK::URL const& url, HistoryHandlingBehavior history_handling, String navigation_id) +WebIDL::ExceptionOr BrowsingContext::navigate_to_a_fragment(AK::URL const& url, HistoryHandlingBehavior history_handling, String navigation_id) { // 1. If historyHandling is not "replace", if (history_handling != HistoryHandlingBehavior::Replace) { @@ -1025,7 +1025,7 @@ DOM::ExceptionOr BrowsingContext::navigate_to_a_fragment(AK::URL const& ur } // https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history -DOM::ExceptionOr BrowsingContext::traverse_the_history(size_t entry_index, HistoryHandlingBehavior history_handling, bool explicit_history_navigation) +WebIDL::ExceptionOr BrowsingContext::traverse_the_history(size_t entry_index, HistoryHandlingBehavior history_handling, bool explicit_history_navigation) { auto* entry = &m_session_history[entry_index]; diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index 29a8f1edb6..23fef535bd 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -140,7 +140,7 @@ public: bool is_allowed_to_navigate(BrowsingContext const&) const; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate - DOM::ExceptionOr navigate( + WebIDL::ExceptionOr navigate( Fetch::Infrastructure::Request resource, BrowsingContext& source_browsing_context, bool exceptions_enabled = false, @@ -151,13 +151,13 @@ public: Function)> process_response_end_of_body = {}); // https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate-fragid - DOM::ExceptionOr navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id); + WebIDL::ExceptionOr navigate_to_a_fragment(AK::URL const&, HistoryHandlingBehavior, String navigation_id); // https://html.spec.whatwg.org/multipage/origin.html#one-permitted-sandboxed-navigator BrowsingContext const* the_one_permitted_sandboxed_navigator() const; // https://html.spec.whatwg.org/multipage/browsing-the-web.html#traverse-the-history - DOM::ExceptionOr traverse_the_history(size_t entry_index, HistoryHandlingBehavior = HistoryHandlingBehavior::Default, bool explicit_history_navigation = false); + WebIDL::ExceptionOr traverse_the_history(size_t entry_index, HistoryHandlingBehavior = HistoryHandlingBehavior::Default, bool explicit_history_navigation = false); Vector> document_family() const; bool document_family_contains(DOM::Document const&) const; diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp index 7e4620aa22..d824ff34e3 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.cpp @@ -21,7 +21,7 @@ static void default_source_size(CanvasImageSource const& image, float& source_wi }); } -DOM::ExceptionOr CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y) +WebIDL::ExceptionOr 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 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 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); } -DOM::ExceptionOr CanvasDrawImage::draw_image(Web::HTML::CanvasImageSource const& image, float destination_x, float destination_y, float destination_width, float destination_height) +WebIDL::ExceptionOr 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 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 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); } -DOM::ExceptionOr 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 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); } diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h index 3a6ab3cebc..e7d324b8d8 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasDrawImage.h @@ -7,9 +7,9 @@ #pragma once #include -#include #include #include +#include namespace Web::HTML { @@ -22,11 +22,11 @@ class CanvasDrawImage { public: virtual ~CanvasDrawImage() = default; - DOM::ExceptionOr draw_image(CanvasImageSource const&, float destination_x, float destination_y); - DOM::ExceptionOr draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height); - DOM::ExceptionOr 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 draw_image(CanvasImageSource const&, float destination_x, float destination_y); + WebIDL::ExceptionOr draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height); + WebIDL::ExceptionOr 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 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 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: CanvasDrawImage() = default; diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageData.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageData.h index ba5f69ed5f..b918917363 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageData.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasImageData.h @@ -16,7 +16,7 @@ public: virtual ~CanvasImageData() = default; virtual JS::GCPtr create_image_data(int width, int height) const = 0; - virtual DOM::ExceptionOr> get_image_data(int x, int y, int width, int height) const = 0; + virtual WebIDL::ExceptionOr> 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; protected: diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp index 2091832fa7..d2460f7fad 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp @@ -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)); } -DOM::ExceptionOr CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise) +WebIDL::ExceptionOr CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise) { if (radius < 0) 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); } -DOM::ExceptionOr 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 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) return DOM::IndexSizeError::create(m_self.global_object(), String::formatted("The major-axis radius provided ({}) is negative.", radius_x)); diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.h index 4d9a0ecd2f..2f7130ad00 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include namespace Web::HTML { @@ -23,8 +23,8 @@ public: 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 rect(float x, float y, float width, float height); - DOM::ExceptionOr arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise); - DOM::ExceptionOr ellipse(float x, float y, float radius_x, float radius_y, float rotation, float start_angle, float end_angle, bool counter_clockwise); + WebIDL::ExceptionOr arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise); + WebIDL::ExceptionOr 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 const& path() const { return m_path; } diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index 213d301e81..e0e0b398c4 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -5,9 +5,9 @@ */ #include -#include #include #include +#include namespace Web::HTML { @@ -49,7 +49,7 @@ CanvasGradient::CanvasGradient(HTML::Window& window, Type type) CanvasGradient::~CanvasGradient() = default; // https://html.spec.whatwg.org/multipage/canvas.html#dom-canvasgradient-addcolorstop -DOM::ExceptionOr CanvasGradient::add_color_stop(double offset, String const& color) +WebIDL::ExceptionOr 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. if (offset < 0 || offset > 1) diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h index 56de9c855d..422222c1e3 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.h @@ -25,7 +25,7 @@ public: static JS::NonnullGCPtr create_linear(HTML::Window&, double x0, double y0, double x1, double y1); static JS::NonnullGCPtr create_conic(HTML::Window&, double start_angle, double x, double y); - DOM::ExceptionOr add_color_stop(double offset, String const& color); + WebIDL::ExceptionOr add_color_stop(double offset, String const& color); ~CanvasGradient(); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 29e916fc27..2b086edf05 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include 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 -DOM::ExceptionOr 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 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. 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 CanvasRenderingContext2D::create_image_data(int width, int } // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata -DOM::ExceptionOr> CanvasRenderingContext2D::get_image_data(int x, int y, int width, int height) const +WebIDL::ExceptionOr> 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. 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 -DOM::ExceptionOr check_usability_of_image(CanvasImageSource const& image) +WebIDL::ExceptionOr check_usability_of_image(CanvasImageSource const& image) { // 1. Switch on image: auto usability = TRY(image.visit( // HTMLOrSVGImageElement - [](JS::Handle const& image_element) -> DOM::ExceptionOr> { + [](JS::Handle const& image_element) -> WebIDL::ExceptionOr> { // FIXME: If image's current request's state is broken, then throw an "InvalidStateError" DOMException. // If image is not fully decodable, then return bad. @@ -494,7 +494,7 @@ DOM::ExceptionOr check_usability_of_image(CanvasImag // HTMLCanvasElement // FIXME: OffscreenCanvas - [](JS::Handle const& canvas_element) -> DOM::ExceptionOr> { + [](JS::Handle const& canvas_element) -> WebIDL::ExceptionOr> { // 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) return DOM::InvalidStateError::create(canvas_element->global_object(), "Canvas width or height is zero"); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index 3ffbd5481f..caaae49815 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -28,6 +27,7 @@ #include #include #include +#include namespace Web::HTML { @@ -58,7 +58,7 @@ public: 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 DOM::ExceptionOr 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 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 stroke() override; @@ -71,7 +71,7 @@ public: virtual void fill(Path2D& path, String const& fill_rule) override; virtual JS::GCPtr create_image_data(int width, int height) const override; - virtual DOM::ExceptionOr> get_image_data(int x, int y, int width, int height) const override; + virtual WebIDL::ExceptionOr> 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 reset_to_default_state() override; @@ -120,7 +120,7 @@ enum class CanvasImageSourceUsability { Good, }; -DOM::ExceptionOr check_usability_of_image(CanvasImageSource const&); +WebIDL::ExceptionOr check_usability_of_image(CanvasImageSource const&); bool image_is_not_origin_clean(CanvasImageSource const&); } diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp index f55851c757..bd4db0052f 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.cpp @@ -13,7 +13,7 @@ namespace Web::HTML { -DOM::ExceptionOr> DOMParser::create_with_global_object(HTML::Window& window) +WebIDL::ExceptionOr> DOMParser::create_with_global_object(HTML::Window& window) { return JS::NonnullGCPtr(*window.heap().allocate(window.realm(), window)); } diff --git a/Userland/Libraries/LibWeb/HTML/DOMParser.h b/Userland/Libraries/LibWeb/HTML/DOMParser.h index 3f61c2c713..8ae6f70f6d 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMParser.h +++ b/Userland/Libraries/LibWeb/HTML/DOMParser.h @@ -8,8 +8,8 @@ #include #include -#include #include +#include namespace Web::HTML { @@ -18,7 +18,7 @@ class DOMParser final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(DOMParser, Bindings::PlatformObject); public: - static DOM::ExceptionOr> create_with_global_object(HTML::Window&); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&); virtual ~DOMParser() override; diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 2db4c8512d..79456fbc97 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -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 -DOM::ExceptionOr DOMStringMap::set_value_of_new_named_property(String const& name, String const& value) +WebIDL::ExceptionOr DOMStringMap::set_value_of_new_named_property(String const& name, String const& value) { AK::StringBuilder builder; @@ -150,7 +150,7 @@ DOM::ExceptionOr DOMStringMap::set_value_of_new_named_property(String cons } // https://html.spec.whatwg.org/multipage/dom.html#dom-domstringmap-setitem -DOM::ExceptionOr DOMStringMap::set_value_of_existing_named_property(String const& name, String const& value) +WebIDL::ExceptionOr DOMStringMap::set_value_of_existing_named_property(String const& name, String const& value) { return set_value_of_new_named_property(name, value); } diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h index 34b5af5d88..2b98b53f23 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.h +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.h @@ -25,8 +25,8 @@ public: String determine_value_of_named_property(String const&) const; - DOM::ExceptionOr set_value_of_new_named_property(String const&, String const&); - DOM::ExceptionOr set_value_of_existing_named_property(String const&, String const&); + WebIDL::ExceptionOr set_value_of_new_named_property(String const&, String const&); + WebIDL::ExceptionOr set_value_of_existing_named_property(String const&, String const&); bool delete_existing_named_property(String const&); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index 6f12735db7..3513098adc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include namespace Web::HTML { @@ -90,7 +90,7 @@ String HTMLElement::content_editable() const } // https://html.spec.whatwg.org/multipage/interaction.html#contenteditable -DOM::ExceptionOr HTMLElement::set_content_editable(String const& content_editable) +WebIDL::ExceptionOr HTMLElement::set_content_editable(String const& content_editable) { if (content_editable.equals_ignoring_case("inherit"sv)) { remove_attribute(HTML::AttributeNames::contenteditable); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.h b/Userland/Libraries/LibWeb/HTML/HTMLElement.h index 972a7cc178..68fdb4c1ff 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.h @@ -25,7 +25,7 @@ public: virtual bool is_editable() const final; String content_editable() const; - DOM::ExceptionOr set_content_editable(String const&); + WebIDL::ExceptionOr set_content_editable(String const&); String inner_text(); void set_inner_text(StringView); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index ac7add85e2..086560a297 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -27,7 +27,7 @@ HTMLOptionsCollection::HTMLOptionsCollection(DOM::ParentNode& root, Function HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement element, Optional before) +WebIDL::ExceptionOr HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement element, Optional before) { auto resolved_element = element.visit( [](auto& e) -> JS::Handle { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h index 7fa5d85ed8..813b202ded 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.h @@ -7,8 +7,8 @@ #pragma once #include -#include #include +#include namespace Web::HTML { @@ -22,7 +22,7 @@ public: static JS::NonnullGCPtr create(DOM::ParentNode& root, Function filter); virtual ~HTMLOptionsCollection() override; - DOM::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); + WebIDL::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); private: HTMLOptionsCollection(DOM::ParentNode& root, Function filter); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 534e75225d..6671dd26b6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -43,7 +43,7 @@ JS::GCPtr const& HTMLSelectElement::options() } // https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-add -DOM::ExceptionOr HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional before) +WebIDL::ExceptionOr HTMLSelectElement::add(HTMLOptionOrOptGroupElement element, Optional before) { // Similarly, the add(element, before) method must act like its namesake method on that same options collection. return const_cast(*options()).add(move(element), move(before)); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h index a8ab71b15a..3e66c8d176 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -25,7 +25,7 @@ public: JS::GCPtr const& options(); - DOM::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); + WebIDL::ExceptionOr add(HTMLOptionOrOptGroupElement element, Optional before = {}); int selected_index() const; void set_selected_index(int); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index aacc49517b..a200f91391 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -97,7 +97,7 @@ JS::GCPtr HTMLTableElement::t_head() return nullptr; } -DOM::ExceptionOr HTMLTableElement::set_t_head(HTMLTableSectionElement* thead) +WebIDL::ExceptionOr 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. VERIFY(thead); @@ -184,7 +184,7 @@ JS::GCPtr HTMLTableElement::t_foot() return nullptr; } -DOM::ExceptionOr HTMLTableElement::set_t_foot(HTMLTableSectionElement* tfoot) +WebIDL::ExceptionOr 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. VERIFY(tfoot); @@ -280,7 +280,7 @@ JS::NonnullGCPtr HTMLTableElement::rows() }); } -DOM::ExceptionOr> HTMLTableElement::insert_row(long index) +WebIDL::ExceptionOr> HTMLTableElement::insert_row(long index) { auto rows = this->rows(); auto rows_length = rows->length(); @@ -306,7 +306,7 @@ DOM::ExceptionOr> HTMLTableElement::insert } // https://html.spec.whatwg.org/multipage/tables.html#dom-table-deleterow -DOM::ExceptionOr HTMLTableElement::delete_row(long index) +WebIDL::ExceptionOr HTMLTableElement::delete_row(long index) { auto rows = this->rows(); auto rows_length = rows->length(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h index 23df8a9f1e..e18dd4058b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -6,11 +6,11 @@ #pragma once -#include #include #include #include #include +#include namespace Web::HTML { @@ -26,12 +26,12 @@ public: void delete_caption(); JS::GCPtr t_head(); - DOM::ExceptionOr set_t_head(HTMLTableSectionElement* thead); + WebIDL::ExceptionOr set_t_head(HTMLTableSectionElement* thead); JS::NonnullGCPtr create_t_head(); void delete_t_head(); JS::GCPtr t_foot(); - DOM::ExceptionOr set_t_foot(HTMLTableSectionElement* tfoot); + WebIDL::ExceptionOr set_t_foot(HTMLTableSectionElement* tfoot); JS::NonnullGCPtr create_t_foot(); void delete_t_foot(); @@ -39,8 +39,8 @@ public: JS::NonnullGCPtr create_t_body(); JS::NonnullGCPtr rows(); - DOM::ExceptionOr> insert_row(long index); - DOM::ExceptionOr delete_row(long index); + WebIDL::ExceptionOr> insert_row(long index); + WebIDL::ExceptionOr delete_row(long index); private: HTMLTableElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index d0f4f04d22..39efff51ec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -36,7 +36,7 @@ JS::NonnullGCPtr HTMLTableSectionElement::rows() const } // https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-insertrow -DOM::ExceptionOr> HTMLTableSectionElement::insert_row(long index) +WebIDL::ExceptionOr> HTMLTableSectionElement::insert_row(long index) { auto rows_collection = rows(); auto rows_collection_size = static_cast(rows_collection->length()); @@ -60,7 +60,7 @@ DOM::ExceptionOr> HTMLTableSectionElement: } // https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-deleterow -DOM::ExceptionOr HTMLTableSectionElement::delete_row(long index) +WebIDL::ExceptionOr HTMLTableSectionElement::delete_row(long index) { auto rows_collection = rows(); auto rows_collection_size = static_cast(rows_collection->length()); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h index c41170b077..0965cdef89 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.h @@ -18,8 +18,8 @@ public: virtual ~HTMLTableSectionElement() override; JS::NonnullGCPtr rows() const; - DOM::ExceptionOr> insert_row(long index); - DOM::ExceptionOr delete_row(long index); + WebIDL::ExceptionOr> insert_row(long index); + WebIDL::ExceptionOr delete_row(long index); private: HTMLTableSectionElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index e46b713f65..fa579167c7 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -30,21 +30,21 @@ void History::visit_edges(Cell::Visitor& visitor) } // https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate -DOM::ExceptionOr History::push_state(JS::Value data, String const&, String const& url) +WebIDL::ExceptionOr History::push_state(JS::Value data, String const&, String const& url) { // NOTE: The second parameter of this function is intentionally unused. return shared_history_push_replace_state(data, url, IsPush::Yes); } // https://html.spec.whatwg.org/multipage/history.html#dom-history-replacestate -DOM::ExceptionOr History::replace_state(JS::Value data, String const&, String const& url) +WebIDL::ExceptionOr History::replace_state(JS::Value data, String const&, String const& url) { // NOTE: The second parameter of this function is intentionally unused. return shared_history_push_replace_state(data, url, IsPush::No); } // https://html.spec.whatwg.org/multipage/history.html#shared-history-push/replace-state-steps -DOM::ExceptionOr History::shared_history_push_replace_state(JS::Value, String const&, IsPush) +WebIDL::ExceptionOr History::shared_history_push_replace_state(JS::Value, String const&, IsPush) { // 1. Let document be history's associated Document. (NOTE: Not necessary) diff --git a/Userland/Libraries/LibWeb/HTML/History.h b/Userland/Libraries/LibWeb/HTML/History.h index 55ab0a2675..b7d22ef12c 100644 --- a/Userland/Libraries/LibWeb/HTML/History.h +++ b/Userland/Libraries/LibWeb/HTML/History.h @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Web::HTML { @@ -21,8 +21,8 @@ public: virtual ~History() override; - DOM::ExceptionOr push_state(JS::Value data, String const& unused, String const& url); - DOM::ExceptionOr replace_state(JS::Value data, String const& unused, String const& url); + WebIDL::ExceptionOr push_state(JS::Value data, String const& unused, String const& url); + WebIDL::ExceptionOr replace_state(JS::Value data, String const& unused, String const& url); private: explicit History(HTML::Window&, DOM::Document&); @@ -33,7 +33,7 @@ private: No, Yes, }; - DOM::ExceptionOr shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push); + WebIDL::ExceptionOr shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push); JS::NonnullGCPtr m_associated_document; }; diff --git a/Userland/Libraries/LibWeb/HTML/Storage.cpp b/Userland/Libraries/LibWeb/HTML/Storage.cpp index dc4855a04f..7db1d4a554 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.cpp +++ b/Userland/Libraries/LibWeb/HTML/Storage.cpp @@ -57,7 +57,7 @@ String Storage::get_item(String const& key) const } // https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem -DOM::ExceptionOr Storage::set_item(String const& key, String const& value) +WebIDL::ExceptionOr Storage::set_item(String const& key, String const& value) { // 1. Let oldValue be null. String old_value; diff --git a/Userland/Libraries/LibWeb/HTML/Storage.h b/Userland/Libraries/LibWeb/HTML/Storage.h index 890023fa5b..409d511949 100644 --- a/Userland/Libraries/LibWeb/HTML/Storage.h +++ b/Userland/Libraries/LibWeb/HTML/Storage.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Web::HTML { @@ -22,7 +22,7 @@ public: size_t length() const; String key(size_t index); String get_item(String const& key) const; - DOM::ExceptionOr set_item(String const& key, String const& value); + WebIDL::ExceptionOr set_item(String const& key, String const& value); void remove_item(String const& key); void clear(); diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 297a5a42b6..f21ec41059 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -596,7 +596,7 @@ Window* Window::parent() } // https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps -DOM::ExceptionOr Window::post_message_impl(JS::Value message, String const&) +WebIDL::ExceptionOr Window::post_message_impl(JS::Value message, String const&) { // FIXME: This is an ad-hoc hack implementation instead, since we don't currently // have serialization and deserialization of messages. diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h index 16e0799415..0f9c09e464 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.h +++ b/Userland/Libraries/LibWeb/HTML/Window.h @@ -108,7 +108,7 @@ public: Window* parent(); - DOM::ExceptionOr post_message_impl(JS::Value, String const& target_origin); + WebIDL::ExceptionOr post_message_impl(JS::Value, String const& target_origin); String name() const; void set_name(String const&); diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index d8c4dc9c53..7797b28ff5 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -8,10 +8,10 @@ #include #include #include -#include #include #include #include +#include namespace Web::HTML { @@ -39,7 +39,7 @@ void Worker::visit_edges(Cell::Visitor& visitor) } // https://html.spec.whatwg.org/multipage/workers.html#dom-worker -DOM::ExceptionOr> Worker::create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document) +WebIDL::ExceptionOr> 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); @@ -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 -DOM::ExceptionOr Worker::terminate() +WebIDL::ExceptionOr Worker::terminate() { dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Terminate"); diff --git a/Userland/Libraries/LibWeb/HTML/Worker.h b/Userland/Libraries/LibWeb/HTML/Worker.h index bcc1a447bd..d3c92d616b 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.h +++ b/Userland/Libraries/LibWeb/HTML/Worker.h @@ -36,13 +36,13 @@ class Worker : public DOM::EventTarget { WEB_PLATFORM_OBJECT(Worker, DOM::EventTarget); public: - static DOM::ExceptionOr> create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document); - static DOM::ExceptionOr> create_with_global_object(HTML::Window& window, FlyString const& script_url, WorkerOptions const options) + static WebIDL::ExceptionOr> create(FlyString const& script_url, WorkerOptions const options, DOM::Document& document); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window& window, FlyString const& script_url, WorkerOptions const options) { return Worker::create(script_url, options, window.associated_document()); } - DOM::ExceptionOr terminate(); + WebIDL::ExceptionOr terminate(); void post_message(JS::Value message, JS::Value transfer); diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp index 93d4e39827..93f929fca4 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp @@ -43,7 +43,7 @@ void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor) } // https://html.spec.whatwg.org/multipage/workers.html#importing-scripts-and-libraries -DOM::ExceptionOr WorkerGlobalScope::import_scripts(Vector urls) +WebIDL::ExceptionOr WorkerGlobalScope::import_scripts(Vector urls) { // 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. @@ -121,7 +121,7 @@ bool WorkerGlobalScope::cross_origin_isolated() const } // https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa -DOM::ExceptionOr WorkerGlobalScope::btoa(String const& data) const +WebIDL::ExceptionOr WorkerGlobalScope::btoa(String const& data) const { // 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. @@ -141,7 +141,7 @@ DOM::ExceptionOr WorkerGlobalScope::btoa(String const& data) const } // https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob -DOM::ExceptionOr WorkerGlobalScope::atob(String const& data) const +WebIDL::ExceptionOr WorkerGlobalScope::atob(String const& data) const { // 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. diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index 66d571f1d1..2d7dee7e36 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -10,10 +10,10 @@ #include #include #include -#include #include #include #include +#include #define ENUMERATE_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \ E(onerror, HTML::EventNames::error) \ @@ -42,7 +42,7 @@ public: JS::NonnullGCPtr location() const; JS::NonnullGCPtr navigator() const; - DOM::ExceptionOr import_scripts(Vector urls); + WebIDL::ExceptionOr import_scripts(Vector urls); #undef __ENUMERATE #define __ENUMERATE(attribute_name, event_name) \ @@ -57,8 +57,8 @@ public: String origin() const; bool is_secure_context() const; bool cross_origin_isolated() const; - DOM::ExceptionOr btoa(String const& data) const; - DOM::ExceptionOr atob(String const& data) const; + WebIDL::ExceptionOr btoa(String const& data) const; + WebIDL::ExceptionOr atob(String const& data) const; // Non-IDL public methods diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp index b84073c281..cc9df8c642 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.cpp @@ -25,7 +25,7 @@ SVGLength::SVGLength(HTML::Window& window, u8 unit_type, float value) SVGLength::~SVGLength() = default; // https://www.w3.org/TR/SVG11/types.html#__svg__SVGLength__value -DOM::ExceptionOr SVGLength::set_value(float value) +WebIDL::ExceptionOr SVGLength::set_value(float value) { // FIXME: Raise an exception if this is read-only. m_value = value; diff --git a/Userland/Libraries/LibWeb/SVG/SVGLength.h b/Userland/Libraries/LibWeb/SVG/SVGLength.h index bd6c90d110..fac3a8cf0a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGLength.h +++ b/Userland/Libraries/LibWeb/SVG/SVGLength.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include namespace Web::SVG { @@ -22,7 +22,7 @@ public: u8 unit_type() const { return m_unit_type; } float value() const { return m_value; } - DOM::ExceptionOr set_value(float value); + WebIDL::ExceptionOr set_value(float value); private: SVGLength(HTML::Window&, u8 unit_type, float value); diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp index e035a96b3e..eeaa7efaa5 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.cpp @@ -11,7 +11,7 @@ namespace Web::Streams { // https://streams.spec.whatwg.org/#rs-constructor -DOM::ExceptionOr> ReadableStream::create_with_global_object(HTML::Window& window) +WebIDL::ExceptionOr> ReadableStream::create_with_global_object(HTML::Window& window) { auto* readable_stream = window.heap().allocate(window.realm(), window); diff --git a/Userland/Libraries/LibWeb/Streams/ReadableStream.h b/Userland/Libraries/LibWeb/Streams/ReadableStream.h index 7a60125e89..94f89096f2 100644 --- a/Userland/Libraries/LibWeb/Streams/ReadableStream.h +++ b/Userland/Libraries/LibWeb/Streams/ReadableStream.h @@ -24,7 +24,7 @@ public: Errored, }; - static DOM::ExceptionOr> create_with_global_object(HTML::Window&); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&); virtual ~ReadableStream() override; diff --git a/Userland/Libraries/LibWeb/URL/URL.cpp b/Userland/Libraries/LibWeb/URL/URL.cpp index 882f3c1e2a..9302c0f818 100644 --- a/Userland/Libraries/LibWeb/URL/URL.cpp +++ b/Userland/Libraries/LibWeb/URL/URL.cpp @@ -16,7 +16,7 @@ JS::NonnullGCPtr URL::create(HTML::Window& window, AK::URL url, JS::Nonnull return *window.heap().allocate(window.realm(), window, move(url), move(query)); } -DOM::ExceptionOr> URL::create_with_global_object(HTML::Window& window, String const& url, String const& base) +WebIDL::ExceptionOr> URL::create_with_global_object(HTML::Window& window, String const& url, String const& base) { // 1. Let parsedBase be null. Optional parsed_base; @@ -26,7 +26,7 @@ DOM::ExceptionOr> URL::create_with_global_object(HTML::Win parsed_base = base; // 2. If parsedBase is failure, then throw a TypeError. 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. AK::URL parsed_url; @@ -36,7 +36,7 @@ DOM::ExceptionOr> URL::create_with_global_object(HTML::Win parsed_url = url; // 4. If parsedURL is failure, then throw a TypeError. 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 parsedURL’s query, if that is non-null, and the empty string otherwise. auto& query = parsed_url.query().is_null() ? String::empty() : parsed_url.query(); // 6. Set this’s URL to parsedURL. @@ -78,13 +78,13 @@ String URL::to_json() const return m_url.serialize(); } -DOM::ExceptionOr URL::set_href(String const& href) +WebIDL::ExceptionOr URL::set_href(String const& href) { // 1. Let parsedURL be the result of running the basic URL parser on the given value. AK::URL parsed_url = href; // 2. If parsedURL is failure, then throw a TypeError. if (!parsed_url.is_valid()) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "Invalid URL" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid URL" }; // 3. Set this’s URL to parsedURL. m_url = move(parsed_url); // 4. Empty this’s query object’s list. diff --git a/Userland/Libraries/LibWeb/URL/URL.h b/Userland/Libraries/LibWeb/URL/URL.h index ce23f6ea9e..849a51871b 100644 --- a/Userland/Libraries/LibWeb/URL/URL.h +++ b/Userland/Libraries/LibWeb/URL/URL.h @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include namespace Web::URL { @@ -20,12 +20,12 @@ class URL : public Bindings::PlatformObject { public: static JS::NonnullGCPtr create(HTML::Window&, AK::URL url, JS::NonnullGCPtr query); - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, String const& url, String const& base); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, String const& url, String const& base); virtual ~URL() override; String href() const; - DOM::ExceptionOr set_href(String const&); + WebIDL::ExceptionOr set_href(String const&); String origin() const; diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp index 511e6f878f..ef12b26927 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp @@ -89,7 +89,7 @@ JS::NonnullGCPtr URLSearchParams::create(HTML::Window& window, // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams // https://url.spec.whatwg.org/#urlsearchparams-initialize -DOM::ExceptionOr> URLSearchParams::create_with_global_object(HTML::Window& window, Variant>, OrderedHashMap, String> const& init) +WebIDL::ExceptionOr> URLSearchParams::create_with_global_object(HTML::Window& window, Variant>, OrderedHashMap, String> const& init) { // 1. If init is a string and starts with U+003F (?), then remove the first code point from init. // NOTE: We do this when we know that it's a string on step 3 of initialization. @@ -108,7 +108,7 @@ DOM::ExceptionOr> URLSearchParams::create_with for (auto const& pair : init_sequence) { // a. If pair does not contain exactly two items, then throw a TypeError. if (pair.size() != 2) - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, String::formatted("Expected only 2 items in pair, got {}", pair.size()) }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Expected only 2 items in pair, got {}", pair.size()) }; // b. Append a new name-value pair whose name is pair’s first item, and value is pair’s second item, to query’s list. list.append(QueryParam { .name = pair[0], .value = pair[1] }); diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h index ea1737e4d6..97413dcb6b 100644 --- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h +++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Web::URL { @@ -24,7 +24,7 @@ class URLSearchParams : public Bindings::PlatformObject { public: static JS::NonnullGCPtr create(HTML::Window&, Vector list); - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, Variant>, OrderedHashMap, String> const& init); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, Variant>, OrderedHashMap, String> const& init); virtual ~URLSearchParams() override; diff --git a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h b/Userland/Libraries/LibWeb/WebIDL/ExceptionOr.h similarity index 76% rename from Userland/Libraries/LibWeb/DOM/ExceptionOr.h rename to Userland/Libraries/LibWeb/WebIDL/ExceptionOr.h index 8e99b6adaf..23944eafa3 100644 --- a/Userland/Libraries/LibWeb/DOM/ExceptionOr.h +++ b/Userland/Libraries/LibWeb/WebIDL/ExceptionOr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh + * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,7 +11,7 @@ #include #include -namespace Web::DOM { +namespace Web::WebIDL { #define ENUMERATE_SIMPLE_WEBIDL_EXCEPTION_TYPES(E) \ E(EvalError) \ @@ -49,7 +49,7 @@ public: { } - ExceptionOr(JS::NonnullGCPtr exception) + ExceptionOr(JS::NonnullGCPtr exception) : m_exception(move(exception)) { } @@ -59,8 +59,8 @@ public: { } - ExceptionOr(Variant> exception) - : m_exception(move(exception).template downcast>()) + ExceptionOr(Variant> exception) + : m_exception(move(exception).template downcast>()) { } @@ -78,9 +78,9 @@ public: return m_result.release_value(); } - Variant> exception() const + Variant> exception() const { - return m_exception.template downcast>(); + return m_exception.template downcast>(); } bool is_exception() const @@ -90,12 +90,13 @@ public: // These are for compatibility with the TRY() macro in AK. [[nodiscard]] bool is_error() const { return is_exception(); } - Variant> release_error() { return exception(); } + Variant> release_error() { return exception(); } private: Optional m_result; + // https://webidl.spec.whatwg.org/#idl-exceptions - Variant> m_exception {}; + Variant> m_exception {}; }; template<> diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index ac2ccc0228..b429277aed 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include namespace Web::WebSockets { @@ -47,7 +47,7 @@ WebSocketClientSocket::~WebSocketClientSocket() = default; WebSocketClientManager::WebSocketClientManager() = default; // https://websockets.spec.whatwg.org/#dom-websocket-websocket -DOM::ExceptionOr> WebSocket::create_with_global_object(HTML::Window& window, String const& url) +WebIDL::ExceptionOr> WebSocket::create_with_global_object(HTML::Window& window, String const& url) { AK::URL url_record(url); if (!url_record.is_valid()) @@ -133,7 +133,7 @@ String WebSocket::protocol() const } // https://websockets.spec.whatwg.org/#dom-websocket-close -DOM::ExceptionOr WebSocket::close(Optional code, Optional reason) +WebIDL::ExceptionOr WebSocket::close(Optional code, Optional reason) { // 1. If code is present, but is neither an integer equal to 1000 nor an integer in the range 3000 to 4999, inclusive, throw an "InvalidAccessError" DOMException. if (code.has_value() && *code != 1000 && (*code < 3000 || *code > 4099)) @@ -160,7 +160,7 @@ DOM::ExceptionOr WebSocket::close(Optional code, Optional rea } // https://websockets.spec.whatwg.org/#dom-websocket-send -DOM::ExceptionOr WebSocket::send(String const& data) +WebIDL::ExceptionOr WebSocket::send(String const& data) { auto state = ready_state(); if (state == WebSocket::ReadyState::Connecting) diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h index bdfacd55cc..f882120f24 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.h +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.h @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #define ENUMERATE_WEBSOCKET_EVENT_HANDLERS(E) \ E(onerror, HTML::EventNames::error) \ @@ -37,7 +37,7 @@ public: Closed = 3, }; - static DOM::ExceptionOr> create_with_global_object(HTML::Window&, String const& url); + static WebIDL::ExceptionOr> create_with_global_object(HTML::Window&, String const& url); virtual ~WebSocket() override; @@ -57,8 +57,8 @@ public: String const& binary_type() { return m_binary_type; }; void set_binary_type(String const& type) { m_binary_type = type; }; - DOM::ExceptionOr close(Optional code, Optional reason); - DOM::ExceptionOr send(String const& data); + WebIDL::ExceptionOr close(Optional code, Optional reason); + WebIDL::ExceptionOr send(String const& data); private: void on_open(); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index db3b747d61..39516aba6b 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +80,7 @@ void XMLHttpRequest::fire_progress_event(String const& event_name, u64 transmitt } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsetext -DOM::ExceptionOr XMLHttpRequest::response_text() const +WebIDL::ExceptionOr XMLHttpRequest::response_text() const { // 1. If this’s response type is not the empty string or "text", then throw an "InvalidStateError" DOMException. if (m_response_type != Bindings::XMLHttpRequestResponseType::Empty && m_response_type != Bindings::XMLHttpRequestResponseType::Text) @@ -94,7 +94,7 @@ DOM::ExceptionOr XMLHttpRequest::response_text() const } // https://xhr.spec.whatwg.org/#response -DOM::ExceptionOr XMLHttpRequest::response() +WebIDL::ExceptionOr XMLHttpRequest::response() { // 1. If this’s response type is the empty string or "text", then: if (m_response_type == Bindings::XMLHttpRequestResponseType::Empty || m_response_type == Bindings::XMLHttpRequestResponseType::Text) { @@ -139,7 +139,7 @@ DOM::ExceptionOr XMLHttpRequest::response() // 7. Otherwise, if this’s response type is "document", set a document response for this. else if (m_response_type == Bindings::XMLHttpRequestResponseType::Document) { // FIXME: Implement this. - return DOM::SimpleException { DOM::SimpleExceptionType::TypeError, "XHR Document type not implemented" }; + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "XHR Document type not implemented" }; } // 8. Otherwise: else { @@ -269,7 +269,7 @@ Optional XMLHttpRequest::get_final_encoding() const } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader -DOM::ExceptionOr XMLHttpRequest::set_request_header(String const& name_string, String const& value_string) +WebIDL::ExceptionOr XMLHttpRequest::set_request_header(String const& name_string, String const& value_string) { auto name = name_string.to_byte_buffer(); auto value = value_string.to_byte_buffer(); @@ -312,13 +312,13 @@ DOM::ExceptionOr XMLHttpRequest::set_request_header(String const& name_str } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open -DOM::ExceptionOr XMLHttpRequest::open(String const& method_string, String const& url) +WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, String const& url) { // 8. If the async argument is omitted, set async to true, and set username and password to null. return open(method_string, url, true, {}, {}); } -DOM::ExceptionOr XMLHttpRequest::open(String const& method_string, String const& url, bool async, String const& username, String const& password) +WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, String const& url, bool async, String const& username, String const& password) { auto method = method_string.to_byte_buffer(); @@ -395,7 +395,7 @@ DOM::ExceptionOr XMLHttpRequest::open(String const& method_string, String } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send -DOM::ExceptionOr XMLHttpRequest::send(Optional body) +WebIDL::ExceptionOr XMLHttpRequest::send(Optional body) { auto& vm = this->vm(); auto& realm = *vm.current_realm(); @@ -548,7 +548,7 @@ String XMLHttpRequest::get_all_response_headers() const } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-overridemimetype -DOM::ExceptionOr XMLHttpRequest::override_mime_type(String const& mime) +WebIDL::ExceptionOr XMLHttpRequest::override_mime_type(String const& mime) { // 1. If this’s state is loading or done, then throw an "InvalidStateError" DOMException. if (m_ready_state == ReadyState::Loading || m_ready_state == ReadyState::Done) @@ -565,7 +565,7 @@ DOM::ExceptionOr XMLHttpRequest::override_mime_type(String const& mime) } // https://xhr.spec.whatwg.org/#ref-for-dom-xmlhttprequest-timeout%E2%91%A2 -DOM::ExceptionOr XMLHttpRequest::set_timeout(u32 timeout) +WebIDL::ExceptionOr XMLHttpRequest::set_timeout(u32 timeout) { // 1. If the current global object is a Window object and this’s synchronous flag is set, // then throw an "InvalidAccessError" DOMException. diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index 1af8eae57b..d4127de532 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -12,13 +12,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include namespace Web::XHR { @@ -41,15 +41,15 @@ public: ReadyState ready_state() const { return m_ready_state; }; Fetch::Infrastructure::Status status() const { return m_status; }; - DOM::ExceptionOr response_text() const; - DOM::ExceptionOr response(); + WebIDL::ExceptionOr response_text() const; + WebIDL::ExceptionOr response(); Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; } - DOM::ExceptionOr open(String const& method, String const& url); - DOM::ExceptionOr open(String const& method, String const& url, bool async, String const& username = {}, String const& password = {}); - DOM::ExceptionOr send(Optional body); + WebIDL::ExceptionOr open(String const& method, String const& url); + WebIDL::ExceptionOr open(String const& method, String const& url, bool async, String const& username = {}, String const& password = {}); + WebIDL::ExceptionOr send(Optional body); - DOM::ExceptionOr set_request_header(String const& header, String const& value); + WebIDL::ExceptionOr set_request_header(String const& header, String const& value); void set_response_type(Bindings::XMLHttpRequestResponseType type) { m_response_type = type; } String get_response_header(String const& name) { return m_response_headers.get(name).value_or({}); } @@ -58,9 +58,9 @@ public: WebIDL::CallbackType* onreadystatechange(); void set_onreadystatechange(WebIDL::CallbackType*); - DOM::ExceptionOr override_mime_type(String const& mime); + WebIDL::ExceptionOr override_mime_type(String const& mime); - DOM::ExceptionOr set_timeout(u32 timeout); + WebIDL::ExceptionOr set_timeout(u32 timeout); u32 timeout() const; private: