mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibJS+LibWeb: Port interned bytecode strings to UTF-16
This was almost a no-op, except we intern JS exception messages. So the bulk of this patch is porting exception messages to UTF-16.
This commit is contained in:
parent
cf61171864
commit
70db474cf0
Notes:
github-actions[bot]
2025-08-14 08:28:16 +00:00
Author: https://github.com/trflynn89
Commit: 70db474cf0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5845
Reviewed-by: https://github.com/gmta ✅
162 changed files with 1405 additions and 1422 deletions
|
@ -182,11 +182,11 @@ WebIDL::ExceptionOr<void> Range::set_start_or_end(GC::Ref<Node> node, u32 offset
|
|||
|
||||
// 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."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
|
||||
|
||||
// 2. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException.
|
||||
if (offset > node->length())
|
||||
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
|
||||
return WebIDL::IndexSizeError::create(realm(), Utf16String::formatted("Node does not contain a child at offset {}", offset));
|
||||
|
||||
// 3. Let bp be the boundary point (node, offset).
|
||||
|
||||
|
@ -243,7 +243,7 @@ WebIDL::ExceptionOr<void> Range::set_start_before(GC::Ref<Node> node)
|
|||
|
||||
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (!parent)
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
|
||||
|
||||
// 3. Set the start of this to boundary point (parent, node’s index).
|
||||
return set_start_or_end(*parent, node->index(), StartOrEnd::Start);
|
||||
|
@ -257,7 +257,7 @@ WebIDL::ExceptionOr<void> Range::set_start_after(GC::Ref<Node> node)
|
|||
|
||||
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (!parent)
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
|
||||
|
||||
// 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);
|
||||
|
@ -271,7 +271,7 @@ WebIDL::ExceptionOr<void> Range::set_end_before(GC::Ref<Node> node)
|
|||
|
||||
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (!parent)
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
|
||||
|
||||
// 3. Set the end of this to boundary point (parent, node’s index).
|
||||
return set_start_or_end(*parent, node->index(), StartOrEnd::End);
|
||||
|
@ -285,7 +285,7 @@ WebIDL::ExceptionOr<void> Range::set_end_after(GC::Ref<Node> node)
|
|||
|
||||
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (!parent)
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
|
||||
|
||||
// 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);
|
||||
|
@ -301,11 +301,11 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_boundary_points(WebIDL::Unsign
|
|||
// - 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(), 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)));
|
||||
return WebIDL::NotSupportedError::create(realm(), Utf16String::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."_string);
|
||||
return WebIDL::WrongDocumentError::create(realm(), "This range is not in the same tree as the source range."_utf16);
|
||||
|
||||
GC::Ptr<Node> this_point_node;
|
||||
u32 this_point_offset = 0;
|
||||
|
@ -386,7 +386,7 @@ WebIDL::ExceptionOr<void> Range::select(GC::Ref<Node> node)
|
|||
|
||||
// 2. If parent is null, then throw an "InvalidNodeTypeError" DOMException.
|
||||
if (!parent)
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Given node has no parent."_utf16);
|
||||
|
||||
// 3. Let index be node’s index.
|
||||
auto index = node->index();
|
||||
|
@ -429,7 +429,7 @@ WebIDL::ExceptionOr<void> Range::select_node_contents(GC::Ref<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."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
|
||||
|
||||
// 2. Let length be the length of node.
|
||||
auto length = node->length();
|
||||
|
@ -503,11 +503,11 @@ WebIDL::ExceptionOr<bool> Range::is_point_in_range(GC::Ref<Node> node, WebIDL::U
|
|||
|
||||
// 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."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
|
||||
|
||||
// 3. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException.
|
||||
if (offset > node->length())
|
||||
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
|
||||
return WebIDL::IndexSizeError::create(realm(), Utf16String::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 }, start());
|
||||
|
@ -524,15 +524,15 @@ WebIDL::ExceptionOr<WebIDL::Short> Range::compare_point(GC::Ref<Node> node, WebI
|
|||
{
|
||||
// 1. If node’s root is different from this’s root, then throw a "WrongDocumentError" DOMException.
|
||||
if (&node->root() != root().ptr())
|
||||
return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_string);
|
||||
return WebIDL::WrongDocumentError::create(realm(), "Given node is not in the same document as the range."_utf16);
|
||||
|
||||
// 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."_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Node cannot be a DocumentType."_utf16);
|
||||
|
||||
// 3. If offset is greater than node’s length, then throw an "IndexSizeError" DOMException.
|
||||
if (offset > node->length())
|
||||
return WebIDL::IndexSizeError::create(realm(), MUST(String::formatted("Node does not contain a child at offset {}", offset)));
|
||||
return WebIDL::IndexSizeError::create(realm(), Utf16String::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 }, start());
|
||||
|
@ -672,7 +672,7 @@ WebIDL::ExceptionOr<GC::Ref<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"_string);
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_utf16);
|
||||
}
|
||||
|
||||
GC::Ptr<Node> new_node;
|
||||
|
@ -816,7 +816,7 @@ WebIDL::ExceptionOr<void> Range::insert(GC::Ref<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"_string);
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Range has inappropriate start node for insertion"_utf16);
|
||||
}
|
||||
|
||||
// 2. Let referenceNode be null.
|
||||
|
@ -887,11 +887,11 @@ WebIDL::ExceptionOr<void> Range::surround_contents(GC::Ref<Node> new_parent)
|
|||
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."_string);
|
||||
return WebIDL::InvalidStateError::create(realm(), "Non-Text node is partially contained in range."_utf16);
|
||||
|
||||
// 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"_string);
|
||||
return WebIDL::InvalidNodeTypeError::create(realm(), "Invalid parent node type"_utf16);
|
||||
|
||||
// 3. Let fragment be the result of extracting this.
|
||||
auto fragment = TRY(extract());
|
||||
|
@ -995,7 +995,7 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::clone_the_contents()
|
|||
// 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"_string);
|
||||
return WebIDL::HierarchyRequestError::create(realm(), "Contained child is a DocumentType"_utf16);
|
||||
}
|
||||
|
||||
// 13. If first partially contained child is a CharacterData node, then:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue