mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
LibWeb/CSS: Serialize the initial combinator of relative selectors
Selector::serialize() is used for both normal and relative selectors. For the latter, we need to serialize their initial combinator, and for the former, we always set the initial combinator as None anyway, so this would be a no-op there. Gets us 3 WPT passes.
This commit is contained in:
parent
8536e23674
commit
7de5032e73
Notes:
github-actions[bot]
2025-05-16 22:31:47 +00:00
Author: https://github.com/AtkinsSJ
Commit: 7de5032e73
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4780
2 changed files with 24 additions and 5 deletions
|
@ -496,6 +496,26 @@ String Selector::serialize() const
|
|||
{
|
||||
StringBuilder s;
|
||||
|
||||
// AD-HOC: If this is a relative selector, we need to serialize the starting combinator.
|
||||
if (!compound_selectors().is_empty()) {
|
||||
switch (compound_selectors().first().combinator) {
|
||||
case Combinator::ImmediateChild:
|
||||
s.append("> "sv);
|
||||
break;
|
||||
case Combinator::NextSibling:
|
||||
s.append("+ "sv);
|
||||
break;
|
||||
case Combinator::SubsequentSibling:
|
||||
s.append("~ "sv);
|
||||
break;
|
||||
case Combinator::Column:
|
||||
s.append("|| "sv);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// To serialize a selector let s be the empty string, run the steps below for each part of the chain of the selector, and finally return s:
|
||||
for (size_t i = 0; i < compound_selectors().size(); ++i) {
|
||||
auto const& compound_selector = compound_selectors()[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue