mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibWeb: Include all floating descendants in BFC root's automatic height
Before this change, we were only considering floating boxes that were immediate children of the BFC root.
This commit is contained in:
parent
005cd4e456
commit
c9a7853fef
3 changed files with 13 additions and 11 deletions
|
@ -705,6 +705,8 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
|
|||
} else if (box.computed_values().float_() == CSS::Float::Right) {
|
||||
float_box(FloatSide::Right, m_right_floats);
|
||||
}
|
||||
|
||||
m_state.get_mutable(root()).add_floating_descendant(box);
|
||||
}
|
||||
|
||||
void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_item_box)
|
||||
|
|
|
@ -341,18 +341,13 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(L
|
|||
// In addition, if the element has any floating descendants
|
||||
// whose bottom margin edge is below the element's bottom content edge,
|
||||
// then the height is increased to include those edges.
|
||||
root.for_each_child_of_type<Box>([&](Layout::Box& child_box) {
|
||||
if (!child_box.is_floating())
|
||||
return IterationDecision::Continue;
|
||||
for (auto* floating_box : state.get(root).floating_descendants()) {
|
||||
auto const& floating_box_state = state.get(*floating_box);
|
||||
float floating_box_bottom = floating_box_state.offset.y() + floating_box_state.content_height() + floating_box_state.margin_box_bottom();
|
||||
|
||||
auto const& child_box_state = state.get(child_box);
|
||||
float child_box_bottom = child_box_state.offset.y() + child_box_state.content_height() + child_box_state.margin_box_bottom();
|
||||
|
||||
if (!bottom.has_value() || child_box_bottom > bottom.value())
|
||||
bottom = child_box_bottom;
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
if (!bottom.has_value() || floating_box_bottom > bottom.value())
|
||||
bottom = floating_box_bottom;
|
||||
}
|
||||
|
||||
return max(0.0f, bottom.value_or(0) - top.value_or(0));
|
||||
}
|
||||
|
|
|
@ -109,6 +109,9 @@ struct LayoutState {
|
|||
|
||||
Optional<LineBoxFragmentCoordinate> containing_line_box_fragment;
|
||||
|
||||
void add_floating_descendant(Box const& box) { m_floating_descendants.set(&box); }
|
||||
auto const& floating_descendants() const { return m_floating_descendants; }
|
||||
|
||||
private:
|
||||
Layout::NodeWithStyleAndBoxModelMetrics* m_node { nullptr };
|
||||
|
||||
|
@ -117,6 +120,8 @@ struct LayoutState {
|
|||
|
||||
bool m_has_definite_width { false };
|
||||
bool m_has_definite_height { false };
|
||||
|
||||
HashTable<Box const*> m_floating_descendants;
|
||||
};
|
||||
|
||||
void commit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue