mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb/CSS: Keep invalid parts of <forgiving-selector-list>
s around
Attempt 2! Reverts 2a5dbedad4
This time, set up a different combinator when producing a relative
invalid selector rather than a standalone one. This fixes the crash.
Original description below for simplicity because it still applies.
---
Selectors like `:is(.valid, &!?!?!invalid)` need to keep the invalid
part around, even though it will never match, for a couple of reasons:
- Serialization needs to include them
- For nesting, we care if a `&` appeared anywhere in the selector, even
in an invalid part.
So this patch introduces an `Invalid` simple selector type, which simply
holds its original ComponentValues. We search through these looking for
`&`, and we dump them out directly when asked to serialize.
This commit is contained in:
parent
329cd946ac
commit
5a1eb9e220
Notes:
github-actions[bot]
2024-11-14 12:20:58 +00:00
Author: https://github.com/AtkinsSJ
Commit: 5a1eb9e220
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2335
8 changed files with 111 additions and 3 deletions
|
@ -506,6 +506,9 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector, int in
|
|||
case CSS::Selector::SimpleSelector::Type::Nesting:
|
||||
type_description = "Nesting";
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::Type::Invalid:
|
||||
type_description = "INVALID";
|
||||
break;
|
||||
}
|
||||
|
||||
builder.appendff("{}:", type_description);
|
||||
|
@ -599,6 +602,14 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector, int in
|
|||
builder.appendff(", value='{}']", attribute.value);
|
||||
}
|
||||
|
||||
if (simple_selector.type == CSS::Selector::SimpleSelector::Type::Invalid) {
|
||||
auto invalid = simple_selector.value.get<CSS::Selector::SimpleSelector::Invalid>();
|
||||
builder.append(" '"sv);
|
||||
for (auto const& component_value : invalid.component_values)
|
||||
builder.append(component_value.to_string());
|
||||
builder.append("'"sv);
|
||||
}
|
||||
|
||||
if (i != relative_selector.simple_selectors.size() - 1)
|
||||
builder.append(", "sv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue