mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibWeb: Skip children based on media when updating the source set
If child has a media attribute and its value does not match the environment, continue to the next child.
This commit is contained in:
parent
87ac906ee6
commit
29d29134ba
5 changed files with 32 additions and 1 deletions
13
Tests/LibWeb/Layout/expected/picture-source-media-query.txt
Normal file
13
Tests/LibWeb/Layout/expected/picture-source-media-query.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x416 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x400 children: inline
|
||||
line 0 width: 400, height: 400, bottom: 400, baseline: 400
|
||||
frag 0 from ImageBox start: 0, length: 0, rect: [8,8 400x400]
|
||||
TextNode <#text>
|
||||
InlineNode <picture>
|
||||
TextNode <#text>
|
||||
InlineNode <source>
|
||||
TextNode <#text>
|
||||
ImageBox <img> at (8,8) content-size 400x400 children: not-inline
|
||||
TextNode <#text>
|
||||
TextNode <#text>
|
BIN
Tests/LibWeb/Layout/input/120.png
Normal file
BIN
Tests/LibWeb/Layout/input/120.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 572 B |
BIN
Tests/LibWeb/Layout/input/400.png
Normal file
BIN
Tests/LibWeb/Layout/input/400.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 592 B |
11
Tests/LibWeb/Layout/input/picture-source-media-query.html
Normal file
11
Tests/LibWeb/Layout/input/picture-source-media-query.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<body>
|
||||
<picture>
|
||||
<source media="(max-width: 600px)" srcset="120.png">
|
||||
<img src="400.png">
|
||||
</picture>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -741,7 +741,14 @@ static void update_the_source_set(DOM::Element& element)
|
|||
if (source_set.is_empty())
|
||||
continue;
|
||||
|
||||
// FIXME: 6. If child has a media attribute, and its value does not match the environment, continue to the next child.
|
||||
// 6. If child has a media attribute, and its value does not match the environment, continue to the next child.
|
||||
if (child->has_attribute(HTML::AttributeNames::media)) {
|
||||
auto media_query = parse_media_query(CSS::Parser::ParsingContext { element.document() },
|
||||
child->attribute(HTML::AttributeNames::media));
|
||||
if (!media_query || !media_query->evaluate(element.document().window())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Parse child's sizes attribute, and let source set's source size be the returned value.
|
||||
source_set.m_source_size = parse_a_sizes_attribute(element.document(), child->attribute(HTML::AttributeNames::sizes));
|
||||
|
|
Loading…
Add table
Reference in a new issue