Skip to content

Commit

Permalink
LibWeb: Fully resolve max-width values on inline-block elements
Browse files Browse the repository at this point in the history
This fixes an issue where `max-width: fit-content` (and other
layout-dependent values) were treated as 0 on inline-blocks.
  • Loading branch information
awesomekling committed Jul 15, 2023
1 parent 1f4f750 commit 2887976
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x35.46875 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x19.46875 children: inline
line 0 width: 102.203125, height: 19.46875, bottom: 19.46875, baseline: 14.53125
frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 100.203125x17.46875]
BlockContainer <span> at (9,9) content-size 100.203125x17.46875 inline-block [BFC] children: inline
line 0 width: 100.203125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 13, rect: [9,9 100.203125x17.46875]
"hello friends"
TextNode <#text>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html><style>
span {
border: 1px solid black;
display: inline-block;
max-width: fit-content;
}
</style><span>hello friends
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l

CSSPixels width = unconstrained_width;
if (!should_treat_max_width_as_none(box, m_available_space->width)) {
auto max_width = box.computed_values().max_width().to_px(box, width_of_containing_block);
auto max_width = calculate_inner_width(box, m_available_space->width, box.computed_values().max_width()).to_px(box);
width = min(width, max_width);
}

Expand Down

0 comments on commit 2887976

Please sign in to comment.