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

@ -230,7 +230,7 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(Node& node, u32 offset, StartO
// 1. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
// 2. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
@ -290,7 +290,7 @@ WebIDL::ExceptionOr<void> 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."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
// 3. Set the start of this to boundary point (parent, nodes index).
return set_start_or_end(*parent, node.index(), StartOrEnd::Start);
@ -304,7 +304,7 @@ WebIDL::ExceptionOr<void> 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."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
// 3. Set the start of this to boundary point (parent, nodes index plus 1).
return set_start_or_end(*parent, node.index() + 1, StartOrEnd::Start);
@ -318,7 +318,7 @@ WebIDL::ExceptionOr<void> 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."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
// 3. Set the end of this to boundary point (parent, nodes index).
return set_start_or_end(*parent, node.index(), StartOrEnd::End);
@ -332,7 +332,7 @@ WebIDL::ExceptionOr<void> 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."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
// 3. Set the end of this to boundary point (parent, nodes index plus 1).
return set_start_or_end(*parent, node.index() + 1, StartOrEnd::End);
@ -352,7 +352,7 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_boundary_points(WebIDL::Unsign
// 2. If thiss root is not the same as sourceRanges 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."_fly_string);
return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."_string);
JS::GCPtr<Node> this_point_node;
u32 this_point_offset = 0;
@ -433,7 +433,7 @@ WebIDL::ExceptionOr<void> 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."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
// 3. Let index be nodes index.
auto index = node.index();
@ -476,7 +476,7 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(Node& node)
{
// 1. If node is a doctype, throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
// 2. Let length be the length of node.
auto length = node.length();
@ -570,7 +570,7 @@ WebIDL::ExceptionOr<bool> Range::is_point_in_range(Node const& node, WebIDL::Uns
// 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
@ -591,11 +591,11 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_point(Node const& node, WebIDL
{
// 1. If nodes root is different from thiss 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."_fly_string);
return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_string);
// 2. If node is a doctype, then throw an "InvalidNodeTypeError" DOMException.
if (is<DocumentType>(node))
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_string);
// 3. If offset is greater than nodes length, then throw an "IndexSizeError" DOMException.
if (offset > node.length())
@ -738,7 +738,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> 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<DocumentType>(*child))
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_fly_string);
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_string);
}
JS::GCPtr<Node> new_node;
@ -885,7 +885,7 @@ WebIDL::ExceptionOr<void> Range::insert(JS::NonnullGCPtr<Node> node)
if ((is<ProcessingInstruction>(*m_start_container) || is<Comment>(*m_start_container))
|| (is<Text>(*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"_fly_string);
return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"_string);
}
// 2. Let referenceNode be null.
@ -956,11 +956,11 @@ WebIDL::ExceptionOr<void> Range::surround_contents(JS::NonnullGCPtr<Node> new_pa
if (is<Text>(*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."_fly_string);
return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."_string);
// 2. If newParent is a Document, DocumentType, or DocumentFragment node, then throw an "InvalidNodeTypeError" DOMException.
if (is<Document>(*new_parent) || is<DocumentType>(*new_parent) || is<DocumentFragment>(*new_parent))
return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_fly_string);
return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_string);
// 3. Let fragment be the result of extracting this.
auto fragment = TRY(extract());
@ -1064,7 +1064,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> 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<DocumentType>(*child))
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_fly_string);
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_string);
}
// 13. If first partially contained child is a CharacterData node, then: