mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Map logical aliases at cascade time
Previously we would incorrectly map these in `CSSStyleProperties::convert_declarations_to_specified_order`, aside from being too early (as it meant we didn't maintain them as distinct from their physical counterparts in CSSStyleProperties), this meant that we didn't yet have the required context to map them correctly. We now map them as part of the cascade process. To compute the mapping context we do a cascade without mapping, and extract the relevant properties (writing-direction and direction).
This commit is contained in:
parent
4e87f85458
commit
cfc8d3031b
Notes:
github-actions[bot]
2025-06-23 14:20:40 +00:00
Author: https://github.com/Calme1709
Commit: cfc8d3031b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5138
Reviewed-by: https://github.com/AtkinsSJ ✅
14 changed files with 848 additions and 141 deletions
|
@ -132,7 +132,7 @@ void populate_all_property_longhands(JsonObject& properties)
|
|||
VERIFY(all_entry.has_value());
|
||||
|
||||
properties.for_each_member([&](auto name, auto value) {
|
||||
if (value.as_object().has_array("longhands"sv) || value.as_object().has_array("logical-alias-for"sv) || value.as_object().has_string("legacy-alias-for"sv) || name == "direction" || name == "unicode-bidi")
|
||||
if (value.as_object().has_array("longhands"sv) || value.as_object().has_string("legacy-alias-for"sv) || name == "direction" || name == "unicode-bidi")
|
||||
return;
|
||||
|
||||
MUST(all_entry->get_array("longhands"sv)->append(JsonValue { name }));
|
||||
|
@ -310,6 +310,8 @@ enum class Quirk {
|
|||
};
|
||||
bool property_has_quirk(PropertyID, Quirk);
|
||||
|
||||
bool property_is_logical_alias(PropertyID);
|
||||
|
||||
} // namespace Web::CSS
|
||||
|
||||
namespace AK {
|
||||
|
@ -1275,6 +1277,33 @@ Vector<PropertyID> shorthands_for_longhand(PropertyID property_id)
|
|||
return { };
|
||||
}
|
||||
}
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
bool property_is_logical_alias(PropertyID property_id)
|
||||
{
|
||||
switch(property_id) {
|
||||
)~~~");
|
||||
|
||||
properties.for_each_member([&](auto& name, auto& value) {
|
||||
if (is_legacy_alias(value.as_object()))
|
||||
return;
|
||||
|
||||
if (value.as_object().has("logical-alias-for"sv)) {
|
||||
auto property_generator = generator.fork();
|
||||
property_generator.set("name:titlecase", title_casify(name));
|
||||
property_generator.append(R"~~~(
|
||||
case PropertyID::@name:titlecase@:
|
||||
)~~~");
|
||||
}
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
)~~~");
|
||||
|
||||
generator.append(R"~~~(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue