mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
LibWeb: Skip abspos boxes layout in intrinsic sizing mode
Absolutely positioned boxes do not affect the size of the formatting context box they belong to, so it's safe to skip their layout entirely when calculating intrinsic size.
This commit is contained in:
parent
90b8bfc04c
commit
4eb16b144e
Notes:
github-actions[bot]
2024-09-11 07:30:53 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/4eb16b144e2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1367
3 changed files with 14 additions and 6 deletions
|
@ -108,12 +108,14 @@ void BlockFormattingContext::parent_context_did_dimension_child_root_box()
|
||||||
box_state.set_content_x(float_containing_block_width - floating_box->offset_from_edge);
|
box_state.set_content_x(float_containing_block_width - floating_box->offset_from_edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can also layout absolutely positioned boxes within this BFC.
|
if (m_layout_mode == LayoutMode::Normal) {
|
||||||
for (auto& box : m_absolutely_positioned_boxes) {
|
// We can also layout absolutely positioned boxes within this BFC.
|
||||||
auto& cb_state = m_state.get(*box->containing_block());
|
for (auto& box : m_absolutely_positioned_boxes) {
|
||||||
auto available_width = AvailableSize::make_definite(cb_state.content_width() + cb_state.padding_left + cb_state.padding_right);
|
auto& cb_state = m_state.get(*box->containing_block());
|
||||||
auto available_height = AvailableSize::make_definite(cb_state.content_height() + cb_state.padding_top + cb_state.padding_bottom);
|
auto available_width = AvailableSize::make_definite(cb_state.content_width() + cb_state.padding_left + cb_state.padding_right);
|
||||||
layout_absolutely_positioned_element(box, AvailableSpace(available_width, available_height));
|
auto available_height = AvailableSize::make_definite(cb_state.content_height() + cb_state.padding_top + cb_state.padding_bottom);
|
||||||
|
layout_absolutely_positioned_element(box, AvailableSpace(available_width, available_height));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,9 @@ void FlexFormattingContext::run(AvailableSpace const& available_space)
|
||||||
|
|
||||||
void FlexFormattingContext::parent_context_did_dimension_child_root_box()
|
void FlexFormattingContext::parent_context_did_dimension_child_root_box()
|
||||||
{
|
{
|
||||||
|
if (m_layout_mode != LayoutMode::Normal)
|
||||||
|
return;
|
||||||
|
|
||||||
flex_container().for_each_child_of_type<Box>([&](Layout::Box& box) {
|
flex_container().for_each_child_of_type<Box>([&](Layout::Box& box) {
|
||||||
if (box.is_absolutely_positioned()) {
|
if (box.is_absolutely_positioned()) {
|
||||||
auto& cb_state = m_state.get(*box.containing_block());
|
auto& cb_state = m_state.get(*box.containing_block());
|
||||||
|
|
|
@ -2005,6 +2005,9 @@ void GridFormattingContext::layout_absolutely_positioned_element(Box const& box,
|
||||||
|
|
||||||
void GridFormattingContext::parent_context_did_dimension_child_root_box()
|
void GridFormattingContext::parent_context_did_dimension_child_root_box()
|
||||||
{
|
{
|
||||||
|
if (m_layout_mode != LayoutMode::Normal)
|
||||||
|
return;
|
||||||
|
|
||||||
grid_container().for_each_child_of_type<Box>([&](Layout::Box& box) {
|
grid_container().for_each_child_of_type<Box>([&](Layout::Box& box) {
|
||||||
if (box.is_absolutely_positioned()) {
|
if (box.is_absolutely_positioned()) {
|
||||||
auto& cb_state = m_state.get(*box.containing_block());
|
auto& cb_state = m_state.get(*box.containing_block());
|
||||||
|
|
Loading…
Add table
Reference in a new issue