LibWeb: Make DOMException take error message as a String

There was no need to use FlyString for error messages, and it just
caused a bunch of churn since these strings typically only existed
during the lifetime of the error.
This commit is contained in:
Andreas Kling 2024-10-12 20:56:21 +02:00 committed by Andreas Kling
commit 175f3febb8
Notes: github-actions[bot] 2024-10-12 19:15:13 +00:00
89 changed files with 464 additions and 462 deletions

View file

@ -147,7 +147,7 @@ WebIDL::ExceptionOr<void> HTMLElement::set_content_editable(StringView content_e
MUST(set_attribute(HTML::AttributeNames::contenteditable, "false"_string));
return {};
}
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'"_fly_string);
return WebIDL::SyntaxError::create(realm(), "Invalid contentEditable value, must be 'true', 'false', or 'inherit'"_string);
}
void HTMLElement::set_inner_text(StringView text)
@ -651,26 +651,26 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ElementInternals>> HTMLElement::attach_inte
{
// 1. If this's is value is not null, then throw a "NotSupportedError" DOMException.
if (is_value().has_value())
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to a customized build-in element"_fly_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to a customized build-in element"_string);
// 2. Let definition be the result of looking up a custom element definition given this's node document, its namespace, its local name, and null as the is value.
auto definition = document().lookup_custom_element_definition(namespace_uri(), local_name(), is_value());
// 3. If definition is null, then throw an "NotSupportedError" DOMException.
if (!definition)
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to an element that is not a custom element"_fly_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals cannot be attached to an element that is not a custom element"_string);
// 4. If definition's disable internals is true, then throw a "NotSupportedError" DOMException.
if (definition->disable_internals())
return WebIDL::NotSupportedError::create(realm(), "ElementInternals are disabled for this custom element"_fly_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals are disabled for this custom element"_string);
// 5. If this's attached internals is non-null, then throw an "NotSupportedError" DOMException.
if (m_attached_internals)
return WebIDL::NotSupportedError::create(realm(), "ElementInternals already attached"_fly_string);
return WebIDL::NotSupportedError::create(realm(), "ElementInternals already attached"_string);
// 6. If this's custom element state is not "precustomized" or "custom", then throw a "NotSupportedError" DOMException.
if (!first_is_one_of(custom_element_state(), DOM::CustomElementState::Precustomized, DOM::CustomElementState::Custom))
return WebIDL::NotSupportedError::create(realm(), "Custom element is in an invalid state to attach ElementInternals"_fly_string);
return WebIDL::NotSupportedError::create(realm(), "Custom element is in an invalid state to attach ElementInternals"_string);
// 7. Set this's attached internals to a new ElementInternals instance whose target element is this.
auto internals = ElementInternals::create(realm(), *this);