mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
LibWeb: Throw parsing error if ::slotted()
argument is not 1 compound
...selector. Grammar per spec: `::slotted( <compound-selector> )`, so we should reject selector as invalid if first compound selector is followed by something else. This change makes layout more correct on https://www.rottentomatoes.com/
This commit is contained in:
parent
27caa1e175
commit
308c2eab0e
Notes:
github-actions[bot]
2025-09-04 12:56:37 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 308c2eab0e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6068
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 54 additions and 0 deletions
|
@ -517,6 +517,15 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
||||||
});
|
});
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
}
|
}
|
||||||
|
function_tokens.discard_whitespace();
|
||||||
|
if (function_tokens.has_next_token()) {
|
||||||
|
ErrorReporter::the().report(InvalidPseudoClassOrElementError {
|
||||||
|
.name = MUST(String::formatted("::{}", pseudo_name)),
|
||||||
|
.value_string = name_token.to_string(),
|
||||||
|
.description = "Trailing tokens after compound selector argument."_string,
|
||||||
|
});
|
||||||
|
return ParseError::SyntaxError;
|
||||||
|
}
|
||||||
|
|
||||||
auto compound_selector = compound_selector_or_error.release_value().release_value();
|
auto compound_selector = compound_selector_or_error.release_value().release_value();
|
||||||
compound_selector.combinator = Selector::Combinator::None;
|
compound_selector.combinator = Selector::Combinator::None;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] children: not-inline
|
||||||
|
BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 50 0+0+0] [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at [8,16] [8+0+0 784 0+0+8] [8+0+0 18 0+0+16] children: not-inline
|
||||||
|
BlockContainer <div> at [8,16] [0+0+0 784 0+0+0] [0+0+0 18 0+0+0] children: not-inline
|
||||||
|
Box <ul> at [48,16] flex-container(row) [0+0+40 744 0+0+0] [16+0+0 18 0+0+16] [FFC] children: not-inline
|
||||||
|
ListItemBox <li> at [48,16] flex-item [0+0+0 57.296875 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
|
||||||
|
ListItemMarkerBox <(anonymous)> at [48,16] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline
|
||||||
|
InlineNode <a> at [48,16] [0+0+0 57.296875 0+0+0] [0+0+0 18 0+0+0]
|
||||||
|
frag 0 from TextNode start: 0, length: 5, rect: [48,16 57.296875x18] baseline: 13.796875
|
||||||
|
"HELLO"
|
||||||
|
TextNode <#text> (not painted)
|
||||||
|
ListItemBox <li> at [105.296875,16] flex-item [0+0+0 16.828125 0+0+0] [0+0+0 18 0+0+0] [BFC] children: inline
|
||||||
|
ListItemMarkerBox <(anonymous)> at [105.296875,16] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] children: not-inline
|
||||||
|
InlineNode <a> at [105.296875,16] [0+0+0 16.828125 0+0+0] [0+0+0 18 0+0+0]
|
||||||
|
frag 0 from TextNode start: 0, length: 2, rect: [105.296875,16 16.828125x18] baseline: 13.796875
|
||||||
|
"HI"
|
||||||
|
TextNode <#text> (not painted)
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x50]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,16 784x18]
|
||||||
|
PaintableWithLines (BlockContainer<DIV>) [8,16 784x18]
|
||||||
|
PaintableBox (Box<UL>) [8,16 784x18]
|
||||||
|
PaintableWithLines (ListItemBox<LI>) [48,16 57.296875x18]
|
||||||
|
MarkerPaintable (ListItemMarkerBox(anonymous)) [48,16 0x0]
|
||||||
|
PaintableWithLines (InlineNode<A>) [48,16 57.296875x18]
|
||||||
|
TextPaintable (TextNode<#text>)
|
||||||
|
PaintableWithLines (ListItemBox<LI>) [105.296875,16 16.828125x18]
|
||||||
|
MarkerPaintable (ListItemMarkerBox(anonymous)) [105.296875,16 0x0]
|
||||||
|
PaintableWithLines (InlineNode<A>) [105.296875,16 16.828125x18]
|
||||||
|
TextPaintable (TextNode<#text>)
|
||||||
|
|
||||||
|
SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto)
|
||||||
|
SC for BlockContainer<HTML> [0,0 800x50] [children: 0] (z-index: auto)
|
11
Tests/LibWeb/Layout/input/misc/invalid-slotted-selector.html
Normal file
11
Tests/LibWeb/Layout/input/misc/invalid-slotted-selector.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html><div><template shadowrootmode="open"><style>
|
||||||
|
slot[name='nav-links']::slotted(ul) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
list-style: none;
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
slot[name='nav-links']::slotted(ul > li) { /* This selector is invalid, because ::slotted argument is limited to 1 compound selector */
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style><slot name="nav-links"></slot></template><ul slot="nav-links"><li><a>HELLO</a></li><li><a>HI</a></li></ul></div>
|
Loading…
Add table
Add a link
Reference in a new issue