mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 22:49:47 +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
|
@ -124,7 +124,7 @@ JS::ThrowCompletionOr<void> 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, MUST(String::formatted("'{}' is not a valid custom element name", name))));
|
||||
return JS::throw_completion(WebIDL::SyntaxError::create(realm, Utf16String::formatted("'{}' is not a valid custom element name", name)));
|
||||
|
||||
// 3. If this's custom element definition set contains an item with name name, then throw a "NotSupportedError" DOMException.
|
||||
auto existing_definition_with_name_iterator = m_custom_element_definitions.find_if([&name](auto const& definition) {
|
||||
|
@ -132,7 +132,7 @@ JS::ThrowCompletionOr<void> 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, MUST(String::formatted("A custom element with name '{}' is already defined", name))));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("A custom element with name '{}' is already defined", name)));
|
||||
|
||||
// 4. If this's custom element definition set contains an item with constructor constructor, then throw a "NotSupportedError" DOMException.
|
||||
auto existing_definition_with_constructor_iterator = m_custom_element_definitions.find_if([&constructor](auto const& definition) {
|
||||
|
@ -140,7 +140,7 @@ JS::ThrowCompletionOr<void> 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"_string));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "The given constructor is already in use by another custom element"_utf16));
|
||||
|
||||
// 5. Let localName be name.
|
||||
String local_name = name;
|
||||
|
@ -152,13 +152,13 @@ JS::ThrowCompletionOr<void> 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, MUST(String::formatted("'{}' is a custom element name, only non-custom elements can be extended", extends.value()))));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("'{}' is a custom element name, only non-custom elements can be extended", 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()))
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, MUST(String::formatted("'{}' is an unknown HTML element", extends.value()))));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, Utf16String::formatted("'{}' is an unknown HTML element", extends.value())));
|
||||
|
||||
// 3. Set localName to extends.
|
||||
local_name = extends.value();
|
||||
|
@ -166,7 +166,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
|
||||
// 8. If this's element definition is running is true, then throw a "NotSupportedError" DOMException.
|
||||
if (m_element_definition_is_running)
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_string));
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Cannot recursively define custom elements"_utf16));
|
||||
|
||||
// 9. Set this's element definition is running to true.
|
||||
m_element_definition_is_running = true;
|
||||
|
@ -363,7 +363,7 @@ WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> CustomElementRegistry::when_define
|
|||
|
||||
// 1. If name is not a valid custom element name, then return a promise rejected with a "SyntaxError" DOMException.
|
||||
if (!is_valid_custom_element_name(name))
|
||||
return WebIDL::create_rejected_promise(realm, WebIDL::SyntaxError::create(realm, MUST(String::formatted("'{}' is not a valid custom element name", name))));
|
||||
return WebIDL::create_rejected_promise(realm, WebIDL::SyntaxError::create(realm, Utf16String::formatted("'{}' is not a valid custom element name", name)));
|
||||
|
||||
// 2. If this's custom element definition set contains an item with name name, then return a promise resolved with that item's constructor.
|
||||
auto existing_definition_iterator = m_custom_element_definitions.find_if([&name](GC::Root<CustomElementDefinition> const& definition) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue