mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 12:47:34 +00:00
LibWeb: Move should_treat_{width,height}_as_auto() to FormattingContext
These are not specific to BFC, so let's move them up to the super class so that other layout classes can use them.
This commit is contained in:
parent
5fbe245406
commit
db318aece0
4 changed files with 15 additions and 15 deletions
|
@ -775,18 +775,6 @@ float BlockFormattingContext::greatest_child_width(Box const& box)
|
||||||
return max_width;
|
return max_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockFormattingContext::should_treat_width_as_auto(Box const& box, AvailableSpace const& available_space)
|
|
||||||
{
|
|
||||||
return box.computed_values().width().is_auto()
|
|
||||||
|| (box.computed_values().width().contains_percentage() && !available_space.width.is_definite());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BlockFormattingContext::should_treat_height_as_auto(Box const& box, AvailableSpace const& available_space)
|
|
||||||
{
|
|
||||||
return box.computed_values().height().is_auto()
|
|
||||||
|| (box.computed_values().height().contains_percentage() && !available_space.height.is_definite());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlockFormattingContext::determine_width_of_child(Box const& box, AvailableSpace const& available_space)
|
void BlockFormattingContext::determine_width_of_child(Box const& box, AvailableSpace const& available_space)
|
||||||
{
|
{
|
||||||
compute_width(box, available_space);
|
compute_width(box, available_space);
|
||||||
|
|
|
@ -48,9 +48,6 @@ public:
|
||||||
|
|
||||||
void layout_block_level_box(Box const&, BlockContainer const&, LayoutMode, float& bottom_of_lowest_margin_box, AvailableSpace const&);
|
void layout_block_level_box(Box const&, BlockContainer const&, LayoutMode, float& bottom_of_lowest_margin_box, AvailableSpace const&);
|
||||||
|
|
||||||
static bool should_treat_width_as_auto(Box const&, AvailableSpace const&);
|
|
||||||
static bool should_treat_height_as_auto(Box const&, AvailableSpace const&);
|
|
||||||
|
|
||||||
virtual bool can_determine_size_of_child() const override { return true; }
|
virtual bool can_determine_size_of_child() const override { return true; }
|
||||||
virtual void determine_width_of_child(Box const&, AvailableSpace const&) override;
|
virtual void determine_width_of_child(Box const&, AvailableSpace const&) override;
|
||||||
virtual void determine_height_of_child(Box const&, AvailableSpace const&) override;
|
virtual void determine_height_of_child(Box const&, AvailableSpace const&) override;
|
||||||
|
|
|
@ -1399,4 +1399,16 @@ float FormattingContext::calculate_stretch_fit_height(Box const& box, AvailableS
|
||||||
- box_state.border_bottom;
|
- box_state.border_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FormattingContext::should_treat_width_as_auto(Box const& box, AvailableSpace const& available_space)
|
||||||
|
{
|
||||||
|
return box.computed_values().width().is_auto()
|
||||||
|
|| (box.computed_values().width().contains_percentage() && !available_space.width.is_definite());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FormattingContext::should_treat_height_as_auto(Box const& box, AvailableSpace const& available_space)
|
||||||
|
{
|
||||||
|
return box.computed_values().height().is_auto()
|
||||||
|
|| (box.computed_values().height().contains_percentage() && !available_space.height.is_definite());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
FormattingContext(Type, LayoutState&, Box const&, FormattingContext* parent = nullptr);
|
FormattingContext(Type, LayoutState&, Box const&, FormattingContext* parent = nullptr);
|
||||||
|
|
||||||
|
static bool should_treat_width_as_auto(Box const&, AvailableSpace const&);
|
||||||
|
static bool should_treat_height_as_auto(Box const&, AvailableSpace const&);
|
||||||
|
|
||||||
float calculate_fit_content_size(float min_content_size, float max_content_size, AvailableSize const&) const;
|
float calculate_fit_content_size(float min_content_size, float max_content_size, AvailableSize const&) const;
|
||||||
|
|
||||||
OwnPtr<FormattingContext> layout_inside(Box const&, LayoutMode, AvailableSpace const&);
|
OwnPtr<FormattingContext> layout_inside(Box const&, LayoutMode, AvailableSpace const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue