1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

AK+Everywhere: Store JSON object keys as String

This commit is contained in:
Timothy Flynn 2025-02-17 12:18:27 -05:00 committed by Tim Flynn
parent 70eb0ba1cd
commit e591636419
Notes: github-actions[bot] 2025-02-21 00:29:28 +00:00
23 changed files with 119 additions and 111 deletions

View file

@ -69,7 +69,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto properties = json.as_object();
// Check we're in alphabetical order
ByteString most_recent_name = "";
String most_recent_name;
properties.for_each_member([&](auto& name, auto&) {
if (name < most_recent_name) {
warnln("`{}` is in the wrong position in `{}`. Please keep this list alphabetical!", name, properties_json_path);
@ -91,7 +91,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
void replace_logical_aliases(JsonObject& properties)
{
AK::HashMap<ByteString, ByteString> logical_aliases;
AK::HashMap<String, ByteString> logical_aliases;
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
auto const& value_as_object = value.as_object();
@ -142,10 +142,10 @@ enum class PropertyID {
All,
)~~~");
Vector<ByteString> inherited_shorthand_property_ids;
Vector<ByteString> inherited_longhand_property_ids;
Vector<ByteString> noninherited_shorthand_property_ids;
Vector<ByteString> noninherited_longhand_property_ids;
Vector<String> inherited_shorthand_property_ids;
Vector<String> inherited_longhand_property_ids;
Vector<String> noninherited_shorthand_property_ids;
Vector<String> noninherited_longhand_property_ids;
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
@ -573,7 +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.
VERIFY(!name.is_empty() && !is_ascii_digit(name.bytes_as_string_view()[0])); // Ensure `PropertyKey`s are not Numbers.
if (is_legacy_alias(value.as_object()))
return;

View file

@ -43,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
static String get_snake_case_function_name_for_css_property_name(ByteString const& name)
static String get_snake_case_function_name_for_css_property_name(StringView name)
{
auto snake_case_name = snake_casify(name);
if (snake_case_name.starts_with('_'))
@ -182,7 +182,7 @@ interface mixin GeneratedCSSStyleProperties {
// For each CSS property property that is a supported CSS property and that begins with the string -webkit-,
// the following partial interface applies where webkit-cased attribute is obtained by running the CSS property
// to IDL attribute algorithm for property, with the lowercase first flag set.
if (name.starts_with("-webkit-"sv)) {
if (name.starts_with_bytes("-webkit-"sv)) {
member_generator.set("name:webkit", css_property_to_idl_attribute(name, /* lowercase_first= */ true));
member_generator.append(R"~~~(
[CEReactions, LegacyNullToEmptyString, AttributeCallbackName=@name:snakecase@_webkit, ImplementedAs=@name:acceptable_cpp@] attribute CSSOMString @name:webkit@;