mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:47:35 +00:00
LibWeb: Resolve horizontal auto margins for images with display: block
This commit is contained in:
parent
f7e034d4b2
commit
5236819f58
3 changed files with 20 additions and 0 deletions
|
@ -0,0 +1,4 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x116 children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 400x100 children: not-inline
|
||||
ImageBox <img> at (158,8) content-size 100x100 children: not-inline
|
|
@ -0,0 +1,11 @@
|
|||
<!doctype html><style>
|
||||
body {
|
||||
width: 400px;
|
||||
}
|
||||
img {
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style><img/>
|
|
@ -210,6 +210,11 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
};
|
||||
|
||||
auto input_width = [&] {
|
||||
if (is<ReplacedBox>(box)) {
|
||||
// NOTE: Replaced elements had their width calculated independently above.
|
||||
// We use that width as the input here to ensure that margins get resolved.
|
||||
return CSS::Length::make_px(box_state.content_width());
|
||||
}
|
||||
if (is<TableWrapper>(box))
|
||||
return CSS::Length::make_px(compute_width_for_table_wrapper(box, available_space));
|
||||
if (should_treat_width_as_auto(box, available_space))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue