mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Rename Layout::Box::size() to content_size()
This property represents the CSS content size, so let's reduce ambiguity by using the spec terminology. We also bring a bunch of related functions along for the ride.
This commit is contained in:
parent
dbe5af3c6f
commit
0608de8c12
17 changed files with 140 additions and 140 deletions
|
@ -154,8 +154,8 @@ static Gfx::FloatSize solve_replaced_size_constraint(float w, float h, const Rep
|
|||
// 10.4 Minimum and maximum widths: 'min-width' and 'max-width'
|
||||
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
|
||||
auto specified_min_width = box.computed_values().min_width().resolved(box, width_of_containing_block).resolved_or_zero(box).to_px(box);
|
||||
auto specified_max_width = box.computed_values().max_width().resolved(box, width_of_containing_block).resolved(CSS::Length::make_px(w), box).to_px(box);
|
||||
|
@ -217,7 +217,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(Box const&
|
|||
return IterationDecision::Continue;
|
||||
|
||||
float child_box_top = child_box.effective_offset().y() - child_box.box_model().margin_box().top;
|
||||
float child_box_bottom = child_box.effective_offset().y() + child_box.height() + child_box.box_model().margin_box().bottom;
|
||||
float child_box_bottom = child_box.effective_offset().y() + child_box.content_height() + child_box.box_model().margin_box().bottom;
|
||||
|
||||
if (!top.has_value() || child_box_top < top.value())
|
||||
top = child_box_top;
|
||||
|
@ -235,7 +235,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(Box const&
|
|||
if (!child_box.is_floating())
|
||||
return IterationDecision::Continue;
|
||||
|
||||
float child_box_bottom = child_box.effective_offset().y() + child_box.height();
|
||||
float child_box_bottom = child_box.effective_offset().y() + child_box.content_height();
|
||||
|
||||
if (!bottom.has_value() || child_box_bottom > bottom.value())
|
||||
bottom = child_box_bottom;
|
||||
|
@ -251,7 +251,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(Box const&
|
|||
float FormattingContext::tentative_width_for_replaced_element(ReplacedBox const& box, CSS::Length const& computed_width)
|
||||
{
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
auto computed_height = box.computed_values().height().resolved(box, height_of_containing_block).resolved_or_auto(box);
|
||||
|
||||
float used_width = computed_width.to_px(box);
|
||||
|
@ -312,7 +312,7 @@ float FormattingContext::compute_width_for_replaced_element(const ReplacedBox& b
|
|||
|
||||
auto zero_value = CSS::Length::make_px(0);
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
|
||||
auto margin_left = box.computed_values().margin().left.resolved(box, width_of_containing_block).resolved_or_zero(box);
|
||||
auto margin_right = box.computed_values().margin().right.resolved(box, width_of_containing_block).resolved_or_zero(box);
|
||||
|
@ -354,7 +354,7 @@ float FormattingContext::compute_width_for_replaced_element(const ReplacedBox& b
|
|||
float FormattingContext::tentative_height_for_replaced_element(ReplacedBox const& box, CSS::Length const& computed_height)
|
||||
{
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto computed_width = box.computed_values().width().resolved(box, width_of_containing_block).resolved_or_auto(box);
|
||||
|
||||
// If 'height' and 'width' both have computed values of 'auto' and the element also has
|
||||
|
@ -387,8 +387,8 @@ float FormattingContext::compute_height_for_replaced_element(const ReplacedBox&
|
|||
// 'inline-block' replaced elements in normal flow and floating replaced elements
|
||||
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
auto specified_width = box.computed_values().width().resolved(box, width_of_containing_block).resolved_or_auto(box);
|
||||
auto specified_height = box.computed_values().height().resolved(box, height_of_containing_block).resolved_or_auto(box);
|
||||
|
||||
|
@ -406,7 +406,7 @@ float FormattingContext::compute_height_for_replaced_element(const ReplacedBox&
|
|||
void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_element(Box& box)
|
||||
{
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto& computed_values = box.computed_values();
|
||||
auto zero_value = CSS::Length::make_px(0);
|
||||
|
||||
|
@ -426,15 +426,15 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
|
|||
auto width = a_width;
|
||||
|
||||
auto solve_for_left = [&] {
|
||||
return CSS::Length(containing_block.width() - margin_left.to_px(box) - border_left - padding_left.to_px(box) - width.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box) - right.to_px(box), CSS::Length::Type::Px);
|
||||
return CSS::Length(containing_block.content_width() - margin_left.to_px(box) - border_left - padding_left.to_px(box) - width.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box) - right.to_px(box), CSS::Length::Type::Px);
|
||||
};
|
||||
|
||||
auto solve_for_width = [&] {
|
||||
return CSS::Length(containing_block.width() - left.to_px(box) - margin_left.to_px(box) - border_left - padding_left.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box) - right.to_px(box), CSS::Length::Type::Px);
|
||||
return CSS::Length(containing_block.content_width() - left.to_px(box) - margin_left.to_px(box) - border_left - padding_left.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box) - right.to_px(box), CSS::Length::Type::Px);
|
||||
};
|
||||
|
||||
auto solve_for_right = [&] {
|
||||
return CSS::Length(containing_block.width() - left.to_px(box) - margin_left.to_px(box) - border_left - padding_left.to_px(box) - width.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box), CSS::Length::Type::Px);
|
||||
return CSS::Length(containing_block.content_width() - left.to_px(box) - margin_left.to_px(box) - border_left - padding_left.to_px(box) - width.to_px(box) - padding_right.to_px(box) - border_right - margin_right.to_px(box), CSS::Length::Type::Px);
|
||||
};
|
||||
|
||||
// If all three of 'left', 'width', and 'right' are 'auto':
|
||||
|
@ -534,7 +534,7 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
|
|||
}
|
||||
}
|
||||
|
||||
box.set_width(used_width.to_px(box));
|
||||
box.set_content_width(used_width.to_px(box));
|
||||
|
||||
box.box_model().margin.left = margin_left.to_px(box);
|
||||
box.box_model().margin.right = margin_right.to_px(box);
|
||||
|
@ -549,15 +549,15 @@ void FormattingContext::compute_width_for_absolutely_positioned_replaced_element
|
|||
// 10.3.8 Absolutely positioned, replaced elements
|
||||
// The used value of 'width' is determined as for inline replaced elements.
|
||||
box.prepare_for_replaced_layout();
|
||||
box.set_width(compute_width_for_replaced_element(box));
|
||||
box.set_content_width(compute_width_for_replaced_element(box));
|
||||
}
|
||||
|
||||
void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_element(Box& box)
|
||||
{
|
||||
auto& computed_values = box.computed_values();
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
|
||||
CSS::Length specified_top = computed_values.offset().top.resolved(box, height_of_containing_block).resolved_or_auto(box);
|
||||
CSS::Length specified_bottom = computed_values.offset().bottom.resolved(box, height_of_containing_block).resolved_or_auto(box);
|
||||
|
@ -585,7 +585,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
const auto& border = box.box_model().border;
|
||||
|
||||
specified_height = CSS::Length(compute_auto_height_for_block_level_element(box), CSS::Length::Type::Px);
|
||||
box.box_model().offset.bottom = containing_block.height() - specified_height.to_px(box) - specified_top.to_px(box) - margin.top - padding.top - border.top - margin.bottom - padding.bottom - border.bottom;
|
||||
box.box_model().offset.bottom = containing_block.content_height() - specified_height.to_px(box) - specified_top.to_px(box) - margin.top - padding.top - border.top - margin.bottom - padding.bottom - border.bottom;
|
||||
}
|
||||
|
||||
else if (specified_height.is_auto() && !specified_top.is_auto() && !specified_bottom.is_auto()) {
|
||||
|
@ -593,7 +593,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
const auto& padding = box.box_model().padding;
|
||||
const auto& border = box.box_model().border;
|
||||
|
||||
specified_height = CSS::Length(containing_block.height() - specified_top.to_px(box) - margin.top - padding.top - border.top - specified_bottom.to_px(box) - margin.bottom - padding.bottom - border.bottom, CSS::Length::Type::Px);
|
||||
specified_height = CSS::Length(containing_block.content_height() - specified_top.to_px(box) - margin.top - padding.top - border.top - specified_bottom.to_px(box) - margin.bottom - padding.bottom - border.bottom, CSS::Length::Type::Px);
|
||||
}
|
||||
|
||||
if (!specified_height.is_auto()) {
|
||||
|
@ -602,15 +602,15 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
|
|||
used_height = min(used_height, specified_max_height.to_px(box));
|
||||
if (!specified_min_height.is_auto())
|
||||
used_height = max(used_height, specified_min_height.to_px(box));
|
||||
box.set_height(used_height);
|
||||
box.set_content_height(used_height);
|
||||
}
|
||||
}
|
||||
|
||||
void FormattingContext::layout_absolutely_positioned_element(Box& box)
|
||||
{
|
||||
auto& containing_block = *box.containing_block();
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
|
||||
auto width_of_containing_block = CSS::Length::make_px(containing_block.content_width());
|
||||
auto height_of_containing_block = CSS::Length::make_px(containing_block.content_height());
|
||||
auto& box_model = box.box_model();
|
||||
|
||||
auto specified_width = box.computed_values().width().resolved(box, width_of_containing_block).resolved_or_auto(box);
|
||||
|
@ -655,7 +655,7 @@ void FormattingContext::layout_absolutely_positioned_element(Box& box)
|
|||
float x_offset = 0
|
||||
- box_model.offset.right
|
||||
- box_model.border_box().right;
|
||||
used_offset.set_x(containing_block.width() + x_offset - box.width() - box_model.margin.right);
|
||||
used_offset.set_x(containing_block.content_width() + x_offset - box.content_width() - box_model.margin.right);
|
||||
} else {
|
||||
float x_offset = box_model.margin_box().left;
|
||||
used_offset.set_x(x_offset);
|
||||
|
@ -669,7 +669,7 @@ void FormattingContext::layout_absolutely_positioned_element(Box& box)
|
|||
float y_offset = 0
|
||||
- box_model.offset.bottom
|
||||
- box_model.border_box().bottom;
|
||||
used_offset.set_y(containing_block.height() + y_offset - box.height() - box_model.margin.bottom);
|
||||
used_offset.set_y(containing_block.content_height() + y_offset - box.content_height() - box_model.margin.bottom);
|
||||
} else {
|
||||
float y_offset = box_model.margin_box().top;
|
||||
used_offset.set_y(y_offset);
|
||||
|
@ -682,7 +682,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_replaced_elemen
|
|||
{
|
||||
// 10.6.5 Absolutely positioned, replaced elements
|
||||
// The used value of 'height' is determined as for inline replaced elements.
|
||||
box.set_height(compute_height_for_replaced_element(box));
|
||||
box.set_content_height(compute_height_for_replaced_element(box));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue