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:
Timothy Flynn 2025-08-07 19:31:52 -04:00 committed by Jelle Raaijmakers
commit 70db474cf0
Notes: github-actions[bot] 2025-08-14 08:28:16 +00:00
162 changed files with 1405 additions and 1422 deletions

View file

@ -58,7 +58,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// 2. If index is greater than length, then throw an IndexSizeError exception.
if (index > length)
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_string);
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_utf16);
// 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()
@ -86,7 +86,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// - If declarations is empty, throw a SyntaxError exception.
if (declarations.custom_properties.is_empty() && declarations.properties.is_empty())
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS declarations block."_string);
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS declarations block."_utf16);
// - Otherwise, set new rule to a new nested declarations rule with declarations as it contents.
new_rule = CSSNestedDeclarations::create(realm(), CSSStyleProperties::create(realm(), move(declarations.properties), move(declarations.custom_properties)));
@ -94,7 +94,7 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// 5. If new rule is a syntax error, throw a SyntaxError exception.
if (!new_rule)
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_string);
return WebIDL::SyntaxError::create(realm(), "Unable to parse CSS rule."_utf16);
auto has_rule_of_type_other_than_specified_before_index = [&](Vector<CSSRule::Type> types, size_t index) {
for (size_t i = 0; i < index; i++) {
@ -138,11 +138,11 @@ WebIDL::ExceptionOr<unsigned> CSSRuleList::insert_a_css_rule(Variant<StringView,
// FIXME: There are more constraints that we should check here - Parser::is_valid_in_the_current_context is probably a good reference for that.
if (rule_is_disallowed || (nested == Nested::Yes && first_is_one_of(new_rule->type(), CSSRule::Type::Import, CSSRule::Type::Namespace)))
return WebIDL::HierarchyRequestError::create(realm(), "Cannot insert rule at specified index."_string);
return WebIDL::HierarchyRequestError::create(realm(), "Cannot insert rule at specified index."_utf16);
// 7. If new rule is an @namespace at-rule, and list contains anything other than @import at-rules, and @namespace at-rules, throw an InvalidStateError exception.
if (new_rule->type() == CSSRule::Type::Namespace && any_of(m_rules, [](auto existing_rule) { return existing_rule->type() != CSSRule::Type::Import && existing_rule->type() != CSSRule::Type::Namespace; }))
return WebIDL::InvalidStateError::create(realm(), "Cannot insert @namespace rule into a stylesheet with non-namespace/import rules"_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot insert @namespace rule into a stylesheet with non-namespace/import rules"_utf16);
// 8. Insert new rule into list at the zero-indexed position index.
m_rules.insert(index, *new_rule);
@ -161,7 +161,7 @@ WebIDL::ExceptionOr<void> 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."_string);
return WebIDL::IndexSizeError::create(realm(), "CSS rule index out of bounds."_utf16);
// 3. Set old rule to the indexth item in list.
CSSRule& old_rule = m_rules[index];
@ -170,7 +170,7 @@ WebIDL::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
if (old_rule.type() == CSSRule::Type::Namespace) {
for (auto& rule : m_rules) {
if (rule->type() != CSSRule::Type::Import && rule->type() != CSSRule::Type::Namespace)
return WebIDL::InvalidStateError::create(realm(), "Cannot remove @namespace rule from a stylesheet with non-namespace/import rules."_string);
return WebIDL::InvalidStateError::create(realm(), "Cannot remove @namespace rule from a stylesheet with non-namespace/import rules."_utf16);
}
}