diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-13 00:10:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-13 00:10:52 +0200 |
commit | 0061a82be388712b07ecb938f83af5f5622f0904 (patch) | |
tree | 53a41009e88fe8b6952c1299420c788f71c2d338 /Libraries/LibWeb/Layout | |
parent | 196a3986d68f795db8afbc04afc34d07298d922a (diff) | |
download | serenity-0061a82be388712b07ecb938f83af5f5622f0904.zip |
LibWeb: Add LayoutTableCell::colspan()
A convenient function for looking up a cell's colspan attribute.
Diffstat (limited to 'Libraries/LibWeb/Layout')
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutTableCell.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutTableCell.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Layout/LayoutTableCell.cpp b/Libraries/LibWeb/Layout/LayoutTableCell.cpp index 7ff80f38b5..d4cab6a2bb 100644 --- a/Libraries/LibWeb/Layout/LayoutTableCell.cpp +++ b/Libraries/LibWeb/Layout/LayoutTableCell.cpp @@ -38,4 +38,10 @@ LayoutTableCell::~LayoutTableCell() { } +size_t LayoutTableCell::colspan() const +{ + ASSERT(node()); + return to<Element>(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); +} + } diff --git a/Libraries/LibWeb/Layout/LayoutTableCell.h b/Libraries/LibWeb/Layout/LayoutTableCell.h index 456ec8a08d..ed9ba3fb03 100644 --- a/Libraries/LibWeb/Layout/LayoutTableCell.h +++ b/Libraries/LibWeb/Layout/LayoutTableCell.h @@ -38,6 +38,8 @@ public: LayoutTableCell* next_cell() { return next_sibling_of_type<LayoutTableCell>(); } const LayoutTableCell* next_cell() const { return next_sibling_of_type<LayoutTableCell>(); } + size_t colspan() const; + private: virtual bool is_table_cell() const override { return true; } virtual const char* class_name() const override { return "LayoutTableCell"; } |