From dbf76e8ae1473426f53c6d04336246e5a721b7b6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 4 Dec 2022 22:44:19 +0300 Subject: [PATCH] LibWeb: Take rowspan into account while table formatting --- Userland/Libraries/LibWeb/Layout/TableCellBox.cpp | 7 +++++++ Userland/Libraries/LibWeb/Layout/TableCellBox.h | 1 + .../Libraries/LibWeb/Layout/TableFormattingContext.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp index ba3e203ae5..4e968059d1 100644 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableCellBox.cpp @@ -29,4 +29,11 @@ size_t TableCellBox::colspan() const return verify_cast(*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_node()).attribute(HTML::AttributeNames::rowspan).to_uint().value_or(1); +} + } diff --git a/Userland/Libraries/LibWeb/Layout/TableCellBox.h b/Userland/Libraries/LibWeb/Layout/TableCellBox.h index b63d8c5b1e..df77bd79c5 100644 --- a/Userland/Libraries/LibWeb/Layout/TableCellBox.h +++ b/Userland/Libraries/LibWeb/Layout/TableCellBox.h @@ -22,6 +22,7 @@ public: TableCellBox const* next_cell() const { return next_sibling_of_type(); } size_t colspan() const; + size_t rowspan() const; static CSS::Display static_display() { return CSS::Display { CSS::Display::Internal::TableCell }; } }; diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index c9e5917ea8..81000fbe3e 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/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(child)->colspan(); - const size_t rowspan = 1; + const size_t rowspan = static_cast(child)->rowspan(); if (x_width < x_current + colspan) x_width = x_current + colspan;