mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 06:17:35 +00:00
LibWeb: Start working on supporting fixed table layouts
Sometimes people make tables with a specific width. In those cases, we can't just use the auto-sizing algorithm, but instead have to respect whatever width the content specifies. This is a bit rickety right now, since we don't implement generation of anonymous table boxes. The basic mechanism here is that block layout (which table-cell uses) now has a virtual way of asking for the width of the logical containing block. This is necessary as table-row does not produce a block-level element and so was previously unable to provide a containing block width for table-cell layout. If the table has a non-auto specified width, we now interpret that as a request to use fixed table layout. This will evolve over time. :^)
This commit is contained in:
parent
daa88448e1
commit
7fc988b919
5 changed files with 45 additions and 13 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Layout/LayoutTableCell.h>
|
||||
#include <LibWeb/Layout/LayoutTableRow.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -44,4 +45,11 @@ size_t LayoutTableCell::colspan() const
|
|||
return to<Element>(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
|
||||
}
|
||||
|
||||
float LayoutTableCell::width_of_logical_containing_block() const
|
||||
{
|
||||
if (auto* row = first_ancestor_of_type<LayoutTableRow>())
|
||||
return row->width();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue