diff --git a/Libraries/LibJS/Console.cpp b/Libraries/LibJS/Console.cpp index 6b81804d8ce..a5372e6f993 100644 --- a/Libraries/LibJS/Console.cpp +++ b/Libraries/LibJS/Console.cpp @@ -172,7 +172,7 @@ static ThrowCompletionOr> create_table_row(Realm& realm, Value r // 2. Set `row["(index)"]` to `rowIndex` { - auto key = PropertyKey("(index)"); + auto key = PropertyKey { "(index)", PropertyKey::StringMayBeNumber::No }; TRY(row->set(key, row_index, Object::ShouldThrowExceptions::No)); add_column(key); @@ -228,12 +228,11 @@ static ThrowCompletionOr> create_table_row(Realm& realm, Value r } // 5. Otherwise, else { - PropertyKey key("Value"); // 5.1. Set `row["Value"]` to `tabularDataItem` - TRY(row->set(key, tabular_data_item, Object::ShouldThrowExceptions::No)); + TRY(row->set(vm.names.Value, tabular_data_item, Object::ShouldThrowExceptions::No)); // 5.2. If `finalColumns` does not contain "Value", append "Value" to `finalColumns` - add_column(key); + add_column(vm.names.Value); } // 6. Return row @@ -322,10 +321,10 @@ ThrowCompletionOr Console::table() auto final_data = Object::create(realm(), nullptr); // 5.2. Set `finalData["rows"]` to `finalRows` - TRY(final_data->set(PropertyKey("rows"), table_rows, Object::ShouldThrowExceptions::No)); + TRY(final_data->set(vm.names.rows, table_rows, Object::ShouldThrowExceptions::No)); // 5.3. Set finalData["columns"] to finalColumns - TRY(final_data->set(PropertyKey("columns"), table_cols, Object::ShouldThrowExceptions::No)); + TRY(final_data->set(vm.names.columns, table_cols, Object::ShouldThrowExceptions::No)); // 5.4. Perform `Printer("table", finalData)` GC::MarkedVector args(vm.heap()); diff --git a/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Libraries/LibJS/Runtime/CommonPropertyNames.h index 2a271c5bad0..5eba514b65e 100644 --- a/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -13,6 +13,7 @@ namespace JS { #define ENUMERATE_STANDARD_PROPERTY_NAMES(P) \ + P(_) \ P(__defineGetter__) \ P(__defineSetter__) \ P(__lookupGetter__) \ @@ -94,6 +95,7 @@ namespace JS { P(copyWithin) \ P(cos) \ P(cosh) \ + P(columns) \ P(count) \ P(countReset) \ P(create) \ @@ -123,6 +125,7 @@ namespace JS { P(difference) \ P(dir) \ P(direction) \ + P(disabledFeatures) \ P(disambiguation) \ P(disposed) \ P(done) \ @@ -170,6 +173,7 @@ namespace JS { P(fontcolor) \ P(fontsize) \ P(forEach) \ + P(formAssociated) \ P(format) \ P(formatMatcher) \ P(formatRange) \ @@ -366,10 +370,12 @@ namespace JS { P(Number) \ P(numberingSystem) \ P(numeric) \ + P(observedAttributes) \ P(of) \ P(offset) \ P(offsetNanoseconds) \ P(omitPadding) \ + P(opener) \ P(overflow) \ P(ownKeys) \ P(padEnd) \ @@ -419,6 +425,7 @@ namespace JS { P(roundingIncrement) \ P(roundingMode) \ P(roundingPriority) \ + P(rows) \ P(script) \ P(seal) \ P(second) \ @@ -569,6 +576,7 @@ namespace JS { P(use) \ P(useGrouping) \ P(UTC) \ + P(Value) \ P(value) \ P(valueOf) \ P(values) \ diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index cf9dcbfc20d..3cf00039511 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -156,7 +156,7 @@ static WebIDL::ExceptionOr> process_a_keyframe_like_object(JS:: auto name = input_property.as_string().utf8_string(); if (name == "all"sv) { - all_value = TRY(keyframe_object.get(JS::PropertyKey { "all"sv })); + all_value = TRY(keyframe_object.get(vm.names.all)); for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) { auto property = static_cast(i); if (CSS::is_animatable_property(property)) @@ -183,7 +183,7 @@ static WebIDL::ExceptionOr> 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 key { property_name.to_byte_string(), JS::PropertyKey::StringMayBeNumber::No }; auto raw_value = TRY(keyframe_object.has_property(key)) ? TRY(keyframe_object.get(key)) : *all_value; using PropertyValuesType = Conditional, String>; @@ -827,7 +827,7 @@ WebIDL::ExceptionOr> KeyframeEffect::get_keyframes for (auto const& [id, value] : keyframe.parsed_properties()) { auto value_string = JS::PrimitiveString::create(vm, value->to_string()); - TRY(object->set(JS::PropertyKey(DeprecatedFlyString(CSS::camel_case_string_from_property_id(id))), value_string, ShouldThrowExceptions::Yes)); + TRY(object->set(JS::PropertyKey { DeprecatedFlyString(CSS::camel_case_string_from_property_id(id)), JS::PropertyKey::StringMayBeNumber::No }, value_string, ShouldThrowExceptions::Yes)); } m_keyframe_objects.append(object); diff --git a/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp b/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp index 4eab2510695..a062418bb3e 100644 --- a/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp +++ b/Libraries/LibWeb/HTML/CustomElements/CustomElementRegistry.cpp @@ -218,7 +218,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We VERIFY(attribute_changed_callback_iterator != lifecycle_callbacks.end()); if (attribute_changed_callback_iterator->value) { // 1. Let observedAttributesIterable be ? Get(constructor, "observedAttributes"). - auto observed_attributes_iterable = TRY(constructor->callback->get(JS::PropertyKey { "observedAttributes" })); + auto observed_attributes_iterable = TRY(constructor->callback->get(vm.names.observedAttributes)); // 2. If observedAttributesIterable is not undefined, then set observedAttributes to the result of converting observedAttributesIterable to a sequence. Rethrow any exceptions from the conversion. if (!observed_attributes_iterable.is_undefined()) @@ -229,7 +229,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We Vector disabled_features; // 7. Let disabledFeaturesIterable be ? Get(constructor, "disabledFeatures"). - auto disabled_features_iterable = TRY(constructor->callback->get(JS::PropertyKey { "disabledFeatures" })); + auto disabled_features_iterable = TRY(constructor->callback->get(vm.names.disabledFeatures)); // 8. If disabledFeaturesIterable is not undefined, then set disabledFeatures to the result of converting disabledFeaturesIterable to a sequence. Rethrow any exceptions from the conversion. if (!disabled_features_iterable.is_undefined()) @@ -242,7 +242,7 @@ JS::ThrowCompletionOr CustomElementRegistry::define(String const& name, We disable_shadow = disabled_features.contains_slow("shadow"sv); // 11. Let formAssociatedValue be ? Get( constructor, "formAssociated"). - auto form_associated_value = TRY(constructor->callback->get(JS::PropertyKey { "formAssociated" })); + auto form_associated_value = TRY(constructor->callback->get(vm.names.formAssociated)); // 12. Set formAssociated to the result of converting formAssociatedValue to a boolean. Rethrow any exceptions from the conversion. // NOTE: Converting to a boolean cannot throw with ECMAScript. diff --git a/Libraries/LibWeb/HTML/Window.cpp b/Libraries/LibWeb/HTML/Window.cpp index 7aa2ce2d79e..db340cbe288 100644 --- a/Libraries/LibWeb/HTML/Window.cpp +++ b/Libraries/LibWeb/HTML/Window.cpp @@ -935,8 +935,7 @@ WebIDL::ExceptionOr Window::set_opener(JS::Value value) // 2. If the given value is non-null, then perform ? DefinePropertyOrThrow(this, "opener", { [[Value]]: the given value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }). if (!value.is_null()) { - static JS::PropertyKey opener_property_key { "opener", JS::PropertyKey::StringMayBeNumber::No }; - TRY(define_property_or_throw(opener_property_key, { .value = value, .writable = true, .enumerable = true, .configurable = true })); + TRY(define_property_or_throw(vm().names.opener, { .value = value, .writable = true, .enumerable = true, .configurable = true })); } return {}; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 784e0233ca9..9c81b1fbbe2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3954,6 +3954,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) } } else if (auto put_forwards_identifier = attribute.extended_attributes.get("PutForwards"sv); put_forwards_identifier.has_value()) { attribute_generator.set("put_forwards_identifier"sv, *put_forwards_identifier); + VERIFY(!put_forwards_identifier->is_empty() && !is_ascii_digit(put_forwards_identifier->byte_at(0))); // Ensure `PropertyKey`s are not Numbers. attribute_generator.append(R"~~~( JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) @@ -3963,7 +3964,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) auto value = vm.argument(0); auto receiver = TRY(throw_dom_exception_if_needed(vm, [&]() { return impl->@attribute.cpp_name@(); })); - TRY(receiver->set(JS::PropertyKey { "@put_forwards_identifier@" }, value, JS::Object::ShouldThrowExceptions::Yes)); + TRY(receiver->set(JS::PropertyKey { "@put_forwards_identifier@", JS::PropertyKey::StringMayBeNumber::No }, value, JS::Object::ShouldThrowExceptions::Yes)); return JS::js_undefined(); } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 57e6f2fe8d7..a5091123b30 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -573,6 +573,7 @@ bool is_animatable_property(PropertyID property_id) properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); + VERIFY(!name.is_empty() && !is_ascii_digit(name[0])); // Ensure `PropertyKey`s are not Numbers. if (is_legacy_alias(value.as_object())) return; diff --git a/Services/WebContent/WebContentConsoleClient.cpp b/Services/WebContent/WebContentConsoleClient.cpp index 821df1cb2b8..f830b7a78b4 100644 --- a/Services/WebContent/WebContentConsoleClient.cpp +++ b/Services/WebContent/WebContentConsoleClient.cpp @@ -152,8 +152,8 @@ JS::ThrowCompletionOr WebContentConsoleClient::printer(JS::Console::L auto table_args = arguments.get>(); auto& table = table_args.at(0).as_object(); - auto& columns = TRY(table.get(JS::PropertyKey("columns"))).as_array().indexed_properties(); - auto& rows = TRY(table.get(JS::PropertyKey("rows"))).as_array().indexed_properties(); + auto& columns = TRY(table.get(vm.names.columns)).as_array().indexed_properties(); + auto& rows = TRY(table.get(vm.names.rows)).as_array().indexed_properties(); StringBuilder html; diff --git a/Utilities/js.cpp b/Utilities/js.cpp index 3564e871407..fca406b13ec 100644 --- a/Utilities/js.cpp +++ b/Utilities/js.cpp @@ -344,10 +344,10 @@ void ReplObject::initialize(JS::Realm& realm) outln("Disable writing last value to '_'"); // We must delete first otherwise this setter gets called recursively. - TRY(global_object.internal_delete(JS::PropertyKey { "_" })); + TRY(global_object.internal_delete(vm.names._)); auto value = vm.argument(0); - TRY(global_object.internal_set(JS::PropertyKey { "_" }, value, &global_object)); + TRY(global_object.internal_set(vm.names._, value, &global_object)); return value; }, attr);