1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

LibWeb: Resolve cyclic declaration/definitions involving Length

This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibWeb/CSS/GridTrackSize.h>
    // That's it, this was enough to cause a compilation error.
This commit is contained in:
Ben Wiederhake 2022-09-13 17:42:39 +02:00 committed by Sam Atkins
parent 53eb35caba
commit 8deced39a8
15 changed files with 192 additions and 125 deletions

View file

@ -422,8 +422,8 @@ float FormattingContext::compute_width_for_replaced_element(LayoutState const& s
auto zero_value = CSS::Length::make_px(0);
auto width_of_containing_block_as_length = CSS::Length::make_px(containing_block_width_for(box, state));
auto margin_left = box.computed_values().margin().left.resolved(box, width_of_containing_block_as_length).resolved(box);
auto margin_right = box.computed_values().margin().right.resolved(box, width_of_containing_block_as_length).resolved(box);
auto margin_left = box.computed_values().margin().left().resolved(box, width_of_containing_block_as_length).resolved(box);
auto margin_right = box.computed_values().margin().right().resolved(box, width_of_containing_block_as_length).resolved(box);
// A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'.
if (margin_left.is_auto())
@ -519,15 +519,15 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
auto margin_right = CSS::Length::make_auto();
auto const border_left = computed_values.border_left().width;
auto const border_right = computed_values.border_right().width;
auto const padding_left = computed_values.padding().left.resolved(box, width_of_containing_block_as_length).to_px(box);
auto const padding_right = computed_values.padding().right.resolved(box, width_of_containing_block_as_length).to_px(box);
auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length).to_px(box);
auto const padding_right = computed_values.padding().right().resolved(box, width_of_containing_block_as_length).to_px(box);
auto try_compute_width = [&](auto const& a_width) {
margin_left = computed_values.margin().left.resolved(box, width_of_containing_block_as_length).resolved(box);
margin_right = computed_values.margin().right.resolved(box, width_of_containing_block_as_length).resolved(box);
margin_left = computed_values.margin().left().resolved(box, width_of_containing_block_as_length).resolved(box);
margin_right = computed_values.margin().right().resolved(box, width_of_containing_block_as_length).resolved(box);
auto left = computed_values.inset().left.resolved(box, width_of_containing_block_as_length).resolved(box);
auto right = computed_values.inset().right.resolved(box, width_of_containing_block_as_length).resolved(box);
auto left = computed_values.inset().left().resolved(box, width_of_containing_block_as_length).resolved(box);
auto right = computed_values.inset().right().resolved(box, width_of_containing_block_as_length).resolved(box);
auto width = a_width;
auto solve_for_left = [&] {
@ -672,8 +672,8 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
auto height_of_containing_block_as_length = CSS::Length::make_px(height_of_containing_block);
auto const& computed_top = computed_values.inset().top;
auto const& computed_bottom = computed_values.inset().bottom;
auto const& computed_top = computed_values.inset().top();
auto const& computed_bottom = computed_values.inset().bottom();
auto const& computed_height = computed_values.height();
auto const& computed_min_height = computed_values.min_height();
auto const& computed_max_height = computed_values.max_height();
@ -686,12 +686,12 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
tentative_height = computed_values.height().resolved(box, height_of_containing_block_as_length).resolved(box);
auto& box_state = m_state.get_mutable(box);
box_state.margin_top = computed_values.margin().top.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_bottom = computed_values.margin().bottom.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_top = computed_values.margin().top().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_bottom = computed_values.margin().bottom().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.border_top = computed_values.border_top().width;
box_state.border_bottom = computed_values.border_bottom().width;
box_state.padding_top = computed_values.padding().top.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.padding_bottom = computed_values.padding().bottom.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.padding_top = computed_values.padding().top().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.padding_bottom = computed_values.padding().bottom().resolved(box, width_of_containing_block_as_length).to_px(box);
if (computed_height.is_auto() && computed_top.is_auto() && computed_bottom.is_auto()) {
tentative_height = CSS::Length(compute_auto_height_for_block_level_element(m_state, box), CSS::Length::Type::Px);
@ -738,25 +738,25 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box)
compute_height_for_absolutely_positioned_element(box);
auto& box_state = m_state.get_mutable(box);
box_state.margin_left = box.computed_values().margin().left.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_top = box.computed_values().margin().top.resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.margin_right = box.computed_values().margin().right.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_bottom = box.computed_values().margin().bottom.resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.margin_left = box.computed_values().margin().left().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_top = box.computed_values().margin().top().resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.margin_right = box.computed_values().margin().right().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.margin_bottom = box.computed_values().margin().bottom().resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.border_left = box.computed_values().border_left().width;
box_state.border_right = box.computed_values().border_right().width;
box_state.border_top = box.computed_values().border_top().width;
box_state.border_bottom = box.computed_values().border_bottom().width;
box_state.inset_left = box.computed_values().inset().left.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.inset_top = box.computed_values().inset().top.resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.inset_right = box.computed_values().inset().right.resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.inset_bottom = box.computed_values().inset().bottom.resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.inset_left = box.computed_values().inset().left().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.inset_top = box.computed_values().inset().top().resolved(box, height_of_containing_block_as_length).to_px(box);
box_state.inset_right = box.computed_values().inset().right().resolved(box, width_of_containing_block_as_length).to_px(box);
box_state.inset_bottom = box.computed_values().inset().bottom().resolved(box, height_of_containing_block_as_length).to_px(box);
if (box.computed_values().inset().left.is_auto() && specified_width.is_auto() && box.computed_values().inset().right.is_auto()) {
if (box.computed_values().margin().left.is_auto())
if (box.computed_values().inset().left().is_auto() && specified_width.is_auto() && box.computed_values().inset().right().is_auto()) {
if (box.computed_values().margin().left().is_auto())
box_state.margin_left = 0;
if (box.computed_values().margin().right.is_auto())
if (box.computed_values().margin().right().is_auto())
box_state.margin_right = 0;
}
@ -772,11 +772,11 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box)
}
auto parent_location = absolute_content_rect(static_cast<Box const&>(*relevant_parent), m_state);
if (!box.computed_values().inset().left.is_auto()) {
if (!box.computed_values().inset().left().is_auto()) {
float x_offset = box_state.inset_left
+ box_state.border_box_left();
used_offset.set_x(x_offset + box_state.margin_left);
} else if (!box.computed_values().inset().right.is_auto()) {
} else if (!box.computed_values().inset().right().is_auto()) {
float x_offset = 0
- box_state.inset_right
- box_state.border_box_right();
@ -787,11 +787,11 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box)
used_offset.set_x(x_offset);
}
if (!box.computed_values().inset().top.is_auto()) {
if (!box.computed_values().inset().top().is_auto()) {
float y_offset = box_state.inset_top
+ box_state.border_box_top();
used_offset.set_y(y_offset + box_state.margin_top);
} else if (!box.computed_values().inset().bottom.is_auto()) {
} else if (!box.computed_values().inset().bottom().is_auto()) {
float y_offset = 0
- box_state.inset_bottom
- box_state.border_box_bottom();
@ -855,8 +855,8 @@ void FormattingContext::compute_inset(Box const& box)
auto const& computed_values = box.computed_values();
// FIXME: Respect the containing block's writing-mode.
resolve_two_opposing_insets(computed_values.inset().left, computed_values.inset().right, box_state.inset_left, box_state.inset_right, containing_block_width_for(box));
resolve_two_opposing_insets(computed_values.inset().top, computed_values.inset().bottom, box_state.inset_top, box_state.inset_bottom, containing_block_height_for(box));
resolve_two_opposing_insets(computed_values.inset().left(), computed_values.inset().right(), box_state.inset_left, box_state.inset_right, containing_block_width_for(box));
resolve_two_opposing_insets(computed_values.inset().top(), computed_values.inset().bottom(), box_state.inset_top, box_state.inset_bottom, containing_block_height_for(box));
}
float FormattingContext::calculate_fit_content_size(float min_content_size, float max_content_size, SizeConstraint constraint, Optional<float> available_space) const