Преглед на файлове

LibWeb: Remove Layout::Box::width_of_logical_containing_block()

This was a hack to percentages within tables relative to the nearest
table-row ancestor instead of the nearest table container.

That didn't actually make sense, so this patch simply removes the hack
in favor of containing_block()->width().
Andreas Kling преди 3 години
родител
ревизия
ca154723f7

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

@@ -120,7 +120,7 @@ void BlockFormattingContext::compute_width(Box& box)
     }
 
     auto& computed_values = box.computed_values();
-    float width_of_containing_block = box.width_of_logical_containing_block();
+    float width_of_containing_block = box.containing_block()->width();
 
     auto zero_value = CSS::Length::make_px(0);
 
@@ -242,7 +242,7 @@ void BlockFormattingContext::compute_width_for_floating_box(Box& box)
 {
     // 10.3.5 Floating, non-replaced elements
     auto& computed_values = box.computed_values();
-    float width_of_containing_block = box.width_of_logical_containing_block();
+    float width_of_containing_block = box.containing_block()->width();
     auto zero_value = CSS::Length::make_px(0);
 
     auto margin_left = computed_values.margin().left.resolved_or_zero(box, width_of_containing_block);
@@ -389,7 +389,7 @@ void BlockFormattingContext::compute_position(Box& box)
 
     auto& box_model = box.box_model();
     auto& computed_values = box.computed_values();
-    float width_of_containing_block = box.width_of_logical_containing_block();
+    float width_of_containing_block = box.containing_block()->width();
 
     auto specified_left = computed_values.offset().left.resolved_or_zero(box, width_of_containing_block);
     auto specified_right = computed_values.offset().right.resolved_or_zero(box, width_of_containing_block);

+ 0 - 7
Userland/Libraries/LibWeb/Layout/Box.cpp

@@ -234,11 +234,4 @@ StackingContext* Box::enclosing_stacking_context()
     VERIFY_NOT_REACHED();
 }
 
-float Box::width_of_logical_containing_block() const
-{
-    auto* containing_block = this->containing_block();
-    VERIFY(containing_block);
-    return containing_block->width();
-}
-
 }

+ 0 - 2
Userland/Libraries/LibWeb/Layout/Box.h

@@ -122,8 +122,6 @@ public:
     virtual void paint_box_shadow(PaintContext& context);
     virtual void paint_background(PaintContext& context);
 
-    virtual float width_of_logical_containing_block() const;
-
     Painting::BorderRadiusData normalized_border_radius_data();
 
     virtual Optional<float> intrinsic_width() const { return {}; }

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

@@ -106,7 +106,7 @@ void FlexFormattingContext::run(Box& run_box, LayoutMode)
 
 void FlexFormattingContext::populate_specified_margins(FlexItem& item, CSS::FlexDirection flex_direction) const
 {
-    auto width_of_containing_block = item.box.width_of_logical_containing_block();
+    auto width_of_containing_block = item.box.containing_block()->width();
     // 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_or_zero(item.box, width_of_containing_block).to_px(item.box);

+ 0 - 7
Userland/Libraries/LibWeb/Layout/TableCellBox.cpp

@@ -31,11 +31,4 @@ size_t TableCellBox::colspan() const
     return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
 }
 
-float TableCellBox::width_of_logical_containing_block() const
-{
-    if (auto* row = first_ancestor_of_type<TableRowBox>())
-        return row->width();
-    return 0;
-}
-
 }

+ 0 - 3
Userland/Libraries/LibWeb/Layout/TableCellBox.h

@@ -22,9 +22,6 @@ public:
     size_t colspan() const;
 
     static CSS::Display static_display() { return CSS::Display { CSS::Display::Internal::TableCell }; }
-
-private:
-    virtual float width_of_logical_containing_block() const override;
 };
 
 }