1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

LibWeb: Size table cells using a combination of min- and max-widths

This gets us a bit closer to the recommended algorithms in CSS 2.2 and
CSS Table Module 3.

A couple of table heavy websites (e.g. news.ycombinator.com,
html5test.com, etc.) now look quite okay. :^)
This commit is contained in:
Simon Wanner 2022-03-29 00:10:59 +02:00 committed by Andreas Kling
parent bc4974648c
commit 7e4793df63
2 changed files with 78 additions and 32 deletions

View file

@ -11,6 +11,13 @@
namespace Web::Layout {
struct ColumnWidth {
float min { 0 };
float max { 0 };
float used { 0 };
bool is_auto { true };
};
class TableFormattingContext final : public BlockFormattingContext {
public:
explicit TableFormattingContext(FormattingState&, BlockContainer const&, FormattingContext* parent);
@ -19,8 +26,8 @@ public:
virtual void run(Box const&, LayoutMode) override;
private:
void calculate_column_widths(Box const& row, CSS::Length const& table_width, Vector<float>& column_widths);
void layout_row(Box const& row, Vector<float>& column_widths);
void calculate_column_widths(Box const& row, CSS::Length const& table_width, Vector<ColumnWidth>& column_widths);
void layout_row(Box const& row, Vector<ColumnWidth>& column_widths);
};
}