Prechádzať zdrojové kódy

LibWeb: Take rowspan into account while table formatting

Aliaksandr Kalenik 2 rokov pred
rodič
commit
dbf76e8ae1

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

@@ -29,4 +29,11 @@ size_t TableCellBox::colspan() const
     return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
 }
 
+size_t TableCellBox::rowspan() const
+{
+    if (!dom_node())
+        return 1;
+    return verify_cast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::rowspan).to_uint().value_or(1);
+}
+
 }

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

@@ -22,6 +22,7 @@ public:
     TableCellBox const* next_cell() const { return next_sibling_of_type<TableCellBox>(); }
 
     size_t colspan() const;
+    size_t rowspan() const;
 
     static CSS::Display static_display() { return CSS::Display { CSS::Display::Internal::TableCell }; }
 };

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

@@ -66,7 +66,7 @@ void TableFormattingContext::calculate_row_column_grid(Box const& box)
                     x_width++;
 
                 const size_t colspan = static_cast<TableCellBox*>(child)->colspan();
-                const size_t rowspan = 1;
+                const size_t rowspan = static_cast<TableCellBox*>(child)->rowspan();
 
                 if (x_width < x_current + colspan)
                     x_width = x_current + colspan;