Parcourir la source

LibWeb: Remove inheritance of `TableRowGroupBox` from `BlockContainer`

Having `TableRowGroupBox` not inherited from `BlockContainer`
allows to write more simpler layout code.
Aliaksandr Kalenik il y a 2 ans
Parent
commit
c8337e9ee8

+ 3 - 6
Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp

@@ -457,19 +457,16 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
         auto& row_group_box_state = m_state.get_mutable(row_group_box);
         auto& row_group_box_state = m_state.get_mutable(row_group_box);
         row_group_box_state.set_content_y(row_group_top_offset);
         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) {
         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);
+            auto const& row_state = m_state.get(row);
             row_group_height += row_state.border_box_height();
             row_group_height += row_state.border_box_height();
             row_group_width = max(row_group_width, row_state.border_box_width());
             row_group_width = max(row_group_width, row_state.border_box_width());
-            row_top_offset += row_state.border_box_height();
         });
         });
 
 
-        row_group_top_offset += row_top_offset;
-
         row_group_box_state.set_content_height(row_group_height);
         row_group_box_state.set_content_height(row_group_height);
         row_group_box_state.set_content_width(row_group_width);
         row_group_box_state.set_content_width(row_group_width);
+
+        row_group_top_offset += row_group_height;
     });
     });
 
 
     for (auto& cell : m_cells) {
     for (auto& cell : m_cells) {

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

@@ -12,7 +12,7 @@
 namespace Web::Layout {
 namespace Web::Layout {
 
 
 TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style)
 TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style)
-    : Layout::BlockContainer(document, element, move(style))
+    : Layout::Box(document, element, move(style))
 {
 {
 }
 }
 
 

+ 3 - 3
Userland/Libraries/LibWeb/Layout/TableRowGroupBox.h

@@ -6,12 +6,12 @@
 
 
 #pragma once
 #pragma once
 
 
-#include <LibWeb/Layout/BlockContainer.h>
+#include <LibWeb/Layout/Box.h>
 
 
 namespace Web::Layout {
 namespace Web::Layout {
 
 
-class TableRowGroupBox final : public BlockContainer {
-    JS_CELL(TableRowGroupBox, BlockContainer);
+class TableRowGroupBox final : public Box {
+    JS_CELL(TableRowGroupBox, Box);
 
 
 public:
 public:
     TableRowGroupBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);
     TableRowGroupBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);