From fa71401bec52561614164fddd5a71971ccb56921 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Mar 2022 15:42:23 +0200 Subject: [PATCH] LibWeb: Rename ComputedValues::offset() => inset() --- .../Libraries/LibWeb/CSS/ComputedValues.h | 6 ++-- .../LibWeb/Layout/FormattingContext.cpp | 30 +++++++++---------- Userland/Libraries/LibWeb/Layout/Node.cpp | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 06577c2a15..88779b1626 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -148,7 +148,7 @@ public: Optional const& max_height() const { return m_noninherited.max_height; } Variant const& vertical_align() const { return m_noninherited.vertical_align; } - const CSS::LengthBox& offset() const { return m_noninherited.offset; } + CSS::LengthBox const& inset() const { return m_noninherited.inset; } const CSS::LengthBox& margin() const { return m_noninherited.margin; } const CSS::LengthBox& padding() const { return m_noninherited.padding; } @@ -227,7 +227,7 @@ protected: Optional height; Optional min_height; Optional max_height; - CSS::LengthBox offset; + CSS::LengthBox inset; CSS::LengthBox margin; CSS::LengthBox padding; BorderData border_left; @@ -293,7 +293,7 @@ public: void set_height(CSS::LengthPercentage const& height) { m_noninherited.height = height; } void set_min_height(CSS::LengthPercentage const& height) { m_noninherited.min_height = height; } void set_max_height(CSS::LengthPercentage const& height) { m_noninherited.max_height = height; } - void set_offset(const CSS::LengthBox& offset) { m_noninherited.offset = offset; } + void set_inset(CSS::LengthBox const& inset) { m_noninherited.inset = inset; } void set_margin(const CSS::LengthBox& margin) { m_noninherited.margin = margin; } void set_padding(const CSS::LengthBox& padding) { m_noninherited.padding = padding; } void set_overflow_x(CSS::Overflow value) { m_noninherited.overflow_x = value; } diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index a2ab711e7b..e76036cd3a 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -495,8 +495,8 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele margin_left = computed_values.margin().left.resolved(box, width_of_containing_block).resolved(box); margin_right = computed_values.margin().right.resolved(box, width_of_containing_block).resolved(box); - auto left = computed_values.offset().left.resolved(box, width_of_containing_block).resolved(box); - auto right = computed_values.offset().right.resolved(box, width_of_containing_block).resolved(box); + auto left = computed_values.inset().left.resolved(box, width_of_containing_block).resolved(box); + auto right = computed_values.inset().right.resolved(box, width_of_containing_block).resolved(box); auto width = a_width; auto solve_for_left = [&] { @@ -640,8 +640,8 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el auto width_of_containing_block = CSS::Length::make_px(containing_block_state.content_width); auto height_of_containing_block = CSS::Length::make_px(containing_block_state.content_height); - CSS::Length specified_top = computed_values.offset().top.resolved(box, height_of_containing_block).resolved(box); - CSS::Length specified_bottom = computed_values.offset().bottom.resolved(box, height_of_containing_block).resolved(box); + CSS::Length specified_top = computed_values.inset().top.resolved(box, height_of_containing_block).resolved(box); + CSS::Length specified_bottom = computed_values.inset().bottom.resolved(box, height_of_containing_block).resolved(box); CSS::Length specified_height = CSS::Length::make_auto(); if (computed_values.height().has_value() && computed_values.height()->is_percentage() @@ -707,16 +707,16 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box) 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().offset().left.resolved(box, width_of_containing_block).to_px(box); - box_state.inset_top = box.computed_values().offset().top.resolved(box, height_of_containing_block).to_px(box); - box_state.inset_right = box.computed_values().offset().right.resolved(box, width_of_containing_block).to_px(box); - box_state.inset_bottom = box.computed_values().offset().bottom.resolved(box, height_of_containing_block).to_px(box); + box_state.inset_left = box.computed_values().inset().left.resolved(box, width_of_containing_block).to_px(box); + box_state.inset_top = box.computed_values().inset().top.resolved(box, height_of_containing_block).to_px(box); + box_state.inset_right = box.computed_values().inset().right.resolved(box, width_of_containing_block).to_px(box); + box_state.inset_bottom = box.computed_values().inset().bottom.resolved(box, height_of_containing_block).to_px(box); auto is_auto = [](auto const& length_percentage) { return length_percentage.is_length() && length_percentage.length().is_auto(); }; - if (is_auto(box.computed_values().offset().left) && specified_width.is_auto() && is_auto(box.computed_values().offset().right)) { + if (is_auto(box.computed_values().inset().left) && specified_width.is_auto() && is_auto(box.computed_values().inset().right)) { if (is_auto(box.computed_values().margin().left)) box_state.margin_left = 0; if (is_auto(box.computed_values().margin().right)) @@ -725,11 +725,11 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box) Gfx::FloatPoint used_offset; - if (!is_auto(box.computed_values().offset().left)) { + if (!is_auto(box.computed_values().inset().left)) { float x_offset = box_state.inset_left + box_state.border_box_left(); used_offset.set_x(x_offset + box_state.margin_left); - } else if (!is_auto(box.computed_values().offset().right)) { + } else if (!is_auto(box.computed_values().inset().right)) { float x_offset = 0 - box_state.inset_right - box_state.border_box_right(); @@ -739,11 +739,11 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box) used_offset.set_x(x_offset); } - if (!is_auto(box.computed_values().offset().top)) { + if (!is_auto(box.computed_values().inset().top)) { float y_offset = box_state.inset_top + box_state.border_box_top(); used_offset.set_y(y_offset + box_state.margin_top); - } else if (!is_auto(box.computed_values().offset().bottom)) { + } else if (!is_auto(box.computed_values().inset().bottom)) { float y_offset = 0 - box_state.inset_bottom - box_state.border_box_bottom(); @@ -779,8 +779,8 @@ void FormattingContext::compute_inset(Box const& box) float width_of_containing_block = m_state.get(*box.containing_block()).content_width; auto width_of_containing_block_as_length = CSS::Length::make_px(width_of_containing_block); - auto specified_left = computed_values.offset().left.resolved(box, width_of_containing_block_as_length).resolved(box); - auto specified_right = computed_values.offset().right.resolved(box, width_of_containing_block_as_length).resolved(box); + auto specified_left = computed_values.inset().left.resolved(box, width_of_containing_block_as_length).resolved(box); + auto specified_right = computed_values.inset().right.resolved(box, width_of_containing_block_as_length).resolved(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). diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 4232aa2a3c..242275d5df 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -509,7 +509,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style) if (auto maybe_length_percentage = computed_style.length_percentage(CSS::PropertyID::MaxHeight); maybe_length_percentage.has_value()) computed_values.set_max_height(maybe_length_percentage.release_value()); - computed_values.set_offset(computed_style.length_box(CSS::PropertyID::Left, CSS::PropertyID::Top, CSS::PropertyID::Right, CSS::PropertyID::Bottom, CSS::Length::make_auto())); + computed_values.set_inset(computed_style.length_box(CSS::PropertyID::Left, CSS::PropertyID::Top, CSS::PropertyID::Right, CSS::PropertyID::Bottom, CSS::Length::make_auto())); computed_values.set_margin(computed_style.length_box(CSS::PropertyID::MarginLeft, CSS::PropertyID::MarginTop, CSS::PropertyID::MarginRight, CSS::PropertyID::MarginBottom, CSS::Length::make_px(0))); computed_values.set_padding(computed_style.length_box(CSS::PropertyID::PaddingLeft, CSS::PropertyID::PaddingTop, CSS::PropertyID::PaddingRight, CSS::PropertyID::PaddingBottom, CSS::Length::make_px(0)));