diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-27 18:00:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-27 18:00:51 +0200 |
commit | ca154723f789e13a2a36880753b950d5891b7f12 (patch) | |
tree | 248d91a712e7390ec1d14b771e7522256b24b3fa | |
parent | 4333d0d639edd14c94aaebaf141603593d045450 (diff) | |
download | serenity-ca154723f789e13a2a36880753b950d5891b7f12.zip |
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().
6 files changed, 4 insertions, 23 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 039700a7ed..d07ab706bb 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/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); diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp index fd6da0d5b6..066386af5f 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.cpp +++ b/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(); -} - } diff --git a/Userland/Libraries/LibWeb/Layout/Box.h b/Userland/Libraries/LibWeb/Layout/Box.h index 914157c42d..1dc913aac4 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.h +++ b/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 {}; } diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index d6f3384d96..c66ecb49d1 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/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); diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp index 98713928f5..c8289c8f18 100644 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp +++ b/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; -} - } diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.h b/Userland/Libraries/LibWeb/Layout/TableCellBox.h index 9a4dad5360..ab78c133f4 100644 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.h +++ b/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; }; } |