mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:17:42 +00:00
LibWeb: Expose size calculation of BlockFormattingContext
This is a hack for the FlexFormattingContext
This commit is contained in:
parent
ce7c8e215f
commit
c51dbb4372
2 changed files with 20 additions and 11 deletions
|
@ -296,19 +296,11 @@ static float compute_auto_height_for_block_level_element(const Box& box)
|
||||||
return bottom.value_or(0) - top.value_or(0);
|
return bottom.value_or(0) - top.value_or(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFormattingContext::compute_height(Box& box)
|
float BlockFormattingContext::compute_theoretical_height(const Box& box)
|
||||||
{
|
{
|
||||||
auto& computed_values = box.computed_values();
|
auto& computed_values = box.computed_values();
|
||||||
auto& containing_block = *box.containing_block();
|
auto& containing_block = *box.containing_block();
|
||||||
|
|
||||||
// First, resolve the top/bottom parts of the surrounding box model.
|
|
||||||
box.box_model().margin.top = computed_values.margin().top.resolved_or_zero(box, containing_block.width()).to_px(box);
|
|
||||||
box.box_model().margin.bottom = computed_values.margin().bottom.resolved_or_zero(box, containing_block.width()).to_px(box);
|
|
||||||
box.box_model().border.top = computed_values.border_top().width;
|
|
||||||
box.box_model().border.bottom = computed_values.border_bottom().width;
|
|
||||||
box.box_model().padding.top = computed_values.padding().top.resolved_or_zero(box, containing_block.width()).to_px(box);
|
|
||||||
box.box_model().padding.bottom = computed_values.padding().bottom.resolved_or_zero(box, containing_block.width()).to_px(box);
|
|
||||||
|
|
||||||
// Then work out what the height is, based on box type and CSS properties.
|
// Then work out what the height is, based on box type and CSS properties.
|
||||||
float height = 0;
|
float height = 0;
|
||||||
if (is<ReplacedBox>(box)) {
|
if (is<ReplacedBox>(box)) {
|
||||||
|
@ -330,7 +322,22 @@ void BlockFormattingContext::compute_height(Box& box)
|
||||||
if (!specified_min_height.is_auto()
|
if (!specified_min_height.is_auto()
|
||||||
&& !(computed_values.min_height().is_percentage() && !containing_block.computed_values().height().is_absolute()))
|
&& !(computed_values.min_height().is_percentage() && !containing_block.computed_values().height().is_absolute()))
|
||||||
height = max(height, specified_min_height.to_px(box));
|
height = max(height, specified_min_height.to_px(box));
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlockFormattingContext::compute_height(Box& box)
|
||||||
|
{
|
||||||
|
auto& computed_values = box.computed_values();
|
||||||
|
auto& containing_block = *box.containing_block();
|
||||||
|
// First, resolve the top/bottom parts of the surrounding box model.
|
||||||
|
box.box_model().margin.top = computed_values.margin().top.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||||
|
box.box_model().margin.bottom = computed_values.margin().bottom.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||||
|
box.box_model().border.top = computed_values.border_top().width;
|
||||||
|
box.box_model().border.bottom = computed_values.border_bottom().width;
|
||||||
|
box.box_model().padding.top = computed_values.padding().top.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||||
|
box.box_model().padding.bottom = computed_values.padding().bottom.resolved_or_zero(box, containing_block.width()).to_px(box);
|
||||||
|
|
||||||
|
auto height = compute_theoretical_height(box);
|
||||||
box.set_height(height);
|
box.set_height(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,11 @@ public:
|
||||||
const Vector<Box*>& left_floating_boxes() const { return m_left_floating_boxes; }
|
const Vector<Box*>& left_floating_boxes() const { return m_left_floating_boxes; }
|
||||||
const Vector<Box*>& right_floating_boxes() const { return m_right_floating_boxes; }
|
const Vector<Box*>& right_floating_boxes() const { return m_right_floating_boxes; }
|
||||||
|
|
||||||
protected:
|
static float compute_theoretical_height(const Box&);
|
||||||
void compute_width(Box&);
|
void compute_width(Box&);
|
||||||
void compute_height(Box&);
|
|
||||||
|
protected:
|
||||||
|
static void compute_height(Box&);
|
||||||
void compute_position(Box&);
|
void compute_position(Box&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue