Skip to content

Commit 2d17010

Browse files
committed
LibWeb: Add handling for view transition selector specificity
The corresponding WPT test was not imported since it still fails for unrelated reasons. As it stands right now, we have no way of testing this behavior.
1 parent 4a140b7 commit 2d17010

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Libraries/LibWeb/CSS/Selector.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,14 @@ u32 Selector::specificity() const
266266
++tag_names;
267267
break;
268268
case SimpleSelector::Type::PseudoElement:
269-
// count the number of type selectors and pseudo-elements in the selector (= C)
270-
// FIXME: This needs special handling for view transition pseudos:
271-
// https://drafts.csswg.org/css-view-transitions-1/#named-view-transition-pseudo
269+
// https://drafts.csswg.org/css-view-transitions-1/#named-view-transition-pseudo
270+
// The specificity of a named view transition pseudo-element selector with a <custom-ident> argument is equivalent
271+
// to a type selector. The specificity of a named view transition pseudo-element selector with a '*' argument is zero.
272+
// NB: We just break before adding to the type (tag name) specificity in case this is a named view transition pseudo that uses '*'
273+
if (first_is_one_of(simple_selector.pseudo_element().type(), CSS::PseudoElement::ViewTransitionGroup, CSS::PseudoElement::ViewTransitionImagePair, CSS::PseudoElement::ViewTransitionOld, CSS::PseudoElement::ViewTransitionNew) && simple_selector.pseudo_element().pt_name_selector().is_universal)
274+
break;
275+
276+
// otherwise just count the number of type selectors and pseudo-elements in the selector (= C)
272277
++tag_names;
273278
break;
274279
case SimpleSelector::Type::Universal:

0 commit comments

Comments
 (0)