LibJS: Replace PropertyKey(char[]) with PropertyKey(FlyString)

...and deal with the fallout.
This commit is contained in:
Andreas Kling 2025-03-16 21:25:29 -05:00 committed by Andreas Kling
commit 53da8893ac
Notes: github-actions[bot] 2025-03-24 22:28:43 +00:00
55 changed files with 254 additions and 251 deletions

View file

@ -139,7 +139,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
realm, [function = GC::make_root(*value)](auto& vm) {
return JS::call(vm, function.value(), JS::js_undefined(), vm.running_execution_context().arguments.span());
},
0, "");
0);
}
// 3. Set crossOriginDesc to PropertyDescriptor{ [[Value]]: value, [[Enumerable]]: false, [[Writable]]: false, [[Configurable]]: true }.
@ -156,7 +156,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
realm, [object_ptr, getter = GC::make_root(*original_descriptor->get)](auto& vm) {
return JS::call(vm, getter.cell(), object_ptr, vm.running_execution_context().arguments.span());
},
0, "");
0);
}
// 3. Let crossOriginSet be undefined.
@ -168,7 +168,7 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
realm, [object_ptr, setter = GC::make_root(*original_descriptor->set)](auto& vm) {
return JS::call(vm, setter.cell(), object_ptr, vm.running_execution_context().arguments.span());
},
0, "");
0);
}
// 5. Set crossOriginDesc to PropertyDescriptor{ [[Get]]: crossOriginGet, [[Set]]: crossOriginSet, [[Enumerable]]: false, [[Configurable]]: true }.

View file

@ -385,7 +385,7 @@ void HTMLDialogElement::set_close_watcher()
event.prevent_default();
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto cancel_callback = realm().heap().allocate<WebIDL::CallbackType>(*cancel_callback_function, realm());
m_close_watcher->add_event_listener_without_options(HTML::EventNames::cancel, DOM::IDLEventListener::create(realm(), cancel_callback));
// - closeAction being to close the dialog given dialog and dialog's request close return value.
@ -395,7 +395,7 @@ void HTMLDialogElement::set_close_watcher()
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto close_callback = realm().heap().allocate<WebIDL::CallbackType>(*close_callback_function, realm());
m_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
// - getEnabledState being to return true if dialog's enable close watcher for requestClose() is true or dialog's computed closed-by state is not None; otherwise false.

View file

@ -1332,7 +1332,7 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
return JS::js_undefined();
},
0, "", &realm());
0, FlyString {}, &realm());
auto close_callback = realm().heap().allocate<WebIDL::CallbackType>(*close_callback_function, realm());
m_popover_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
// - getEnabledState being to return true.

View file

@ -1051,7 +1051,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
commit_pending_changes();
return JS::js_undefined();
},
0, "", &realm());
0, FlyString {}, &realm());
auto mouseup_callback = realm().heap().allocate<WebIDL::CallbackType>(*mouseup_callback_function, realm());
DOM::AddEventListenerOptions mouseup_listener_options;
mouseup_listener_options.once = true;
@ -1064,7 +1064,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
}
return JS::js_undefined();
},
0, "", &realm());
0, FlyString {}, &realm());
auto step_up_callback = realm().heap().allocate<WebIDL::CallbackType>(*up_callback_function, realm());
up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_up_callback));
up_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
@ -1086,7 +1086,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
}
return JS::js_undefined();
},
0, "", &realm());
0, FlyString {}, &realm());
auto step_down_callback = realm().heap().allocate<WebIDL::CallbackType>(*down_callback_function, realm());
down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_down_callback));
down_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
@ -1147,7 +1147,7 @@ void HTMLInputElement::create_file_input_shadow_tree()
return JS::js_undefined();
};
auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, "", &realm);
auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, FlyString {}, &realm);
auto on_button_click_callback = realm.heap().allocate<WebIDL::CallbackType>(on_button_click_function, realm);
m_file_button->add_event_listener_without_options(UIEvents::EventNames::click, DOM::IDLEventListener::create(realm, on_button_click_callback));
@ -1198,7 +1198,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
auto keydown_callback_function = JS::NativeFunction::create(
realm(), [this](JS::VM& vm) {
auto key = MUST(vm.argument(0).get(vm, "key")).as_string().utf8_string();
auto key = MUST(vm.argument(0).get(vm, "key"_fly_string)).as_string().utf8_string();
if (key == "ArrowLeft" || key == "ArrowDown")
MUST(step_down());
@ -1213,13 +1213,13 @@ void HTMLInputElement::create_range_input_shadow_tree()
user_interaction_did_change_input_value();
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto keydown_callback = realm().heap().allocate<WebIDL::CallbackType>(*keydown_callback_function, realm());
add_event_listener_without_options(UIEvents::EventNames::keydown, DOM::IDLEventListener::create(realm(), keydown_callback));
auto wheel_callback_function = JS::NativeFunction::create(
realm(), [this](JS::VM& vm) {
auto delta_y = MUST(vm.argument(0).get(vm, "deltaY")).as_i32();
auto delta_y = MUST(vm.argument(0).get(vm, "deltaY"_fly_string)).as_i32();
if (delta_y > 0) {
MUST(step_down());
} else {
@ -1228,12 +1228,12 @@ void HTMLInputElement::create_range_input_shadow_tree()
user_interaction_did_change_input_value();
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto wheel_callback = realm().heap().allocate<WebIDL::CallbackType>(*wheel_callback_function, realm());
add_event_listener_without_options(UIEvents::EventNames::wheel, DOM::IDLEventListener::create(realm(), wheel_callback));
auto update_slider_by_mouse = [this](JS::VM& vm) {
auto client_x = MUST(vm.argument(0).get(vm, "clientX")).as_double();
auto client_x = MUST(vm.argument(0).get(vm, "clientX"_fly_string)).as_double();
auto rect = get_bounding_client_rect();
double minimum = *min();
double maximum = *max();
@ -1251,7 +1251,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
update_slider_by_mouse(vm);
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto mousemove_callback = realm().heap().allocate<WebIDL::CallbackType>(*mousemove_callback_function, realm());
auto mousemove_listener = DOM::IDLEventListener::create(realm(), mousemove_callback);
auto& window = static_cast<HTML::Window&>(relevant_global_object(*this));
@ -1263,7 +1263,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
window.remove_event_listener_without_options(UIEvents::EventNames::mousemove, mousemove_listener);
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto mouseup_callback = realm().heap().allocate<WebIDL::CallbackType>(*mouseup_callback_function, realm());
DOM::AddEventListenerOptions mouseup_listener_options;
mouseup_listener_options.once = true;
@ -1271,7 +1271,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined();
},
0, "", &realm());
0, ""_fly_string, &realm());
auto mousedown_callback = realm().heap().allocate<WebIDL::CallbackType>(*mousedown_callback_function, realm());
add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback));
}

View file

@ -34,8 +34,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
ModuleSpecifierMap sorted_and_normalised_imports;
// 4. If parsed["imports"] exists, then:
if (TRY(parsed_object.has_property("imports"))) {
auto imports = TRY(parsed_object.get("imports"));
if (TRY(parsed_object.has_property("imports"_fly_string))) {
auto imports = TRY(parsed_object.get("imports"_fly_string));
// If parsed["imports"] is not an ordered map, then throw a TypeError indicating that the value for the "imports" top-level key needs to be a JSON object.
if (!imports.is_object())
@ -49,8 +49,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
HashMap<URL::URL, ModuleSpecifierMap> sorted_and_normalised_scopes;
// 6. If parsed["scopes"] exists, then:
if (TRY(parsed_object.has_property("scopes"))) {
auto scopes = TRY(parsed_object.get("scopes"));
if (TRY(parsed_object.has_property("scopes"_fly_string))) {
auto scopes = TRY(parsed_object.get("scopes"_fly_string));
// If parsed["scopes"] is not an ordered map, then throw a TypeError indicating that the value for the "scopes" top-level key needs to be a JSON object.
if (!scopes.is_object())
@ -64,8 +64,8 @@ WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteStr
ModuleIntegrityMap normalised_integrity;
// 8. If parsed["integrity"] exists, then:
if (TRY(parsed_object.has_property("integrity"))) {
auto integrity = TRY(parsed_object.get("integrity"));
if (TRY(parsed_object.has_property("integrity"_fly_string))) {
auto integrity = TRY(parsed_object.get("integrity"_fly_string));
// 1. If parsed["integrity"] is not an ordered map, then throw a TypeError indicating that the value for the "integrity" top-level key needs to be a JSON object.
if (!integrity.is_object())

View file

@ -121,7 +121,7 @@ GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::count_queuing_strategy_
};
// 2. Let F be ! CreateBuiltinFunction(steps, 0, "size", « », globalObjects relevant Realm).
auto function = JS::NativeFunction::create(realm, move(steps), 0, "size", &realm);
auto function = JS::NativeFunction::create(realm, move(steps), 0, "size"_fly_string, &realm);
// 3. Set globalObjects count queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObjects relevant settings object.
// FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec
@ -146,7 +146,7 @@ GC::Ref<WebIDL::CallbackType> UniversalGlobalScopeMixin::byte_length_queuing_str
};
// 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObjects relevant Realm).
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm);
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size"_fly_string, &realm);
// 3. Set globalObjects byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObjects relevant settings object.
// FIXME: Update spec comment to pass globalObject's relevant realm once Streams spec is updated for ShadowRealm spec

View file

@ -734,7 +734,7 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
WindowOrWorkerGlobalScopeMixin::initialize(realm);
if (s_internals_object_exposed)
define_direct_property("internals", realm.create<Internals::Internals>(realm), JS::default_attributes);
define_direct_property("internals"_fly_string, realm.create<Internals::Internals>(realm), JS::default_attributes);
if (url.scheme() == "about"sv && url.paths().size() == 1) {
auto const& path = url.paths().first();

View file

@ -633,7 +633,7 @@ void WindowOrWorkerGlobalScopeMixin::queue_the_performance_observer_task()
// droppedEntriesCount if droppedEntriesCount is not null, otherwise unset.
auto callback_options = JS::Object::create(realm, realm.intrinsics().object_prototype());
if (dropped_entries_count.has_value())
MUST(callback_options->create_data_property("droppedEntriesCount", JS::Value(dropped_entries_count.value())));
MUST(callback_options->create_data_property("droppedEntriesCount"_fly_string, JS::Value(dropped_entries_count.value())));
// 9. Call pos observer callback with observerEntryList as the first argument, with po as the second
// argument and as callback this value, and with callbackOptions as the third argument.