mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb/CSS: Add flags for element-backed & tree-abiding pseudo-elements
Generate a couple of functions for checking if a pseudo-element fits these categories.
This commit is contained in:
Notes:
github-actions[bot]
2026-04-08 09:38:21 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/492cfc58d9e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8728
@@ -87,6 +87,8 @@ Optional<PseudoElement> aliased_pseudo_element_from_string(StringView);
|
||||
WEB_API StringView pseudo_element_name(PseudoElement);
|
||||
|
||||
bool is_has_allowed_pseudo_element(PseudoElement);
|
||||
bool is_tree_abiding_pseudo_element(PseudoElement);
|
||||
bool is_element_backed_pseudo_element(PseudoElement);
|
||||
bool is_pseudo_element_root(PseudoElement);
|
||||
bool pseudo_element_supports_property(PseudoElement, PropertyID);
|
||||
|
||||
@@ -222,6 +224,65 @@ bool is_has_allowed_pseudo_element(PseudoElement pseudo_element)
|
||||
}
|
||||
}
|
||||
|
||||
bool is_tree_abiding_pseudo_element(PseudoElement pseudo_element)
|
||||
{
|
||||
// Element-backed pseudo-elements are always tree-abiding.
|
||||
// https://drafts.csswg.org/css-pseudo-4/#element-backed
|
||||
if (is_element_backed_pseudo_element(pseudo_element))
|
||||
return true;
|
||||
|
||||
switch (pseudo_element) {
|
||||
)~~~");
|
||||
|
||||
pseudo_elements_data.for_each_member([&](auto& name, JsonValue const& value) {
|
||||
auto& pseudo_element = value.as_object();
|
||||
if (pseudo_element.has("alias-for"sv))
|
||||
return;
|
||||
if (!pseudo_element.get_bool("is-tree-abiding"sv).value_or(false))
|
||||
return;
|
||||
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
|
||||
member_generator.append(R"~~~(
|
||||
case PseudoElement::@name:titlecase@:
|
||||
return true;
|
||||
)~~~");
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_element_backed_pseudo_element(PseudoElement pseudo_element)
|
||||
{
|
||||
switch (pseudo_element) {
|
||||
)~~~");
|
||||
|
||||
pseudo_elements_data.for_each_member([&](auto& name, JsonValue const& value) {
|
||||
auto& pseudo_element = value.as_object();
|
||||
if (pseudo_element.has("alias-for"sv))
|
||||
return;
|
||||
if (!pseudo_element.get_bool("is-element-backed"sv).value_or(false))
|
||||
return;
|
||||
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
|
||||
member_generator.append(R"~~~(
|
||||
case PseudoElement::@name:titlecase@:
|
||||
return true;
|
||||
)~~~");
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_pseudo_element_root(PseudoElement pseudo_element)
|
||||
{
|
||||
switch (pseudo_element) {
|
||||
|
||||
Reference in New Issue
Block a user