mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibJS: Use FlyString in PropertyKey instead of DeprecatedFlyString
This required dealing with *substantial* fallout.
This commit is contained in:
parent
fc744e3f3f
commit
46a5710238
Notes:
github-actions[bot]
2025-03-24 22:28:26 +00:00
Author: https://github.com/awesomekling
Commit: 46a5710238
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4067
Reviewed-by: https://github.com/trflynn89
110 changed files with 985 additions and 987 deletions
|
@ -185,7 +185,7 @@ static WebIDL::ExceptionOr<KeyframeType<AL>> process_a_keyframe_like_object(JS::
|
|||
// 1. Let raw value be the result of calling the [[Get]] internal method on keyframe input, with property name
|
||||
// as the property key and keyframe input as the receiver.
|
||||
// 2. Check the completion record of raw value.
|
||||
JS::PropertyKey key { property_name.to_byte_string(), JS::PropertyKey::StringMayBeNumber::No };
|
||||
JS::PropertyKey key { property_name, JS::PropertyKey::StringMayBeNumber::No };
|
||||
auto raw_value = TRY(keyframe_object.has_property(key)) ? TRY(keyframe_object.get(key)) : *all_value;
|
||||
|
||||
using PropertyValuesType = Conditional<AL == AllowLists::Yes, Vector<String>, String>;
|
||||
|
@ -827,7 +827,7 @@ WebIDL::ExceptionOr<GC::RootVector<JS::Object*>> KeyframeEffect::get_keyframes()
|
|||
|
||||
for (auto const& [id, value] : keyframe.parsed_properties()) {
|
||||
auto value_string = JS::PrimitiveString::create(vm, value->to_string(CSS::CSSStyleValue::SerializationMode::Normal));
|
||||
TRY(object->set(JS::PropertyKey { DeprecatedFlyString(CSS::camel_case_string_from_property_id(id)), JS::PropertyKey::StringMayBeNumber::No }, value_string, ShouldThrowExceptions::Yes));
|
||||
TRY(object->set(JS::PropertyKey { CSS::camel_case_string_from_property_id(id), JS::PropertyKey::StringMayBeNumber::No }, value_string, ShouldThrowExceptions::Yes));
|
||||
}
|
||||
|
||||
m_keyframe_objects.append(object);
|
||||
|
|
|
@ -369,7 +369,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
|
||||
// 2. Let url be the result of resolving a module specifier given moduleScript and specifier.
|
||||
auto url = TRY(Bindings::throw_dom_exception_if_needed(vm, [&] {
|
||||
return HTML::resolve_module_specifier(*module_script, specifier_string.to_byte_string());
|
||||
return HTML::resolve_module_specifier(*module_script, specifier_string);
|
||||
}));
|
||||
|
||||
// 3. Return the serialization of url.
|
||||
|
@ -388,9 +388,9 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
};
|
||||
|
||||
// 8.1.6.7.2 HostGetSupportedImportAttributes(), https://html.spec.whatwg.org/multipage/webappapis.html#hostgetsupportedimportassertions
|
||||
s_main_thread_vm->host_get_supported_import_attributes = []() -> Vector<ByteString> {
|
||||
s_main_thread_vm->host_get_supported_import_attributes = []() -> Vector<String> {
|
||||
// 1. Return « "type" ».
|
||||
return { "type"sv };
|
||||
return { "type"_string };
|
||||
};
|
||||
|
||||
// 8.1.6.7.3 HostLoadImportedModule(referrer, moduleRequest, loadState, payload), https://html.spec.whatwg.org/multipage/webappapis.html#hostloadimportedmodule
|
||||
|
@ -460,7 +460,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
|
||||
// 2. Resolve a module specifier given referencingScript and moduleRequest.[[Specifier]], catching any
|
||||
// exceptions. If they throw an exception, let resolutionError be the thrown exception.
|
||||
auto maybe_exception = HTML::resolve_module_specifier(referencing_script, module_request.module_specifier);
|
||||
auto maybe_exception = HTML::resolve_module_specifier(referencing_script, module_request.module_specifier.to_string());
|
||||
|
||||
// 3. If the previous step threw an exception, then:
|
||||
if (maybe_exception.is_exception()) {
|
||||
|
@ -500,7 +500,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
|
|||
|
||||
// 8. Let url be the result of resolving a module specifier given referencingScript and moduleRequest.[[Specifier]],
|
||||
// catching any exceptions. If they throw an exception, let resolutionError be the thrown exception.
|
||||
auto url = HTML::resolve_module_specifier(referencing_script, module_request.module_specifier);
|
||||
auto url = HTML::resolve_module_specifier(referencing_script, module_request.module_specifier.to_string());
|
||||
|
||||
// 9. If the previous step threw an exception, then:
|
||||
if (url.is_exception()) {
|
||||
|
|
|
@ -41,7 +41,7 @@ JS::ThrowCompletionOr<bool> PlatformObject::is_named_property_exposed_on_object(
|
|||
|
||||
// 1. If P is not a supported property name of O, then return false.
|
||||
// NOTE: This is in it's own variable to enforce the type.
|
||||
if (!is_supported_property_name(MUST(String::from_byte_string(property_key.to_string()))))
|
||||
if (!is_supported_property_name(property_key.to_string()))
|
||||
return false;
|
||||
|
||||
// 2. If O has an own property named P, then return false.
|
||||
|
@ -118,7 +118,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> PlatformObject::legacy_p
|
|||
// 1. If the result of running the named property visibility algorithm with property name P and object O is true, then:
|
||||
if (TRY(is_named_property_exposed_on_object(property_name))) {
|
||||
// FIXME: It's unfortunate that this is done twice, once in is_named_property_exposed_on_object and here.
|
||||
auto property_name_string = MUST(FlyString::from_deprecated_fly_string(property_name.to_string()));
|
||||
auto property_name_string = property_name.to_string();
|
||||
|
||||
// 1. Let operation be the operation used to declare the named property getter.
|
||||
// 2. Let value be an uninitialized variable.
|
||||
|
@ -236,7 +236,7 @@ JS::ThrowCompletionOr<bool> PlatformObject::internal_set(JS::PropertyKey const&
|
|||
// 2. If O implements an interface with a named property setter and P is a String, then:
|
||||
if (m_legacy_platform_object_flags->has_named_property_setter && property_name.is_string()) {
|
||||
// 1. Invoke the named property setter on O with P and V.
|
||||
TRY(throw_dom_exception_if_needed(vm, [&] { return invoke_named_property_setter(MUST(String::from_byte_string(property_name.as_string())), value); }));
|
||||
TRY(throw_dom_exception_if_needed(vm, [&] { return invoke_named_property_setter(property_name.as_string(), value); }));
|
||||
|
||||
// 2. Return true.
|
||||
return true;
|
||||
|
@ -282,7 +282,7 @@ JS::ThrowCompletionOr<bool> PlatformObject::internal_define_own_property(JS::Pro
|
|||
// 2. If O supports named properties, O does not implement an interface with the [Global] extended attribute, P is a String, and P is not an unforgeable property name of O, then:
|
||||
// FIXME: Check if P is not an unforgeable property name of O
|
||||
if (m_legacy_platform_object_flags->supports_named_properties && !m_legacy_platform_object_flags->has_global_interface_extended_attribute && property_name.is_string()) {
|
||||
auto const property_name_as_string = MUST(FlyString::from_deprecated_fly_string(property_name.as_string()));
|
||||
auto const property_name_as_string = property_name.as_string();
|
||||
|
||||
// 1. Let creating be true if P is not a supported property name, and false otherwise.
|
||||
bool creating = !is_supported_property_name(property_name_as_string);
|
||||
|
@ -360,7 +360,7 @@ JS::ThrowCompletionOr<bool> PlatformObject::internal_delete(JS::PropertyKey cons
|
|||
// 4. Otherwise, operation was defined with an identifier:
|
||||
// 1. Perform method steps of operation with O as this and « P » as the argument values.
|
||||
// 2. If operation was declared with a return type of boolean and the steps returned false, then return false.
|
||||
auto did_deletion_fail = TRY(throw_dom_exception_if_needed(vm, [&] { return delete_value(MUST(String::from_byte_string(property_name_string))); }));
|
||||
auto did_deletion_fail = TRY(throw_dom_exception_if_needed(vm, [&] { return delete_value(property_name_string); }));
|
||||
if (!m_legacy_platform_object_flags->named_property_deleter_has_identifier)
|
||||
VERIFY(did_deletion_fail != DidDeletionFail::NotRelevant);
|
||||
|
||||
|
@ -423,7 +423,7 @@ JS::ThrowCompletionOr<GC::RootVector<JS::Value>> PlatformObject::internal_own_pr
|
|||
// 3. If O supports named properties, then for each P of O’s supported property names that is visible according to the named property visibility algorithm, append P to keys.
|
||||
if (m_legacy_platform_object_flags->supports_named_properties) {
|
||||
for (auto& named_property : supported_property_names()) {
|
||||
if (TRY(is_named_property_exposed_on_object(named_property.to_deprecated_fly_string())))
|
||||
if (TRY(is_named_property_exposed_on_object(named_property)))
|
||||
keys.append(JS::PrimitiveString::create(vm, named_property));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4737,7 +4737,7 @@ void Document::start_intersection_observing_a_lazy_loading_element(Element& elem
|
|||
// 2. If doc's lazy load intersection observer is null, set it to a new IntersectionObserver instance, initialized as follows:
|
||||
if (!m_lazy_load_intersection_observer) {
|
||||
// - The callback is these steps, with arguments entries and observer:
|
||||
auto callback = JS::NativeFunction::create(realm, "", [this](JS::VM& vm) -> JS::ThrowCompletionOr<JS::Value> {
|
||||
auto callback = JS::NativeFunction::create(realm, ""_fly_string, [this](JS::VM& vm) -> JS::ThrowCompletionOr<JS::Value> {
|
||||
// For each entry in entries using a method of iteration which does not trigger developer-modifiable array accessors or iteration hooks:
|
||||
auto& entries = as<JS::Array>(vm.argument(0).as_object());
|
||||
auto entries_length = MUST(MUST(entries.get(vm.names.length)).to_length(vm));
|
||||
|
|
|
@ -513,7 +513,7 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(FlyString
|
|||
|
||||
// 6. Return scope. (NOTE: Not necessary)
|
||||
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, name.to_deprecated_fly_string(), builder.to_byte_string(), program->body(), program->parameters(), program->function_length(), program->local_variables_names(), scope, nullptr, JS::FunctionKind::Normal, program->is_strict_mode(),
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, name, builder.to_byte_string(), program->body(), program->parameters(), program->function_length(), program->local_variables_names(), scope, nullptr, JS::FunctionKind::Normal, program->is_strict_mode(),
|
||||
program->parsing_insights(), is_arrow_function);
|
||||
|
||||
// 10. Remove settings object's realm execution context from the JavaScript execution context stack.
|
||||
|
|
|
@ -59,8 +59,8 @@ Vector<CrossOriginProperty> cross_origin_properties(Variant<HTML::Location const
|
|||
bool is_cross_origin_accessible_window_property_name(JS::PropertyKey const& property_key)
|
||||
{
|
||||
// A JavaScript property name P is a cross-origin accessible window property name if it is "window", "self", "location", "close", "closed", "focus", "blur", "frames", "length", "top", "opener", "parent", "postMessage", or an array index property name.
|
||||
static Array<DeprecatedFlyString, 13> property_names {
|
||||
"window"sv, "self"sv, "location"sv, "close"sv, "closed"sv, "focus"sv, "blur"sv, "frames"sv, "length"sv, "top"sv, "opener"sv, "parent"sv, "postMessage"sv
|
||||
static Array<FlyString, 13> property_names {
|
||||
"window"_fly_string, "self"_fly_string, "location"_fly_string, "close"_fly_string, "closed"_fly_string, "focus"_fly_string, "blur"_fly_string, "frames"_fly_string, "length"_fly_string, "top"_fly_string, "opener"_fly_string, "parent"_fly_string, "postMessage"_fly_string
|
||||
};
|
||||
return (property_key.is_string() && any_of(property_names, [&](auto const& name) { return property_key.as_string() == name; })) || property_key.is_number();
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
|
|||
if (!property_key.is_string()) {
|
||||
return {};
|
||||
}
|
||||
auto const& property_key_string = MUST(FlyString::from_deprecated_fly_string(property_key.as_string()));
|
||||
auto const& property_key_string = property_key.as_string();
|
||||
|
||||
// 2. For each e of CrossOriginProperties(O):
|
||||
for (auto const& entry : cross_origin_properties(object_const_variant)) {
|
||||
|
|
|
@ -208,7 +208,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
// 4. For each callbackName of the keys of lifecycleCallbacks:
|
||||
for (auto const& callback_name : { CustomElementReactionNames::connectedCallback, CustomElementReactionNames::disconnectedCallback, CustomElementReactionNames::adoptedCallback, CustomElementReactionNames::attributeChangedCallback }) {
|
||||
// 1. Let callbackValue be ? Get(prototype, callbackName).
|
||||
auto callback_value = TRY(prototype.get(callback_name.to_deprecated_fly_string()));
|
||||
auto callback_value = TRY(prototype.get(callback_name));
|
||||
|
||||
// 2. If callbackValue is not undefined, then set the value of the entry in lifecycleCallbacks with key callbackName to the result of
|
||||
// converting callbackValue to the Web IDL Function callback type.
|
||||
|
@ -259,7 +259,7 @@ JS::ThrowCompletionOr<void> CustomElementRegistry::define(String const& name, We
|
|||
if (form_associated) {
|
||||
for (auto const& callback_name : { CustomElementReactionNames::formAssociatedCallback, CustomElementReactionNames::formResetCallback, CustomElementReactionNames::formDisabledCallback, CustomElementReactionNames::formStateRestoreCallback }) {
|
||||
// 1. Let callbackValue be ? Get(prototype, callbackName).
|
||||
auto callback_value = TRY(prototype.get(callback_name.to_deprecated_fly_string()));
|
||||
auto callback_value = TRY(prototype.get(callback_name));
|
||||
|
||||
// 2. If callbackValue is not undefined, then set lifecycleCallbacks[callbackName] to the result of converting callbackValue
|
||||
// to the Web IDL Function callback type.
|
||||
|
|
|
@ -118,7 +118,7 @@ Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllColle
|
|||
return Empty {};
|
||||
|
||||
// 2. Return the result of getting the "all"-indexed or named element(s) from this, given nameOrIndex.
|
||||
return get_the_all_indexed_or_named_elements(name_or_index.value().to_deprecated_fly_string());
|
||||
return get_the_all_indexed_or_named_elements(name_or_index.value());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlallcollection-nameditem
|
||||
|
@ -211,7 +211,7 @@ Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllColle
|
|||
}
|
||||
|
||||
// 2. Return the result of getting the "all"-named element(s) from collection given nameOrIndex.
|
||||
return get_the_all_named_elements(MUST(FlyString::from_deprecated_fly_string(name_or_index.as_string())));
|
||||
return get_the_all_named_elements(name_or_index.as_string());
|
||||
}
|
||||
|
||||
Optional<JS::Value> HTMLAllCollection::item_value(size_t index) const
|
||||
|
|
|
@ -61,19 +61,19 @@ ScriptFetchOptions default_script_fetch_options()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#module-type-from-module-request
|
||||
ByteString module_type_from_module_request(JS::ModuleRequest const& module_request)
|
||||
String module_type_from_module_request(JS::ModuleRequest const& module_request)
|
||||
{
|
||||
// 1. Let moduleType be "javascript".
|
||||
ByteString module_type = "javascript"sv;
|
||||
String module_type = "javascript"_string;
|
||||
|
||||
// 2. If moduleRequest.[[Attributes]] has a Record entry such that entry.[[Key]] is "type", then:
|
||||
for (auto const& entry : module_request.attributes) {
|
||||
if (entry.key != "type"sv)
|
||||
if (entry.key != "type"_string)
|
||||
continue;
|
||||
|
||||
// 1. If entry.[[Value]] is "javascript", then set moduleType to null.
|
||||
if (entry.value == "javascript"sv)
|
||||
module_type = nullptr;
|
||||
if (entry.value == "javascript"_string)
|
||||
module_type = ""_string; // FIXME: This should be null!
|
||||
// 2. Otherwise, set moduleType to entry.[[Value]].
|
||||
else
|
||||
module_type = entry.value;
|
||||
|
@ -85,7 +85,7 @@ ByteString module_type_from_module_request(JS::ModuleRequest const& module_reque
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
|
||||
// https://whatpr.org/html/9893/webappapis.html#resolve-a-module-specifier
|
||||
WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referring_script, ByteString const& specifier)
|
||||
WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referring_script, String const& specifier)
|
||||
{
|
||||
auto& vm = Bindings::main_thread_vm();
|
||||
|
||||
|
@ -124,10 +124,10 @@ WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referri
|
|||
auto serialized_base_url = base_url->serialize();
|
||||
|
||||
// 7. Let asURL be the result of resolving a URL-like module specifier given specifier and baseURL.
|
||||
auto as_url = resolve_url_like_module_specifier(specifier, *base_url);
|
||||
auto as_url = resolve_url_like_module_specifier(specifier.to_byte_string(), *base_url);
|
||||
|
||||
// 8. Let normalizedSpecifier be the serialization of asURL, if asURL is non-null; otherwise, specifier.
|
||||
auto normalized_specifier = as_url.has_value() ? as_url->serialize().to_byte_string() : specifier;
|
||||
auto normalized_specifier = as_url.has_value() ? as_url->serialize() : specifier;
|
||||
|
||||
// 9. Let result be a URL-or-null, initially null.
|
||||
Optional<URL::URL> result;
|
||||
|
@ -142,7 +142,7 @@ WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referri
|
|||
// 1. If scopePrefix is serializedBaseURL, or if scopePrefix ends with U+002F (/) and scopePrefix is a code unit prefix of serializedBaseURL, then:
|
||||
if (scope_prefix == serialized_base_url || (scope_prefix.ends_with('/') && Infra::is_code_unit_prefix(scope_prefix, serialized_base_url))) {
|
||||
// 1. Let scopeImportsMatch be the result of resolving an imports match given normalizedSpecifier, asURL, and scopeImports.
|
||||
auto scope_imports_match = TRY(resolve_imports_match(normalized_specifier, as_url, scope_imports));
|
||||
auto scope_imports_match = TRY(resolve_imports_match(normalized_specifier.to_byte_string(), as_url, scope_imports));
|
||||
|
||||
// 2. If scopeImportsMatch is not null, then set result to scopeImportsMatch, and break.
|
||||
if (scope_imports_match.has_value()) {
|
||||
|
@ -154,7 +154,7 @@ WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referri
|
|||
|
||||
// 11. If result is null, set result be the result of resolving an imports match given normalizedSpecifier, asURL, and importMap's imports.
|
||||
if (!result.has_value())
|
||||
result = TRY(resolve_imports_match(normalized_specifier, as_url, import_map.imports()));
|
||||
result = TRY(resolve_imports_match(normalized_specifier.to_byte_string(), as_url, import_map.imports()));
|
||||
|
||||
// 12. If result is null, set it to asURL.
|
||||
// Spec-Note: By this point, if result was null, specifier wasn't remapped to anything by importMap, but it might have been able to be turned into a URL.
|
||||
|
@ -164,7 +164,7 @@ WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referri
|
|||
// 13. If result is not null, then:
|
||||
if (result.has_value()) {
|
||||
// 1. Add module to resolved module set given realm, serializedBaseURL, normalizedSpecifier, and asURL.
|
||||
add_module_to_resolved_module_set(*realm, serialized_base_url, MUST(String::from_byte_string(normalized_specifier)), as_url);
|
||||
add_module_to_resolved_module_set(*realm, serialized_base_url, normalized_specifier, as_url);
|
||||
|
||||
// 2. Return result.
|
||||
return result.release_value();
|
||||
|
@ -180,7 +180,7 @@ WebIDL::ExceptionOr<Optional<URL::URL>> resolve_imports_match(ByteString const&
|
|||
// 1. For each specifierKey → resolutionResult of specifierMap:
|
||||
for (auto const& [specifier_key, resolution_result] : specifier_map) {
|
||||
// 1. If specifierKey is normalizedSpecifier, then:
|
||||
if (specifier_key == normalized_specifier) {
|
||||
if (specifier_key.bytes_as_string_view() == normalized_specifier) {
|
||||
// 1. If resolutionResult is null, then throw a TypeError indicating that resolution of specifierKey was blocked by a null entry.
|
||||
if (!resolution_result.has_value())
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Import resolution of '{}' was blocked by a null entry.", specifier_key).release_value_but_fixme_should_propagate_errors() };
|
||||
|
@ -193,7 +193,7 @@ WebIDL::ExceptionOr<Optional<URL::URL>> resolve_imports_match(ByteString const&
|
|||
// 2. If all of the following are true:
|
||||
if (
|
||||
// - specifierKey ends with U+002F (/);
|
||||
specifier_key.ends_with("/"sv) &&
|
||||
specifier_key.bytes_as_string_view().ends_with("/"sv) &&
|
||||
// - specifierKey is a code unit prefix of normalizedSpecifier; and
|
||||
Infra::is_code_unit_prefix(specifier_key, normalized_specifier) &&
|
||||
// - either asURL is null, or asURL is special,
|
||||
|
@ -207,7 +207,7 @@ WebIDL::ExceptionOr<Optional<URL::URL>> resolve_imports_match(ByteString const&
|
|||
// 2. Assert: resolutionResult is a URL.
|
||||
// 3. Let afterPrefix be the portion of normalizedSpecifier after the initial specifierKey prefix.
|
||||
// FIXME: Clarify if this is meant by the portion after the initial specifierKey prefix.
|
||||
auto after_prefix = normalized_specifier.substring(specifier_key.length());
|
||||
auto after_prefix = normalized_specifier.substring(specifier_key.bytes_as_string_view().length());
|
||||
|
||||
// 4. Assert: resolutionResult, serialized, ends with U+002F (/), as enforced during parsing.
|
||||
VERIFY(resolution_result->serialize().ends_with('/'));
|
||||
|
@ -321,7 +321,7 @@ String resolve_a_module_integrity_metadata(const URL::URL& url, EnvironmentSetti
|
|||
|
||||
// 2. If map's integrity[url] does not exist, then return the empty string.
|
||||
// 3. Return map's integrity[url].
|
||||
return MUST(String::from_byte_string(map.integrity().get(url).value_or("")));
|
||||
return map.integrity().get(url).value_or(""_string);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script
|
||||
|
@ -623,7 +623,7 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
OnFetchScriptComplete on_complete)
|
||||
{
|
||||
// 1. Let moduleType be "javascript".
|
||||
ByteString module_type = "javascript"sv;
|
||||
String module_type = "javascript"_string;
|
||||
|
||||
// 2. If moduleRequest was given, then set moduleType to the result of running the module type from module request steps given moduleRequest.
|
||||
if (module_request.has_value())
|
||||
|
@ -639,8 +639,8 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
|
||||
// 5. If moduleMap[(url, moduleType)] is "fetching", wait in parallel until that entry's value changes,
|
||||
// then queue a task on the networking task source to proceed with running the following steps.
|
||||
if (module_map.is_fetching(url, module_type)) {
|
||||
module_map.wait_for_change(realm.heap(), url, module_type, [on_complete, &realm](auto entry) -> void {
|
||||
if (module_map.is_fetching(url, module_type.to_byte_string())) {
|
||||
module_map.wait_for_change(realm.heap(), url, module_type.to_byte_string(), [on_complete, &realm](auto entry) -> void {
|
||||
HTML::queue_global_task(HTML::Task::Source::Networking, realm.global_object(), GC::create_function(realm.heap(), [on_complete, entry] {
|
||||
// FIXME: This should run other steps, for now we just assume the script loaded.
|
||||
VERIFY(entry.type == ModuleMap::EntryType::ModuleScript || entry.type == ModuleMap::EntryType::Failed);
|
||||
|
@ -653,14 +653,14 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
}
|
||||
|
||||
// 6. If moduleMap[(url, moduleType)] exists, run onComplete given moduleMap[(url, moduleType)], and return.
|
||||
auto entry = module_map.get(url, module_type);
|
||||
auto entry = module_map.get(url, module_type.to_byte_string());
|
||||
if (entry.has_value() && entry->type == ModuleMap::EntryType::ModuleScript) {
|
||||
on_complete->function()(entry->module_script);
|
||||
return;
|
||||
}
|
||||
|
||||
// 7. Set moduleMap[(url, moduleType)] to "fetching".
|
||||
module_map.set(url, module_type, { ModuleMap::EntryType::Fetching, nullptr });
|
||||
module_map.set(url, module_type.to_byte_string(), { ModuleMap::EntryType::Fetching, nullptr });
|
||||
|
||||
// 8. Let request be a new request whose URL is url, mode is "cors", referrer is referrer, and client is fetchClient.
|
||||
auto request = Fetch::Infrastructure::Request::create(realm.vm());
|
||||
|
@ -670,7 +670,7 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
request->set_client(&fetch_client);
|
||||
|
||||
// 9. Set request's destination to the result of running the fetch destination from module type steps given destination and moduleType.
|
||||
request->set_destination(fetch_destination_from_module_type(destination, module_type));
|
||||
request->set_destination(fetch_destination_from_module_type(destination, module_type.to_byte_string()));
|
||||
|
||||
// 10. If destination is "worker", "sharedworker", or "serviceworker", and isTopLevel is true, then set request's mode to "same-origin".
|
||||
if ((destination == Fetch::Infrastructure::Request::Destination::Worker || destination == Fetch::Infrastructure::Request::Destination::SharedWorker || destination == Fetch::Infrastructure::Request::Destination::ServiceWorker) && is_top_level == TopLevelModule::Yes)
|
||||
|
@ -691,7 +691,7 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
// - response's status is not an ok status,
|
||||
if (body_bytes.has<Empty>() || body_bytes.has<Fetch::Infrastructure::FetchAlgorithms::ConsumeBodyFailureTag>() || !Fetch::Infrastructure::is_ok_status(response->status())) {
|
||||
// then set moduleMap[(url, moduleType)] to null, run onComplete given null, and abort these steps.
|
||||
module_map.set(url, module_type, { ModuleMap::EntryType::Failed, nullptr });
|
||||
module_map.set(url, module_type.to_byte_string(), { ModuleMap::EntryType::Failed, nullptr });
|
||||
on_complete->function()(nullptr);
|
||||
return;
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ void fetch_single_module_script(JS::Realm& realm,
|
|||
// FIXME: 9. If mimeType is a JSON MIME type and moduleType is "json", then set moduleScript to the result of creating a JSON module script given sourceText and settingsObject.
|
||||
|
||||
// 10. Set moduleMap[(url, moduleType)] to moduleScript, and run onComplete given moduleScript.
|
||||
module_map.set(url, module_type, { ModuleMap::EntryType::ModuleScript, module_script });
|
||||
module_map.set(url, module_type.to_byte_string(), { ModuleMap::EntryType::ModuleScript, module_script });
|
||||
on_complete->function()(module_script);
|
||||
};
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
ByteString module_type_from_module_request(JS::ModuleRequest const&);
|
||||
WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referring_script, ByteString const& specifier);
|
||||
String module_type_from_module_request(JS::ModuleRequest const&);
|
||||
WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referring_script, String const& specifier);
|
||||
WebIDL::ExceptionOr<Optional<URL::URL>> resolve_imports_match(ByteString const& normalized_specifier, Optional<URL::URL> as_url, ModuleSpecifierMap const&);
|
||||
Optional<URL::URL> resolve_url_like_module_specifier(ByteString const& specifier, URL::URL const& base_url);
|
||||
ScriptFetchOptions get_descendant_script_fetch_options(ScriptFetchOptions const& original_options, URL::URL const& url, EnvironmentSettingsObject& settings_object);
|
||||
|
|
|
@ -31,7 +31,7 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
auto& parsed_object = parsed.as_object();
|
||||
|
||||
// 3. Let sortedAndNormalizedImports be an empty ordered map.
|
||||
ModuleSpecifierMap sorted_and_normalised_imports;
|
||||
ModuleSpecifierMap sorted_and_normalized_imports;
|
||||
|
||||
// 4. If parsed["imports"] exists, then:
|
||||
if (TRY(parsed_object.has_property("imports"_fly_string))) {
|
||||
|
@ -42,11 +42,11 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "The 'imports' top-level value of an importmap needs to be a JSON object."_string };
|
||||
|
||||
// Set sortedAndNormalizedImports to the result of sorting and normalizing a module specifier map given parsed["imports"] and baseURL.
|
||||
sorted_and_normalised_imports = TRY(sort_and_normalise_module_specifier_map(realm, imports.as_object(), base_url));
|
||||
sorted_and_normalized_imports = TRY(sort_and_normalise_module_specifier_map(realm, imports.as_object(), base_url));
|
||||
}
|
||||
|
||||
// 5. Let sortedAndNormalizedScopes be an empty ordered map.
|
||||
HashMap<URL::URL, ModuleSpecifierMap> sorted_and_normalised_scopes;
|
||||
HashMap<URL::URL, ModuleSpecifierMap> sorted_and_normalized_scopes;
|
||||
|
||||
// 6. If parsed["scopes"] exists, then:
|
||||
if (TRY(parsed_object.has_property("scopes"_fly_string))) {
|
||||
|
@ -57,11 +57,11 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "The 'scopes' top-level value of an importmap needs to be a JSON object."_string };
|
||||
|
||||
// Set sortedAndNormalizedScopes to the result of sorting and normalizing scopes given parsed["scopes"] and baseURL.
|
||||
sorted_and_normalised_scopes = TRY(sort_and_normalise_scopes(realm, scopes.as_object(), base_url));
|
||||
sorted_and_normalized_scopes = TRY(sort_and_normalise_scopes(realm, scopes.as_object(), base_url));
|
||||
}
|
||||
|
||||
// 7. Let normalizedIntegrity be an empty ordered map.
|
||||
ModuleIntegrityMap normalised_integrity;
|
||||
ModuleIntegrityMap normalized_integrity;
|
||||
|
||||
// 8. If parsed["integrity"] exists, then:
|
||||
if (TRY(parsed_object.has_property("integrity"_fly_string))) {
|
||||
|
@ -72,7 +72,7 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "The 'integrity' top-level value of an importmap needs to be a JSON object."_string };
|
||||
|
||||
// 2. Set normalizedIntegrity to the result of normalizing a module integrity map given parsed["integrity"] and baseURL.
|
||||
normalised_integrity = TRY(normalize_module_integrity_map(realm, integrity.as_object(), base_url));
|
||||
normalized_integrity = TRY(normalize_module_integrity_map(realm, integrity.as_object(), base_url));
|
||||
}
|
||||
|
||||
// 9. If parsed's keys contains any items besides "imports", "scopes", or "integrity", then the user agent should report a warning to the console indicating that an invalid top-level key was present in the import map.
|
||||
|
@ -86,14 +86,14 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
|
|||
|
||||
// 10. Return an import map whose imports are sortedAndNormalizedImports, whose scopes are sortedAndNormalizedScopes, and whose integrity are normalizedIntegrity.
|
||||
ImportMap import_map;
|
||||
import_map.set_imports(sorted_and_normalised_imports);
|
||||
import_map.set_scopes(sorted_and_normalised_scopes);
|
||||
import_map.set_integrity(normalised_integrity);
|
||||
import_map.set_imports(sorted_and_normalized_imports);
|
||||
import_map.set_scopes(sorted_and_normalized_scopes);
|
||||
import_map.set_integrity(normalized_integrity);
|
||||
return import_map;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#normalizing-a-specifier-key
|
||||
Optional<DeprecatedFlyString> normalise_specifier_key(JS::Realm& realm, DeprecatedFlyString specifier_key, URL::URL base_url)
|
||||
Optional<FlyString> normalize_specifier_key(JS::Realm& realm, FlyString specifier_key, URL::URL base_url)
|
||||
{
|
||||
// 1. If specifierKey is the empty string, then:
|
||||
if (specifier_key.is_empty()) {
|
||||
|
@ -102,15 +102,15 @@ Optional<DeprecatedFlyString> normalise_specifier_key(JS::Realm& realm, Deprecat
|
|||
console.output_debug_message(JS::Console::LogLevel::Warn, "Specifier keys may not be empty"sv);
|
||||
|
||||
// 2. Return null.
|
||||
return Optional<DeprecatedFlyString> {};
|
||||
return Optional<FlyString> {};
|
||||
}
|
||||
|
||||
// 2. Let url be the result of resolving a URL-like module specifier, given specifierKey and baseURL.
|
||||
auto url = resolve_url_like_module_specifier(specifier_key, base_url);
|
||||
auto url = resolve_url_like_module_specifier(specifier_key.to_string().to_byte_string(), base_url);
|
||||
|
||||
// 3. If url is not null, then return the serialization of url.
|
||||
if (url.has_value())
|
||||
return url->serialize().to_byte_string();
|
||||
return url->serialize();
|
||||
|
||||
// 4. Return specifierKey.
|
||||
return specifier_key;
|
||||
|
@ -120,17 +120,17 @@ Optional<DeprecatedFlyString> normalise_specifier_key(JS::Realm& realm, Deprecat
|
|||
WebIDL::ExceptionOr<ModuleSpecifierMap> sort_and_normalise_module_specifier_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url)
|
||||
{
|
||||
// 1. Let normalized be an empty ordered map.
|
||||
ModuleSpecifierMap normalised;
|
||||
ModuleSpecifierMap normalized;
|
||||
|
||||
// 2. For each specifierKey → value of originalMap:
|
||||
for (auto& specifier_key : original_map.shape().property_table().keys()) {
|
||||
auto value = TRY(original_map.get(specifier_key.as_string()));
|
||||
|
||||
// 1. Let normalizedSpecifierKey be the result of normalizing a specifier key given specifierKey and baseURL.
|
||||
auto normalised_specifier_key = normalise_specifier_key(realm, specifier_key.as_string(), base_url);
|
||||
auto normalized_specifier_key = normalize_specifier_key(realm, specifier_key.as_string(), base_url);
|
||||
|
||||
// 2. If normalizedSpecifierKey is null, then continue.
|
||||
if (!normalised_specifier_key.has_value())
|
||||
if (!normalized_specifier_key.has_value())
|
||||
continue;
|
||||
|
||||
// 3. If value is not a string, then:
|
||||
|
@ -140,7 +140,7 @@ WebIDL::ExceptionOr<ModuleSpecifierMap> sort_and_normalise_module_specifier_map(
|
|||
console.output_debug_message(JS::Console::LogLevel::Warn, "Addresses need to be strings"sv);
|
||||
|
||||
// 2. Set normalized[normalizedSpecifierKey] to null.
|
||||
normalised.set(normalised_specifier_key.value(), {});
|
||||
normalized.set(normalized_specifier_key.value().to_string(), {});
|
||||
|
||||
// 3. Continue.
|
||||
continue;
|
||||
|
@ -156,39 +156,39 @@ WebIDL::ExceptionOr<ModuleSpecifierMap> sort_and_normalise_module_specifier_map(
|
|||
console.output_debug_message(JS::Console::LogLevel::Warn, "Address was invalid"sv);
|
||||
|
||||
// 2. Set normalized[normalizedSpecifierKey] to null.
|
||||
normalised.set(normalised_specifier_key.value(), {});
|
||||
normalized.set(normalized_specifier_key.value().to_string(), {});
|
||||
|
||||
// 3. Continue.
|
||||
continue;
|
||||
}
|
||||
|
||||
// 6. If specifierKey ends with U+002F (/), and the serialization of addressURL does not end with U+002F (/), then:
|
||||
if (specifier_key.as_string().ends_with("/"sv) && !address_url->serialize().ends_with('/')) {
|
||||
if (specifier_key.as_string().bytes_as_string_view().ends_with("/"sv) && !address_url->serialize().ends_with('/')) {
|
||||
// 1. The user agent may report a warning to the console indicating that an invalid address was given for the specifier key specifierKey; since specifierKey ends with a slash, the address needs to as well.
|
||||
auto& console = realm.intrinsics().console_object()->console();
|
||||
console.output_debug_message(JS::Console::LogLevel::Warn,
|
||||
MUST(String::formatted("An invalid address was given for the specifier key ({}); since specifierKey ends with a slash, the address needs to as well", specifier_key.as_string())));
|
||||
|
||||
// 2. Set normalized[normalizedSpecifierKey] to null.
|
||||
normalised.set(normalised_specifier_key.value(), {});
|
||||
normalized.set(normalized_specifier_key.value().to_string(), {});
|
||||
|
||||
// 3. Continue.
|
||||
continue;
|
||||
}
|
||||
|
||||
// 7. Set normalized[normalizedSpecifierKey] to addressURL.
|
||||
normalised.set(normalised_specifier_key.value(), address_url.value());
|
||||
normalized.set(normalized_specifier_key.value().to_string(), address_url.value());
|
||||
}
|
||||
|
||||
// 3. Return the result of sorting in descending order normalized, with an entry a being less than an entry b if a's key is code unit less than b's key.
|
||||
return normalised;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-scopes
|
||||
WebIDL::ExceptionOr<HashMap<URL::URL, ModuleSpecifierMap>> sort_and_normalise_scopes(JS::Realm& realm, JS::Object& original_map, URL::URL base_url)
|
||||
{
|
||||
// 1. Let normalized be an empty ordered map.
|
||||
HashMap<URL::URL, ModuleSpecifierMap> normalised;
|
||||
HashMap<URL::URL, ModuleSpecifierMap> normalized;
|
||||
|
||||
// 2. For each scopePrefix → potentialSpecifierMap of originalMap:
|
||||
for (auto& scope_prefix : original_map.shape().property_table().keys()) {
|
||||
|
@ -214,25 +214,25 @@ WebIDL::ExceptionOr<HashMap<URL::URL, ModuleSpecifierMap>> sort_and_normalise_sc
|
|||
|
||||
// 4. Let normalizedScopePrefix be the serialization of scopePrefixURL.
|
||||
// 5. Set normalized[normalizedScopePrefix] to the result of sorting and normalizing a module specifier map given potentialSpecifierMap and baseURL.
|
||||
normalised.set(scope_prefix_url.value(), TRY(sort_and_normalise_module_specifier_map(realm, potential_specifier_map.as_object(), base_url)));
|
||||
normalized.set(scope_prefix_url.value(), TRY(sort_and_normalise_module_specifier_map(realm, potential_specifier_map.as_object(), base_url)));
|
||||
}
|
||||
|
||||
// 3. Return the result of sorting in descending order normalized, with an entry a being less than an entry b if a's key is code unit less than b's key.
|
||||
return normalised;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#normalizing-a-module-integrity-map
|
||||
WebIDL::ExceptionOr<ModuleIntegrityMap> normalize_module_integrity_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url)
|
||||
{
|
||||
// 1. Let normalized be an empty ordered map.
|
||||
ModuleIntegrityMap normalised;
|
||||
ModuleIntegrityMap normalized;
|
||||
|
||||
// 2. For each key → value of originalMap:
|
||||
for (auto& key : original_map.shape().property_table().keys()) {
|
||||
auto value = TRY(original_map.get(key.as_string()));
|
||||
|
||||
// 1. Let resolvedURL be the result of resolving a URL-like module specifier given key and baseURL.
|
||||
auto resolved_url = resolve_url_like_module_specifier(key.as_string(), base_url);
|
||||
auto resolved_url = resolve_url_like_module_specifier(key.as_string().to_string().to_byte_string(), base_url);
|
||||
|
||||
// 2. If resolvedURL is null, then:
|
||||
if (!resolved_url.has_value()) {
|
||||
|
@ -257,11 +257,11 @@ WebIDL::ExceptionOr<ModuleIntegrityMap> normalize_module_integrity_map(JS::Realm
|
|||
}
|
||||
|
||||
// 4. Set normalized[resolvedURL] to value.
|
||||
normalised.set(resolved_url.release_value(), value.as_string().byte_string());
|
||||
normalized.set(resolved_url.release_value(), value.as_string().utf8_string());
|
||||
}
|
||||
|
||||
// 3. Return normalized.
|
||||
return normalised;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#merge-module-specifier-maps
|
||||
|
@ -316,13 +316,13 @@ void merge_existing_and_new_import_maps(Window& global, ImportMap& new_import_ma
|
|||
// 1. If scopePrefix is record's serialized base URL, or if scopePrefix ends with U+002F (/) and scopePrefix is a code unit prefix of record's serialized base URL, then:
|
||||
if (scope_prefix.to_string() == record.serialized_base_url || (scope_prefix.to_string().ends_with('/') && record.serialized_base_url.has_value() && Infra::is_code_unit_prefix(scope_prefix.to_string(), *record.serialized_base_url))) {
|
||||
// 1. For each specifierKey → resolutionResult of scopeImports:
|
||||
scope_imports.remove_all_matching([&](ByteString const& specifier_key, Optional<URL::URL> const&) {
|
||||
scope_imports.remove_all_matching([&](String const& specifier_key, Optional<URL::URL> const&) {
|
||||
// 1. If specifierKey is record's specifier, or if all of the following conditions are true:
|
||||
// * specifierKey ends with U+002F (/);
|
||||
// * specifierKey is a code unit prefix of record's specifier;
|
||||
// * either record's specifier as a URL is null or is special,
|
||||
// then:
|
||||
if (specifier_key.view() == record.specifier
|
||||
if (specifier_key.bytes_as_string_view() == record.specifier
|
||||
|| (specifier_key.ends_with('/')
|
||||
&& Infra::is_code_unit_prefix(specifier_key, record.specifier)
|
||||
&& record.specifier_is_null_or_url_like_that_is_special)) {
|
||||
|
@ -373,9 +373,9 @@ void merge_existing_and_new_import_maps(Window& global, ImportMap& new_import_ma
|
|||
// 6. For each record of global's resolved module set:
|
||||
for (auto const& record : global.resolved_module_set()) {
|
||||
// 1. For each specifier → url of newImportMapImports:
|
||||
new_import_map_imports.remove_all_matching([&](ByteString const& specifier, Optional<URL::URL> const&) {
|
||||
new_import_map_imports.remove_all_matching([&](String const& specifier, Optional<URL::URL> const&) {
|
||||
// 1. If specifier starts with record's specifier, then:
|
||||
if (specifier.starts_with(record.specifier)) {
|
||||
if (specifier.bytes_as_string_view().starts_with(record.specifier)) {
|
||||
// 1. The user agent may report a warning to the console indicating the ignored rule. They may choose to
|
||||
// avoid reporting if the rule is identical to an existing one.
|
||||
auto& console = realm.intrinsics().console_object()->console();
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
using ModuleSpecifierMap = HashMap<ByteString, Optional<URL::URL>>;
|
||||
using ModuleIntegrityMap = HashMap<URL::URL, ByteString>;
|
||||
using ModuleSpecifierMap = HashMap<String, Optional<URL::URL>>;
|
||||
using ModuleIntegrityMap = HashMap<URL::URL, String>;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#import-map
|
||||
class ImportMap {
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
};
|
||||
|
||||
WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteString const& input, URL::URL base_url);
|
||||
Optional<DeprecatedFlyString> normalise_specifier_key(JS::Realm& realm, DeprecatedFlyString specifier_key, URL::URL base_url);
|
||||
Optional<FlyString> normalize_specifier_key(JS::Realm& realm, FlyString specifier_key, URL::URL base_url);
|
||||
WebIDL::ExceptionOr<ModuleSpecifierMap> sort_and_normalise_module_specifier_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
|
||||
WebIDL::ExceptionOr<HashMap<URL::URL, ModuleSpecifierMap>> sort_and_normalise_scopes(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
|
||||
WebIDL::ExceptionOr<ModuleIntegrityMap> normalize_module_integrity_map(JS::Realm& realm, JS::Object& original_map, URL::URL base_url);
|
||||
|
|
|
@ -521,8 +521,8 @@ WebIDL::ExceptionOr<void> serialize_reg_exp_object(JS::VM& vm, SerializationReco
|
|||
// Note: A Regex<ECMA262> object is perfectly happy to be reconstructed with just the source+flags
|
||||
// In the future, we could optimize the work being done on the deserialize step by serializing
|
||||
// more of the internal state (the [[RegExpMatcher]] internal slot)
|
||||
TRY(serialize_string(vm, serialized, TRY_OR_THROW_OOM(vm, String::from_byte_string(regexp_object.pattern()))));
|
||||
TRY(serialize_string(vm, serialized, TRY_OR_THROW_OOM(vm, String::from_byte_string(regexp_object.flags()))));
|
||||
TRY(serialize_string(vm, serialized, regexp_object.pattern()));
|
||||
TRY(serialize_string(vm, serialized, regexp_object.flags()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -684,8 +684,8 @@ WebIDL::ExceptionOr<void> serialize_viewed_array_buffer(JS::VM& vm, Vector<u32>&
|
|||
// [[ArrayBufferSerialized]]: bufferSerialized, [[ByteLength]]: value.[[ByteLength]],
|
||||
// [[ByteOffset]]: value.[[ByteOffset]], [[ArrayLength]]: value.[[ArrayLength]] }.
|
||||
serialize_enum(vector, ValueTag::ArrayBufferView);
|
||||
vector.extend(move(buffer_serialized)); // [[ArrayBufferSerialized]]
|
||||
TRY(serialize_string(vm, vector, view.element_name())); // [[Constructor]]
|
||||
vector.extend(move(buffer_serialized)); // [[ArrayBufferSerialized]]
|
||||
TRY(serialize_string(vm, vector, view.element_name().to_string())); // [[Constructor]]
|
||||
serialize_primitive_type(vector, JS::typed_array_byte_length(view_record));
|
||||
serialize_primitive_type(vector, view.byte_offset());
|
||||
serialize_primitive_type(vector, JS::typed_array_length(view_record));
|
||||
|
|
|
@ -740,9 +740,9 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
auto const& path = url.paths().first();
|
||||
|
||||
if (path == "processes"sv)
|
||||
define_direct_property("processes", realm.create<Internals::Processes>(realm), JS::default_attributes);
|
||||
define_direct_property("processes"_fly_string, realm.create<Internals::Processes>(realm), JS::default_attributes);
|
||||
else if (path == "settings"sv)
|
||||
define_direct_property("settings", realm.create<Internals::Settings>(realm), JS::default_attributes);
|
||||
define_direct_property("settings"_fly_string, realm.create<Internals::Settings>(realm), JS::default_attributes);
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
@ -119,7 +119,7 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> WindowProxy::internal_ge
|
|||
auto navigable_property_set = m_window->document_tree_child_navigable_target_name_property_set();
|
||||
auto property_key_string = property_key.to_string();
|
||||
|
||||
if (auto navigable = navigable_property_set.get(property_key_string.view()); navigable.has_value()) {
|
||||
if (auto navigable = navigable_property_set.get(property_key_string); navigable.has_value()) {
|
||||
// 1. Let value be the active WindowProxy of the named object of W with the name P.
|
||||
auto value = navigable.value()->active_window_proxy();
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ WebIDL::ExceptionOr<ByteBuffer> serialize_javascript_value_to_json_bytes(JS::VM&
|
|||
auto map_value_js_value = convert_an_infra_value_to_a_json_compatible_javascript_value(realm, map_entry.value);
|
||||
|
||||
// 3. Perform ! CreateDataPropertyOrThrow(jsValue, mapKey, mapValueJSValue).
|
||||
MUST(js_value->create_data_property_or_throw(map_entry.key.to_byte_string(), map_value_js_value));
|
||||
MUST(js_value->create_data_property_or_throw(map_entry.key, map_value_js_value));
|
||||
}
|
||||
|
||||
// 6. Return jsValue.
|
||||
|
|
|
@ -54,7 +54,7 @@ void Instance::initialize(JS::Realm& realm)
|
|||
[&](Wasm::FunctionAddress const& address) {
|
||||
Optional<GC::Ptr<JS::FunctionObject>> object = m_function_instances.get(address);
|
||||
if (!object.has_value()) {
|
||||
object = Detail::create_native_function(vm, address, export_.name(), this);
|
||||
object = Detail::create_native_function(vm, address, MUST(String::from_byte_string(export_.name())), this);
|
||||
m_function_instances.set(address, *object);
|
||||
}
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@ JS::ThrowCompletionOr<NonnullRefPtr<CompiledWebAssemblyModule>> compile_a_webass
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ExportedWasmFunction);
|
||||
|
||||
GC::Ref<ExportedWasmFunction> ExportedWasmFunction::create(JS::Realm& realm, DeprecatedFlyString const& name, Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> behavior, Wasm::FunctionAddress exported_address)
|
||||
GC::Ref<ExportedWasmFunction> ExportedWasmFunction::create(JS::Realm& realm, FlyString const& name, Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> behavior, Wasm::FunctionAddress exported_address)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
auto prototype = realm.intrinsics().function_prototype();
|
||||
|
@ -383,13 +383,13 @@ GC::Ref<ExportedWasmFunction> ExportedWasmFunction::create(JS::Realm& realm, Dep
|
|||
prototype);
|
||||
}
|
||||
|
||||
ExportedWasmFunction::ExportedWasmFunction(DeprecatedFlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>> behavior, Wasm::FunctionAddress exported_address, JS::Object& prototype)
|
||||
ExportedWasmFunction::ExportedWasmFunction(FlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>> behavior, Wasm::FunctionAddress exported_address, JS::Object& prototype)
|
||||
: NativeFunction(move(name), move(behavior), prototype)
|
||||
, m_exported_address(exported_address)
|
||||
{
|
||||
}
|
||||
|
||||
JS::NativeFunction* create_native_function(JS::VM& vm, Wasm::FunctionAddress address, ByteString const& name, Instance* instance)
|
||||
JS::NativeFunction* create_native_function(JS::VM& vm, Wasm::FunctionAddress address, String const& name, Instance* instance)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
Optional<Wasm::FunctionType> type;
|
||||
|
@ -545,7 +545,7 @@ JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value, Wasm::ValueType type)
|
|||
[](Wasm::HostFunction& host_function) {
|
||||
return host_function.name();
|
||||
});
|
||||
return create_native_function(vm, address, name);
|
||||
return create_native_function(vm, address, MUST(String::from_byte_string(name)));
|
||||
}
|
||||
case Wasm::ValueType::ExternReference: {
|
||||
auto ref_ = wasm_value.to<Wasm::Reference>();
|
||||
|
|
|
@ -71,13 +71,13 @@ class ExportedWasmFunction final : public JS::NativeFunction {
|
|||
GC_DECLARE_ALLOCATOR(ExportedWasmFunction);
|
||||
|
||||
public:
|
||||
static GC::Ref<ExportedWasmFunction> create(JS::Realm&, DeprecatedFlyString const& name, ESCAPING Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>, Wasm::FunctionAddress);
|
||||
static GC::Ref<ExportedWasmFunction> create(JS::Realm&, FlyString const& name, ESCAPING Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>, Wasm::FunctionAddress);
|
||||
virtual ~ExportedWasmFunction() override = default;
|
||||
|
||||
Wasm::FunctionAddress exported_address() const { return m_exported_address; }
|
||||
|
||||
protected:
|
||||
ExportedWasmFunction(DeprecatedFlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>>, Wasm::FunctionAddress, Object& prototype);
|
||||
ExportedWasmFunction(FlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>>, Wasm::FunctionAddress, Object& prototype);
|
||||
|
||||
private:
|
||||
Wasm::FunctionAddress m_exported_address;
|
||||
|
@ -87,7 +87,7 @@ WebAssemblyCache& get_cache(JS::Realm&);
|
|||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS::VM&, Wasm::Module const&, GC::Ptr<JS::Object> import_object);
|
||||
JS::ThrowCompletionOr<NonnullRefPtr<CompiledWebAssemblyModule>> compile_a_webassembly_module(JS::VM&, ByteBuffer);
|
||||
JS::NativeFunction* create_native_function(JS::VM&, Wasm::FunctionAddress address, ByteString const& name, Instance* instance = nullptr);
|
||||
JS::NativeFunction* create_native_function(JS::VM&, Wasm::FunctionAddress address, String const& name, Instance* instance = nullptr);
|
||||
JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM&, JS::Value value, Wasm::ValueType const& type);
|
||||
Wasm::Value default_webassembly_value(JS::VM&, Wasm::ValueType type);
|
||||
JS::Value to_js_value(JS::VM&, Wasm::Value& wasm_value, Wasm::ValueType type);
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
namespace Web::WebDriver {
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-web-window-identifier
|
||||
static JS::PropertyKey const WEB_WINDOW_IDENTIFIER { "window-fcc6-11e5-b4f8-330a88ab9d7f" };
|
||||
static JS::PropertyKey const WEB_WINDOW_IDENTIFIER { "window-fcc6-11e5-b4f8-330a88ab9d7f"_fly_string };
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-web-frame-identifier
|
||||
static JS::PropertyKey const WEB_FRAME_IDENTIFIER { "frame-075b-4da1-b6ba-e579c2d3230a" };
|
||||
static JS::PropertyKey const WEB_FRAME_IDENTIFIER { "frame-075b-4da1-b6ba-e579c2d3230a"_fly_string };
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-windowproxy-reference-object
|
||||
JsonObject window_proxy_reference_object(HTML::WindowProxy const& window)
|
||||
|
|
|
@ -26,11 +26,11 @@ namespace Web::WebDriver {
|
|||
|
||||
// https://w3c.github.io/webdriver/#dfn-web-element-identifier
|
||||
static String const web_element_identifier = "element-6066-11e4-a52e-4f735466cecf"_string;
|
||||
static JS::PropertyKey web_element_identifier_key { web_element_identifier.to_byte_string() };
|
||||
static JS::PropertyKey web_element_identifier_key { web_element_identifier };
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-shadow-root-identifier
|
||||
static String const shadow_root_identifier = "shadow-6066-11e4-a52e-4f735466cecf"_string;
|
||||
static JS::PropertyKey shadow_root_identifier_key { shadow_root_identifier.to_byte_string() };
|
||||
static JS::PropertyKey shadow_root_identifier_key { shadow_root_identifier };
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-browsing-context-group-node-map
|
||||
static HashMap<GC::RawPtr<HTML::BrowsingContextGroup const>, HashTable<String>> browsing_context_group_node_map;
|
||||
|
|
|
@ -67,7 +67,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(HTML::BrowsingCo
|
|||
// The result of parsing global scope above.
|
||||
// strict
|
||||
// The result of parsing strict above.
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, "", move(source_text), function_expression->body(), function_expression->parameters(), function_expression->function_length(), function_expression->local_variables_names(), &global_scope, nullptr, function_expression->kind(), function_expression->is_strict_mode(), function_expression->parsing_insights());
|
||||
auto function = JS::ECMAScriptFunctionObject::create(realm, ""_fly_string, move(source_text), function_expression->body(), function_expression->parameters(), function_expression->function_length(), function_expression->local_variables_names(), &global_scope, nullptr, function_expression->kind(), function_expression->is_strict_mode(), function_expression->parsing_insights());
|
||||
|
||||
// 9. Let completion be Function.[[Call]](window, parameters) with function as the this value.
|
||||
// NOTE: This is not entirely clear, but I don't think they mean actually passing `function` as
|
||||
|
|
|
@ -170,7 +170,7 @@ struct Formatter<Web::WebIDL::Exception> : Formatter<FormatString> {
|
|||
|
||||
if (value.is_object()) {
|
||||
auto& object = value.as_object();
|
||||
static const JS::PropertyKey message_property_key { "message" };
|
||||
static const JS::PropertyKey message_property_key { "message"_fly_string };
|
||||
auto has_message_or_error = object.has_own_property(message_property_key);
|
||||
if (!has_message_or_error.is_error() && has_message_or_error.value()) {
|
||||
auto message_object = object.get_without_side_effects(message_property_key);
|
||||
|
|
|
@ -228,7 +228,7 @@ JS::ThrowCompletionOr<ResolvedOverload> resolve_overload(JS::VM& vm, IDL::Effect
|
|||
// then remove from S all other entries.
|
||||
else if (value.is_object() && value.as_object().is_typed_array()
|
||||
&& has_overload_with_argument_type_or_subtype_matching(overloads, i, [&](IDL::Type const& type) {
|
||||
if (type.is_plain() && (type.name() == static_cast<JS::TypedArrayBase const&>(value.as_object()).element_name() || type.name() == "BufferSource" || type.name() == "ArrayBufferView"))
|
||||
if (type.is_plain() && (type.name() == static_cast<JS::TypedArrayBase const&>(value.as_object()).element_name().bytes_as_string_view() || type.name() == "BufferSource" || type.name() == "ArrayBufferView"))
|
||||
return true;
|
||||
if (type.is_object())
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue