ソースを参照

LibWeb: Convert LayoutState to new pixel units

Sam Atkins 2 年 前
コミット
c70dcaefcd

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -833,7 +833,7 @@ void Document::update_layout()
     if (!browsing_context())
         return;
 
-    auto viewport_rect = browsing_context()->viewport_rect().to_type<float>();
+    auto viewport_rect = browsing_context()->viewport_rect();
 
     if (!m_layout_root) {
         m_next_layout_node_serial_id = 0;

+ 13 - 13
Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp

@@ -309,7 +309,7 @@ void BlockFormattingContext::compute_width_for_floating_box(Box const& box, Avai
 
 void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox const& box, AvailableSpace const& available_space)
 {
-    m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box, available_space).value());
+    m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box, available_space));
 }
 
 void BlockFormattingContext::compute_height(Box const& box, AvailableSpace const& available_space)
@@ -338,7 +338,7 @@ void BlockFormattingContext::compute_height(Box const& box, AvailableSpace const
         height = max(height, calculate_inner_height(box, available_space.height, computed_values.min_height()).to_px(box));
     }
 
-    m_state.get_mutable(box).set_content_height(height.value());
+    m_state.get_mutable(box).set_content_height(height);
 }
 
 void BlockFormattingContext::layout_inline_children(BlockContainer const& block_container, LayoutMode layout_mode, AvailableSpace const& available_space)
@@ -354,9 +354,9 @@ void BlockFormattingContext::layout_inline_children(BlockContainer const& block_
         available_space);
 
     if (!block_container_state.has_definite_width())
-        block_container_state.set_content_width(context.automatic_content_width().value());
+        block_container_state.set_content_width(context.automatic_content_width());
     if (!block_container_state.has_definite_height())
-        block_container_state.set_content_height(context.automatic_content_height().value());
+        block_container_state.set_content_height(context.automatic_content_height());
 }
 
 static bool margins_collapse_through(Box const& box, LayoutState& state)
@@ -396,7 +396,7 @@ CSSPixels BlockFormattingContext::compute_auto_height_for_block_level_element(Bo
 
     // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
     if (box.children_are_inline() && !box_state.line_boxes.is_empty())
-        return box_state.line_boxes.last().bottom();
+        return box_state.line_boxes.last().bottom().value();
 
     // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin does not collapse with the element's bottom margin
     // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
@@ -427,7 +427,7 @@ CSSPixels BlockFormattingContext::compute_auto_height_for_block_level_element(Bo
                 margin_bottom = 0;
             }
 
-            return max(0.0f, child_box_state.offset.y() + child_box_state.content_height() + child_box_state.border_box_bottom() + margin_bottom.value());
+            return max(0.0f, (child_box_state.offset.y() + child_box_state.content_height() + child_box_state.border_box_bottom() + margin_bottom).value());
         }
     }
 
@@ -546,9 +546,9 @@ void BlockFormattingContext::layout_block_level_children(BlockContainer const& b
     if (layout_mode == LayoutMode::IntrinsicSizing) {
         auto& block_container_state = m_state.get_mutable(block_container);
         if (!block_container_state.has_definite_width())
-            block_container_state.set_content_width(greatest_child_width(block_container).value());
+            block_container_state.set_content_width(greatest_child_width(block_container));
         if (!block_container_state.has_definite_height())
-            block_container_state.set_content_height(bottom_of_lowest_margin_box.value());
+            block_container_state.set_content_height(bottom_of_lowest_margin_box);
     }
 }
 
@@ -629,7 +629,7 @@ void BlockFormattingContext::place_block_level_element_in_normal_flow_vertically
     if ((computed_values.clear() == CSS::Clear::Right || computed_values.clear() == CSS::Clear::Both) && !child_box.is_flex_item())
         clear_floating_boxes(m_right_floats);
 
-    box_state.set_content_offset(Gfx::FloatPoint { box_state.offset.x(), y.value() });
+    box_state.set_content_offset(CSSPixelPoint { box_state.offset.x(), y.value() });
 }
 
 void BlockFormattingContext::place_block_level_element_in_normal_flow_horizontally(Box const& child_box, AvailableSpace const& available_space)
@@ -713,7 +713,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
     // First we place the box normally (to get the right y coordinate.)
     // If we have a LineBuilder, we're in the middle of inline layout, otherwise this is block layout.
     if (line_builder) {
-        auto y = line_builder->y_for_float_to_be_inserted_here(box).value();
+        auto y = line_builder->y_for_float_to_be_inserted_here(box);
         box_state.set_content_y(y + box_state.margin_box_top());
     } else {
         place_block_level_element_in_normal_flow_vertically(box, y + box_state.margin_box_top());
@@ -753,7 +753,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
             }
 
             if (fits_on_line) {
-                auto const previous_rect = margin_box_rect_in_ancestor_coordinate_space(previous_box.box, root(), m_state).to_type<CSSPixels>();
+                auto const previous_rect = margin_box_rect_in_ancestor_coordinate_space(previous_box.box, root(), m_state);
                 if (previous_rect.contains_vertically(y_in_root + side_data.y_offset)) {
                     // This box touches another already floating box. Stack after others.
                     offset_from_edge = wanted_offset_from_edge;
@@ -856,8 +856,8 @@ void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_ite
 
     marker_state.set_content_height(max(image_height, marker.font().glyph_height() + 1).value());
 
-    marker_state.set_content_offset({ -(marker_state.content_width() + default_marker_width.value()),
-        max(0.f, (marker.line_height() - marker_state.content_height()) / 2.f) });
+    marker_state.set_content_offset({ -(marker_state.content_width() + default_marker_width),
+        max(CSSPixels(0.f), (CSSPixels(marker.line_height()) - marker_state.content_height()) / 2.f) });
 
     if (marker_state.content_height() > list_item_state.content_height())
         list_item_state.set_content_height(marker_state.content_height());

+ 21 - 21
Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp

@@ -442,43 +442,43 @@ bool FlexFormattingContext::is_cross_auto(Box const& box) const
 void FlexFormattingContext::set_main_size(Box const& box, CSSPixels size)
 {
     if (is_row_layout())
-        m_state.get_mutable(box).set_content_width(size.value());
+        m_state.get_mutable(box).set_content_width(size);
     else
-        m_state.get_mutable(box).set_content_height(size.value());
+        m_state.get_mutable(box).set_content_height(size);
 }
 
 void FlexFormattingContext::set_cross_size(Box const& box, CSSPixels size)
 {
     if (is_row_layout())
-        m_state.get_mutable(box).set_content_height(size.value());
+        m_state.get_mutable(box).set_content_height(size);
     else
-        m_state.get_mutable(box).set_content_width(size.value());
+        m_state.get_mutable(box).set_content_width(size);
 }
 
 void FlexFormattingContext::set_offset(Box const& box, CSSPixels main_offset, CSSPixels cross_offset)
 {
     if (is_row_layout())
-        m_state.get_mutable(box).offset = Gfx::FloatPoint { main_offset, cross_offset };
+        m_state.get_mutable(box).offset = CSSPixelPoint { main_offset, cross_offset };
     else
-        m_state.get_mutable(box).offset = Gfx::FloatPoint { cross_offset, main_offset };
+        m_state.get_mutable(box).offset = CSSPixelPoint { cross_offset, main_offset };
 }
 
 void FlexFormattingContext::set_main_axis_first_margin(FlexItem& item, CSSPixels margin)
 {
     item.margins.main_before = margin;
     if (is_row_layout())
-        m_state.get_mutable(item.box).margin_left = margin.value();
+        m_state.get_mutable(item.box).margin_left = margin;
     else
-        m_state.get_mutable(item.box).margin_top = margin.value();
+        m_state.get_mutable(item.box).margin_top = margin;
 }
 
 void FlexFormattingContext::set_main_axis_second_margin(FlexItem& item, CSSPixels margin)
 {
     item.margins.main_after = margin;
     if (is_row_layout())
-        m_state.get_mutable(item.box).margin_right = margin.value();
+        m_state.get_mutable(item.box).margin_right = margin;
     else
-        m_state.get_mutable(item.box).margin_bottom = margin.value();
+        m_state.get_mutable(item.box).margin_bottom = margin;
 }
 
 // https://drafts.csswg.org/css-flexbox-1/#algo-available
@@ -581,10 +581,10 @@ CSSPixels FlexFormattingContext::calculate_indefinite_main_size(FlexItem const&
         // NOTE: Flex items should always create an independent formatting context!
         VERIFY(independent_formatting_context);
 
-        box_state.set_content_width(fit_content_cross_size.value());
+        box_state.set_content_width(fit_content_cross_size);
         independent_formatting_context->run(item.box, LayoutMode::Normal, m_available_space_for_items->space);
 
-        return independent_formatting_context->automatic_content_height().value();
+        return independent_formatting_context->automatic_content_height();
     }
 
     return calculate_fit_content_main_size(item);
@@ -708,9 +708,9 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
     //       The spec just barely hand-waves about this, but it seems to *roughly* match what other engines do.
     //       See "Note" section here: https://drafts.csswg.org/css-flexbox-1/#definite-sizes
     if (is_row_layout())
-        m_state.get_mutable(flex_item.box).set_temporary_content_width(flex_item.hypothetical_main_size.value());
+        m_state.get_mutable(flex_item.box).set_temporary_content_width(flex_item.hypothetical_main_size);
     else
-        m_state.get_mutable(flex_item.box).set_temporary_content_height(flex_item.hypothetical_main_size.value());
+        m_state.get_mutable(flex_item.box).set_temporary_content_height(flex_item.hypothetical_main_size);
 }
 
 // https://drafts.csswg.org/css-flexbox-1/#min-size-auto
@@ -825,13 +825,13 @@ void FlexFormattingContext::determine_main_size_of_flex_container()
 
     if (is_row_layout()) {
         if (!flex_container().is_out_of_flow(*parent()) && m_state.get(*flex_container().containing_block()).has_definite_width()) {
-            set_main_size(flex_container(), calculate_stretch_fit_width(flex_container(), m_available_space_for_flex_container->space.width).value());
+            set_main_size(flex_container(), calculate_stretch_fit_width(flex_container(), m_available_space_for_flex_container->space.width));
         } else {
-            set_main_size(flex_container(), calculate_max_content_width(flex_container()).value());
+            set_main_size(flex_container(), calculate_max_content_width(flex_container()));
         }
     } else {
         if (!has_definite_main_size(flex_container()))
-            set_main_size(flex_container(), calculate_max_content_height(flex_container(), m_available_space_for_flex_container->space.width).value());
+            set_main_size(flex_container(), calculate_max_content_height(flex_container(), m_available_space_for_flex_container->space.width));
     }
 }
 
@@ -1091,9 +1091,9 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
 
     auto& containing_block_state = throwaway_state.get_mutable(flex_container());
     if (is_row_layout()) {
-        containing_block_state.set_content_width(item.main_size.value());
+        containing_block_state.set_content_width(item.main_size);
     } else {
-        containing_block_state.set_content_height(item.main_size.value());
+        containing_block_state.set_content_height(item.main_size);
     }
 
     auto& box_state = throwaway_state.get_mutable(item.box);
@@ -2054,13 +2054,13 @@ CSSPixelPoint FlexFormattingContext::calculate_static_position(Box const& box) c
     if (!pack_from_end)
         main_offset += specified_main_size(flex_container()) - specified_main_size(box);
 
-    auto static_position_offset = is_row_layout() ? Gfx::FloatPoint { main_offset, cross_offset } : Gfx::FloatPoint { cross_offset, main_offset };
+    auto static_position_offset = is_row_layout() ? CSSPixelPoint { main_offset, cross_offset } : CSSPixelPoint { cross_offset, main_offset };
 
     auto absolute_position_of_flex_container = absolute_content_rect(flex_container(), m_state).location();
     auto absolute_position_of_abspos_containing_block = absolute_content_rect(*box.containing_block(), m_state).location();
     auto diff = absolute_position_of_flex_container - absolute_position_of_abspos_containing_block;
 
-    return (static_position_offset + diff).to_type<CSSPixels>();
+    return static_position_offset + diff;
 }
 
 }

+ 19 - 19
Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

@@ -632,7 +632,7 @@ void FormattingContext::compute_width_for_absolutely_positioned_replaced_element
     // The used value of 'width' is determined as for inline replaced elements.
     // FIXME: This const_cast is gross.
     const_cast<ReplacedBox&>(box).prepare_for_replaced_layout();
-    m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box, available_space).value());
+    m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box, available_space));
 }
 
 // https://drafts.csswg.org/css-position-3/#abs-non-replaced-height
@@ -819,14 +819,14 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
 // NOTE: This is different from content_box_rect_in_ancestor_coordinate_space() as this does *not* follow the containing block chain up, but rather the parent() chain.
 static CSSPixelRect content_box_rect_in_static_position_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
 {
-    auto rect = content_box_rect(box, state).to_type<CSSPixels>();
+    auto rect = content_box_rect(box, state);
     if (&box == &ancestor_box)
         return rect;
     for (auto const* current = box.parent(); current; current = current->parent()) {
         if (current == &ancestor_box)
             return rect;
         auto const& current_state = state.get(static_cast<Box const&>(*current));
-        rect.translate_by(current_state.offset.to_type<CSSPixels>());
+        rect.translate_by(current_state.offset);
     }
     // If we get here, ancestor_box was not an ancestor of `box`!
     VERIFY_NOT_REACHED();
@@ -934,7 +934,7 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
             + box_state.border_box_left();
         used_offset.set_x(x_offset + box_state.margin_left);
     } else if (!computed_right.is_auto()) {
-        CSSPixels x_offset = 0
+        CSSPixels x_offset = CSSPixels(0)
             - box_state.inset_right
             - box_state.border_box_right();
         used_offset.set_x(width_of_containing_block + x_offset - box_state.content_width() - box_state.margin_right);
@@ -948,7 +948,7 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
             + box_state.border_box_top();
         used_offset.set_y(y_offset + box_state.margin_top);
     } else if (!computed_bottom.is_auto()) {
-        CSSPixels y_offset = 0
+        CSSPixels y_offset = CSSPixels(0)
             - box_state.inset_bottom
             - box_state.border_box_bottom();
         used_offset.set_y(height_of_containing_block + y_offset - box_state.content_height() - box_state.margin_bottom);
@@ -960,7 +960,7 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
     // NOTE: Absolutely positioned boxes are relative to the *padding edge* of the containing block.
     used_offset.translate_by(-containing_block_state.padding_left, -containing_block_state.padding_top);
 
-    box_state.set_content_offset(used_offset.to_type<float>());
+    box_state.set_content_offset(used_offset);
 
     if (independent_formatting_context)
         independent_formatting_context->parent_context_did_dimension_child_root_box();
@@ -970,7 +970,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.
-    m_state.get_mutable(box).set_content_height(compute_height_for_replaced_element(m_state, box, available_space).value());
+    m_state.get_mutable(box).set_content_height(compute_height_for_replaced_element(m_state, box, available_space));
 }
 
 // https://www.w3.org/TR/css-position-3/#relpos-insets
@@ -979,7 +979,7 @@ void FormattingContext::compute_inset(Box const& box)
     if (box.computed_values().position() != CSS::Position::Relative)
         return;
 
-    auto resolve_two_opposing_insets = [&](CSS::LengthPercentage const& computed_start, CSS::LengthPercentage const& computed_end, float& used_start, float& used_end, CSSPixels reference_for_percentage) {
+    auto resolve_two_opposing_insets = [&](CSS::LengthPercentage const& computed_start, CSS::LengthPercentage const& computed_end, CSSPixels& used_start, CSSPixels& used_end, CSSPixels reference_for_percentage) {
         auto resolved_first = computed_start.resolved(box, CSS::Length::make_px(reference_for_percentage)).resolved(box);
         auto resolved_second = computed_end.resolved(box, CSS::Length::make_px(reference_for_percentage)).resolved(box);
 
@@ -992,16 +992,16 @@ void FormattingContext::compute_inset(Box const& box)
             // If only one is auto, its used value becomes the negation of the other, and the box is shifted by the specified amount.
             if (resolved_first.is_auto()) {
                 used_end = resolved_second.to_px(box);
-                used_start = 0 - used_end;
+                used_start = -used_end;
             } else {
                 used_start = resolved_first.to_px(box);
-                used_end = 0 - used_start;
+                used_end = -used_start;
             }
         } else {
             // If neither is auto, the position is over-constrained; (with respect to the writing mode of its containing block)
             // the computed end side value is ignored, and its used value becomes the negation of the start side.
             used_start = resolved_first.to_px(box);
-            used_end = 0 - used_start;
+            used_end = -used_start;
         }
     };
 
@@ -1082,7 +1082,7 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box)
         cache.min_content_width = context->greatest_child_width(box).value();
     }
 
-    if (!isfinite(*cache.min_content_width)) {
+    if (!isfinite(cache.min_content_width->value())) {
         // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine.
         dbgln("FIXME: Calculated non-finite min-content width for {}", box.debug_description());
         cache.min_content_width = 0;
@@ -1120,7 +1120,7 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
         cache.max_content_width = context->greatest_child_width(box).value();
     }
 
-    if (!isfinite(*cache.max_content_width)) {
+    if (!isfinite(cache.max_content_width->value())) {
         // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine.
         dbgln("FIXME: Calculated non-finite max-content width for {}", box.debug_description());
         cache.max_content_width = 0;
@@ -1135,12 +1135,12 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
         return *box.intrinsic_height();
 
     bool is_cacheable = available_width.is_definite() || available_width.is_intrinsic_sizing_constraint();
-    Optional<float>* cache_slot = nullptr;
+    Optional<CSSPixels>* cache_slot = nullptr;
     if (is_cacheable) {
         auto& root_state = m_state.m_root;
         auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
         if (available_width.is_definite()) {
-            cache_slot = &cache.min_content_height_with_definite_available_width.ensure(available_width.to_px().value());
+            cache_slot = &cache.min_content_height_with_definite_available_width.ensure(available_width.to_px());
         } else if (available_width.is_min_content()) {
             cache_slot = &cache.min_content_height_with_min_content_available_width;
         } else if (available_width.is_max_content()) {
@@ -1169,7 +1169,7 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box
     }
 
     if (cache_slot) {
-        *cache_slot = min_content_height.value();
+        *cache_slot = min_content_height;
     }
     return min_content_height;
 }
@@ -1180,12 +1180,12 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box
         return *box.intrinsic_height();
 
     bool is_cacheable = available_width.is_definite() || available_width.is_intrinsic_sizing_constraint();
-    Optional<float>* cache_slot = nullptr;
+    Optional<CSSPixels>* cache_slot = nullptr;
     if (is_cacheable) {
         auto& root_state = m_state.m_root;
         auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
         if (available_width.is_definite()) {
-            cache_slot = &cache.max_content_height_with_definite_available_width.ensure(available_width.to_px().value());
+            cache_slot = &cache.max_content_height_with_definite_available_width.ensure(available_width.to_px());
         } else if (available_width.is_min_content()) {
             cache_slot = &cache.max_content_height_with_min_content_available_width;
         } else if (available_width.is_max_content()) {
@@ -1215,7 +1215,7 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box
     }
 
     if (cache_slot) {
-        *cache_slot = max_content_height.value();
+        *cache_slot = max_content_height;
     }
 
     return max_content_height;

+ 2 - 2
Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp

@@ -1732,8 +1732,8 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
             y_start += m_grid_rows[i].base_size;
         for (int i = 0; i < row_end; i++)
             y_end += m_grid_rows[i].base_size;
-        child_box_state.set_content_width((x_end - x_start).value());
-        child_box_state.set_content_height((y_end - y_start).value());
+        child_box_state.set_content_width((x_end - x_start));
+        child_box_state.set_content_height((y_end - y_start));
         child_box_state.offset = { x_start, y_start };
 
         auto available_space_for_children = AvailableSpace(AvailableSize::make_definite(child_box_state.content_width()), AvailableSize::make_definite(child_box_state.content_height()));

+ 7 - 7
Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp

@@ -41,7 +41,7 @@ BlockFormattingContext const& InlineFormattingContext::parent() const
 CSSPixels InlineFormattingContext::leftmost_x_offset_at(CSSPixels y) const
 {
     // NOTE: Floats are relative to the BFC root box, not necessarily the containing block of this IFC.
-    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state).to_type<CSSPixels>();
+    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state);
     CSSPixels y_in_root = box_in_root_rect.y() + y;
     auto space = parent().space_used_by_floats(y_in_root);
     return space.left;
@@ -51,7 +51,7 @@ CSSPixels InlineFormattingContext::available_space_for_line(CSSPixels y) const
 {
     // NOTE: Floats are relative to the BFC root box, not necessarily the containing block of this IFC.
     auto& root_block = parent().root();
-    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), root_block, m_state).to_type<CSSPixels>();
+    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), root_block, m_state);
     CSSPixels y_in_root = box_in_root_rect.y() + y;
     auto space = parent().space_used_by_floats(y_in_root);
 
@@ -117,8 +117,8 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l
         if (is<SVGSVGBox>(box))
             (void)layout_inside(replaced, layout_mode, *m_available_space);
 
-        box_state.set_content_width(compute_width_for_replaced_element(m_state, replaced, *m_available_space).value());
-        box_state.set_content_height(compute_height_for_replaced_element(m_state, replaced, *m_available_space).value());
+        box_state.set_content_width(compute_width_for_replaced_element(m_state, replaced, *m_available_space));
+        box_state.set_content_height(compute_height_for_replaced_element(m_state, replaced, *m_available_space));
         return;
     }
 
@@ -161,7 +161,7 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l
         width = max(width, min_width);
     }
 
-    box_state.set_content_width(width.value());
+    box_state.set_content_width(width);
 
     auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(*m_available_space));
 
@@ -317,7 +317,7 @@ void InlineFormattingContext::generate_line_boxes(LayoutMode layout_mode)
 
 bool InlineFormattingContext::any_floats_intrude_at_y(CSSPixels y) const
 {
-    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state).to_type<CSSPixels>();
+    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state);
     CSSPixels y_in_root = box_in_root_rect.y() + y;
     auto space = parent().space_used_by_floats(y_in_root);
     return space.left > 0 || space.right > 0;
@@ -325,7 +325,7 @@ bool InlineFormattingContext::any_floats_intrude_at_y(CSSPixels y) const
 
 bool InlineFormattingContext::can_fit_new_line_at_y(CSSPixels y) const
 {
-    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state).to_type<CSSPixels>();
+    auto box_in_root_rect = content_box_rect_in_ancestor_coordinate_space(containing_block(), parent().root(), m_state);
     CSSPixels y_in_root = box_in_root_rect.y() + y;
     auto space_top = parent().space_used_by_floats(y_in_root);
     auto space_bottom = parent().space_used_by_floats(y_in_root + containing_block().line_height() - 1);

+ 35 - 35
Userland/Libraries/LibWeb/Layout/LayoutState.cpp

@@ -65,10 +65,10 @@ void LayoutState::commit()
         auto& node = const_cast<NodeWithStyleAndBoxModelMetrics&>(used_values.node());
 
         // Transfer box model metrics.
-        node.box_model().inset = { used_values.inset_top, used_values.inset_right, used_values.inset_bottom, used_values.inset_left };
-        node.box_model().padding = { used_values.padding_top, used_values.padding_right, used_values.padding_bottom, used_values.padding_left };
-        node.box_model().border = { used_values.border_top, used_values.border_right, used_values.border_bottom, used_values.border_left };
-        node.box_model().margin = { used_values.margin_top, used_values.margin_right, used_values.margin_bottom, used_values.margin_left };
+        node.box_model().inset = { used_values.inset_top.value(), used_values.inset_right.value(), used_values.inset_bottom.value(), used_values.inset_left.value() };
+        node.box_model().padding = { used_values.padding_top.value(), used_values.padding_right.value(), used_values.padding_bottom.value(), used_values.padding_left.value() };
+        node.box_model().border = { used_values.border_top.value(), used_values.border_right.value(), used_values.border_bottom.value(), used_values.border_left.value() };
+        node.box_model().margin = { used_values.margin_top.value(), used_values.margin_right.value(), used_values.margin_bottom.value(), used_values.margin_left.value() };
 
         node.set_paintable(node.create_paintable());
 
@@ -76,7 +76,7 @@ void LayoutState::commit()
         if (is<Layout::Box>(node)) {
             auto& box = static_cast<Layout::Box const&>(node);
             auto& paint_box = const_cast<Painting::PaintableBox&>(*box.paint_box());
-            paint_box.set_offset(used_values.offset.to_type<CSSPixels>());
+            paint_box.set_offset(used_values.offset);
             paint_box.set_content_size(used_values.content_width(), used_values.content_height());
             paint_box.set_overflow_data(move(used_values.overflow_data));
             paint_box.set_containing_line_box_fragment(used_values.containing_line_box_fragment);
@@ -97,7 +97,7 @@ void LayoutState::commit()
         text_node->set_paintable(text_node->create_paintable());
 }
 
-float box_baseline(LayoutState const& state, Box const& box)
+CSSPixels box_baseline(LayoutState const& state, Box const& box)
 {
     auto const& box_state = state.get(box);
 
@@ -123,7 +123,7 @@ float box_baseline(LayoutState const& state, Box const& box)
     }
 
     if (!box_state.line_boxes.is_empty())
-        return box_state.border_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline().value();
+        return box_state.border_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline();
     if (box.has_children() && !box.children_are_inline()) {
         auto const* child_box = box.last_child_of_type<Box>();
         VERIFY(child_box);
@@ -132,10 +132,10 @@ float box_baseline(LayoutState const& state, Box const& box)
     return box_state.border_box_height();
 }
 
-Gfx::FloatRect margin_box_rect(Box const& box, LayoutState const& state)
+CSSPixelRect margin_box_rect(Box const& box, LayoutState const& state)
 {
     auto const& box_state = state.get(box);
-    auto rect = Gfx::FloatRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
+    auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
     rect.set_x(rect.x() - box_state.margin_box_left());
     rect.set_width(rect.width() + box_state.margin_box_left() + box_state.margin_box_right());
     rect.set_y(rect.y() - box_state.margin_box_top());
@@ -143,10 +143,10 @@ Gfx::FloatRect margin_box_rect(Box const& box, LayoutState const& state)
     return rect;
 }
 
-Gfx::FloatRect border_box_rect(Box const& box, LayoutState const& state)
+CSSPixelRect border_box_rect(Box const& box, LayoutState const& state)
 {
     auto const& box_state = state.get(box);
-    auto rect = Gfx::FloatRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
+    auto rect = CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
     rect.set_x(rect.x() - box_state.border_box_left());
     rect.set_width(rect.width() + box_state.border_box_left() + box_state.border_box_right());
     rect.set_y(rect.y() - box_state.border_box_top());
@@ -154,7 +154,7 @@ Gfx::FloatRect border_box_rect(Box const& box, LayoutState const& state)
     return rect;
 }
 
-Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
+CSSPixelRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
 {
     auto rect = border_box_rect(box, state);
     if (&box == &ancestor_box)
@@ -169,13 +169,13 @@ Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box
     VERIFY_NOT_REACHED();
 }
 
-Gfx::FloatRect content_box_rect(Box const& box, LayoutState const& state)
+CSSPixelRect content_box_rect(Box const& box, LayoutState const& state)
 {
     auto const& box_state = state.get(box);
-    return Gfx::FloatRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
+    return CSSPixelRect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
 }
 
-Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
+CSSPixelRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
 {
     auto rect = content_box_rect(box, state);
     if (&box == &ancestor_box)
@@ -190,7 +190,7 @@ Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box
     VERIFY_NOT_REACHED();
 }
 
-Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
+CSSPixelRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
 {
     auto rect = margin_box_rect(box, state);
     if (&box == &ancestor_box)
@@ -205,10 +205,10 @@ Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box
     VERIFY_NOT_REACHED();
 }
 
-Gfx::FloatRect absolute_content_rect(Box const& box, LayoutState const& state)
+CSSPixelRect absolute_content_rect(Box const& box, LayoutState const& state)
 {
     auto const& box_state = state.get(box);
-    Gfx::FloatRect rect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
+    CSSPixelRect rect { box_state.offset, { box_state.content_width(), box_state.content_height() } };
     for (auto* block = box.containing_block(); block; block = block->containing_block())
         rect.translate_by(state.get(*block).offset);
     return rect;
@@ -229,7 +229,7 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
 
     auto const& computed_values = node.computed_values();
 
-    auto is_definite_size = [&](CSS::Size const& size, float& resolved_definite_size, bool width) {
+    auto is_definite_size = [&](CSS::Size const& size, CSSPixels& resolved_definite_size, bool width) {
         // A size that can be determined without performing layout; that is,
         // a <length>,
         // a measure of text (without consideration of line-wrapping),
@@ -248,7 +248,7 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
                 && (node.parent()->display().is_flow_root_inside()
                     || node.parent()->display().is_flow_inside())) {
                 if (containing_block_has_definite_size) {
-                    float available_width = containing_block_used_values->content_width();
+                    CSSPixels available_width = containing_block_used_values->content_width();
                     resolved_definite_size = available_width
                         - margin_left
                         - margin_right
@@ -296,14 +296,14 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
         return false;
     };
 
-    float min_width = 0;
+    CSSPixels min_width = 0;
     bool has_definite_min_width = is_definite_size(computed_values.min_width(), min_width, true);
-    float max_width = 0;
+    CSSPixels max_width = 0;
     bool has_definite_max_width = is_definite_size(computed_values.max_width(), max_width, true);
 
-    float min_height = 0;
+    CSSPixels min_height = 0;
     bool has_definite_min_height = is_definite_size(computed_values.min_height(), min_height, false);
-    float max_height = 0;
+    CSSPixels max_height = 0;
     bool has_definite_max_height = is_definite_size(computed_values.max_height(), max_height, false);
 
     m_has_definite_width = is_definite_size(computed_values.width(), m_content_width, true);
@@ -324,34 +324,34 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
     }
 }
 
-void LayoutState::UsedValues::set_content_width(float width)
+void LayoutState::UsedValues::set_content_width(CSSPixels width)
 {
     m_content_width = width;
     m_has_definite_width = true;
 }
 
-void LayoutState::UsedValues::set_content_height(float height)
+void LayoutState::UsedValues::set_content_height(CSSPixels height)
 {
     m_content_height = height;
     m_has_definite_height = true;
 }
 
-void LayoutState::UsedValues::set_temporary_content_width(float width)
+void LayoutState::UsedValues::set_temporary_content_width(CSSPixels width)
 {
     m_content_width = width;
 }
 
-void LayoutState::UsedValues::set_temporary_content_height(float height)
+void LayoutState::UsedValues::set_temporary_content_height(CSSPixels height)
 {
     m_content_height = height;
 }
 
-float LayoutState::resolved_definite_width(Box const& box) const
+CSSPixels LayoutState::resolved_definite_width(Box const& box) const
 {
     return get(box).content_width();
 }
 
-float LayoutState::resolved_definite_height(Box const& box) const
+CSSPixels LayoutState::resolved_definite_height(Box const& box) const
 {
     return get(box).content_height();
 }
@@ -390,18 +390,18 @@ AvailableSpace LayoutState::UsedValues::available_inner_space_or_constraints_fro
     return AvailableSpace(inner_width, inner_height);
 }
 
-void LayoutState::UsedValues::set_content_offset(Gfx::FloatPoint offset)
+void LayoutState::UsedValues::set_content_offset(CSSPixelPoint new_offset)
 {
-    set_content_x(offset.x());
-    set_content_y(offset.y());
+    set_content_x(new_offset.x());
+    set_content_y(new_offset.y());
 }
 
-void LayoutState::UsedValues::set_content_x(float x)
+void LayoutState::UsedValues::set_content_x(CSSPixels x)
 {
     offset.set_x(x);
 }
 
-void LayoutState::UsedValues::set_content_y(float y)
+void LayoutState::UsedValues::set_content_y(CSSPixels y)
 {
     offset.set_y(y);
 }

+ 58 - 58
Userland/Libraries/LibWeb/Layout/LayoutState.h

@@ -48,15 +48,15 @@ struct LayoutState {
         NodeWithStyleAndBoxModelMetrics const& node() const { return *m_node; }
         void set_node(NodeWithStyleAndBoxModelMetrics&, UsedValues const* containing_block_used_values);
 
-        float content_width() const { return m_content_width; }
-        float content_height() const { return m_content_height; }
-        void set_content_width(float);
-        void set_content_height(float);
+        CSSPixels content_width() const { return m_content_width; }
+        CSSPixels content_height() const { return m_content_height; }
+        void set_content_width(CSSPixels);
+        void set_content_height(CSSPixels);
 
         // NOTE: These are used by FlexFormattingContext to assign a temporary main size to items
         //       early on, so that descendants have something to resolve percentages against.
-        void set_temporary_content_width(float);
-        void set_temporary_content_height(float);
+        void set_temporary_content_width(CSSPixels);
+        void set_temporary_content_height(CSSPixels);
 
         bool has_definite_width() const { return m_has_definite_width && width_constraint == SizeConstraint::None; }
         bool has_definite_height() const { return m_has_definite_height && height_constraint == SizeConstraint::None; }
@@ -66,52 +66,52 @@ struct LayoutState {
         // the constraint is used in that axis instead.
         AvailableSpace available_inner_space_or_constraints_from(AvailableSpace const& outer_space) const;
 
-        void set_content_offset(Gfx::FloatPoint);
-        void set_content_x(float);
-        void set_content_y(float);
+        void set_content_offset(CSSPixelPoint);
+        void set_content_x(CSSPixels);
+        void set_content_y(CSSPixels);
 
-        Gfx::FloatPoint offset;
+        CSSPixelPoint offset;
 
         SizeConstraint width_constraint { SizeConstraint::None };
         SizeConstraint height_constraint { SizeConstraint::None };
 
-        float margin_left { 0 };
-        float margin_right { 0 };
-        float margin_top { 0 };
-        float margin_bottom { 0 };
+        CSSPixels margin_left { 0 };
+        CSSPixels margin_right { 0 };
+        CSSPixels margin_top { 0 };
+        CSSPixels margin_bottom { 0 };
 
-        float border_left { 0 };
-        float border_right { 0 };
-        float border_top { 0 };
-        float border_bottom { 0 };
+        CSSPixels border_left { 0 };
+        CSSPixels border_right { 0 };
+        CSSPixels border_top { 0 };
+        CSSPixels border_bottom { 0 };
 
-        float padding_left { 0 };
-        float padding_right { 0 };
-        float padding_top { 0 };
-        float padding_bottom { 0 };
+        CSSPixels padding_left { 0 };
+        CSSPixels padding_right { 0 };
+        CSSPixels padding_top { 0 };
+        CSSPixels padding_bottom { 0 };
 
-        float inset_left { 0 };
-        float inset_right { 0 };
-        float inset_top { 0 };
-        float inset_bottom { 0 };
+        CSSPixels inset_left { 0 };
+        CSSPixels inset_right { 0 };
+        CSSPixels inset_top { 0 };
+        CSSPixels inset_bottom { 0 };
 
         Vector<LineBox> line_boxes;
 
-        float margin_box_left() const { return margin_left + border_left + padding_left; }
-        float margin_box_right() const { return margin_right + border_right + padding_right; }
-        float margin_box_top() const { return margin_top + border_top + padding_top; }
-        float margin_box_bottom() const { return margin_bottom + border_bottom + padding_bottom; }
+        CSSPixels margin_box_left() const { return margin_left + border_left + padding_left; }
+        CSSPixels margin_box_right() const { return margin_right + border_right + padding_right; }
+        CSSPixels margin_box_top() const { return margin_top + border_top + padding_top; }
+        CSSPixels margin_box_bottom() const { return margin_bottom + border_bottom + padding_bottom; }
 
-        float margin_box_width() const { return margin_box_left() + content_width() + margin_box_right(); }
-        float margin_box_height() const { return margin_box_top() + content_height() + margin_box_bottom(); }
+        CSSPixels margin_box_width() const { return margin_box_left() + content_width() + margin_box_right(); }
+        CSSPixels margin_box_height() const { return margin_box_top() + content_height() + margin_box_bottom(); }
 
-        float border_box_left() const { return border_left + padding_left; }
-        float border_box_right() const { return border_right + padding_right; }
-        float border_box_top() const { return border_top + padding_top; }
-        float border_box_bottom() const { return border_bottom + padding_bottom; }
+        CSSPixels border_box_left() const { return border_left + padding_left; }
+        CSSPixels border_box_right() const { return border_right + padding_right; }
+        CSSPixels border_box_top() const { return border_top + padding_top; }
+        CSSPixels border_box_bottom() const { return border_bottom + padding_bottom; }
 
-        float border_box_width() const { return border_box_left() + content_width() + border_box_right(); }
-        float border_box_height() const { return border_box_top() + content_height() + border_box_bottom(); }
+        CSSPixels border_box_width() const { return border_box_left() + content_width() + border_box_right(); }
+        CSSPixels border_box_height() const { return border_box_top() + content_height() + border_box_bottom(); }
 
         Optional<Painting::PaintableBox::OverflowData> overflow_data;
 
@@ -133,8 +133,8 @@ struct LayoutState {
 
         Layout::NodeWithStyleAndBoxModelMetrics* m_node { nullptr };
 
-        float m_content_width { 0 };
-        float m_content_height { 0 };
+        CSSPixels m_content_width { 0 };
+        CSSPixels m_content_height { 0 };
 
         bool m_has_definite_width { false };
         bool m_has_definite_height { false };
@@ -142,8 +142,8 @@ struct LayoutState {
         HashTable<Box const*> m_floating_descendants;
     };
 
-    float resolved_definite_width(Box const&) const;
-    float resolved_definite_height(Box const&) const;
+    CSSPixels resolved_definite_width(Box const&) const;
+    CSSPixels resolved_definite_height(Box const&) const;
 
     void commit();
 
@@ -158,17 +158,17 @@ struct LayoutState {
     // We cache intrinsic sizes once determined, as they will not change over the course of a full layout.
     // This avoids computing them several times while performing flex layout.
     struct IntrinsicSizes {
-        Optional<float> min_content_width;
-        Optional<float> max_content_width;
+        Optional<CSSPixels> min_content_width;
+        Optional<CSSPixels> max_content_width;
 
         // NOTE: Since intrinsic heights depend on the amount of available width, we have to cache
         //       three separate kinds of results, depending on the available width at the time of calculation.
-        HashMap<float, Optional<float>> min_content_height_with_definite_available_width;
-        HashMap<float, Optional<float>> max_content_height_with_definite_available_width;
-        Optional<float> min_content_height_with_min_content_available_width;
-        Optional<float> max_content_height_with_min_content_available_width;
-        Optional<float> min_content_height_with_max_content_available_width;
-        Optional<float> max_content_height_with_max_content_available_width;
+        HashMap<CSSPixels, Optional<CSSPixels>> min_content_height_with_definite_available_width;
+        HashMap<CSSPixels, Optional<CSSPixels>> max_content_height_with_definite_available_width;
+        Optional<CSSPixels> min_content_height_with_min_content_available_width;
+        Optional<CSSPixels> max_content_height_with_min_content_available_width;
+        Optional<CSSPixels> min_content_height_with_max_content_available_width;
+        Optional<CSSPixels> max_content_height_with_max_content_available_width;
     };
 
     HashMap<NodeWithStyleAndBoxModelMetrics const*, NonnullOwnPtr<IntrinsicSizes>> mutable intrinsic_sizes;
@@ -177,13 +177,13 @@ struct LayoutState {
     LayoutState const& m_root;
 };
 
-Gfx::FloatRect absolute_content_rect(Box const&, LayoutState const&);
-Gfx::FloatRect margin_box_rect(Box const&, LayoutState const&);
-Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
-Gfx::FloatRect border_box_rect(Box const&, LayoutState const&);
-Gfx::FloatRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
-Gfx::FloatRect content_box_rect(Box const&, LayoutState const&);
-Gfx::FloatRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
-float box_baseline(LayoutState const& state, Box const& box);
+CSSPixelRect absolute_content_rect(Box const&, LayoutState const&);
+CSSPixelRect margin_box_rect(Box const&, LayoutState const&);
+CSSPixelRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
+CSSPixelRect border_box_rect(Box const&, LayoutState const&);
+CSSPixelRect border_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
+CSSPixelRect content_box_rect(Box const&, LayoutState const&);
+CSSPixelRect content_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
+CSSPixels box_baseline(LayoutState const& state, Box const& box);
 
 }

+ 4 - 4
Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp

@@ -81,7 +81,7 @@ void SVGFormattingContext::run(Box const& box, LayoutMode, [[maybe_unused]] Avai
             if (maybe_view_box.has_value()) {
                 auto view_box = maybe_view_box.value();
                 CSSPixelPoint viewbox_offset = { view_box.min_x, view_box.min_y };
-                geometry_box_state.set_content_offset((path_bounding_box.top_left() + viewbox_offset).to_type<float>());
+                geometry_box_state.set_content_offset(path_bounding_box.top_left() + viewbox_offset);
 
                 geometry_box_state.set_content_width(view_box.width);
                 geometry_box_state.set_content_height(view_box.height);
@@ -89,9 +89,9 @@ void SVGFormattingContext::run(Box const& box, LayoutMode, [[maybe_unused]] Avai
                 return IterationDecision::Continue;
             }
 
-            geometry_box_state.set_content_offset(path_bounding_box.top_left().to_type<float>());
-            geometry_box_state.set_content_width(path_bounding_box.width().value());
-            geometry_box_state.set_content_height(path_bounding_box.height().value());
+            geometry_box_state.set_content_offset(path_bounding_box.top_left());
+            geometry_box_state.set_content_width(path_bounding_box.width());
+            geometry_box_state.set_content_height(path_bounding_box.height());
         }
 
         return IterationDecision::Continue;

+ 19 - 19
Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp

@@ -174,14 +174,14 @@ void TableFormattingContext::compute_table_width(CSSPixels& extra_width)
         // If the table-root has 'width: auto', the used width is the greater of
         // min(GRIDMAX, the table’s containing block width), the used min-width of the table.
         used_width = max(min(grid_max, width_of_table_containing_block), used_min_width);
-        table_box_state.set_content_width(used_width.value());
+        table_box_state.set_content_width(used_width);
     } else {
         // If the table-root’s width property has a computed value (resolving to
         // resolved-table-width) other than auto, the used width is the greater
         // of resolved-table-width, and the used min-width of the table.
         CSSPixels resolved_table_width = computed_values.width().resolved(table_box, CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box);
         used_width = max(resolved_table_width, used_min_width);
-        table_box_state.set_content_width(used_width.value());
+        table_box_state.set_content_width(used_width);
     }
 
     if (used_width > grid_min) {
@@ -212,7 +212,7 @@ void TableFormattingContext::determine_intrisic_size_of_table_container(Availabl
         CSSPixels grid_min = 0.0f;
         for (auto& column : m_columns)
             grid_min += column.min_width;
-        table_box_state.set_content_width(grid_min.value());
+        table_box_state.set_content_width(grid_min);
     }
 
     if (available_space.width.is_max_content()) {
@@ -220,7 +220,7 @@ void TableFormattingContext::determine_intrisic_size_of_table_container(Availabl
         CSSPixels grid_max = 0.0f;
         for (auto& column : m_columns)
             grid_max += column.max_width;
-        table_box_state.set_content_width(grid_max.value());
+        table_box_state.set_content_width(grid_max);
     }
 }
 
@@ -278,10 +278,10 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
         cell_state.border_left = (should_hide_borders && is_left_most_cell) ? 0 : cell.box.computed_values().border_left().width;
         cell_state.border_right = (should_hide_borders && is_right_most_cell) ? 0 : cell.box.computed_values().border_right().width;
 
-        cell_state.set_content_width((span_width - cell_state.border_box_left() - cell_state.border_box_right()).value());
+        cell_state.set_content_width((span_width - cell_state.border_box_left() - cell_state.border_box_right()));
         auto independent_formatting_context = layout_inside(cell.box, LayoutMode::Normal, cell_state.available_inner_space_or_constraints_from(available_space));
         VERIFY(independent_formatting_context);
-        cell_state.set_content_height(independent_formatting_context->automatic_content_height().value());
+        cell_state.set_content_height(independent_formatting_context->automatic_content_height());
         independent_formatting_context->parent_context_did_dimension_child_root_box();
 
         cell.baseline = box_baseline(m_state, cell.box);
@@ -300,9 +300,9 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
             row_width += column.used_width;
         }
 
-        row_state.set_content_height(row.used_width.value());
-        row_state.set_content_width(row_width.value());
-        row_state.set_content_y(row_top_offset.value());
+        row_state.set_content_height(row.used_width);
+        row_state.set_content_width(row_width);
+        row_state.set_content_y(row_top_offset);
         row_top_offset += row_state.content_height();
     }
 
@@ -312,12 +312,12 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
         CSSPixels row_group_width = 0.0f;
 
         auto& row_group_box_state = m_state.get_mutable(row_group_box);
-        row_group_box_state.set_content_y(row_group_top_offset.value());
+        row_group_box_state.set_content_y(row_group_top_offset);
 
         CSSPixels row_top_offset = 0.0f;
         row_group_box.template for_each_child_of_type<TableRowBox>([&](auto& row) {
             auto& row_state = m_state.get_mutable(row);
-            row_state.set_content_y(row_top_offset.value());
+            row_state.set_content_y(row_top_offset);
             row_group_height += row_state.border_box_height();
             row_group_width = max(row_group_width, row_state.border_box_width());
             row_top_offset += row_state.border_box_height();
@@ -325,8 +325,8 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
 
         row_group_top_offset += row_top_offset;
 
-        row_group_box_state.set_content_height(row_group_height.value());
-        row_group_box_state.set_content_width(row_group_width.value());
+        row_group_box_state.set_content_height(row_group_height);
+        row_group_box_state.set_content_width(row_group_width);
     });
 
     for (auto& cell : m_cells) {
@@ -338,16 +338,16 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
         if (vertical_align.has<CSS::VerticalAlign>()) {
             switch (vertical_align.get<CSS::VerticalAlign>()) {
             case CSS::VerticalAlign::Middle: {
-                cell_state.padding_top += ((row_content_height - cell_border_box_height) / 2).value();
-                cell_state.padding_bottom += ((row_content_height - cell_border_box_height) / 2).value();
+                cell_state.padding_top += (row_content_height - cell_border_box_height) / 2;
+                cell_state.padding_bottom += (row_content_height - cell_border_box_height) / 2;
                 break;
             }
             // FIXME: implement actual 'top' and 'bottom' support instead of fall back to 'baseline'
             case CSS::VerticalAlign::Top:
             case CSS::VerticalAlign::Bottom:
             case CSS::VerticalAlign::Baseline: {
-                cell_state.padding_top += (m_rows[cell.row_index].baseline - cell.baseline).value();
-                cell_state.padding_bottom += (row_content_height - cell_border_box_height).value();
+                cell_state.padding_top += m_rows[cell.row_index].baseline - cell.baseline;
+                cell_state.padding_bottom += row_content_height - cell_border_box_height;
                 break;
             }
             default:
@@ -355,10 +355,10 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
             }
         }
 
-        cell_state.offset = row_state.offset.translated(cell_state.border_box_left() + m_columns[cell.column_index].left_offset.value(), cell_state.border_box_top());
+        cell_state.offset = row_state.offset.translated(cell_state.border_box_left() + m_columns[cell.column_index].left_offset, cell_state.border_box_top());
     }
 
-    m_state.get_mutable(context_box()).set_content_height(total_content_height.value());
+    m_state.get_mutable(context_box()).set_content_height(total_content_height);
 
     // FIXME: This is a total hack, we should respect the 'height' property.
     m_automatic_content_height = total_content_height;