summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-19 17:00:50 +0000
committerAndreas Kling <kling@serenityos.org>2022-01-20 00:04:10 +0100
commitbfcbab0dcfe642021ec279f30209cf4c07993f54 (patch)
treec5fe036ddb28ae6f2042f70c851cd2f17db73bda /Userland/Libraries/LibWeb/Layout
parentcff44831a84e2061dab388512ee36efd3b891d10 (diff)
downloadserenity-bfcbab0dcfe642021ec279f30209cf4c07993f54.zip
LibWeb: Remove reference_for_percent parameter from Length::resolved()
Despite looking like it was still needed, it was only used for passing to other calls to Length::resolved() recursively. This makes the various `foo.resolved().resolved()` calls a lot less awkward. (Though, still quite awkward.) I think we'd need to separate calculated lengths out to properly tidy these calls up, but one yak at a time. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp62
-rw-r--r--Userland/Libraries/LibWeb/Layout/Box.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp24
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp80
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp12
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineNode.cpp10
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp2
7 files changed, 98 insertions, 98 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index b43b288325..901be0b723 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -80,7 +80,7 @@ void BlockFormattingContext::apply_transformations_to_children(Box& box)
continue;
transformation.values.first().visit(
[&](CSS::Length& value) {
- transform_y_offset += value.resolved_or_zero(child_box, child_box.width()).to_px(child_box);
+ transform_y_offset += value.resolved_or_zero(child_box).to_px(child_box);
},
[&](float value) {
transform_y_offset += value;
@@ -128,13 +128,13 @@ void BlockFormattingContext::compute_width(Box& box)
auto margin_left = CSS::Length::make_auto();
auto margin_right = CSS::Length::make_auto();
- const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
+ const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
auto try_compute_width = [&](const auto& a_width) {
CSS::Length width = a_width;
- margin_left = computed_values.margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- margin_right = computed_values.margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
+ margin_left = computed_values.margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ margin_right = computed_values.margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
float total_px = computed_values.border_left().width + computed_values.border_right().width;
for (auto& value : { margin_left, padding_left, width, padding_right, margin_right }) {
@@ -208,14 +208,14 @@ void BlockFormattingContext::compute_width(Box& box)
return width;
};
- auto specified_width = computed_values.width().resolved(width_of_containing_block_as_length).resolved_or_auto(box, width_of_containing_block);
+ auto specified_width = computed_values.width().resolved(width_of_containing_block_as_length).resolved_or_auto(box);
// 1. The tentative used width is calculated (without 'min-width' and 'max-width')
auto used_width = try_compute_width(specified_width);
// 2. The tentative used width is greater than 'max-width', the rules above are applied again,
// but this time using the computed value of 'max-width' as the computed value for 'width'.
- auto specified_max_width = computed_values.max_width().resolved(width_of_containing_block_as_length).resolved_or_auto(box, width_of_containing_block);
+ auto specified_max_width = computed_values.max_width().resolved(width_of_containing_block_as_length).resolved_or_auto(box);
if (!specified_max_width.is_auto()) {
if (used_width.to_px(box) > specified_max_width.to_px(box)) {
used_width = try_compute_width(specified_max_width);
@@ -224,7 +224,7 @@ void BlockFormattingContext::compute_width(Box& box)
// 3. If the resulting width is smaller than 'min-width', the rules above are applied again,
// but this time using the value of 'min-width' as the computed value for 'width'.
- auto specified_min_width = computed_values.min_width().resolved(width_of_containing_block_as_length).resolved_or_auto(box, width_of_containing_block);
+ auto specified_min_width = computed_values.min_width().resolved(width_of_containing_block_as_length).resolved_or_auto(box);
if (!specified_min_width.is_auto()) {
if (used_width.to_px(box) < specified_min_width.to_px(box)) {
used_width = try_compute_width(specified_min_width);
@@ -248,10 +248,10 @@ void BlockFormattingContext::compute_width_for_floating_box(Box& box)
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
auto zero_value = CSS::Length::make_px(0);
- auto margin_left = computed_values.margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- auto margin_right = computed_values.margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
+ auto margin_left = computed_values.margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ auto margin_right = computed_values.margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
// If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'.
if (margin_left.is_auto())
@@ -259,7 +259,7 @@ void BlockFormattingContext::compute_width_for_floating_box(Box& box)
if (margin_right.is_auto())
margin_right = zero_value;
- auto width = computed_values.width().resolved(width_of_containing_block_as_length).resolved_or_auto(box, width_of_containing_block);
+ auto width = computed_values.width().resolved(width_of_containing_block_as_length).resolved_or_auto(box);
// If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width.
if (width.is_auto()) {
@@ -277,7 +277,7 @@ void BlockFormattingContext::compute_width_for_floating_box(Box& box)
width = CSS::Length(min(max(result.preferred_minimum_width, available_width), result.preferred_width), CSS::Length::Type::Px);
}
- float final_width = width.resolved_or_zero(box, width_of_containing_block).to_px(box);
+ float final_width = width.resolved_or_zero(box).to_px(box);
box.set_width(final_width);
box.box_model().margin.left = margin_left.to_px(box);
box.box_model().margin.right = margin_right.to_px(box);
@@ -311,15 +311,15 @@ float BlockFormattingContext::compute_theoretical_height(Box const& box)
|| (computed_values.height().is_percentage() && !is_absolute(containing_block.computed_values().height()))) {
height = compute_auto_height_for_block_level_element(box, ConsiderFloats::No);
} else {
- height = computed_values.height().resolved(containing_block_height).resolved_or_auto(box, containing_block.height()).to_px(box);
+ height = computed_values.height().resolved(containing_block_height).resolved_or_auto(box).to_px(box);
}
}
- auto specified_max_height = computed_values.max_height().resolved(containing_block_height).resolved_or_auto(box, containing_block.height());
+ auto specified_max_height = computed_values.max_height().resolved(containing_block_height).resolved_or_auto(box);
if (!specified_max_height.is_auto()
&& !(computed_values.max_height().is_percentage() && !is_absolute(containing_block.computed_values().height())))
height = min(height, specified_max_height.to_px(box));
- auto specified_min_height = computed_values.min_height().resolved(containing_block_height).resolved_or_auto(box, containing_block.height());
+ auto specified_min_height = computed_values.min_height().resolved(containing_block_height).resolved_or_auto(box);
if (!specified_min_height.is_auto()
&& !(computed_values.min_height().is_percentage() && !is_absolute(containing_block.computed_values().height())))
height = max(height, specified_min_height.to_px(box));
@@ -335,13 +335,13 @@ void BlockFormattingContext::compute_height(Box& box)
// First, resolve the top/bottom parts of the surrounding box model.
// FIXME: While negative values are generally allowed for margins, for now just ignore those for height calculation
- box.box_model().margin.top = max(computed_values.margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(box, containing_block.width()).to_px(box), 0);
- box.box_model().margin.bottom = max(computed_values.margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(box, containing_block.width()).to_px(box), 0);
+ box.box_model().margin.top = max(computed_values.margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(box).to_px(box), 0);
+ box.box_model().margin.bottom = max(computed_values.margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(box).to_px(box), 0);
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(width_of_containing_block_as_length).resolved_or_zero(box, containing_block.width()).to_px(box);
- box.box_model().padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(box, containing_block.width()).to_px(box);
+ box.box_model().padding.top = computed_values.padding().top.resolved(width_of_containing_block_as_length).resolved_or_zero(box).to_px(box);
+ box.box_model().padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(box).to_px(box);
auto height = compute_theoretical_height(box);
box.set_height(height);
@@ -357,8 +357,8 @@ void BlockFormattingContext::compute_position(Box& box)
float width_of_containing_block = box.containing_block()->width();
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
- auto specified_left = computed_values.offset().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
- auto specified_right = computed_values.offset().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box, width_of_containing_block);
+ auto specified_left = computed_values.offset().left.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
+ auto specified_right = computed_values.offset().right.resolved(width_of_containing_block_as_length).resolved_or_zero(box);
if (specified_left.is_auto() && specified_right.is_auto()) {
// If both 'left' and 'right' are 'auto' (their initial values), the used values are '0' (i.e., the boxes stay in their original position).
@@ -440,12 +440,12 @@ void BlockFormattingContext::place_block_level_replaced_element_in_normal_flow(B
auto& replaced_element_box_model = child_box.box_model();
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
- replaced_element_box_model.margin.top = child_box.computed_values().margin().top.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
- replaced_element_box_model.margin.bottom = child_box.computed_values().margin().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
+ replaced_element_box_model.margin.top = child_box.computed_values().margin().top.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
+ replaced_element_box_model.margin.bottom = child_box.computed_values().margin().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
replaced_element_box_model.border.top = child_box.computed_values().border_top().width;
replaced_element_box_model.border.bottom = child_box.computed_values().border_bottom().width;
- replaced_element_box_model.padding.top = child_box.computed_values().padding().top.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
- replaced_element_box_model.padding.bottom = child_box.computed_values().padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
+ replaced_element_box_model.padding.top = child_box.computed_values().padding().top.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
+ replaced_element_box_model.padding.bottom = child_box.computed_values().padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
float x = replaced_element_box_model.margin.left
+ replaced_element_box_model.border.left
@@ -463,12 +463,12 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl
auto& computed_values = child_box.computed_values();
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
- box_model.margin.top = computed_values.margin().top.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
- box_model.margin.bottom = computed_values.margin().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
+ box_model.margin.top = computed_values.margin().top.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
+ box_model.margin.bottom = computed_values.margin().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
box_model.border.top = computed_values.border_top().width;
box_model.border.bottom = computed_values.border_bottom().width;
- box_model.padding.top = computed_values.padding().top.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
- box_model.padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block, containing_block.width()).to_px(child_box);
+ box_model.padding.top = computed_values.padding().top.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
+ box_model.padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(containing_block).to_px(child_box);
float x = box_model.margin.left
+ box_model.border.left
diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp
index a65433b540..a276b0d1c0 100644
--- a/Userland/Libraries/LibWeb/Layout/Box.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Box.cpp
@@ -103,9 +103,9 @@ void Box::paint_box_shadow(PaintContext& context)
return;
auto resolved_box_shadow_data = Painting::BoxShadowData {
- .offset_x = (int)box_shadow_data->offset_x.resolved_or_zero(*this, width()).to_px(*this),
- .offset_y = (int)box_shadow_data->offset_y.resolved_or_zero(*this, width()).to_px(*this),
- .blur_radius = (int)box_shadow_data->blur_radius.resolved_or_zero(*this, width()).to_px(*this),
+ .offset_x = (int)box_shadow_data->offset_x.resolved_or_zero(*this).to_px(*this),
+ .offset_y = (int)box_shadow_data->offset_y.resolved_or_zero(*this).to_px(*this),
+ .blur_radius = (int)box_shadow_data->blur_radius.resolved_or_zero(*this).to_px(*this),
.color = box_shadow_data->color
};
Painting::paint_box_shadow(context, enclosing_int_rect(bordered_rect()), resolved_box_shadow_data);
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 4704c8b973..01cdfae536 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -21,7 +21,7 @@ static float get_pixel_size(Box const& box, CSS::LengthPercentage const& length_
{
auto inner_main_size = CSS::Length::make_px(box.containing_block()->width());
return length_percentage.resolved(inner_main_size)
- .resolved(CSS::Length::make_px(0), box, box.containing_block()->width())
+ .resolved(CSS::Length::make_px(0), box)
.to_px(box);
}
@@ -118,15 +118,15 @@ void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::Flex
auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block);
// FIXME: This should also take reverse-ness into account
if (flex_direction == CSS::FlexDirection::Row || flex_direction == CSS::FlexDirection::RowReverse) {
- item.margins.main_before = item.box.computed_values().margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.main_after = item.box.computed_values().margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.cross_before = item.box.computed_values().margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.cross_after = item.box.computed_values().margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
+ item.margins.main_before = item.box.computed_values().margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.main_after = item.box.computed_values().margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.cross_before = item.box.computed_values().margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.cross_after = item.box.computed_values().margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
} else {
- item.margins.main_before = item.box.computed_values().margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.main_after = item.box.computed_values().margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.cross_before = item.box.computed_values().margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
- item.margins.cross_after = item.box.computed_values().margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box, width_of_containing_block).to_px(item.box);
+ item.margins.main_before = item.box.computed_values().margin().top.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.main_after = item.box.computed_values().margin().bottom.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.cross_before = item.box.computed_values().margin().left.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
+ item.margins.cross_after = item.box.computed_values().margin().right.resolved(width_of_containing_block_as_length).resolved_or_zero(item.box).to_px(item.box);
}
};
@@ -143,7 +143,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
flex_container().set_width(flex_container().containing_block()->width());
} else {
auto container_width = flex_container().containing_block()->width();
- auto width = flex_container().computed_values().width().resolved(CSS::Length::make_px(container_width)).resolved_or_zero(flex_container(), container_width).to_px(flex_container());
+ auto width = flex_container().computed_values().width().resolved(CSS::Length::make_px(container_width)).resolved_or_zero(flex_container()).to_px(flex_container());
flex_container().set_width(width);
}
@@ -151,7 +151,7 @@ void FlexFormattingContext::generate_anonymous_flex_items()
flex_container().set_height(flex_container().containing_block()->height());
} else {
auto container_height = flex_container().containing_block()->height();
- auto height = flex_container().computed_values().height().resolved(CSS::Length::make_px(container_height)).resolved_or_zero(flex_container(), flex_container().containing_block()->height()).to_px(flex_container());
+ auto height = flex_container().computed_values().height().resolved(CSS::Length::make_px(container_height)).resolved_or_zero(flex_container()).to_px(flex_container());
flex_container().set_height(height);
}
@@ -238,7 +238,7 @@ float FlexFormattingContext::specified_main_size_of_child_box(Box const& child_b
{
auto main_size_of_parent = specified_main_size(flex_container());
auto value = is_row_layout() ? child_box.computed_values().width() : child_box.computed_values().height();
- return value.resolved(CSS::Length::make_px(main_size_of_parent)).resolved_or_zero(child_box, main_size_of_parent).to_px(child_box);
+ return value.resolved(CSS::Length::make_px(main_size_of_parent)).resolved_or_zero(child_box).to_px(child_box);
}
float FlexFormattingContext::specified_main_min_size(Box const& box) const
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 70c825c65a..b3f589f202 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -157,10 +157,10 @@ static Gfx::FloatSize solve_replaced_size_constraint(float w, float h, const Rep
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 specified_min_width = box.computed_values().min_width().resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width()).to_px(box);
- auto specified_max_width = box.computed_values().max_width().resolved(width_of_containing_block).resolved(CSS::Length::make_px(w), box, containing_block.width()).to_px(box);
- auto specified_min_height = box.computed_values().min_height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height()).to_px(box);
- auto specified_max_height = box.computed_values().max_height().resolved(height_of_containing_block).resolved(CSS::Length::make_px(h), box, containing_block.height()).to_px(box);
+ auto specified_min_width = box.computed_values().min_width().resolved(width_of_containing_block).resolved_or_zero(box).to_px(box);
+ auto specified_max_width = box.computed_values().max_width().resolved(width_of_containing_block).resolved(CSS::Length::make_px(w), box).to_px(box);
+ auto specified_min_height = box.computed_values().min_height().resolved(height_of_containing_block).resolved_or_auto(box).to_px(box);
+ auto specified_max_height = box.computed_values().max_height().resolved(height_of_containing_block).resolved(CSS::Length::make_px(h), box).to_px(box);
auto min_width = min(specified_min_width, specified_max_width);
auto max_width = max(specified_min_width, specified_max_width);
@@ -252,7 +252,7 @@ float FormattingContext::tentative_width_for_replaced_element(ReplacedBox const&
{
auto& containing_block = *box.containing_block();
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
- auto computed_height = box.computed_values().height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
+ auto computed_height = box.computed_values().height().resolved(height_of_containing_block).resolved_or_auto(box);
float used_width = computed_width.to_px(box);
@@ -314,8 +314,8 @@ float FormattingContext::compute_width_for_replaced_element(const ReplacedBox& b
auto& containing_block = *box.containing_block();
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
- auto margin_left = box.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
- auto margin_right = box.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
+ auto margin_left = box.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_zero(box);
+ auto margin_right = box.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_zero(box);
// A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'.
if (margin_left.is_auto())
@@ -323,14 +323,14 @@ float FormattingContext::compute_width_for_replaced_element(const ReplacedBox& b
if (margin_right.is_auto())
margin_right = zero_value;
- auto specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box);
// 1. The tentative used width is calculated (without 'min-width' and 'max-width')
auto used_width = tentative_width_for_replaced_element(box, specified_width);
// 2. The tentative used width is greater than 'max-width', the rules above are applied again,
// but this time using the computed value of 'max-width' as the computed value for 'width'.
- auto specified_max_width = box.computed_values().max_width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_max_width = box.computed_values().max_width().resolved(width_of_containing_block).resolved_or_auto(box);
if (!specified_max_width.is_auto()) {
if (used_width > specified_max_width.to_px(box)) {
used_width = tentative_width_for_replaced_element(box, specified_max_width);
@@ -339,7 +339,7 @@ float FormattingContext::compute_width_for_replaced_element(const ReplacedBox& b
// 3. If the resulting width is smaller than 'min-width', the rules above are applied again,
// but this time using the value of 'min-width' as the computed value for 'width'.
- auto specified_min_width = box.computed_values().min_width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_min_width = box.computed_values().min_width().resolved(width_of_containing_block).resolved_or_auto(box);
if (!specified_min_width.is_auto()) {
if (used_width < specified_min_width.to_px(box)) {
used_width = tentative_width_for_replaced_element(box, specified_min_width);
@@ -355,7 +355,7 @@ float FormattingContext::tentative_height_for_replaced_element(ReplacedBox const
{
auto& containing_block = *box.containing_block();
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
- auto computed_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto computed_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box);
// If 'height' and 'width' both have computed values of 'auto' and the element also has
// an intrinsic height, then that intrinsic height is the used value of 'height'.
@@ -389,8 +389,8 @@ float FormattingContext::compute_height_for_replaced_element(const ReplacedBox&
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 specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
- auto specified_height = box.computed_values().height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
+ auto specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box);
+ auto specified_height = box.computed_values().height().resolved(height_of_containing_block).resolved_or_auto(box);
float used_height = tentative_height_for_replaced_element(box, specified_height);
@@ -414,15 +414,15 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
auto margin_right = CSS::Length::make_auto();
const auto border_left = computed_values.border_left().width;
const auto border_right = computed_values.border_right().width;
- const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
- const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
+ const auto padding_left = computed_values.padding().left.resolved(width_of_containing_block).resolved_or_zero(box);
+ const auto padding_right = computed_values.padding().right.resolved(width_of_containing_block).resolved_or_zero(box);
auto try_compute_width = [&](const auto& a_width) {
- margin_left = computed_values.margin().left.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
- margin_right = computed_values.margin().right.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width());
+ margin_left = computed_values.margin().left.resolved(width_of_containing_block).resolved_or_zero(box);
+ margin_right = computed_values.margin().right.resolved(width_of_containing_block).resolved_or_zero(box);
- auto left = computed_values.offset().left.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
- auto right = computed_values.offset().right.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto left = computed_values.offset().left.resolved(width_of_containing_block).resolved_or_auto(box);
+ auto right = computed_values.offset().right.resolved(width_of_containing_block).resolved_or_auto(box);
auto width = a_width;
auto solve_for_left = [&] {
@@ -511,14 +511,14 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
return width;
};
- auto specified_width = computed_values.width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_width = computed_values.width().resolved(width_of_containing_block).resolved_or_auto(box);
// 1. The tentative used width is calculated (without 'min-width' and 'max-width')
auto used_width = try_compute_width(specified_width);
// 2. The tentative used width is greater than 'max-width', the rules above are applied again,
// but this time using the computed value of 'max-width' as the computed value for 'width'.
- auto specified_max_width = computed_values.max_width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_max_width = computed_values.max_width().resolved(width_of_containing_block).resolved_or_auto(box);
if (!specified_max_width.is_auto()) {
if (used_width.to_px(box) > specified_max_width.to_px(box)) {
used_width = try_compute_width(specified_max_width);
@@ -527,7 +527,7 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
// 3. If the resulting width is smaller than 'min-width', the rules above are applied again,
// but this time using the value of 'min-width' as the computed value for 'width'.
- auto specified_min_width = computed_values.min_width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_min_width = computed_values.min_width().resolved(width_of_containing_block).resolved_or_auto(box);
if (!specified_min_width.is_auto()) {
if (used_width.to_px(box) < specified_min_width.to_px(box)) {
used_width = try_compute_width(specified_min_width);
@@ -559,25 +559,25 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
auto width_of_containing_block = CSS::Length::make_px(containing_block.width());
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
- CSS::Length specified_top = computed_values.offset().top.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
- CSS::Length specified_bottom = computed_values.offset().bottom.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
+ CSS::Length specified_top = computed_values.offset().top.resolved(height_of_containing_block).resolved_or_auto(box);
+ CSS::Length specified_bottom = computed_values.offset().bottom.resolved(height_of_containing_block).resolved_or_auto(box);
CSS::Length specified_height;
if (computed_values.height().is_percentage() && !(containing_block.computed_values().height().is_length() && containing_block.computed_values().height().length().is_absolute())) {
specified_height = CSS::Length::make_auto();
} else {
- specified_height = computed_values.height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
+ specified_height = computed_values.height().resolved(height_of_containing_block).resolved_or_auto(box);
}
- auto specified_max_height = computed_values.max_height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
- auto specified_min_height = computed_values.min_height().resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height());
+ auto specified_max_height = computed_values.max_height().resolved(height_of_containing_block).resolved_or_auto(box);
+ auto specified_min_height = computed_values.min_height().resolved(height_of_containing_block).resolved_or_auto(box);
- box.box_model().margin.top = computed_values.margin().top.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width()).to_px(box);
- box.box_model().margin.bottom = computed_values.margin().bottom.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width()).to_px(box);
+ box.box_model().margin.top = computed_values.margin().top.resolved(width_of_containing_block).resolved_or_zero(box).to_px(box);
+ box.box_model().margin.bottom = computed_values.margin().bottom.resolved(width_of_containing_block).resolved_or_zero(box).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(width_of_containing_block).resolved_or_zero(box, containing_block.width()).to_px(box);
- box.box_model().padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(box, containing_block.width()).to_px(box);
+ box.box_model().padding.top = computed_values.padding().top.resolved(width_of_containing_block).resolved_or_zero(box).to_px(box);
+ box.box_model().padding.bottom = computed_values.padding().bottom.resolved(width_of_containing_block).resolved_or_zero(box).to_px(box);
if (specified_height.is_auto() && !specified_top.is_auto() && specified_bottom.is_auto()) {
const auto& margin = box.box_model().margin;
@@ -613,26 +613,26 @@ void FormattingContext::layout_absolutely_positioned_element(Box& box)
auto height_of_containing_block = CSS::Length::make_px(containing_block.height());
auto& box_model = box.box_model();
- auto specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width());
+ auto specified_width = box.computed_values().width().resolved(width_of_containing_block).resolved_or_auto(box);
compute_width_for_absolutely_positioned_element(box);
(void)layout_inside(box, LayoutMode::Default);
compute_height_for_absolutely_positioned_element(box);
- box_model.margin.left = box.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width()).to_px(box);
- box_model.margin.top = box.computed_values().margin().top.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height()).to_px(box);
- box_model.margin.right = box.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width()).to_px(box);
- box_model.margin.bottom = box.computed_values().margin().bottom.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height()).to_px(box);
+ box_model.margin.left = box.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.margin.top = box.computed_values().margin().top.resolved(height_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.margin.right = box.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.margin.bottom = box.computed_values().margin().bottom.resolved(height_of_containing_block).resolved_or_auto(box).to_px(box);
box_model.border.left = box.computed_values().border_left().width;
box_model.border.right = box.computed_values().border_right().width;
box_model.border.top = box.computed_values().border_top().width;
box_model.border.bottom = box.computed_values().border_bottom().width;
- box_model.offset.left = box.computed_values().offset().left.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width()).to_px(box);
- box_model.offset.top = box.computed_values().offset().top.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height()).to_px(box);
- box_model.offset.right = box.computed_values().offset().right.resolved(width_of_containing_block).resolved_or_auto(box, containing_block.width()).to_px(box);
- box_model.offset.bottom = box.computed_values().offset().bottom.resolved(height_of_containing_block).resolved_or_auto(box, containing_block.height()).to_px(box);
+ box_model.offset.left = box.computed_values().offset().left.resolved(width_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.offset.top = box.computed_values().offset().top.resolved(height_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.offset.right = box.computed_values().offset().right.resolved(width_of_containing_block).resolved_or_auto(box).to_px(box);
+ box_model.offset.bottom = box.computed_values().offset().bottom.resolved(height_of_containing_block).resolved_or_auto(box).to_px(box);
auto is_auto = [](auto const& length_percentage) {
return length_percentage.is_length() && length_percentage.length().is_auto();
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index 06f463f0b9..a8d0eb9d83 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -195,13 +195,13 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
auto result = calculate_shrink_to_fit_widths(inline_block);
auto width_of_containing_block = CSS::Length::make_px(containing_block().width());
- auto margin_left = inline_block.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_zero(inline_block, containing_block().width()).to_px(inline_block);
+ auto margin_left = inline_block.computed_values().margin().left.resolved(width_of_containing_block).resolved_or_zero(inline_block).to_px(inline_block);
auto border_left_width = inline_block.computed_values().border_left().width;
- auto padding_left = inline_block.computed_values().padding().left.resolved(width_of_containing_block).resolved_or_zero(inline_block, containing_block().width()).to_px(inline_block);
+ auto padding_left = inline_block.computed_values().padding().left.resolved(width_of_containing_block).resolved_or_zero(inline_block).to_px(inline_block);
- auto margin_right = inline_block.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_zero(inline_block, containing_block().width()).to_px(inline_block);
+ auto margin_right = inline_block.computed_values().margin().right.resolved(width_of_containing_block).resolved_or_zero(inline_block).to_px(inline_block);
auto border_right_width = inline_block.computed_values().border_right().width;
- auto padding_right = inline_block.computed_values().padding().right.resolved(width_of_containing_block).resolved_or_zero(inline_block, containing_block().width()).to_px(inline_block);
+ auto padding_right = inline_block.computed_values().padding().right.resolved(width_of_containing_block).resolved_or_zero(inline_block).to_px(inline_block);
auto available_width = containing_block().width()
- margin_left
@@ -215,7 +215,7 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
inline_block.set_width(width);
} else {
auto container_width = CSS::Length::make_px(containing_block().width());
- inline_block.set_width(inline_block.computed_values().width().resolved(container_width).resolved_or_zero(inline_block, containing_block().width()).to_px(inline_block));
+ inline_block.set_width(inline_block.computed_values().width().resolved(container_width).resolved_or_zero(inline_block).to_px(inline_block));
}
(void)layout_inside(inline_block, layout_mode);
@@ -223,7 +223,7 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
// FIXME: (10.6.6) If 'height' is 'auto', the height depends on the element's descendants per 10.6.7.
} else {
auto container_height = CSS::Length::make_px(containing_block().height());
- inline_block.set_height(inline_block.computed_values().height().resolved(container_height).resolved_or_zero(inline_block, containing_block().height()).to_px(inline_block));
+ inline_block.set_height(inline_block.computed_values().height().resolved(container_height).resolved_or_zero(inline_block).to_px(inline_block));
}
return;
}
diff --git a/Userland/Libraries/LibWeb/Layout/InlineNode.cpp b/Userland/Libraries/LibWeb/Layout/InlineNode.cpp
index 501a1800ab..a5e2a2bbfc 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineNode.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineNode.cpp
@@ -36,14 +36,14 @@ void InlineNode::split_into_lines(InlineFormattingContext& context, LayoutMode l
};
if (is_not_undefined_or_auto(computed_values().padding().left)) {
- float padding_left = computed_values().padding().left.resolved(CSS::Length::make_px(containing_block.width())).resolved(CSS::Length::make_px(0), *this, containing_block.width()).to_px(*this);
+ float padding_left = computed_values().padding().left.resolved(CSS::Length::make_px(containing_block.width())).resolved(CSS::Length::make_px(0), *this).to_px(*this);
containing_block.ensure_last_line_box().add_fragment(*this, 0, 0, padding_left, 0, LineBoxFragment::Type::Leading);
}
NodeWithStyleAndBoxModelMetrics::split_into_lines(context, layout_mode);
if (is_not_undefined_or_auto(computed_values().padding().right)) {
- float padding_right = computed_values().padding().right.resolved(CSS::Length::make_px(containing_block.width())).resolved(CSS::Length::make_px(0), *this, containing_block.width()).to_px(*this);
+ float padding_right = computed_values().padding().right.resolved(CSS::Length::make_px(containing_block.width())).resolved(CSS::Length::make_px(0), *this).to_px(*this);
containing_block.ensure_last_line_box().add_fragment(*this, 0, 0, padding_right, 0, LineBoxFragment::Type::Trailing);
}
}
@@ -66,9 +66,9 @@ void InlineNode::paint(PaintContext& context, PaintPhase phase)
if (auto computed_box_shadow = computed_values().box_shadow(); computed_box_shadow.has_value()) {
auto box_shadow_data = Painting::BoxShadowData {
- .offset_x = (int)computed_box_shadow->offset_x.resolved_or_zero(*this, rect.width()).to_px(*this),
- .offset_y = (int)computed_box_shadow->offset_y.resolved_or_zero(*this, rect.height()).to_px(*this),
- .blur_radius = (int)computed_box_shadow->blur_radius.resolved_or_zero(*this, rect.width()).to_px(*this),
+ .offset_x = (int)computed_box_shadow->offset_x.resolved_or_zero(*this).to_px(*this),
+ .offset_y = (int)computed_box_shadow->offset_y.resolved_or_zero(*this).to_px(*this),
+ .blur_radius = (int)computed_box_shadow->blur_radius.resolved_or_zero(*this).to_px(*this),
.color = computed_box_shadow->color
};
Painting::paint_box_shadow(context, enclosing_int_rect(rect), box_shadow_data);
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 298704a737..be8bd5e9cc 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -460,7 +460,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
if (border.line_style == CSS::LineStyle::None)
border.width = 0;
else
- border.width = specified_style.length_or_fallback(width_property, {}).resolved_or_zero(*this, 0).to_px(*this);
+ border.width = specified_style.length_or_fallback(width_property, {}).resolved_or_zero(*this).to_px(*this);
};
do_border_style(computed_values.border_left(), CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftStyle);