From 41928c2902781a6e79435a5bcf389a62c85758cb Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Wed, 6 Sep 2023 16:03:01 +1200 Subject: [PATCH] LibWeb: Port DOMException interface from DeprecatedString to String --- .../BindingsGenerator/IDLGenerators.cpp | 2 +- Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp | 6 +-- .../Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 2 +- .../CSS/ResolvedCSSStyleDeclaration.cpp | 6 +-- Userland/Libraries/LibWeb/Crypto/Crypto.cpp | 6 +-- .../Libraries/LibWeb/Crypto/SubtleCrypto.cpp | 6 +-- Userland/Libraries/LibWeb/DOM/AbortSignal.cpp | 2 +- .../Libraries/LibWeb/DOM/CharacterData.cpp | 4 +- .../Libraries/LibWeb/DOM/DOMTokenList.cpp | 4 +- Userland/Libraries/LibWeb/DOM/Document.cpp | 46 +++++++++---------- Userland/Libraries/LibWeb/DOM/Element.cpp | 32 ++++++------- .../Libraries/LibWeb/DOM/ElementFactory.cpp | 10 ++-- Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 4 +- .../Libraries/LibWeb/DOM/NamedNodeMap.cpp | 6 +-- Userland/Libraries/LibWeb/DOM/Node.cpp | 36 +++++++-------- .../Libraries/LibWeb/DOM/NodeIterator.cpp | 2 +- Userland/Libraries/LibWeb/DOM/ParentNode.cpp | 4 +- Userland/Libraries/LibWeb/DOM/Range.cpp | 40 ++++++++-------- Userland/Libraries/LibWeb/DOM/StaticRange.cpp | 4 +- Userland/Libraries/LibWeb/DOM/Text.cpp | 2 +- Userland/Libraries/LibWeb/DOM/TreeWalker.cpp | 2 +- .../LibWeb/DOMParsing/XMLSerializer.cpp | 28 +++++------ .../Libraries/LibWeb/Encoding/TextDecoder.cpp | 2 +- .../Fetch/Infrastructure/FetchController.cpp | 2 +- .../Fetch/Infrastructure/HTTP/Bodies.cpp | 2 +- .../LibWeb/Geometry/DOMMatrixReadOnly.cpp | 2 +- .../Libraries/LibWeb/HTML/BrowsingContext.cpp | 2 +- .../LibWeb/HTML/Canvas/CanvasPath.cpp | 6 +-- .../Libraries/LibWeb/HTML/CanvasGradient.cpp | 8 ++-- .../Libraries/LibWeb/HTML/CanvasPattern.cpp | 2 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 6 +-- .../HTML/CrossOrigin/AbstractOperations.cpp | 6 +-- .../CustomElements/CustomElementRegistry.cpp | 14 +++--- .../Libraries/LibWeb/HTML/DOMStringMap.cpp | 2 +- .../Libraries/LibWeb/HTML/HTMLElement.cpp | 2 +- .../LibWeb/HTML/HTMLInputElement.cpp | 8 ++-- .../LibWeb/HTML/HTMLMediaElement.cpp | 4 +- .../Libraries/LibWeb/HTML/HTMLMediaElement.h | 2 +- .../LibWeb/HTML/HTMLOptionsCollection.cpp | 4 +- .../LibWeb/HTML/HTMLTableElement.cpp | 8 ++-- .../LibWeb/HTML/HTMLTableRowElement.cpp | 4 +- .../LibWeb/HTML/HTMLTableSectionElement.cpp | 4 +- Userland/Libraries/LibWeb/HTML/History.cpp | 10 ++-- Userland/Libraries/LibWeb/HTML/Location.cpp | 28 +++++------ Userland/Libraries/LibWeb/HTML/Navigable.cpp | 2 +- .../Libraries/LibWeb/HTML/NavigateEvent.cpp | 12 ++--- Userland/Libraries/LibWeb/HTML/Navigation.cpp | 30 ++++++------ .../LibWeb/HTML/Scripting/ClassicScript.cpp | 2 +- .../LibWeb/HTML/Scripting/ModuleScript.cpp | 2 +- .../LibWeb/HTML/StructuredSerialize.cpp | 12 ++--- Userland/Libraries/LibWeb/HTML/Window.cpp | 4 +- .../LibWeb/HTML/WindowOrWorkerGlobalScope.cpp | 4 +- .../Libraries/LibWeb/HTML/WindowProxy.cpp | 6 +-- Userland/Libraries/LibWeb/HTML/Worker.cpp | 4 +- .../LibWeb/HighResolutionTime/Performance.cpp | 4 +- .../PerformanceObserver.cpp | 4 +- .../Libraries/LibWeb/Selection/Selection.cpp | 16 +++---- .../LibWeb/UserTiming/PerformanceMark.cpp | 2 +- .../LibWeb/WebAudio/AudioContext.cpp | 6 +-- .../Libraries/LibWeb/WebIDL/DOMException.cpp | 6 +-- .../Libraries/LibWeb/WebIDL/DOMException.h | 32 ++++++------- .../Libraries/LibWeb/WebIDL/DOMException.idl | 2 +- .../Libraries/LibWeb/WebSockets/WebSocket.cpp | 16 +++---- Userland/Libraries/LibWeb/XHR/FormData.cpp | 2 +- .../Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 42 ++++++++--------- 65 files changed, 296 insertions(+), 296 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 2db5b22bae9..a39e877cbcb 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3567,7 +3567,7 @@ JS::ThrowCompletionOr> @constructor_class@::constru // 11. If element is an already constructed marker, then throw an "InvalidStateError" DOMException. if (element.has()) - return JS::throw_completion(WebIDL::InvalidStateError::create(realm, "Custom element has already been constructed"sv)); + return JS::throw_completion(WebIDL::InvalidStateError::create(realm, "Custom element has already been constructed"_fly_string)); // 12. Perform ? element.[[SetPrototypeOf]](prototype). auto actual_element = element.get>(); diff --git a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp index 4ab2a040eec..cf86402475a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSRuleList.cpp @@ -64,7 +64,7 @@ WebIDL::ExceptionOr CSSRuleList::insert_a_css_rule(Variant length) - return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."); + return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_fly_string); // 3. Set new rule to the results of performing parse a CSS rule on argument rule. // NOTE: The insert-a-css-rule spec expects `rule` to be a string, but the CSSStyleSheet.insertRule() @@ -81,7 +81,7 @@ WebIDL::ExceptionOr CSSRuleList::insert_a_css_rule(Variant CSSRuleList::remove_a_css_rule(u32 index) // 2. If index is greater than or equal to length, then throw an IndexSizeError exception. if (index >= length) - return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."); + return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_fly_string); // 3. Set old rule to the indexth item in list. CSSRule& old_rule = m_rules[index]; diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 5a70d837e5b..dbaa87cadab 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -67,7 +67,7 @@ WebIDL::ExceptionOr CSSStyleSheet::insert_rule(StringView rule, unsign // 4. If parsed rule is a syntax error, return parsed rule. if (!parsed_rule) - return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."); + return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_fly_string); // FIXME: 5. If parsed rule is an @import rule, and the constructed flag is set, throw a SyntaxError DOMException. diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index ce6236644aa..0f19fb4c8c7 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -940,14 +940,14 @@ Optional ResolvedCSSStyleDeclaration::property(PropertyID propert WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView, StringView) { // 1. If the computed flag is set, then throw a NoModificationAllowedError exception. - return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"); + return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"_fly_string); } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::remove_property(PropertyID) { // 1. If the computed flag is set, then throw a NoModificationAllowedError exception. - return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove properties from result of getComputedStyle()"); + return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove properties from result of getComputedStyle()"_fly_string); } DeprecatedString ResolvedCSSStyleDeclaration::serialized() const @@ -964,7 +964,7 @@ DeprecatedString ResolvedCSSStyleDeclaration::serialized() const WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::set_css_text(StringView) { // 1. If the computed flag is set, then throw a NoModificationAllowedError exception. - return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"); + return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"_fly_string); } } diff --git a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp index 17d9fc380e5..33f78b91408 100644 --- a/Userland/Libraries/LibWeb/Crypto/Crypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/Crypto.cpp @@ -44,16 +44,16 @@ 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()))) - return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"); + return WebIDL::TypeMismatchError::create(realm(), "array must be one of Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array, or BigUint64Array"_fly_string); auto& typed_array = static_cast(array.as_object()); // 2. If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm. if (typed_array.byte_length() > 65536) - return WebIDL::QuotaExceededError::create(realm(), "array's byteLength may not be greater than 65536"); + return WebIDL::QuotaExceededError::create(realm(), "array's byteLength may not be greater than 65536"_fly_string); // IMPLEMENTATION DEFINED: If the viewed array buffer is detached, throw a InvalidStateError and terminate the algorithm. if (typed_array.viewed_array_buffer()->is_detached()) - return WebIDL::InvalidStateError::create(realm(), "array is detached"); + return WebIDL::InvalidStateError::create(realm(), "array is detached"_fly_string); // FIXME: Handle SharedArrayBuffers // 3. Overwrite all elements of array with cryptographically strong random values of the appropriate type. diff --git a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp index 97b9dd29869..4eb7aa24f92 100644 --- a/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp +++ b/Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp @@ -42,7 +42,7 @@ JS::NonnullGCPtr SubtleCrypto::digest(String const& algorithm, JS:: // 2. Let data be the result of getting a copy of the bytes held by the data parameter passed to the digest() method. auto data_buffer_or_error = WebIDL::get_buffer_source_copy(*data.cell()); if (data_buffer_or_error.is_error()) { - auto error = WebIDL::OperationError::create(realm, "Failed to copy bytes from ArrayBuffer"); + auto error = WebIDL::OperationError::create(realm, "Failed to copy bytes from ArrayBuffer"_fly_string); auto promise = JS::Promise::create(realm); promise->reject(error.ptr()); return promise; @@ -64,7 +64,7 @@ JS::NonnullGCPtr SubtleCrypto::digest(String const& algorithm, JS:: } // 4. If an error occurred, return a Promise rejected with normalizedAlgorithm. else { - auto error = WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("Invalid hash function '{}'", algorithm)); + auto error = WebIDL::NotSupportedError::create(realm, MUST(String::formatted("Invalid hash function '{}'", algorithm))); auto promise = JS::Promise::create(realm); promise->reject(error.ptr()); return promise; @@ -85,7 +85,7 @@ JS::NonnullGCPtr SubtleCrypto::digest(String const& algorithm, JS:: auto digest = hash.digest(); auto result_buffer = ByteBuffer::copy(digest.immutable_data(), hash.digest_size()); if (result_buffer.is_error()) { - auto error = WebIDL::OperationError::create(realm, "Failed to create result buffer"); + auto error = WebIDL::OperationError::create(realm, "Failed to create result buffer"_fly_string); promise->reject(error.ptr()); return promise; } diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp index a6b22b15fed..9cfcd5b14f8 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.cpp @@ -50,7 +50,7 @@ void AbortSignal::signal_abort(JS::Value reason) if (!reason.is_undefined()) m_abort_reason = reason; else - m_abort_reason = WebIDL::AbortError::create(realm(), "Aborted without reason").ptr(); + m_abort_reason = WebIDL::AbortError::create(realm(), "Aborted without reason"_fly_string).ptr(); // 3. For each algorithm in signal’s abort algorithms: run algorithm. for (auto& algorithm : m_abort_algorithms) diff --git a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp index 8bfa1f7bf4f..a485f78c628 100644 --- a/Userland/Libraries/LibWeb/DOM/CharacterData.cpp +++ b/Userland/Libraries/LibWeb/DOM/CharacterData.cpp @@ -44,7 +44,7 @@ WebIDL::ExceptionOr CharacterData::substring_data(size_t offse // 2. If offset is greater than length, then throw an "IndexSizeError" DOMException. if (offset > length) - return WebIDL::IndexSizeError::create(realm(), "Substring offset out of range."); + return WebIDL::IndexSizeError::create(realm(), "Substring offset out of range."_fly_string); // 3. If offset plus count is greater than length, return a string whose value is the code units from the offsetth code unit // to the end of node’s data, and then return. @@ -63,7 +63,7 @@ WebIDL::ExceptionOr CharacterData::replace_data(size_t offset, size_t coun // 2. If offset is greater than length, then throw an "IndexSizeError" DOMException. if (offset > length) - return WebIDL::IndexSizeError::create(realm(), "Replacement offset out of range."); + return WebIDL::IndexSizeError::create(realm(), "Replacement offset out of range."_fly_string); // 3. If offset plus count is greater than length, then set count to length minus offset. if (offset + count > length) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 1425d3ad5f7..b702cee1549 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -240,9 +240,9 @@ void DOMTokenList::set_value(String const& value) WebIDL::ExceptionOr DOMTokenList::validate_token(StringView token) const { if (token.is_empty()) - return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed"); + return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed"_fly_string); if (any_of(token, Infra::is_ascii_whitespace)) - return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed"); + return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed"_fly_string); return {}; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index c667d71d6e1..6a846bac2a6 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -433,11 +433,11 @@ WebIDL::ExceptionOr Document::run_the_document_write_steps(DeprecatedStrin { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException. if (m_type == Type::XML) - return WebIDL::InvalidStateError::create(realm(), "write() called on XML document."); + return WebIDL::InvalidStateError::create(realm(), "write() called on XML document."_fly_string); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException. if (m_throw_on_dynamic_markup_insertion_counter > 0) - return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."); + return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_fly_string); // 3. If document's active parser was aborted is true, then return. if (m_active_parser_was_aborted) @@ -468,18 +468,18 @@ WebIDL::ExceptionOr Document::open(DeprecatedString const&, Deprecate { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. if (m_type == Type::XML) - return WebIDL::InvalidStateError::create(realm(), "open() called on XML document."); + return WebIDL::InvalidStateError::create(realm(), "open() called on XML document."_fly_string); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException. if (m_throw_on_dynamic_markup_insertion_counter > 0) - return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."); + return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_fly_string); // FIXME: 3. Let entryDocument be the entry global object's associated Document. auto& entry_document = *this; // 4. If document's origin is not same origin to entryDocument's origin, then throw a "SecurityError" DOMException. if (origin() != entry_document.origin()) - return WebIDL::SecurityError::create(realm(), "Document.origin() not the same as entryDocument's."); + return WebIDL::SecurityError::create(realm(), "Document.origin() not the same as entryDocument's."_fly_string); // 5. If document has an active parser whose script nesting level is greater than 0, then return document. if (m_parser && m_parser->script_nesting_level() > 0) @@ -539,7 +539,7 @@ WebIDL::ExceptionOr> Document::open(DeprecatedStrin { // 1. If this is not fully active, then throw an "InvalidAccessError" DOMException exception. if (!is_fully_active()) - return WebIDL::InvalidAccessError::create(realm(), "Cannot perform open on a document that isn't fully active."sv); + return WebIDL::InvalidAccessError::create(realm(), "Cannot perform open on a document that isn't fully active."_fly_string); // 2. Return the result of running the window open steps with url, name, and features. return window().open_impl(url, name, features); @@ -550,11 +550,11 @@ WebIDL::ExceptionOr Document::close() { // 1. If document is an XML document, then throw an "InvalidStateError" DOMException exception. if (m_type == Type::XML) - return WebIDL::InvalidStateError::create(realm(), "close() called on XML document."); + return WebIDL::InvalidStateError::create(realm(), "close() called on XML document."_fly_string); // 2. If document's throw-on-dynamic-markup-insertion counter is greater than 0, then throw an "InvalidStateError" DOMException. if (m_throw_on_dynamic_markup_insertion_counter > 0) - return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."); + return WebIDL::InvalidStateError::create(realm(), "throw-on-dynamic-markup-insertion-counter greater than zero."_fly_string); // 3. If there is no script-created parser associated with the document, then return. if (!m_parser) @@ -678,7 +678,7 @@ HTML::HTMLElement* Document::body() WebIDL::ExceptionOr Document::set_body(HTML::HTMLElement* new_body) { if (!is(new_body) && !is(new_body)) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid document body element, must be 'body' or 'frameset'"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid document body element, must be 'body' or 'frameset'"_fly_string); auto* existing_body = body(); if (existing_body) { @@ -688,7 +688,7 @@ WebIDL::ExceptionOr Document::set_body(HTML::HTMLElement* new_body) auto* document_element = this->document_element(); if (!document_element) - return WebIDL::HierarchyRequestError::create(realm(), "Missing document element"); + return WebIDL::HierarchyRequestError::create(realm(), "Missing document element"_fly_string); (void)TRY(document_element->append_child(*new_body)); return {}; @@ -1367,7 +1367,7 @@ WebIDL::ExceptionOr> Document::create_element(Deprecat // 1. If localName does not match the Name production, then throw an "InvalidCharacterError" DOMException. if (!is_valid_name(local_name)) - return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in tag name."); + return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in tag name."_fly_string); // 2. If this is an HTML document, then set localName to localName in ASCII lowercase. if (document_type() == Type::HTML) @@ -1500,7 +1500,7 @@ WebIDL::ExceptionOr> Document::create_event(DeprecatedSt // 3. If constructor is null, then throw a "NotSupportedError" DOMException. if (!event) { - return WebIDL::NotSupportedError::create(realm, "No constructor for interface found"); + return WebIDL::NotSupportedError::create(realm, "No constructor for interface found"_fly_string); } // FIXME: 4. If the interface indicated by constructor is not exposed on the relevant global object of this, then throw a "NotSupportedError" DOMException. @@ -1570,7 +1570,7 @@ WebIDL::ExceptionOr> Document::import_node(JS::NonnullGCP { // 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException. if (is(*node) || is(*node)) - return WebIDL::NotSupportedError::create(realm(), "Cannot import a document or shadow root."); + return WebIDL::NotSupportedError::create(realm(), "Cannot import a document or shadow root."_fly_string); // 2. Return a clone of node, with this and the clone children flag set if deep is true. return node->clone_node(this, deep); @@ -1644,10 +1644,10 @@ void Document::adopt_node(Node& node) WebIDL::ExceptionOr> Document::adopt_node_binding(JS::NonnullGCPtr node) { if (is(*node)) - return WebIDL::NotSupportedError::create(realm(), "Cannot adopt a document into a document"); + return WebIDL::NotSupportedError::create(realm(), "Cannot adopt a document into a document"_fly_string); if (is(*node)) - return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"); + return WebIDL::HierarchyRequestError::create(realm(), "Cannot adopt a shadow root into a document"_fly_string); if (is(*node) && verify_cast(*node).host()) return node; @@ -2265,11 +2265,11 @@ bool Document::is_valid_name(DeprecatedString const& name) WebIDL::ExceptionOr Document::validate_qualified_name(JS::Realm& realm, DeprecatedString const& qualified_name) { if (qualified_name.is_empty()) - return WebIDL::InvalidCharacterError::create(realm, "Empty string is not a valid qualified name."); + return WebIDL::InvalidCharacterError::create(realm, "Empty string is not a valid qualified name."_fly_string); Utf8View utf8view { qualified_name }; if (!utf8view.validate()) - return WebIDL::InvalidCharacterError::create(realm, "Invalid qualified name."); + return WebIDL::InvalidCharacterError::create(realm, "Invalid qualified name."_fly_string); Optional colon_offset; @@ -2279,19 +2279,19 @@ WebIDL::ExceptionOr Document::validate_qualified_nam auto code_point = *it; if (code_point == ':') { if (colon_offset.has_value()) - return WebIDL::InvalidCharacterError::create(realm, "More than one colon (:) in qualified name."); + return WebIDL::InvalidCharacterError::create(realm, "More than one colon (:) in qualified name."_fly_string); colon_offset = utf8view.byte_offset_of(it); at_start_of_name = true; continue; } if (at_start_of_name) { if (!is_valid_name_start_character(code_point)) - return WebIDL::InvalidCharacterError::create(realm, "Invalid start of qualified name."); + return WebIDL::InvalidCharacterError::create(realm, "Invalid start of qualified name."_fly_string); at_start_of_name = false; continue; } if (!is_valid_name_character(code_point)) - return WebIDL::InvalidCharacterError::create(realm, "Invalid character in qualified name."); + return WebIDL::InvalidCharacterError::create(realm, "Invalid character in qualified name."_fly_string); } if (!colon_offset.has_value()) @@ -2301,10 +2301,10 @@ WebIDL::ExceptionOr Document::validate_qualified_nam }; if (*colon_offset == 0) - return WebIDL::InvalidCharacterError::create(realm, "Qualified name can't start with colon (:)."); + return WebIDL::InvalidCharacterError::create(realm, "Qualified name can't start with colon (:)."_fly_string); if (*colon_offset >= (qualified_name.length() - 1)) - return WebIDL::InvalidCharacterError::create(realm, "Qualified name can't end with colon (:)."); + return WebIDL::InvalidCharacterError::create(realm, "Qualified name can't end with colon (:)."_fly_string); return Document::PrefixAndTagName { .prefix = qualified_name.substring_view(0, *colon_offset), @@ -2985,7 +2985,7 @@ WebIDL::ExceptionOr> Document::create_attribute(Deprecate { // 1. If localName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. if (!is_valid_name(local_name)) - return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in attribute name."); + return WebIDL::InvalidCharacterError::create(realm(), "Invalid character in attribute name."_fly_string); // 2. If this is an HTML document, then set localName to localName in ASCII lowercase. // 3. Return a new attribute whose local name is localName and node document is this. diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 6a2e3f483a5..2ea33c771bf 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -136,7 +136,7 @@ WebIDL::ExceptionOr Element::set_attribute(DeprecatedFlyString const& name // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // FIXME: Proper name validation if (name.is_empty()) - return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty"); + return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty"_fly_string); // 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase. // FIXME: Handle the second condition, assume it is an HTML document for now. @@ -193,19 +193,19 @@ WebIDL::ExceptionOr validate_and_extract(JS::Realm& realm, Deprec // 6. If prefix is non-null and namespace is null, then throw a "NamespaceError" DOMException. if (!prefix.is_null() && namespace_.is_null()) - return WebIDL::NamespaceError::create(realm, "Prefix is non-null and namespace is null."); + return WebIDL::NamespaceError::create(realm, "Prefix is non-null and namespace is null."_fly_string); // 7. If prefix is "xml" and namespace is not the XML namespace, then throw a "NamespaceError" DOMException. if (prefix == "xml"sv && namespace_ != Namespace::XML) - return WebIDL::NamespaceError::create(realm, "Prefix is 'xml' and namespace is not the XML namespace."); + return WebIDL::NamespaceError::create(realm, "Prefix is 'xml' and namespace is not the XML namespace."_fly_string); // 8. If either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace, then throw a "NamespaceError" DOMException. if ((qualified_name == "xmlns"sv || prefix == "xmlns"sv) && namespace_ != Namespace::XMLNS) - return WebIDL::NamespaceError::create(realm, "Either qualifiedName or prefix is 'xmlns' and namespace is not the XMLNS namespace."); + return WebIDL::NamespaceError::create(realm, "Either qualifiedName or prefix is 'xmlns' and namespace is not the XMLNS namespace."_fly_string); // 9. If namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns", then throw a "NamespaceError" DOMException. if (namespace_ == Namespace::XMLNS && !(qualified_name == "xmlns"sv || prefix == "xmlns"sv)) - return WebIDL::NamespaceError::create(realm, "Namespace is the XMLNS namespace and neither qualifiedName nor prefix is 'xmlns'."); + return WebIDL::NamespaceError::create(realm, "Namespace is the XMLNS namespace and neither qualifiedName nor prefix is 'xmlns'."_fly_string); // 10. Return namespace, prefix, and localName. return QualifiedName { local_name, prefix, namespace_ }; @@ -289,7 +289,7 @@ WebIDL::ExceptionOr Element::toggle_attribute(DeprecatedFlyString const& n // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException. // FIXME: Proper name validation if (name.is_empty()) - return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty"); + return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty"_fly_string); // 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase. // FIXME: Handle the second condition, assume it is an HTML document for now. @@ -556,7 +556,7 @@ WebIDL::ExceptionOr> Element::attach_shadow(ShadowR { // 1. If this’s namespace is not the HTML namespace, then throw a "NotSupportedError" DOMException. if (namespace_() != Namespace::HTML) - return WebIDL::NotSupportedError::create(realm(), "Element's namespace is not the HTML namespace"sv); + return WebIDL::NotSupportedError::create(realm(), "Element's namespace is not the HTML namespace"_fly_string); // 2. If this’s local name is not one of the following: // - a valid custom element name @@ -564,7 +564,7 @@ WebIDL::ExceptionOr> Element::attach_shadow(ShadowR if (!HTML::is_valid_custom_element_name(local_name()) && !local_name().is_one_of("article", "aside", "blockquote", "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6", "header", "main", "nav", "p", "section", "span")) { // then throw a "NotSupportedError" DOMException. - return WebIDL::NotSupportedError::create(realm(), DeprecatedString::formatted("Element '{}' cannot be a shadow host", local_name())); + return WebIDL::NotSupportedError::create(realm(), MUST(String::formatted("Element '{}' cannot be a shadow host", local_name()))); } // 3. If this’s local name is a valid custom element name, or this’s is value is not null, then: @@ -574,12 +574,12 @@ WebIDL::ExceptionOr> Element::attach_shadow(ShadowR // 2. If definition is not null and definition’s disable shadow is true, then throw a "NotSupportedError" DOMException. if (definition && definition->disable_shadow()) - return WebIDL::NotSupportedError::create(realm(), "Cannot attach a shadow root to a custom element that has disabled shadow roots"sv); + return WebIDL::NotSupportedError::create(realm(), "Cannot attach a shadow root to a custom element that has disabled shadow roots"_fly_string); } // 4. If this is a shadow host, then throw an "NotSupportedError" DOMException. if (is_shadow_host()) - return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host"); + return WebIDL::NotSupportedError::create(realm(), "Element already is a shadow host"_fly_string); // 5. Let shadow be a new shadow root whose node document is this’s node document, host is this, and mode is init["mode"]. auto shadow = heap().allocate(realm(), document(), *this, init.mode); @@ -622,7 +622,7 @@ WebIDL::ExceptionOr Element::matches(StringView selectors) const // 2. If s is failure, then throw a "SyntaxError" DOMException. if (!maybe_selectors.has_value()) - return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); + return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_fly_string); // 3. If the result of match a selector against an element, using s, this, and scoping root this, returns success, then return true; otherwise, return false. auto sel = maybe_selectors.value(); @@ -641,7 +641,7 @@ WebIDL::ExceptionOr Element::closest(StringView selectors) // 2. If s is failure, then throw a "SyntaxError" DOMException. if (!maybe_selectors.has_value()) - return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); + return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_fly_string); auto matches_selectors = [this](CSS::SelectorList const& selector_list, Element const* element) { // 4. For each element in elements, if match a selector against an element, using s, element, and scoping root this, returns success, return element. @@ -1308,7 +1308,7 @@ WebIDL::ExceptionOr Element::insert_adjacent_html(DeprecatedString positio // If context is null or a Document, throw a "NoModificationAllowedError" DOMException. if (!context || context->is_document()) - return WebIDL::NoModificationAllowedError::create(realm(), "insertAdjacentHTML: context is null or a Document"sv); + return WebIDL::NoModificationAllowedError::create(realm(), "insertAdjacentHTML: context is null or a Document"_fly_string); } // - If position is an ASCII case-insensitive match for the string "afterbegin" // - If position is an ASCII case-insensitive match for the string "beforeend" @@ -1320,7 +1320,7 @@ WebIDL::ExceptionOr Element::insert_adjacent_html(DeprecatedString positio // Otherwise else { // Throw a "SyntaxError" DOMException. - return WebIDL::SyntaxError::create(realm(), "insertAdjacentHTML: invalid position argument"sv); + return WebIDL::SyntaxError::create(realm(), "insertAdjacentHTML: invalid position argument"_fly_string); } // 2. If context is not an Element or the following are all true: @@ -1407,7 +1407,7 @@ WebIDL::ExceptionOr> Element::insert_adjacent(DeprecatedString c // -> Otherwise // Throw a "SyntaxError" DOMException. - return WebIDL::SyntaxError::create(realm(), DeprecatedString::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'"sv, where)); + return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Unknown position '{}'. Must be one of 'beforebegin', 'afterbegin', 'beforeend' or 'afterend'"sv, where))); } // https://dom.spec.whatwg.org/#dom-element-insertadjacentelement @@ -1711,7 +1711,7 @@ JS::ThrowCompletionOr Element::upgrade_element(JS::NonnullGCPtr JS::ThrowCompletionOr { // 1. If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException. if (custom_element_definition->disable_shadow() && shadow_root()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Custom element definition disables shadow DOM and the custom element has a shadow root"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Custom element definition disables shadow DOM and the custom element has a shadow root"_fly_string)); // 2. Set element's custom element state to "precustomized". m_custom_element_state = CustomElementState::Precustomized; diff --git a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp index 1c2fad9521b..4707ee9a928 100644 --- a/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Userland/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -561,23 +561,23 @@ WebIDL::ExceptionOr> create_element(Document& document // 5. If result’s attribute list is not empty, then throw a "NotSupportedError" DOMException. if (element->has_attributes()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have attributes"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have attributes"_fly_string)); // 6. If result has children, then throw a "NotSupportedError" DOMException. if (element->has_children()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have children"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have children"_fly_string)); // 7. If result’s parent is not null, then throw a "NotSupportedError" DOMException. if (element->parent()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have a parent"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have a parent"_fly_string)); // 8. If result’s node document is not document, then throw a "NotSupportedError" DOMException. if (&element->document() != &document) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must be in the same document that element creation was invoked in"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must be in the same document that element creation was invoked in"_fly_string)); // 9. If result’s local name is not equal to localName, then throw a "NotSupportedError" DOMException. if (element->local_name() != local_name) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must have the same local name that element creation was invoked with"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must have the same local name that element creation was invoked with"_fly_string)); // 10. Set result’s namespace prefix to prefix. element->set_prefix(prefix); diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index f61efb6ccda..d85556d87f3 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -248,10 +248,10 @@ 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()) - return WebIDL::InvalidStateError::create(realm(), "The event is already being dispatched."); + return WebIDL::InvalidStateError::create(realm(), "The event is already being dispatched."_fly_string); if (!event.initialized()) - return WebIDL::InvalidStateError::create(realm(), "Cannot dispatch an uninitialized event."); + return WebIDL::InvalidStateError::create(realm(), "Cannot dispatch an uninitialized event."_fly_string); // 2. Initialize event’s isTrusted attribute to false. event.set_is_trusted(false); diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp index c2f36ce73e7..cb15e840dc1 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.cpp @@ -112,7 +112,7 @@ WebIDL::ExceptionOr NamedNodeMap::remove_named_item(StringView qual // 2. If attr is null, then throw a "NotFoundError" DOMException. if (!attribute) - return WebIDL::NotFoundError::create(realm(), DeprecatedString::formatted("Attribute with name '{}' not found", qualified_name)); + return WebIDL::NotFoundError::create(realm(), MUST(String::formatted("Attribute with name '{}' not found", qualified_name))); // 3. Return attr. return attribute; @@ -126,7 +126,7 @@ WebIDL::ExceptionOr NamedNodeMap::remove_named_item_ns(StringView n // 2. If attr is null, then throw a "NotFoundError" DOMException. if (!attribute) - return WebIDL::NotFoundError::create(realm(), DeprecatedString::formatted("Attribute with namespace '{}' and local name '{}' not found", namespace_, local_name)); + return WebIDL::NotFoundError::create(realm(), MUST(String::formatted("Attribute with namespace '{}' and local name '{}' not found", namespace_, local_name))); // 3. Return attr. return attribute; @@ -197,7 +197,7 @@ 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())) - return WebIDL::InUseAttributeError::create(realm(), "Attribute must not already be in use"sv); + return WebIDL::InUseAttributeError::create(realm(), "Attribute must not already be in use"_fly_string); // 2. Let oldAttr be the result of getting an attribute given attr’s namespace, attr’s local name, and element. size_t old_attribute_index = 0; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 17ecb782acc..38a0cf45ca4 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -334,24 +334,24 @@ WebIDL::ExceptionOr Node::ensure_pre_insertion_validity(JS::NonnullGCPtr(this) && !is(this) && !is(this)) - return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"); + return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"_fly_string); // 2. If node is a host-including inclusive ancestor of parent, then throw a "HierarchyRequestError" DOMException. if (node->is_host_including_inclusive_ancestor_of(*this)) - return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"); + return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"_fly_string); // 3. If child is non-null and its parent is not parent, then throw a "NotFoundError" DOMException. if (child && child->parent() != this) - return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"); + return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"_fly_string); // FIXME: All the following "Invalid node type for insertion" messages could be more descriptive. // 4. If node is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException. if (!is(*node) && !is(*node) && !is(*node) && !is(*node) && !is(*node) && !is(*node)) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); // 5. If either node is a Text node and parent is a document, or node is a doctype and parent is not a document, then throw a "HierarchyRequestError" DOMException. if ((is(*node) && is(this)) || (is(*node) && !is(this))) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); // 6. If parent is a document, and any of the statements below, switched on the interface node implements, are true, then throw a "HierarchyRequestError" DOMException. if (is(this)) { @@ -362,18 +362,18 @@ WebIDL::ExceptionOr Node::ensure_pre_insertion_validity(JS::NonnullGCPtr(*node).child_element_count(); if ((node_element_child_count > 1 || node->has_child_of_type()) || (node_element_child_count == 1 && (has_child_of_type() || is(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order())))) { - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } } else if (is(*node)) { // Element // If parent has an element child, child is a doctype, or child is non-null and a doctype is following child. if (has_child_of_type() || is(child.ptr()) || (child && child->has_following_node_of_type_in_tree_order())) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } else if (is(*node)) { // DocumentType // parent has a doctype child, child is non-null and an element is preceding child, or child is null and parent has an element child. if (has_child_of_type() || (child && child->has_preceding_node_of_type_in_tree_order()) || (!child && has_child_of_type())) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } } @@ -521,7 +521,7 @@ WebIDL::ExceptionOr> Node::pre_remove(JS::NonnullGCPtrparent() != this) - return WebIDL::NotFoundError::create(realm(), "Child does not belong to this node"); + return WebIDL::NotFoundError::create(realm(), "Child does not belong to this node"_fly_string); // 2. Remove child. child->remove(); @@ -664,25 +664,25 @@ WebIDL::ExceptionOr> Node::replace_child(JS::NonnullGCPtr { // If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. if (!is(this) && !is(this) && !is(this)) - return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"); + return WebIDL::HierarchyRequestError::create(realm(), "Can only insert into a document, document fragment or element"_fly_string); // 2. If node is a host-including inclusive ancestor of parent, then throw a "HierarchyRequestError" DOMException. if (node->is_host_including_inclusive_ancestor_of(*this)) - return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"); + return WebIDL::HierarchyRequestError::create(realm(), "New node is an ancestor of this node"_fly_string); // 3. If child’s parent is not parent, then throw a "NotFoundError" DOMException. if (child->parent() != this) - return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"); + return WebIDL::NotFoundError::create(realm(), "This node is not the parent of the given child"_fly_string); // FIXME: All the following "Invalid node type for insertion" messages could be more descriptive. // 4. If node is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException. if (!is(*node) && !is(*node) && !is(*node) && !is(*node) && !is(*node) && !is(*node)) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); // 5. If either node is a Text node and parent is a document, or node is a doctype and parent is not a document, then throw a "HierarchyRequestError" DOMException. if ((is(*node) && is(this)) || (is(*node) && !is(this))) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); // If parent is a document, and any of the statements below, switched on the interface node implements, are true, then throw a "HierarchyRequestError" DOMException. if (is(this)) { @@ -693,18 +693,18 @@ WebIDL::ExceptionOr> Node::replace_child(JS::NonnullGCPtr auto node_element_child_count = verify_cast(*node).child_element_count(); if ((node_element_child_count > 1 || node->has_child_of_type()) || (node_element_child_count == 1 && (first_child_of_type() != child || child->has_following_node_of_type_in_tree_order()))) { - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } } else if (is(*node)) { // Element // parent has an element child that is not child or a doctype is following child. if (first_child_of_type() != child || child->has_following_node_of_type_in_tree_order()) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } else if (is(*node)) { // DocumentType // parent has a doctype child that is not child, or an element is preceding child. if (first_child_of_type() != node || child->has_preceding_node_of_type_in_tree_order()) - return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Invalid node type for insertion"_fly_string); } } @@ -848,7 +848,7 @@ WebIDL::ExceptionOr> Node::clone_node_binding(bool deep) { // 1. If this is a shadow root, then throw a "NotSupportedError" DOMException. if (is(*this)) - return WebIDL::NotSupportedError::create(realm(), "Cannot clone shadow root"); + return WebIDL::NotSupportedError::create(realm(), "Cannot clone shadow root"_fly_string); // 2. Return a clone of this, with the clone children flag set if deep is true. return clone_node(nullptr, deep); diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp index e61576c7717..e6fd48ef8c5 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.cpp @@ -139,7 +139,7 @@ JS::ThrowCompletionOr NodeIterator::filter(Node& node) { // 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException. if (m_active) - return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active")); + return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_fly_string)); // 2. Let n be node’s nodeType attribute value − 1. auto n = node.node_type() - 1; diff --git a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp index cb45bdb7118..fff262d2cb0 100644 --- a/Userland/Libraries/LibWeb/DOM/ParentNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/ParentNode.cpp @@ -30,7 +30,7 @@ WebIDL::ExceptionOr> ParentNode::query_selector(StringView se // 2. If s is failure, then throw a "SyntaxError" DOMException. if (!maybe_selectors.has_value()) - return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); + return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_fly_string); auto selectors = maybe_selectors.value(); @@ -62,7 +62,7 @@ WebIDL::ExceptionOr> ParentNode::query_selector_all(S // 2. If s is failure, then throw a "SyntaxError" DOMException. if (!maybe_selectors.has_value()) - return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"); + return WebIDL::SyntaxError::create(realm(), "Failed to parse selector"_fly_string); auto selectors = maybe_selectors.value(); diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 57a7793e683..9393fa7d9a0 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -165,11 +165,11 @@ WebIDL::ExceptionOr Range::set_start_or_end(Node& node, u32 offset, StartO // 1. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException. if (is(node)) - return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string); // 2. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException. if (offset > node.length()) - return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset)); + return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset))); // 3. Let bp be the boundary point (node, offset). @@ -225,7 +225,7 @@ WebIDL::ExceptionOr Range::set_start_before(Node& node) // 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException. if (!parent) - return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_fly_string); // 3. Set the start of this to boundary point (parent, node’s index). return set_start_or_end(*parent, node.index(), StartOrEnd::Start); @@ -239,7 +239,7 @@ WebIDL::ExceptionOr Range::set_start_after(Node& node) // 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException. if (!parent) - return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_fly_string); // 3. Set the start of this to boundary point (parent, node’s index plus 1). return set_start_or_end(*parent, node.index() + 1, StartOrEnd::Start); @@ -253,7 +253,7 @@ WebIDL::ExceptionOr Range::set_end_before(Node& node) // 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException. if (!parent) - return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_fly_string); // 3. Set the end of this to boundary point (parent, node’s index). return set_start_or_end(*parent, node.index(), StartOrEnd::End); @@ -267,7 +267,7 @@ WebIDL::ExceptionOr Range::set_end_after(Node& node) // 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException. if (!parent) - return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_fly_string); // 3. Set the end of this to boundary point (parent, node’s index plus 1). return set_start_or_end(*parent, node.index() + 1, StartOrEnd::End); @@ -283,11 +283,11 @@ WebIDL::ExceptionOr Range::compare_boundary_points(u16 how, Range const& so // - END_TO_START, // then throw a "NotSupportedError" DOMException. if (how != HowToCompareBoundaryPoints::START_TO_START && how != HowToCompareBoundaryPoints::START_TO_END && how != HowToCompareBoundaryPoints::END_TO_END && how != HowToCompareBoundaryPoints::END_TO_START) - return WebIDL::NotSupportedError::create(realm(), DeprecatedString::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how)); + return WebIDL::NotSupportedError::create(realm(), MUST(String::formatted("Expected 'how' to be one of START_TO_START (0), START_TO_END (1), END_TO_END (2) or END_TO_START (3), got {}", how))); // 2. If this’s root is not the same as sourceRange’s root, then throw a "WrongDocumentError" DOMException. if (&root() != &source_range.root()) - return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."); + return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."_fly_string); JS::GCPtr this_point_node; u32 this_point_offset = 0; @@ -368,7 +368,7 @@ WebIDL::ExceptionOr Range::select(Node& node) // 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException. if (!parent) - return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_fly_string); // 3. Let index be node’s index. auto index = node.index(); @@ -411,7 +411,7 @@ WebIDL::ExceptionOr Range::select_node_contents(Node& node) { // 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException. if (is(node)) - return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string); // 2. Let length be the length of node. auto length = node.length(); @@ -505,11 +505,11 @@ WebIDL::ExceptionOr Range::is_point_in_range(Node const& node, u32 offset) // 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException. if (is(node)) - return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string); // 3. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException. if (offset > node.length()) - return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset)); + return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset))); // 4. If (node, offset) is before start or after end, return false. auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point(node, offset, m_start_container, m_start_offset); @@ -526,15 +526,15 @@ WebIDL::ExceptionOr Range::compare_point(Node const& node, u32 offset) cons { // 1. If node’s root is different from this’s root, then throw a "WrongDocumentError" DOMException. if (&node.root() != &root()) - return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."); + return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_fly_string); // 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException. if (is(node)) - return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."); + return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string); // 3. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException. if (offset > node.length()) - return WebIDL::IndexSizeError::create(realm(), DeprecatedString::formatted("Node does not contain a child at offset {}", offset)); + return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset))); // 4. If (node, offset) is before start, return −1. auto relative_position_to_start = position_of_boundary_point_relative_to_other_boundary_point(node, offset, m_start_container, m_start_offset); @@ -667,7 +667,7 @@ WebIDL::ExceptionOr> Range::extract() // 12. If any member of contained children is a doctype, then throw a "HierarchyRequestError" DOMException. for (auto const& child : contained_children) { if (is(*child)) - return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"); + return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_fly_string); } JS::GCPtr new_node; @@ -814,7 +814,7 @@ WebIDL::ExceptionOr Range::insert(JS::NonnullGCPtr node) if ((is(*m_start_container) || is(*m_start_container)) || (is(*m_start_container) && !m_start_container->parent_node()) || m_start_container.ptr() == node.ptr()) { - return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"); + return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"_fly_string); } // 2. Let referenceNode be null. @@ -885,11 +885,11 @@ WebIDL::ExceptionOr Range::surround_contents(JS::NonnullGCPtr new_pa if (is(*end_non_text_node)) end_non_text_node = end_non_text_node->parent_node(); if (start_non_text_node != end_non_text_node) - return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."); + return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."_fly_string); // 2. If newParent is a Document, DocumentType, or DocumentFragment node, then throw an "InvalidNodeTypeError" DOMException. if (is(*new_parent) || is(*new_parent) || is(*new_parent)) - return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"); + return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_fly_string); // 3. Let fragment be the result of extracting this. auto fragment = TRY(extract()); @@ -993,7 +993,7 @@ WebIDL::ExceptionOr> Range::clone_the_content // 12. If any member of contained children is a doctype, then throw a "HierarchyRequestError" DOMException. for (auto const& child : contained_children) { if (is(*child)) - return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"); + return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_fly_string); } // 13. If first partially contained child is a CharacterData node, then: diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp index 41f6722a2a7..595665b3ac8 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.cpp @@ -26,10 +26,10 @@ WebIDL::ExceptionOr> StaticRange::construct_impl(J { // 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)) - return WebIDL::InvalidNodeTypeError::create(realm, "startContainer cannot be a DocumentType or Attribute node."); + return WebIDL::InvalidNodeTypeError::create(realm, "startContainer cannot be a DocumentType or Attribute node."_fly_string); if (is(*init.end_container) || is(*init.end_container)) - return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."); + return WebIDL::InvalidNodeTypeError::create(realm, "endContainer cannot be a DocumentType or Attribute node."_fly_string); // 2. Set this’s start to (init["startContainer"], init["startOffset"]) and end to (init["endContainer"], init["endOffset"]). return realm.heap().allocate(realm, *init.start_container, init.start_offset, *init.end_container, init.end_offset); diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 483d24e3e59..72fd150e886 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -58,7 +58,7 @@ WebIDL::ExceptionOr> Text::split_text(size_t offset) // 2. If offset is greater than length, then throw an "IndexSizeError" DOMException. if (offset > length) - return WebIDL::IndexSizeError::create(realm(), "Split offset is greater than length"); + return WebIDL::IndexSizeError::create(realm(), "Split offset is greater than length"_fly_string); // 3. Let count be length minus offset. auto count = length - offset; diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp index e86a8a50b31..f0c36a3e6f1 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.cpp @@ -237,7 +237,7 @@ JS::ThrowCompletionOr TreeWalker::filter(Node& node) { // 1. If traverser’s active flag is set, then throw an "InvalidStateError" DOMException. if (m_active) - return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active")); + return throw_completion(WebIDL::InvalidStateError::create(realm(), "NodeIterator is already active"_fly_string)); // 2. Let n be node’s nodeType attribute value − 1. auto n = node.node_type() - 1; diff --git a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp index 820ad9aac5a..be941556f9f 100644 --- a/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp +++ b/Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp @@ -339,7 +339,7 @@ static WebIDL::ExceptionOr serialize_element_attributes(DOM::E }); if (local_name_set_iterator != local_name_set.end()) - return WebIDL::InvalidStateError::create(realm, "Element contains two attributes with identical namespaces and local names"); + return WebIDL::InvalidStateError::create(realm, "Element contains two attributes with identical namespaces and local names"_fly_string); } // 2. Create a new tuple consisting of attr's namespaceURI attribute and localName attribute, and add it to the localname set. @@ -392,12 +392,12 @@ static WebIDL::ExceptionOr serialize_element_attributes(DOM::E // 2. If the require well-formed flag is set (its value is true), and the value of attr's value attribute matches the XMLNS namespace, // then throw an exception; the serialization of this attribute would produce invalid XML because the XMLNS namespace is reserved and cannot be applied as an element's namespace via XML parsing. if (require_well_formed == RequireWellFormed::Yes && attribute->value() == Namespace::XMLNS) - return WebIDL::InvalidStateError::create(realm, "The XMLNS namespace cannot be used as an element's namespace"); + return WebIDL::InvalidStateError::create(realm, "The XMLNS namespace cannot be used as an element's namespace"_fly_string); // 3. If the require well-formed flag is set (its value is true), and the value of attr's value attribute is the empty string, // then throw an exception; namespace prefix declarations cannot be used to undeclare a namespace (use a default namespace declaration instead). if (require_well_formed == RequireWellFormed::Yes && attribute->value().is_empty()) - return WebIDL::InvalidStateError::create(realm, "Attribute's value is empty"); + return WebIDL::InvalidStateError::create(realm, "Attribute's value is empty"_fly_string); // 4. [If] the attr's prefix matches the string "xmlns", then let candidate prefix be the string "xmlns". if (attribute->prefix() == "xmlns"sv) @@ -440,12 +440,12 @@ static WebIDL::ExceptionOr serialize_element_attributes(DOM::E // or does not match the XML Name production or equals "xmlns" and attribute namespace is null, then throw an exception; the serialization of this attr would not be a well-formed attribute. if (require_well_formed == RequireWellFormed::Yes) { if (attribute->local_name().view().contains(':')) - return WebIDL::InvalidStateError::create(realm, "Attribute's local name contains a colon"); + return WebIDL::InvalidStateError::create(realm, "Attribute's local name contains a colon"_fly_string); // FIXME: Check attribute's local name against the XML Name production. if (attribute->local_name() == "xmlns"sv && attribute_namespace.is_null()) - return WebIDL::InvalidStateError::create(realm, "Attribute's local name is 'xmlns' and the attribute has no namespace"); + return WebIDL::InvalidStateError::create(realm, "Attribute's local name is 'xmlns' and the attribute has no namespace"_fly_string); } // 9. Append the following strings to result, in the order listed: @@ -475,7 +475,7 @@ static WebIDL::ExceptionOr serialize_element(DOM::Element cons // then throw an exception; the serialization of this node would not be a well-formed element. if (require_well_formed == RequireWellFormed::Yes) { if (element.local_name().view().contains(':')) - return WebIDL::InvalidStateError::create(realm, "Element's local name contains a colon"); + return WebIDL::InvalidStateError::create(realm, "Element's local name contains a colon"_fly_string); // FIXME: Check element's local name against the XML Char production. } @@ -547,7 +547,7 @@ static WebIDL::ExceptionOr serialize_element(DOM::Element cons if (prefix == "xmlns"sv) { // 1. If the require well-formed flag is set, then throw an error. An Element with prefix "xmlns" will not legally round-trip in a conforming XML parser. if (require_well_formed == RequireWellFormed::Yes) - return WebIDL::InvalidStateError::create(realm, "Elements prefix is 'xmlns'"); + return WebIDL::InvalidStateError::create(realm, "Elements prefix is 'xmlns'"_fly_string); // 2. Let candidate prefix be the value of prefix. candidate_prefix = prefix; @@ -714,7 +714,7 @@ static WebIDL::ExceptionOr serialize_document(DOM::Document co // 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. if (require_well_formed == RequireWellFormed::Yes && !document.document_element()) - return WebIDL::InvalidStateError::create(document.realm(), "Document has no document element"); + return WebIDL::InvalidStateError::create(document.realm(), "Document has no document element"_fly_string); // Otherwise, run the following steps: // 1. Let serialized document be an empty string. @@ -738,10 +738,10 @@ static WebIDL::ExceptionOr serialize_comment(DOM::Comment cons // FIXME: Check comment's data against the XML Char production. if (comment.data().contains("--"sv)) - return WebIDL::InvalidStateError::create(comment.realm(), "Comment data contains two adjacent hyphens"); + return WebIDL::InvalidStateError::create(comment.realm(), "Comment data contains two adjacent hyphens"_fly_string); if (comment.data().ends_with('-')) - return WebIDL::InvalidStateError::create(comment.realm(), "Comment data ends with a hyphen"); + return WebIDL::InvalidStateError::create(comment.realm(), "Comment data ends with a hyphen"_fly_string); } // Otherwise, return the concatenation of "". @@ -796,7 +796,7 @@ static WebIDL::ExceptionOr serialize_document_type(DOM::Docume // both a """ (U+0022 QUOTATION MARK) and a "'" (U+0027 APOSTROPHE), then throw an exception; the serialization of this node would not be a well-formed document type declaration. // FIXME: Check systemId against the XML Char production. if (document_type.system_id().contains('"') && document_type.system_id().contains('\'')) - return WebIDL::InvalidStateError::create(document_type.realm(), "Document type system ID contains both a quotation mark and an apostrophe"); + return WebIDL::InvalidStateError::create(document_type.realm(), "Document type system ID contains both a quotation mark and an apostrophe"_fly_string); } // 3. Let markup be an empty string. @@ -858,16 +858,16 @@ static WebIDL::ExceptionOr serialize_processing_instruction(DO // 1. If the require well-formed flag is set (its value is true), and node's target contains a ":" (U+003A COLON) character // or is an ASCII case-insensitive match for the string "xml", then throw an exception; the serialization of this node's target would not be well-formed. if (processing_instruction.target().contains(':')) - return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction target contains a colon"); + return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction target contains a colon"_fly_string); if (Infra::is_ascii_case_insensitive_match(processing_instruction.target(), "xml"sv)) - return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction target is equal to 'xml'"); + return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction target is equal to 'xml'"_fly_string); // 2. 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 // the string "?>" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN), then throw an exception; the serialization of this node's data would not be well-formed. // FIXME: Check data against the XML Char production. if (processing_instruction.data().contains("?>"sv)) - return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction data contains a terminator"); + return WebIDL::InvalidStateError::create(processing_instruction.realm(), "Processing instruction data contains a terminator"_fly_string); } // 3. Let markup be the concatenation of the following, in the order listed: diff --git a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp index cb1a10cbe32..7e0ad625a10 100644 --- a/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp +++ b/Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp @@ -51,7 +51,7 @@ WebIDL::ExceptionOr TextDecoder::decode(Optionalcell()); if (data_buffer_or_error.is_error()) - return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer"); + return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer"_fly_string); auto& data_buffer = data_buffer_or_error.value(); return TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({ data_buffer.data(), data_buffer.size() })); } diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp index 94bb778ae6f..2d291b6296b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/FetchController.cpp @@ -64,7 +64,7 @@ void FetchController::abort(JS::Realm& realm, Optional error) m_state = State::Aborted; // 2. Let fallbackError be an "AbortError" DOMException. - auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"sv); + auto fallback_error = WebIDL::AbortError::create(realm, "Fetch was aborted"_fly_string); // 3. Set error to fallbackError if it is not given. if (!error.has_value()) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp index ec462231aa6..3f868fe399b 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp @@ -90,7 +90,7 @@ WebIDL::ExceptionOr Body::fully_read(JS::Realm& realm, Web::Fetch::Infrast TRY_OR_THROW_OOM(vm, success_steps(move(byte_buffer))); } else { // Empty, Blob, FormData - error_steps(WebIDL::DOMException::create(realm, "DOMException", "Reading from Blob, FormData or null source is not yet implemented"sv)); + error_steps(WebIDL::DOMException::create(realm, "DOMException"_fly_string, "Reading from Blob, FormData or null source is not yet implemented"_fly_string)); } return {}; } diff --git a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp index 45f8d08b0b7..a3d1735c319 100644 --- a/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp +++ b/Userland/Libraries/LibWeb/Geometry/DOMMatrixReadOnly.cpp @@ -378,7 +378,7 @@ WebIDL::ExceptionOr DOMMatrixReadOnly::to_string() const || !isfinite(m21()) || !isfinite(m22()) || !isfinite(m23()) || !isfinite(m24()) || !isfinite(m31()) || !isfinite(m32()) || !isfinite(m33()) || !isfinite(m34()) || !isfinite(m41()) || !isfinite(m42()) || !isfinite(m43()) || !isfinite(m44())) { - return WebIDL::InvalidStateError::create(realm(), "Cannot stringify non-finite matrix values"); + return WebIDL::InvalidStateError::create(realm(), "Cannot stringify non-finite matrix values"_fly_string); } // 2. Let string be the empty string. diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 508f8ba79fd..e30fc4371b9 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -1104,7 +1104,7 @@ WebIDL::ExceptionOr BrowsingContext::navigate( // 1. If exceptionsEnabled is given and is true, then throw a "SecurityError" DOMException. if (exceptions_enabled) { VERIFY(source_browsing_context.active_document()); - return WebIDL::SecurityError::create(source_browsing_context.active_document()->realm(), "Source browsing context not allowed to navigate"sv); + return WebIDL::SecurityError::create(source_browsing_context.active_document()->realm(), "Source browsing context not allowed to navigate"_fly_string); } // FIXME: 2. Otherwise, the user agent may instead offer to open resource in a new top-level browsing context diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp index 1b42fb3bbc0..3e6492397d3 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasPath.cpp @@ -48,17 +48,17 @@ void CanvasPath::bezier_curve_to(double cp1x, double cp1y, double cp2x, double c WebIDL::ExceptionOr CanvasPath::arc(float x, float y, float radius, float start_angle, float end_angle, bool counter_clockwise) { if (radius < 0) - return WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The radius provided ({}) is negative.", radius)); + return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The radius provided ({}) is negative.", radius))); return ellipse(x, y, radius, radius, 0, start_angle, end_angle, 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 WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The major-axis radius provided ({}) is negative.", radius_x)); + return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The major-axis radius provided ({}) is negative.", radius_x))); if (radius_y < 0) - return WebIDL::IndexSizeError::create(m_self->realm(), DeprecatedString::formatted("The minor-axis radius provided ({}) is negative.", radius_y)); + return WebIDL::IndexSizeError::create(m_self->realm(), MUST(String::formatted("The minor-axis radius provided ({}) is negative.", radius_y))); if (constexpr float tau = M_TAU; (!counter_clockwise && (end_angle - start_angle) >= tau) || (counter_clockwise && (start_angle - end_angle) >= tau)) { diff --git a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp index d8e23c34fdd..274276b1c6c 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasGradient.cpp @@ -17,9 +17,9 @@ WebIDL::ExceptionOr> CanvasGradient::create_rad { // If either of r0 or r1 are negative, then an "IndexSizeError" DOMException must be thrown. if (r0 < 0) - return WebIDL::IndexSizeError::create(realm, "The r0 passed is less than 0"); + return WebIDL::IndexSizeError::create(realm, "The r0 passed is less than 0"_fly_string); if (r1 < 0) - return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"); + return WebIDL::IndexSizeError::create(realm, "The r1 passed is less than 0"_fly_string); auto radial_gradient = TRY_OR_THROW_OOM(realm.vm(), Gfx::CanvasRadialGradientPaintStyle::create(Gfx::FloatPoint { x0, y0 }, r0, Gfx::FloatPoint { x1, y1 }, r1)); return realm.heap().allocate(realm, realm, *radial_gradient); @@ -58,14 +58,14 @@ WebIDL::ExceptionOr CanvasGradient::add_color_stop(double offset, StringVi { // 1. If the offset is less than 0 or greater than 1, then throw an "IndexSizeError" DOMException. if (offset < 0 || offset > 1) - return WebIDL::IndexSizeError::create(realm(), "CanvasGradient color stop offset out of bounds"); + return WebIDL::IndexSizeError::create(realm(), "CanvasGradient color stop offset out of bounds"_fly_string); // 2. Let parsed color be the result of parsing color. auto parsed_color = Color::from_string(color); // 3. If parsed color is failure, throw a "SyntaxError" DOMException. if (!parsed_color.has_value()) - return WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient"); + return WebIDL::SyntaxError::create(realm(), "Could not parse color for CanvasGradient"_fly_string); // 4. Place a new stop on the gradient, at offset offset relative to the whole gradient, and with the color parsed color. TRY_OR_THROW_OOM(realm().vm(), m_gradient->add_color_stop(offset, parsed_color.value())); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp index 39714b28c3b..455b6db9a36 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasPattern.cpp @@ -119,7 +119,7 @@ WebIDL::ExceptionOr> CanvasPattern::create(JS::Realm& r // then throw a "SyntaxError" DOMException. auto repetition_value = parse_repetition(repetition); if (!repetition_value.has_value()) - return WebIDL::SyntaxError::create(realm, "Repetition value is not valid"); + return WebIDL::SyntaxError::create(realm, "Repetition value is not valid"_fly_string); // Note: Bitmap won't be null here, as if it were it would have "bad" usability. auto const& bitmap = *image.visit([](auto const& source) -> Gfx::Bitmap const* { return source->bitmap(); }); diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 92d441bc2d4..cc63862fa9f 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -320,11 +320,11 @@ WebIDL::ExceptionOr> CanvasRenderingContext2D::get_image_da { // 1. If either the sw or sh arguments are zero, then throw an "IndexSizeError" DOMException. if (width == 0 || height == 0) - return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"); + return WebIDL::IndexSizeError::create(realm(), "Width and height must not be zero"_fly_string); // 2. If the CanvasRenderingContext2D's origin-clean flag is set to false, then throw a "SecurityError" DOMException. if (!m_origin_clean) - return WebIDL::SecurityError::create(realm(), "CanvasRenderingContext2D is not origin-clean"); + return WebIDL::SecurityError::create(realm(), "CanvasRenderingContext2D is not origin-clean"_fly_string); // 3. Let imageData be a new ImageData object. // 4. Initialize imageData given sw, sh, settings set to settings, and defaultColorSpace set to this's color space. @@ -572,7 +572,7 @@ WebIDL::ExceptionOr check_usability_of_image(CanvasI [](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 WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"); + return WebIDL::InvalidStateError::create(canvas_element->realm(), "Canvas width or height is zero"_fly_string); return Optional {}; })); if (usability.has_value()) diff --git a/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp b/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp index 8d1f9f43636..9896570e080 100644 --- a/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp +++ b/Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp @@ -78,7 +78,7 @@ JS::ThrowCompletionOr cross_origin_property_fallback(JS: return JS::PropertyDescriptor { .value = JS::js_undefined(), .writable = false, .enumerable = false, .configurable = true }; // 2. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't access property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(String::formatted("Can't access property '{}' on cross-origin object", property_key)))); } // 7.2.3.3 IsPlatformObjectSameOrigin ( O ), https://html.spec.whatwg.org/multipage/browsers.html#isplatformobjectsameorigin-(-o-) @@ -205,7 +205,7 @@ JS::ThrowCompletionOr cross_origin_get(JS::VM& vm, JS::Object const& // 6. If getter is undefined, then throw a "SecurityError" DOMException. if (!getter.has_value()) - return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't get property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(String::formatted("Can't get property '{}' on cross-origin object", property_key)))); // 7. Return ? Call(getter, Receiver). return JS::call(vm, *getter, receiver); @@ -231,7 +231,7 @@ JS::ThrowCompletionOr cross_origin_set(JS::VM& vm, JS::Object& object, JS: } // 4. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), DeprecatedString::formatted("Can't set property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(*vm.current_realm(), MUST(String::formatted("Can't set property '{}' on cross-origin object", property_key)))); } // 7.2.3.7 CrossOriginOwnPropertyKeys ( O ), https://html.spec.whatwg.org/multipage/browsers.html#crossoriginownpropertykeys-(-o-) diff --git a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp index 2820df4f3f3..21186f1e887 100644 --- a/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp +++ b/Userland/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp @@ -112,7 +112,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We // 2. If name is not a valid custom element name, then throw a "SyntaxError" DOMException. if (!is_valid_custom_element_name(name)) - return JS::throw_completion(WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("'{}' is not a valid custom element name"sv, name))); + return JS::throw_completion(WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name"sv, name)))); // 3. If this CustomElementRegistry contains an entry with name name, then throw a "NotSupportedError" DOMException. auto existing_definition_with_name_iterator = m_custom_element_definitions.find_if([&name](JS::Handle const& definition) { @@ -120,7 +120,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We }); if (existing_definition_with_name_iterator != m_custom_element_definitions.end()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("A custom element with name '{}' is already defined"sv, name))); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("A custom element with name '{}' is already defined"sv, name)))); // 4. If this CustomElementRegistry contains an entry with constructor constructor, then throw a "NotSupportedError" DOMException. auto existing_definition_with_constructor_iterator = m_custom_element_definitions.find_if([&constructor](JS::Handle const& definition) { @@ -128,7 +128,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We }); if (existing_definition_with_constructor_iterator != m_custom_element_definitions.end()) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"_fly_string)); // 5. Let localName be name. String local_name = name; @@ -140,11 +140,11 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We if (extends.has_value()) { // 1. If extends is a valid custom element name, then throw a "NotSupportedError" DOMException. if (is_valid_custom_element_name(extends.value())) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("'{}' is a custom element name, only non-custom elements can be extended"sv, extends.value()))); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is a custom element name, only non-custom elements can be extended"sv, extends.value())))); // 2. If the element interface for extends and the HTML namespace is HTMLUnknownElement (e.g., if extends does not indicate an element definition in this specification), then throw a "NotSupportedError" DOMException. if (DOM::is_unknown_html_element(extends.value().to_deprecated_string())) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, DeprecatedString::formatted("'{}' is an unknown HTML element"sv, extends.value()))); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is an unknown HTML element"sv, extends.value())))); // 3. Set localName to extends. local_name = extends.value(); @@ -152,7 +152,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We // 8. If this CustomElementRegistry's element definition is running flag is set, then throw a "NotSupportedError" DOMException. if (m_element_definition_is_running) - return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"sv)); + return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_fly_string)); // 9. Set this CustomElementRegistry's element definition is running flag. m_element_definition_is_running = true; @@ -334,7 +334,7 @@ WebIDL::ExceptionOr> CustomElementRegistry::when_d // 1. If name is not a valid custom element name, then return a new promise rejected with a "SyntaxError" DOMException. if (!is_valid_custom_element_name(name)) { auto promise = JS::Promise::create(realm); - promise->reject(WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("'{}' is not a valid custom element name"sv, name))); + promise->reject(WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name"sv, name)))); return promise; } diff --git a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp index 7b3fb7da528..9e1270c1d42 100644 --- a/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp +++ b/Userland/Libraries/LibWeb/HTML/DOMStringMap.cpp @@ -136,7 +136,7 @@ WebIDL::ExceptionOr DOMStringMap::set_value_of_new_named_property(Deprecat if (current_character == '-' && character_index + 1 < name.length()) { auto next_character = name[character_index + 1]; if (is_ascii_lower_alpha(next_character)) - return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character."); + return WebIDL::SyntaxError::create(realm(), "Name cannot contain a '-' followed by a lowercase character."_fly_string); } // 2. For each ASCII upper alpha in name, insert a U+002D HYPHEN-MINUS character (-) before the character and replace the character with the same character converted to ASCII lowercase. diff --git a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp index e24564cf873..53c65a38e42 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -119,7 +119,7 @@ WebIDL::ExceptionOr HTMLElement::set_content_editable(StringView content_e MUST(set_attribute(HTML::AttributeNames::contenteditable, "false")); return {}; } - return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'"); + return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'"_fly_string); } void HTMLElement::set_inner_text(StringView text) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4777ad32e0d..9515fed11e6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -223,7 +223,7 @@ WebIDL::ExceptionOr HTMLInputElement::show_picker() // 1. If this is not mutable, then throw an "InvalidStateError" DOMException. if (!m_is_mutable) - return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"sv); + return WebIDL::InvalidStateError::create(realm(), "Element is not mutable"_fly_string); // 2. If this's relevant settings object's origin is not same origin with this's relevant settings object's top-level origin, // and this's type attribute is not in the File Upload state or Color state, then throw a "SecurityError" DOMException. @@ -231,14 +231,14 @@ WebIDL::ExceptionOr HTMLInputElement::show_picker() // and has never been guarded by an origin check. if (!relevant_settings_object(*this).origin().is_same_origin(relevant_settings_object(*this).top_level_origin) && m_type != TypeAttributeState::FileUpload && m_type != TypeAttributeState::Color) { - return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"sv); + return WebIDL::SecurityError::create(realm(), "Cross origin pickers are not allowed"_fly_string); } // 3. If this's relevant global object does not have transient activation, then throw a "NotAllowedError" DOMException. // FIXME: The global object we get here should probably not need casted to Window to check for transient activation auto& global_object = relevant_global_object(*this); if (!is(global_object) || !static_cast(global_object).has_transient_activation()) { - return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"sv); + return WebIDL::NotAllowedError::create(realm(), "Too long since user activation to show picker"_fly_string); } // 4. Show the picker, if applicable, for this. @@ -342,7 +342,7 @@ WebIDL::ExceptionOr HTMLInputElement::set_value(String const& value) if (type_state() == TypeAttributeState::FileUpload) { // On setting, if the new value is the empty string, empty the list of selected files; otherwise, throw an "InvalidStateError" DOMException. if (!value.is_empty()) - return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"sv); + return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"_fly_string); m_selected_files = nullptr; return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index bc8a364fca4..bcb3fff9733 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -342,7 +342,7 @@ WebIDL::ExceptionOr> HTMLMediaElement::play() // 2. If the media element's error attribute is not null and its code is MEDIA_ERR_SRC_NOT_SUPPORTED, then return a promise // rejected with a "NotSupportedError" DOMException. if (m_error && m_error->code() == MediaError::Code::SrcNotSupported) { - auto error = WebIDL::NotSupportedError::create(realm, m_error->message().to_deprecated_string()); + auto error = WebIDL::NotSupportedError::create(realm, m_error->message()); auto promise = WebIDL::create_rejected_promise(realm, error); return JS::NonnullGCPtr { verify_cast(*promise->promise()) }; @@ -396,7 +396,7 @@ WebIDL::ExceptionOr HTMLMediaElement::set_volume(double volume) // set to the new value. If the new value is outside the range 0.0 to 1.0 inclusive, then, on setting, an // "IndexSizeError" DOMException must be thrown instead. if (volume < 0.0 || volume > 1.0) - return WebIDL::IndexSizeError::create(realm(), "Volume must be in the range 0.0 to 1.0, inclusive"sv); + return WebIDL::IndexSizeError::create(realm(), "Volume must be in the range 0.0 to 1.0, inclusive"_fly_string); m_volume = volume; volume_or_muted_attribute_changed(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h index 93c5221cc3f..9f064624fa7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.h @@ -197,7 +197,7 @@ private: { auto& realm = this->realm(); - auto error = ErrorType::create(realm, message.to_deprecated_fly_string()); + auto error = ErrorType::create(realm, message); reject_pending_play_promises(promises, error); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp index 382d07d46db..43270097d47 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLOptionsCollection.cpp @@ -45,11 +45,11 @@ WebIDL::ExceptionOr HTMLOptionsCollection::add(HTMLOptionOrOptGroupElement // 1. If element is an ancestor of the select element on which the HTMLOptionsCollection is rooted, then throw a "HierarchyRequestError" DOMException. if (resolved_element->is_ancestor_of(root())) - return WebIDL::HierarchyRequestError::create(realm(), "The provided element is an ancestor of the root select element."); + return WebIDL::HierarchyRequestError::create(realm(), "The provided element is an ancestor of the root select element."_fly_string); // 2. If before is an element, but that element isn't a descendant of the select element on which the HTMLOptionsCollection is rooted, then throw a "NotFoundError" DOMException. if (before_element && !before_element->is_descendant_of(root())) - return WebIDL::NotFoundError::create(realm(), "The 'before' element is not a descendant of the root select element."); + return WebIDL::NotFoundError::create(realm(), "The 'before' element is not a descendant of the root select element."_fly_string); // 3. If element and before are the same element, then return. if (before_element && (resolved_element.ptr() == before_element.ptr())) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp index 957b3852f57..be2e88718f0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -153,7 +153,7 @@ WebIDL::ExceptionOr HTMLTableElement::set_t_head(HTMLTableSectionElement* { // If the new value is neither null nor a thead element, then a "HierarchyRequestError" DOMException must be thrown instead. if (thead && thead->local_name() != TagNames::thead) - return WebIDL::HierarchyRequestError::create(realm(), "Element is not thead"); + return WebIDL::HierarchyRequestError::create(realm(), "Element is not thead"_fly_string); // On setting, if the new value is null or a thead element, the first thead element child of the table element, // if any, must be removed, @@ -251,7 +251,7 @@ WebIDL::ExceptionOr HTMLTableElement::set_t_foot(HTMLTableSectionElement* { // If the new value is neither null nor a tfoot element, then a "HierarchyRequestError" DOMException must be thrown instead. if (tfoot && tfoot->local_name() != TagNames::tfoot) - return WebIDL::HierarchyRequestError::create(realm(), "Element is not tfoot"); + return WebIDL::HierarchyRequestError::create(realm(), "Element is not tfoot"_fly_string); // On setting, if the new value is null or a tfoot element, the first tfoot element child of the table element, // if any, must be removed, @@ -363,7 +363,7 @@ WebIDL::ExceptionOr> HTMLTableElement::ins auto rows_length = rows->length(); if (index < -1 || index > (long)rows_length) { - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string); } auto& tr = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML))); if (rows_length == 0 && !has_child_of_type()) { @@ -390,7 +390,7 @@ WebIDL::ExceptionOr HTMLTableElement::delete_row(long index) // 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException. if (index < -1 || index >= (long)rows_length) - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_fly_string); // 2. If index is −1, then remove the last element in the rows collection from its parent, or do nothing if the rows collection is empty. if (index == -1) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index 729cf2beea9..f07f16aa0c1 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -129,7 +129,7 @@ WebIDL::ExceptionOr> HTMLTableRowElement: // 1. If index is less than −1 or greater than the number of elements in the cells collection, then throw an "IndexSizeError" DOMException. if (index < -1 || index > cells_collection_size) - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of cells"_fly_string); // 2. Let table cell be the result of creating an element given this tr element's node document, td, and the HTML namespace. auto& table_cell = static_cast(*TRY(DOM::create_element(document(), HTML::TagNames::td, Namespace::HTML))); @@ -154,7 +154,7 @@ WebIDL::ExceptionOr HTMLTableRowElement::delete_cell(i32 index) // 1. If index is less than −1 or greater than or equal to the number of elements in the cells collection, then throw an "IndexSizeError" DOMException. if (index < -1 || index >= cells_collection_size) - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of cells"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of cells"_fly_string); // 2. If index is −1, then remove the last element in the cells collection from its parent, or do nothing if the cells collection is empty. if (index == -1) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp index d5ad0f23a05..7a39e253660 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp @@ -54,7 +54,7 @@ WebIDL::ExceptionOr> HTMLTableSectionEleme // 1. If index is less than −1 or greater than the number of elements in the rows collection, throw an "IndexSizeError" DOMException. if (index < -1 || index > rows_collection_size) - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than the number of rows"_fly_string); // 2. Let table row be the result of creating an element given this element's node document, tr, and the HTML namespace. auto& table_row = static_cast(*TRY(DOM::create_element(document(), TagNames::tr, Namespace::HTML))); @@ -78,7 +78,7 @@ WebIDL::ExceptionOr HTMLTableSectionElement::delete_row(long index) // 1. If index is less than −1 or greater than or equal to the number of elements in the rows collection, then throw an "IndexSizeError" DOMException. if (index < -1 || index >= rows_collection_size) - return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"); + return WebIDL::IndexSizeError::create(realm(), "Index is negative or greater than or equal to the number of rows"_fly_string); // 2. If index is −1, then remove the last element in the rows collection from this element, or do nothing if the rows collection is empty. if (index == -1) { diff --git a/Userland/Libraries/LibWeb/HTML/History.cpp b/Userland/Libraries/LibWeb/HTML/History.cpp index 9a6b5a7182d..8ebc1a97ce4 100644 --- a/Userland/Libraries/LibWeb/HTML/History.cpp +++ b/Userland/Libraries/LibWeb/HTML/History.cpp @@ -55,7 +55,7 @@ WebIDL::ExceptionOr History::length() const { // 1. If this's associated Document is not fully active, then throw a "SecurityError" DOMException. if (!m_associated_document->is_fully_active()) - return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."sv); + return WebIDL::SecurityError::create(realm(), "Cannot perform length on a document that isn't fully active."_fly_string); // 2. Return the number of entries in the top-level browsing context's joint session history. auto const* browsing_context = m_associated_document->browsing_context(); @@ -72,7 +72,7 @@ WebIDL::ExceptionOr History::go(long delta = 0) // 2. If document is not fully active, then throw a "SecurityError" DOMException. if (!m_associated_document->is_fully_active()) - return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."sv); + return WebIDL::SecurityError::create(realm(), "Cannot perform go on a document that isn't fully active."_fly_string); // 3. If delta is 0, then act as if the location.reload() method was called, and return. auto* browsing_context = m_associated_document->browsing_context(); @@ -157,7 +157,7 @@ WebIDL::ExceptionOr History::shared_history_push_replace_state(JS::Value v // 2. If document is not fully active, then throw a "SecurityError" DOMException. if (!document->is_fully_active()) - return WebIDL::SecurityError::create(realm(), "Cannot perform pushState or replaceState on a document that isn't fully active."sv); + return WebIDL::SecurityError::create(realm(), "Cannot perform pushState or replaceState on a document that isn't fully active."_fly_string); // 3. Optionally, return. (For example, the user agent might disallow calls to these methods that are invoked on a timer, // or from event listeners that are not triggered in response to a clear user action, or that are invoked in rapid succession.) @@ -178,14 +178,14 @@ WebIDL::ExceptionOr History::shared_history_push_replace_state(JS::Value v // 2. If that fails, then throw a "SecurityError" DOMException. if (!parsed_url.is_valid()) - return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"sv); + return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_fly_string); // 3. Set newURL to the resulting URL record. new_url = parsed_url; // 4. If document cannot have its URL rewritten to newURL, then throw a "SecurityError" DOMException. if (!can_have_its_url_rewritten(document, new_url)) - return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"sv); + return WebIDL::SecurityError::create(realm(), "Cannot pushState or replaceState to incompatible URL"_fly_string); } // FIXME: 7. Let navigation be history's relevant global object's navigation API. diff --git a/Userland/Libraries/LibWeb/HTML/Location.cpp b/Userland/Libraries/LibWeb/HTML/Location.cpp index 180590bf87b..cb5b70714f4 100644 --- a/Userland/Libraries/LibWeb/HTML/Location.cpp +++ b/Userland/Libraries/LibWeb/HTML/Location.cpp @@ -108,7 +108,7 @@ WebIDL::ExceptionOr Location::href() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 2. Return this's url, serialized. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize())); @@ -144,7 +144,7 @@ WebIDL::ExceptionOr Location::origin() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 2. Return the serialization of this's url's origin. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_origin())); @@ -158,7 +158,7 @@ WebIDL::ExceptionOr Location::protocol() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 2. Return this's url's scheme, followed by ":". return TRY_OR_THROW_OOM(vm, String::formatted("{}:", url().scheme())); @@ -178,7 +178,7 @@ WebIDL::ExceptionOr Location::host() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 2. Let url be this's url. auto url = this->url(); @@ -209,7 +209,7 @@ WebIDL::ExceptionOr Location::hostname() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); auto url = this->url(); @@ -235,7 +235,7 @@ WebIDL::ExceptionOr Location::port() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); auto url = this->url(); @@ -261,7 +261,7 @@ WebIDL::ExceptionOr Location::pathname() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 2. Return the result of URL path serializing this Location object's url. return TRY_OR_THROW_OOM(vm, String::from_deprecated_string(url().serialize_path())); @@ -281,7 +281,7 @@ WebIDL::ExceptionOr Location::search() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); auto url = this->url(); @@ -307,7 +307,7 @@ WebIDL::ExceptionOr Location::hash() const // 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. auto const relevant_document = this->relevant_document(); if (relevant_document && !relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); auto url = this->url(); @@ -331,7 +331,7 @@ WebIDL::ExceptionOr Location::set_hash(String const& value) // 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 3. Let copyURL be a copy of this's url. auto copy_url = this->url(); @@ -381,12 +381,12 @@ WebIDL::ExceptionOr Location::assign(String const& url) const // 2. If this's relevant Document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException. if (!relevant_document->origin().is_same_origin_domain(entry_settings_object().origin())) - return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"sv); + return WebIDL::SecurityError::create(realm(), "Location's relevant document is not same origin-domain with the entry settings object's origin"_fly_string); // 3. Parse url relative to the entry settings object. If that failed, throw a "SyntaxError" DOMException. auto assign_url = entry_settings_object().parse_url(url); if (!assign_url.is_valid()) - return WebIDL::SyntaxError::create(realm(), DeprecatedString::formatted("Invalid URL '{}'", url)); + return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url))); // 4. Location-object navigate this to the resulting URL record. auto& window = verify_cast(HTML::current_global_object()); @@ -469,7 +469,7 @@ JS::ThrowCompletionOr Location::internal_define_own_property(JS::PropertyK } // 2. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't define property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(realm(), MUST(String::formatted("Can't define property '{}' on cross-origin object", property_key)))); } // 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get @@ -506,7 +506,7 @@ JS::ThrowCompletionOr Location::internal_delete(JS::PropertyKey const& pro return JS::Object::internal_delete(property_key); // 2. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(realm(), DeprecatedString::formatted("Can't delete property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(realm(), MUST(String::formatted("Can't delete property '{}' on cross-origin object", property_key)))); } // 7.10.5.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/history.html#location-ownpropertykeys diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 77e34ebc30c..e569e0f75fb 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -842,7 +842,7 @@ WebIDL::ExceptionOr Navigable::navigate( if (!source_document->navigable()->allowed_by_sandboxing_to_navigate(*this, source_snapshot_params)) { // 1. If exceptionsEnabled is true, then throw a "SecurityError" DOMException. if (exceptions_enabled) { - return WebIDL::SecurityError::create(realm, "Source document's node navigable is not allowed to navigate"sv); + return WebIDL::SecurityError::create(realm, "Source document's node navigable is not allowed to navigate"_fly_string); } // 2 Return. diff --git a/Userland/Libraries/LibWeb/HTML/NavigateEvent.cpp b/Userland/Libraries/LibWeb/HTML/NavigateEvent.cpp index 211d888c1d2..e50d6c0f177 100644 --- a/Userland/Libraries/LibWeb/HTML/NavigateEvent.cpp +++ b/Userland/Libraries/LibWeb/HTML/NavigateEvent.cpp @@ -72,11 +72,11 @@ WebIDL::ExceptionOr NavigateEvent::intercept(NavigationInterceptOptions co // 2. If this's canIntercept attribute was initialized to false, then throw a "SecurityError" DOMException. if (!m_can_intercept) - return WebIDL::SecurityError::create(realm, "NavigateEvent cannot be intercepted"); + return WebIDL::SecurityError::create(realm, "NavigateEvent cannot be intercepted"_fly_string); // 3. If this's dispatch flag is unset, then throw an "InvalidStateError" DOMException. if (!this->dispatched()) - return WebIDL::InvalidStateError::create(realm, "NavigationEvent is not dispatched yet"); + return WebIDL::InvalidStateError::create(realm, "NavigationEvent is not dispatched yet"_fly_string); // 4. Assert: this's interception state is either "none" or "intercepted". VERIFY(m_interception_state == InterceptionState::None || m_interception_state == InterceptionState::Intercepted); @@ -130,7 +130,7 @@ WebIDL::ExceptionOr NavigateEvent::scroll() // 2. If this's interception state is not "committed", then throw an "InvalidStateError" DOMException. if (m_interception_state != InterceptionState::Committed) - return WebIDL::InvalidStateError::create(realm(), "Cannot scroll NavigationEvent that is not committed"); + return WebIDL::InvalidStateError::create(realm(), "Cannot scroll NavigationEvent that is not committed"_fly_string); // 3. Process scroll behavior given this. process_scroll_behavior(); @@ -147,15 +147,15 @@ WebIDL::ExceptionOr NavigateEvent::perform_shared_checks() // then throw an "InvalidStateError" DOMException. auto& associated_document = verify_cast(relevant_global_object(*this)).associated_document(); if (!associated_document.is_fully_active()) - return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"); + return WebIDL::InvalidStateError::create(realm(), "Document is not fully active"_fly_string); // 2. If event's isTrusted attribute was initialized to false, then throw a "SecurityError" DOMException. if (!this->is_trusted()) - return WebIDL::SecurityError::create(realm(), "NavigateEvent is not trusted"); + return WebIDL::SecurityError::create(realm(), "NavigateEvent is not trusted"_fly_string); // 3. If event's canceled flag is set, then throw an "InvalidStateError" DOMException. if (this->cancelled()) - return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled"); + return WebIDL::InvalidStateError::create(realm(), "NavigateEvent already cancelled"_fly_string); return {}; } diff --git a/Userland/Libraries/LibWeb/HTML/Navigation.cpp b/Userland/Libraries/LibWeb/HTML/Navigation.cpp index 260bc2ed0e9..f88db5185e9 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigation.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigation.cpp @@ -125,7 +125,7 @@ WebIDL::ExceptionOr Navigation::update_current_entry(NavigationUpdateCurre // 2. If current is null, then throw an "InvalidStateError" DOMException. if (current == nullptr) - return WebIDL::InvalidStateError::create(realm(), "Cannot update current NavigationHistoryEntry when there is no current entry"sv); + return WebIDL::InvalidStateError::create(realm(), "Cannot update current NavigationHistoryEntry when there is no current entry"_fly_string); // 3. Let serializedState be StructuredSerializeForStorage(options["state"]), rethrowing any exceptions. auto serialized_state = TRY(structured_serialize_for_storage(vm(), options.state)); @@ -210,7 +210,7 @@ WebIDL::ExceptionOr Navigation::navigate(String url, Navigatio // Otherwise, let urlRecord be the resulting URL record. auto url_record = relevant_settings_object(*this).parse_url(url); if (!url_record.is_valid()) - return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL")); + return early_error_result(WebIDL::SyntaxError::create(realm, "Cannot navigate to Invalid URL"_fly_string)); // 2. Let document be this's relevant global object's associated Document. auto& document = verify_cast(relevant_global_object(*this)).associated_document(); @@ -218,7 +218,7 @@ WebIDL::ExceptionOr Navigation::navigate(String url, Navigatio // 3. If options["history"] is "push", and the navigation must be a replace given urlRecord and document, // then return an early error result for a "NotSupportedError" DOMException. if (options.history == Bindings::NavigationHistoryBehavior::Push && navigation_must_be_a_replace(url_record, document)) - return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested")); + return early_error_result(WebIDL::NotSupportedError::create(realm, "Navigation must be a replace, but push was requested"_fly_string)); // 4. Let state be options["state"], if it exists; otherwise, undefined. auto state = options.state.value_or(JS::js_undefined()); @@ -237,11 +237,11 @@ WebIDL::ExceptionOr Navigation::navigate(String url, Navigatio // 6. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException. if (!document.is_fully_active()) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string)); // 7. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException. if (document.unload_counter() > 0) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string)); // 8. Let info be options["info"], if it exists; otherwise, undefined. auto info = options.info.value_or(JS::js_undefined()); @@ -270,7 +270,7 @@ WebIDL::ExceptionOr Navigation::navigate(String url, Navigatio // that upcoming API method tracker to ongoing. if (m_upcoming_non_traverse_api_method_tracker == api_method_tracker) { m_upcoming_non_traverse_api_method_tracker = nullptr; - return early_error_result(WebIDL::AbortError::create(realm, "Navigation aborted")); + return early_error_result(WebIDL::AbortError::create(realm, "Navigation aborted"_fly_string)); } // 12. Return a navigation API method tracker-derived result for apiMethodTracker. @@ -313,11 +313,11 @@ WebIDL::ExceptionOr Navigation::reload(NavigationReloadOptions // 5. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException. if (!document.is_fully_active()) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string)); // 6. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException. if (document.unload_counter() > 0) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string)); // 7. Let info be options["info"], if it exists; otherwise, undefined. auto info = options.info.value_or(JS::js_undefined()); @@ -341,7 +341,7 @@ WebIDL::ExceptionOr Navigation::traverse_to(String key, Naviga // 1. If this's current entry index is −1, then return an early error result for an "InvalidStateError" DOMException. if (m_current_entry_index == -1) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: no current session history entry")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: no current session history entry"_fly_string)); // 2. If this's entry list does not contain a NavigationHistoryEntry whose session history entry's navigation API key equals key, // then return an early error result for an "InvalidStateError" DOMException. @@ -349,7 +349,7 @@ WebIDL::ExceptionOr Navigation::traverse_to(String key, Naviga return entry->session_history_entry().navigation_api_key == key; }); if (it == m_entry_list.end()) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: key not found in session history list")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot traverseTo: key not found in session history list"_fly_string)); // 3. Return the result of performing a navigation API traversal given this, key, and options. return perform_a_navigation_api_traversal(key, options); @@ -363,7 +363,7 @@ WebIDL::ExceptionOr Navigation::back(NavigationOptions const& // 1. If this's current entry index is −1 or 0, then return an early error result for an "InvalidStateError" DOMException. if (m_current_entry_index == -1 || m_current_entry_index == 0) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate back: no previous session history entry")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate back: no previous session history entry"_fly_string)); // 2. Let key be this's entry list[this's current entry index − 1]'s session history entry's navigation API key. auto key = m_entry_list[m_current_entry_index - 1]->session_history_entry().navigation_api_key; @@ -381,7 +381,7 @@ WebIDL::ExceptionOr Navigation::forward(NavigationOptions cons // 1. If this's current entry index is −1 or is equal to this's entry list's size − 1, // then return an early error result for an "InvalidStateError" DOMException. if (m_current_entry_index == -1 || m_current_entry_index == static_cast(m_entry_list.size() - 1)) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate forward: no next session history entry")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Cannot navigate forward: no next session history entry"_fly_string)); // 2. Let key be this's entry list[this's current entry index + 1]'s session history entry's navigation API key. auto key = m_entry_list[m_current_entry_index + 1]->session_history_entry().navigation_api_key; @@ -610,11 +610,11 @@ WebIDL::ExceptionOr Navigation::perform_a_navigation_api_trave // 2. If document is not fully active, then return an early error result for an "InvalidStateError" DOMException. if (!document.is_fully_active()) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document is not fully active"_fly_string)); // 3. If document's unload counter is greater than 0, then return an early error result for an "InvalidStateError" DOMException. if (document.unload_counter() > 0) - return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded")); + return early_error_result(WebIDL::InvalidStateError::create(realm, "Document already unloaded"_fly_string)); // 4. Let current be the current entry of navigation. auto current = current_entry(); @@ -666,7 +666,7 @@ WebIDL::ExceptionOr Navigation::perform_a_navigation_api_trave queue_global_task(HTML::Task::Source::NavigationAndTraversal, relevant_global_object(*this), [this, api_method_tracker] { auto& reject_realm = relevant_realm(*this); WebIDL::reject_promise(reject_realm, api_method_tracker->finished_promise, - WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry")); + WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_fly_string)); }); // 2. Abort these steps. diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp index 4d18d2f8f12..44916f0227c 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp @@ -118,7 +118,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors, JS::GCPtrreject(WebIDL::QuotaExceededError::create(settings_object().realm(), "Failed to evaluate module script").ptr()); + promise->reject(WebIDL::QuotaExceededError::create(settings_object().realm(), "Failed to evaluate module script"_fly_string).ptr()); evaluation_promise = promise; } else { diff --git a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp index 99db5aa5104..c73eb05f437 100644 --- a/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp +++ b/Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp @@ -127,7 +127,7 @@ public: // 5. If Type(value) is Symbol, then throw a "DataCloneError" DOMException. if (value.is_symbol()) - return WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize Symbol"sv); + return WebIDL::DataCloneError::create(*m_vm.current_realm(), "Cannot serialize Symbol"_fly_string); // 6. Let serialized be an uninitialized value. // NOTE: We use the range of the soon-to-be-serialized value in our serialized data buffer @@ -173,7 +173,7 @@ public: // 12 - 24: FIXME: Serialize other data types else { - return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Unsupported type"sv)); + return throw_completion(WebIDL::DataCloneError::create(*m_vm.current_realm(), "Unsupported type"_fly_string)); } // 25. Set memory[value] to serialized. @@ -302,7 +302,7 @@ public: break; } default: - m_error = "Unsupported type"sv; + m_error = "Unsupported type"_fly_string; break; } } @@ -311,16 +311,16 @@ public: WebIDL::ExceptionOr result() { - if (m_error.is_null()) + if (!m_error.has_value()) return m_memory[0]; - return WebIDL::DataCloneError::create(*m_vm.current_realm(), m_error); + return WebIDL::DataCloneError::create(*m_vm.current_realm(), m_error.value()); } private: JS::VM& m_vm; SerializationRecord const& m_vector; JS::MarkedVector m_memory; // Index -> JS value - StringView m_error; + Optional m_error; static WebIDL::ExceptionOr> deserialize_string_primitive(JS::VM& vm, Vector const& vector, u32& position) { diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 0ae92b2f2af..3c2e470a186 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -363,7 +363,7 @@ WebIDL::ExceptionOr> Window::open_impl(StringView url, St if (!url.is_empty()) { url_record = entry_settings_object().parse_url(url); if (!url_record.is_valid()) - return WebIDL::SyntaxError::create(realm(), "URL is not valid"); + return WebIDL::SyntaxError::create(realm(), "URL is not valid"_fly_string); } // FIXME: 5. If urlRecord matches about:blank, then perform the URL and history update steps given target browsing context's active document and urlRecord. @@ -393,7 +393,7 @@ WebIDL::ExceptionOr> Window::open_impl(StringView url, St // 2. Parse url relative to the entry settings object, and set urlRecord to the resulting URL record, if any. If the parse a URL algorithm failed, then throw a "SyntaxError" DOMException. url_record = entry_settings_object().parse_url(url); if (!url_record.is_valid()) - return WebIDL::SyntaxError::create(realm(), "URL is not valid"); + return WebIDL::SyntaxError::create(realm(), "URL is not valid"_fly_string); // 3. Let request be a new request whose URL is urlRecord. auto request = Fetch::Infrastructure::Request::create(vm); diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp index 8aa1cf47ecb..31fd059487f 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp @@ -96,7 +96,7 @@ WebIDL::ExceptionOr WindowOrWorkerGlobalScopeMixin::btoa(String const& d byte_string.ensure_capacity(data.bytes().size()); for (u32 code_point : Utf8View(data)) { if (code_point > 0xff) - return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"); + return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"_fly_string); byte_string.append(code_point); } @@ -116,7 +116,7 @@ WebIDL::ExceptionOr WindowOrWorkerGlobalScopeMixin::atob(String const& d // 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException. if (decoded_data.is_error()) - return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"); + return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"_fly_string); // 3. Return decodedData. // decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8. diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp index 3887b75f783..9522314ba23 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -95,7 +95,7 @@ JS::ThrowCompletionOr> WindowProxy::internal_ge return Optional {}; // 2. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't access property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(String::formatted("Can't access property '{}' on cross-origin object", property_key)))); } // 6. Return PropertyDescriptor{ [[Value]]: value, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: true }. @@ -145,7 +145,7 @@ JS::ThrowCompletionOr WindowProxy::internal_define_own_property(JS::Proper } // 3. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't define property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(String::formatted("Can't define property '{}' on cross-origin object", property_key)))); } // 7.4.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-get @@ -218,7 +218,7 @@ JS::ThrowCompletionOr WindowProxy::internal_delete(JS::PropertyKey const& } // 3. Throw a "SecurityError" DOMException. - return throw_completion(WebIDL::SecurityError::create(m_window->realm(), DeprecatedString::formatted("Can't delete property '{}' on cross-origin object", property_key))); + return throw_completion(WebIDL::SecurityError::create(m_window->realm(), MUST(String::formatted("Can't delete property '{}' on cross-origin object", property_key)))); } // 7.4.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-ownpropertykeys diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 8a821ee6bd6..2dd7452ce8a 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -51,7 +51,7 @@ WebIDL::ExceptionOr> Worker::create(String const& scrip { // NOTE: We don't start a worker because they're not properly implemented yet and would likely crash. dbgln("FIXME: Implement web workers"); - return WebIDL::NotSupportedError::create(document.realm(), "Web workers not supported yet"); + return WebIDL::NotSupportedError::create(document.realm(), "Web workers not supported yet"_fly_string); dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url); @@ -75,7 +75,7 @@ WebIDL::ExceptionOr> Worker::create(String const& scrip // 4. If this fails, throw a "SyntaxError" DOMException. if (!url.is_valid()) { dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", script_url); - return WebIDL::SyntaxError::create(document.realm(), "url is not valid"); + return WebIDL::SyntaxError::create(document.realm(), "url is not valid"_fly_string); } // 5. Let worker URL be the resulting URL record. diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 5ccdbc5e121..6827cf67707 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -119,7 +119,7 @@ WebIDL::ExceptionOr Performance::conver // 5. If endTime is 0, throw an InvalidAccessError. if (end_time == 0) - return WebIDL::InvalidAccessError::create(realm, DeprecatedString::formatted("The '{}' entry in the PerformanceTiming interface is equal to 0, meaning it hasn't happened yet", name)); + return WebIDL::InvalidAccessError::create(realm, MUST(String::formatted("The '{}' entry in the PerformanceTiming interface is equal to 0, meaning it hasn't happened yet", name))); // 6. Return result of subtracting startTime from endTime. return static_cast(end_time - start_time); @@ -153,7 +153,7 @@ WebIDL::ExceptionOr Performance::conver }); if (!maybe_entry.has_value()) - return WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("No PerformanceMark object with name '{}' found in the performance timeline", mark_string)); + return WebIDL::SyntaxError::create(realm, MUST(String::formatted("No PerformanceMark object with name '{}' found in the performance timeline", mark_string))); return maybe_entry.value()->start_time(); } diff --git a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp index 221c6475d57..5e09b439a5d 100644 --- a/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp +++ b/Userland/Libraries/LibWeb/PerformanceTimeline/PerformanceObserver.cpp @@ -74,12 +74,12 @@ WebIDL::ExceptionOr PerformanceObserver::observe(PerformanceObserverInit& // 2. If this's observer type is "single" and options's entryTypes member is present, then throw an "InvalidModificationError". else if (m_observer_type == ObserverType::Single) { if (options.entry_types.has_value()) - return WebIDL::InvalidModificationError::create(realm, "Cannot change a PerformanceObserver from observing a single type to observing multiple types"sv); + return WebIDL::InvalidModificationError::create(realm, "Cannot change a PerformanceObserver from observing a single type to observing multiple types"_fly_string); } // 3. If this's observer type is "multiple" and options's type member is present, then throw an "InvalidModificationError". else if (m_observer_type == ObserverType::Multiple) { if (options.type.has_value()) - return WebIDL::InvalidModificationError::create(realm, "Cannot change a PerformanceObserver from observing multiple types to observing a single type"sv); + return WebIDL::InvalidModificationError::create(realm, "Cannot change a PerformanceObserver from observing multiple types to observing a single type"_fly_string); } // 5. Set this's requires dropped entries to true. diff --git a/Userland/Libraries/LibWeb/Selection/Selection.cpp b/Userland/Libraries/LibWeb/Selection/Selection.cpp index 1047cc0d447..7f6166df0dc 100644 --- a/Userland/Libraries/LibWeb/Selection/Selection.cpp +++ b/Userland/Libraries/LibWeb/Selection/Selection.cpp @@ -118,7 +118,7 @@ WebIDL::ExceptionOr> Selection::get_range_at(unsigned inde { // The method must throw an IndexSizeError exception if index is not 0, or if this is empty. if (index != 0 || is_empty()) - return WebIDL::IndexSizeError::create(realm(), "Selection.getRangeAt() on empty Selection or with invalid argument"sv); + return WebIDL::IndexSizeError::create(realm(), "Selection.getRangeAt() on empty Selection or with invalid argument"_fly_string); // Otherwise, it must return a reference to (not a copy of) this's range. return m_range; @@ -149,7 +149,7 @@ WebIDL::ExceptionOr Selection::remove_range(JS::NonnullGCPtr r } // Otherwise, it must throw a NotFoundError. - return WebIDL::NotFoundError::create(realm(), "Selection.removeRange() with invalid argument"sv); + return WebIDL::NotFoundError::create(realm(), "Selection.removeRange() with invalid argument"_fly_string); } // https://w3c.github.io/selection-api/#dom-selection-removeallranges @@ -177,7 +177,7 @@ WebIDL::ExceptionOr Selection::collapse(JS::GCPtr node, unsigne // 2. The method must throw an IndexSizeError exception if offset is longer than node's length and abort these steps. if (offset > node->length()) { - return WebIDL::IndexSizeError::create(realm(), "Selection.collapse() with offset longer than node's length"sv); + return WebIDL::IndexSizeError::create(realm(), "Selection.collapse() with offset longer than node's length"_fly_string); } // 3. If node's root is not the document associated with this, abort these steps. @@ -208,7 +208,7 @@ WebIDL::ExceptionOr Selection::collapse_to_start() { // 1. The method must throw InvalidStateError exception if the this is empty. if (!m_range) { - return WebIDL::InvalidStateError::create(realm(), "Selection.collapse_to_start() on empty range"sv); + return WebIDL::InvalidStateError::create(realm(), "Selection.collapse_to_start() on empty range"_fly_string); } // 2. Otherwise, it must create a new range @@ -228,7 +228,7 @@ WebIDL::ExceptionOr Selection::collapse_to_end() { // 1. The method must throw InvalidStateError exception if the this is empty. if (!m_range) { - return WebIDL::InvalidStateError::create(realm(), "Selection.collapse_to_end() on empty range"sv); + return WebIDL::InvalidStateError::create(realm(), "Selection.collapse_to_end() on empty range"_fly_string); } // 2. Otherwise, it must create a new range @@ -253,7 +253,7 @@ WebIDL::ExceptionOr Selection::extend(JS::NonnullGCPtr node, un // 2. If this is empty, throw an InvalidStateError exception and abort these steps. if (!m_range) { - return WebIDL::InvalidStateError::create(realm(), "Selection.extend() on empty range"sv); + return WebIDL::InvalidStateError::create(realm(), "Selection.extend() on empty range"_fly_string); } // 3. Let oldAnchor and oldFocus be the this's anchor and focus, and let newFocus be the boundary point (node, offset). @@ -298,10 +298,10 @@ WebIDL::ExceptionOr Selection::set_base_and_extent(JS::NonnullGCPtr anchor_node->length()) - return WebIDL::IndexSizeError::create(realm(), "Anchor offset points outside of the anchor node"); + return WebIDL::IndexSizeError::create(realm(), "Anchor offset points outside of the anchor node"_fly_string); if (focus_offset > focus_node->length()) - return WebIDL::IndexSizeError::create(realm(), "Focus offset points outside of the focus node"); + return WebIDL::IndexSizeError::create(realm(), "Focus offset points outside of the focus node"_fly_string); // 2. If the roots of anchorNode or focusNode are not the document associated with this, abort these steps. if (&anchor_node->root() != m_document.ptr()) diff --git a/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp b/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp index b2c5c3727ff..5b931ae60bc 100644 --- a/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp +++ b/Userland/Libraries/LibWeb/UserTiming/PerformanceMark.cpp @@ -41,7 +41,7 @@ WebIDL::ExceptionOr> PerformanceMark::construc #undef __ENUMERATE_NAVIGATION_TIMING_ENTRY_NAME if (matched) - return WebIDL::SyntaxError::create(realm, DeprecatedString::formatted("'{}' markName cannot be used in a Window context because it is part of the PerformanceTiming interface", mark_name)); + return WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' markName cannot be used in a Window context because it is part of the PerformanceTiming interface", mark_name))); } // NOTE: Step 2 (creating the entry) is done after determining values, as we set the values once during creation and never change them after. diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp index 058349e3595..af44cf9a4bc 100644 --- a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -114,7 +114,7 @@ WebIDL::ExceptionOr> AudioContext::resume() // 3. If the [[control thread state]] on the AudioContext is closed reject the promise with InvalidStateError, abort these steps, returning promise. if (state() == Bindings::AudioContextState::Closed) { - WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed.")); + WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed."_fly_string)); return JS::NonnullGCPtr { verify_cast(*promise->promise()) }; } @@ -196,7 +196,7 @@ WebIDL::ExceptionOr> AudioContext::suspend() // 3. If the [[control thread state]] on the AudioContext is closed reject the promise with InvalidStateError, abort these steps, returning promise. if (state() == Bindings::AudioContextState::Closed) { - WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed.")); + WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed."_fly_string)); return JS::NonnullGCPtr { verify_cast(*promise->promise()) }; } @@ -250,7 +250,7 @@ WebIDL::ExceptionOr> AudioContext::close() // 3. If the [[control thread state]] flag on the AudioContext is closed reject the promise with InvalidStateError, abort these steps, returning promise. if (state() == Bindings::AudioContextState::Closed) { - WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed.")); + WebIDL::reject_promise(realm, promise, WebIDL::InvalidStateError::create(realm, "Audio context is already closed."_fly_string)); return JS::NonnullGCPtr { verify_cast(*promise->promise()) }; } diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp index baaeac3a3f7..893e642ced8 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.cpp @@ -9,17 +9,17 @@ namespace Web::WebIDL { -JS::NonnullGCPtr DOMException::create(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) +JS::NonnullGCPtr DOMException::create(JS::Realm& realm, FlyString const& name, FlyString const& message) { return realm.heap().allocate(realm, realm, name, message); } -JS::NonnullGCPtr DOMException::construct_impl(JS::Realm& realm, DeprecatedFlyString const& message, DeprecatedFlyString const& name) +JS::NonnullGCPtr DOMException::construct_impl(JS::Realm& realm, FlyString const& message, FlyString const& name) { return realm.heap().allocate(realm, realm, name, message); } -DOMException::DOMException(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message) +DOMException::DOMException(JS::Realm& realm, FlyString const& name, FlyString const& message) : PlatformObject(realm) , m_name(name) , m_message(message) diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.h b/Userland/Libraries/LibWeb/WebIDL/DOMException.h index 9753ce344e4..229bd6d7a0e 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.h +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.h @@ -6,8 +6,8 @@ #pragma once -#include #include +#include #include #include @@ -78,7 +78,7 @@ namespace Web::WebIDL { __ENUMERATE(OperationError) \ __ENUMERATE(NotAllowedError) -static u16 get_legacy_code_for_name(DeprecatedFlyString const& name) +static u16 get_legacy_code_for_name(FlyString const& name) { #define __ENUMERATE(ErrorName, code) \ if (name == #ErrorName) \ @@ -93,35 +93,35 @@ class DOMException final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(DOMException, Bindings::PlatformObject); public: - static JS::NonnullGCPtr create(JS::Realm& realm, DeprecatedFlyString const& name, DeprecatedFlyString const& message); + static JS::NonnullGCPtr create(JS::Realm& realm, FlyString const& name, FlyString const& message); // JS constructor has message first, name second // FIXME: This is a completely pointless footgun, let's use the same order for both factories. - static JS::NonnullGCPtr construct_impl(JS::Realm& realm, DeprecatedFlyString const& message, DeprecatedFlyString const& name); + static JS::NonnullGCPtr construct_impl(JS::Realm& realm, FlyString const& message, FlyString const& name); virtual ~DOMException() override; - DeprecatedFlyString const& name() const { return m_name; } - DeprecatedFlyString const& message() const { return m_message; } + FlyString const& name() const { return m_name; } + FlyString const& message() const { return m_message; } u16 code() const { return get_legacy_code_for_name(m_name); } protected: - DOMException(JS::Realm&, DeprecatedFlyString const& name, DeprecatedFlyString const& message); + DOMException(JS::Realm&, FlyString const& name, FlyString const& message); virtual void initialize(JS::Realm&) override; private: - DeprecatedFlyString m_name; - DeprecatedFlyString m_message; + FlyString m_name; + FlyString m_message; }; -#define __ENUMERATE(ErrorName) \ - class ErrorName final { \ - public: \ - static JS::NonnullGCPtr create(JS::Realm& realm, DeprecatedFlyString const& message) \ - { \ - return DOMException::create(realm, #ErrorName, message); \ - } \ +#define __ENUMERATE(ErrorName) \ + class ErrorName final { \ + public: \ + static JS::NonnullGCPtr create(JS::Realm& realm, FlyString const& message) \ + { \ + return DOMException::create(realm, #ErrorName##_fly_string, message); \ + } \ }; ENUMERATE_DOM_EXCEPTION_ERROR_NAMES #undef __ENUMERATE diff --git a/Userland/Libraries/LibWeb/WebIDL/DOMException.idl b/Userland/Libraries/LibWeb/WebIDL/DOMException.idl index 39c52ca83f3..f150db7b004 100644 --- a/Userland/Libraries/LibWeb/WebIDL/DOMException.idl +++ b/Userland/Libraries/LibWeb/WebIDL/DOMException.idl @@ -1,5 +1,5 @@ // https://webidl.spec.whatwg.org/#idl-DOMException -[Exposed=*, Serializable, UseDeprecatedAKString] +[Exposed=*, Serializable] interface DOMException { constructor(optional DOMString message = "", optional DOMString name = "Error"); diff --git a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp index bf58ac04591..9904c7f1139 100644 --- a/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/WebSockets/WebSocket.cpp @@ -65,7 +65,7 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R // 3. If urlRecord is failure, then throw a "SyntaxError" DOMException. if (!url_record.is_valid()) - return WebIDL::SyntaxError::create(realm, "Invalid URL"); + return WebIDL::SyntaxError::create(realm, "Invalid URL"_fly_string); // 4. If urlRecord’s scheme is "http", then set urlRecord’s scheme to "ws". if (url_record.scheme() == "http"sv) @@ -76,11 +76,11 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R // 6. If urlRecord’s scheme is not "ws" or "wss", then throw a "SyntaxError" DOMException. if (!url_record.scheme().is_one_of("ws"sv, "wss"sv)) - return WebIDL::SyntaxError::create(realm, "Invalid protocol"sv); + return WebIDL::SyntaxError::create(realm, "Invalid protocol"_fly_string); // 7. If urlRecord’s fragment is non-null, then throw a "SyntaxError" DOMException. if (url_record.fragment().has_value()) - return WebIDL::SyntaxError::create(realm, "Presence of URL fragment is invalid"sv); + return WebIDL::SyntaxError::create(realm, "Presence of URL fragment is invalid"_fly_string); Vector protocols_sequence; // 8. If protocols is a string, set protocols to a sequence consisting of just that string. @@ -101,10 +101,10 @@ WebIDL::ExceptionOr> WebSocket::construct_impl(JS::R // separator characters as defined in [RFC2616] and MUST all be unique strings. auto protocol = sorted_protocols[i]; if (i < sorted_protocols.size() - 1 && protocol == sorted_protocols[i + 1]) - return WebIDL::SyntaxError::create(realm, "Found a duplicate protocol name in the specified list"sv); + return WebIDL::SyntaxError::create(realm, "Found a duplicate protocol name in the specified list"_fly_string); for (auto code_point : protocol.code_points()) { if (code_point < '\x21' || code_point > '\x7E') - return WebIDL::SyntaxError::create(realm, "Found invalid character in subprotocol name"sv); + return WebIDL::SyntaxError::create(realm, "Found invalid character in subprotocol name"_fly_string); } } @@ -205,13 +205,13 @@ WebIDL::ExceptionOr WebSocket::close(Optional code, Optional { // 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)) - return WebIDL::InvalidAccessError::create(realm(), "The close error code is invalid"); + return WebIDL::InvalidAccessError::create(realm(), "The close error code is invalid"_fly_string); // 2. If reason is present, then run these substeps: if (reason.has_value()) { // 1. Let reasonBytes be the result of encoding reason. // 2. If reasonBytes is longer than 123 bytes, then throw a "SyntaxError" DOMException. if (reason->bytes().size() > 123) - return WebIDL::SyntaxError::create(realm(), "The close reason is longer than 123 bytes"); + return WebIDL::SyntaxError::create(realm(), "The close reason is longer than 123 bytes"_fly_string); } // 3. Run the first matching steps from the following list: auto state = ready_state(); @@ -232,7 +232,7 @@ WebIDL::ExceptionOr WebSocket::send(Variant, JS::Ha { auto state = ready_state(); if (state == WebSocket::ReadyState::Connecting) - return WebIDL::InvalidStateError::create(realm(), "Websocket is still CONNECTING"); + return WebIDL::InvalidStateError::create(realm(), "Websocket is still CONNECTING"_fly_string); if (state == WebSocket::ReadyState::Open) { TRY_OR_THROW_OOM(vm(), data.visit( diff --git a/Userland/Libraries/LibWeb/XHR/FormData.cpp b/Userland/Libraries/LibWeb/XHR/FormData.cpp index 86d05ad72a7..5689ea3fc2b 100644 --- a/Userland/Libraries/LibWeb/XHR/FormData.cpp +++ b/Userland/Libraries/LibWeb/XHR/FormData.cpp @@ -25,7 +25,7 @@ WebIDL::ExceptionOr> FormData::construct_impl(JS::Rea auto entry_list = TRY(construct_entry_list(realm, form.value())); // 2. If list is null, then throw an "InvalidStateError" DOMException. if (!entry_list.has_value()) - return WebIDL::InvalidStateError::create(realm, "Form element does not contain any entries."); + return WebIDL::InvalidStateError::create(realm, "Form element does not contain any entries."_fly_string); // 3. Set this’s entry list to list. list = entry_list.release_value(); } diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index bf6f3fba34c..fff7c13bab4 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -109,7 +109,7 @@ 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) - return WebIDL::InvalidStateError::create(realm(), "XHR responseText can only be used for responseType \"\" or \"text\""); + return WebIDL::InvalidStateError::create(realm(), "XHR responseText can only be used for responseType \"\" or \"text\""_fly_string); // 2. If this’s state is not loading or done, then return the empty string. if (m_state != State::Loading && m_state != State::Done) @@ -127,11 +127,11 @@ WebIDL::ExceptionOr XMLHttpRequest::set_response_type(Bindings::XMLHttpReq // 2. If this’s state is loading or done, then throw an "InvalidStateError" DOMException. if (m_state == State::Loading || m_state == State::Done) - return WebIDL::InvalidStateError::create(realm(), "Can't readyState when XHR is loading or done"); + return WebIDL::InvalidStateError::create(realm(), "Can't readyState when XHR is loading or done"_fly_string); // 3. If the current global object is a Window object and this’s synchronous flag is set, then throw an "InvalidAccessError" DOMException. if (is(HTML::current_global_object()) && m_synchronous) - return WebIDL::InvalidAccessError::create(realm(), "Can't set readyState on synchronous XHR in Window environment"); + return WebIDL::InvalidAccessError::create(realm(), "Can't set readyState on synchronous XHR in Window environment"_fly_string); // 4. Set this’s response type to the given value. m_response_type = response_type; @@ -316,20 +316,20 @@ WebIDL::ExceptionOr XMLHttpRequest::set_request_header(String const& name_ // 1. If this’s state is not opened, then throw an "InvalidStateError" DOMException. if (m_state != State::Opened) - return WebIDL::InvalidStateError::create(realm, "XHR readyState is not OPENED"); + return WebIDL::InvalidStateError::create(realm, "XHR readyState is not OPENED"_fly_string); // 2. If this’s send() flag is set, then throw an "InvalidStateError" DOMException. if (m_send) - return WebIDL::InvalidStateError::create(realm, "XHR send() flag is already set"); + return WebIDL::InvalidStateError::create(realm, "XHR send() flag is already set"_fly_string); // 3. Normalize value. auto normalized_value = TRY_OR_THROW_OOM(vm, Fetch::Infrastructure::normalize_header_value(value)); // 4. If name is not a header name or value is not a header value, then throw a "SyntaxError" DOMException. if (!Fetch::Infrastructure::is_header_name(name)) - return WebIDL::SyntaxError::create(realm, "Header name contains invalid characters."); + return WebIDL::SyntaxError::create(realm, "Header name contains invalid characters."_fly_string); if (!Fetch::Infrastructure::is_header_value(value)) - return WebIDL::SyntaxError::create(realm, "Header value contains invalid characters."); + return WebIDL::SyntaxError::create(realm, "Header value contains invalid characters."_fly_string); auto header = Fetch::Infrastructure::Header { .name = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(name)), @@ -361,16 +361,16 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri if (is(HTML::relevant_global_object(*this))) { auto const& window = static_cast(HTML::relevant_global_object(*this)); if (!window.associated_document().is_fully_active()) - return WebIDL::InvalidStateError::create(realm(), "Invalid state: Window's associated document is not fully active."); + return WebIDL::InvalidStateError::create(realm(), "Invalid state: Window's associated document is not fully active."_fly_string); } // 2. If method is not a method, then throw a "SyntaxError" DOMException. if (!Fetch::Infrastructure::is_method(method)) - return WebIDL::SyntaxError::create(realm(), "An invalid or illegal string was specified."); + return WebIDL::SyntaxError::create(realm(), "An invalid or illegal string was specified."_fly_string); // 3. If method is a forbidden method, then throw a "SecurityError" DOMException. if (Fetch::Infrastructure::is_forbidden_method(method)) - return WebIDL::SecurityError::create(realm(), "Forbidden method, must not be 'CONNECT', 'TRACE', or 'TRACK'"); + return WebIDL::SecurityError::create(realm(), "Forbidden method, must not be 'CONNECT', 'TRACE', or 'TRACK'"_fly_string); // 4. Normalize method. auto normalized_method = TRY_OR_THROW_OOM(vm(), Fetch::Infrastructure::normalize_method(method)); @@ -381,7 +381,7 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri // 6. If parsedURL is failure, then throw a "SyntaxError" DOMException. if (!parsed_url.is_valid()) - return WebIDL::SyntaxError::create(realm(), "Invalid URL"); + return WebIDL::SyntaxError::create(realm(), "Invalid URL"_fly_string); // 7. If the async argument is omitted, set async to true, and set username and password to null. // NOTE: This is handled in the overload lacking the async argument. @@ -401,7 +401,7 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri if (!async && is(HTML::current_global_object()) && (m_timeout != 0 || m_response_type != Bindings::XMLHttpRequestResponseType::Empty)) { - return WebIDL::InvalidAccessError::create(realm(), "Synchronous XMLHttpRequests in a Window context do not support timeout or a non-empty responseType"); + return WebIDL::InvalidAccessError::create(realm(), "Synchronous XMLHttpRequests in a Window context do not support timeout or a non-empty responseType"_fly_string); } // 10. Terminate this’s fetch controller. @@ -449,11 +449,11 @@ WebIDL::ExceptionOr XMLHttpRequest::send(Optional XMLHttpRequest::override_mime_type(String const& mime) // 1. If this’s state is loading or done, then throw an "InvalidStateError" DOMException. if (m_state == State::Loading || m_state == State::Done) - return WebIDL::InvalidStateError::create(realm(), "Cannot override MIME type when state is Loading or Done."); + return WebIDL::InvalidStateError::create(realm(), "Cannot override MIME type when state is Loading or Done."_fly_string); // 2. Set this’s override MIME type to the result of parsing mime. m_override_mime_type = TRY_OR_THROW_OOM(vm, MimeSniff::MimeType::parse(mime)); @@ -935,7 +935,7 @@ 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. if (is(HTML::current_global_object()) && m_synchronous) - return WebIDL::InvalidAccessError::create(realm(), "Use of XMLHttpRequest's timeout attribute is not supported in the synchronous mode in window context."); + return WebIDL::InvalidAccessError::create(realm(), "Use of XMLHttpRequest's timeout attribute is not supported in the synchronous mode in window context."_fly_string); // 2. Set this’s timeout to the given value. m_timeout = timeout; @@ -960,11 +960,11 @@ WebIDL::ExceptionOr XMLHttpRequest::set_with_credentials(bool with_credent // 1. If this’s state is not unsent or opened, then throw an "InvalidStateError" DOMException. if (m_state != State::Unsent && m_state != State::Opened) - return WebIDL::InvalidStateError::create(realm, "XHR readyState is not UNSENT or OPENED"); + return WebIDL::InvalidStateError::create(realm, "XHR readyState is not UNSENT or OPENED"_fly_string); // 2. If this’s send() flag is set, then throw an "InvalidStateError" DOMException. if (m_send) - return WebIDL::InvalidStateError::create(realm, "XHR send() flag is already set"); + return WebIDL::InvalidStateError::create(realm, "XHR send() flag is already set"_fly_string); // 3. Set this’s cross-origin credentials to the given value. m_cross_origin_credentials = with_credentials; @@ -1107,15 +1107,15 @@ WebIDL::ExceptionOr XMLHttpRequest::handle_errors() // 2. If xhr’s timed out flag is set, then run the request error steps for xhr, timeout, and "TimeoutError" DOMException. if (m_timed_out) - return TRY(request_error_steps(EventNames::timeout, WebIDL::TimeoutError::create(realm(), "Timed out"sv))); + return TRY(request_error_steps(EventNames::timeout, WebIDL::TimeoutError::create(realm(), "Timed out"_fly_string))); // 3. Otherwise, if xhr’s response’s aborted flag is set, run the request error steps for xhr, abort, and "AbortError" DOMException. if (m_response->aborted()) - return TRY(request_error_steps(EventNames::abort, WebIDL::AbortError::create(realm(), "Aborted"sv))); + return TRY(request_error_steps(EventNames::abort, WebIDL::AbortError::create(realm(), "Aborted"_fly_string))); // 4. Otherwise, if xhr’s response is a network error, then run the request error steps for xhr, error, and "NetworkError" DOMException. if (m_response->is_network_error()) - return TRY(request_error_steps(EventNames::error, WebIDL::NetworkError::create(realm(), "Network error"sv))); + return TRY(request_error_steps(EventNames::error, WebIDL::NetworkError::create(realm(), "Network error"_fly_string))); return {}; }