mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Use available size in calculate_inner_height()
Although the parameter is named "available size," it is always supposed to represent the containing block size whenever it has a definite value. Therefore, it is possible to simply use this value instead of performing a containing block lookup. This change actually improves correctness for grid items whose containing block is defined by the grid area, as `Node::containing_block()` does not account for this.
This commit is contained in:
parent
e3499c7953
commit
6481ef821d
Notes:
github-actions[bot]
2024-09-15 16:01:00 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 6481ef821d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1407
3 changed files with 37 additions and 11 deletions
|
@ -1639,19 +1639,10 @@ CSSPixels FormattingContext::calculate_inner_width(Layout::Box const& box, Avail
|
|||
return width.resolved(box, width_of_containing_block).to_px(box);
|
||||
}
|
||||
|
||||
CSSPixels FormattingContext::calculate_inner_height(Layout::Box const& box, AvailableSize const&, CSS::Size const& height) const
|
||||
CSSPixels FormattingContext::calculate_inner_height(Layout::Box const& box, AvailableSize const& available_height, CSS::Size const& height) const
|
||||
{
|
||||
VERIFY(!height.is_auto());
|
||||
|
||||
auto const* containing_block = box.non_anonymous_containing_block();
|
||||
auto const& containing_block_state = m_state.get(*containing_block);
|
||||
auto height_of_containing_block = containing_block_state.content_height();
|
||||
if (box.computed_values().position() == CSS::Positioning::Absolute) {
|
||||
// https://www.w3.org/TR/css-position-3/#def-cb
|
||||
// If the box has position: absolute, then the containing block is formed by the padding edge of the ancestor
|
||||
height_of_containing_block += containing_block_state.padding_top + containing_block_state.padding_bottom;
|
||||
}
|
||||
|
||||
auto height_of_containing_block = available_height.to_px_or_zero();
|
||||
auto& computed_values = box.computed_values();
|
||||
if (computed_values.box_sizing() == CSS::BoxSizing::BorderBox) {
|
||||
auto width_of_containing_block = containing_block_width_for(box);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue