mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibWeb: Override width calculation for table wrappers
Introduce `TableWrapper` type so table wrappers could be distinguished from block containers and override width calculation for table wrappers (CSS 2.2 spec, section 17.5.2) inside BFCs in the way that their width should be equal to width of table box they wrap.
This commit is contained in:
parent
7526f9a8b7
commit
709fe01f52
8 changed files with 74 additions and 1 deletions
|
@ -17,6 +17,8 @@
|
|||
#include <LibWeb/Layout/ListItemBox.h>
|
||||
#include <LibWeb/Layout/ListItemMarkerBox.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Layout/TableBox.h>
|
||||
#include <LibWeb/Layout/TableWrapper.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -193,6 +195,8 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
};
|
||||
|
||||
auto input_width = [&] {
|
||||
if (is<TableWrapper>(box))
|
||||
return CSS::Length::make_px(compute_width_for_table_wrapper(box, available_space));
|
||||
if (should_treat_width_as_auto(box, available_space))
|
||||
return CSS::Length::make_auto();
|
||||
return calculate_inner_width(box, available_space.width, computed_values.width());
|
||||
|
@ -312,6 +316,18 @@ void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_n
|
|||
m_state.get_mutable(box).set_content_width(compute_width_for_replaced_element(m_state, box, available_space));
|
||||
}
|
||||
|
||||
CSSPixels BlockFormattingContext::compute_width_for_table_wrapper(Box const& box, AvailableSpace const& available_space)
|
||||
{
|
||||
// 17.5.2
|
||||
// Table wrapper width should be equal to width of table box it contains
|
||||
LayoutState throwaway_state(&m_state);
|
||||
auto context = create_independent_formatting_context_if_needed(throwaway_state, box);
|
||||
VERIFY(context);
|
||||
context->run(box, LayoutMode::IntrinsicSizing, m_state.get(box).available_inner_space_or_constraints_from(available_space));
|
||||
auto const* table_box = box.first_child_of_type<TableBox>();
|
||||
return throwaway_state.get(*table_box).content_width();
|
||||
}
|
||||
|
||||
void BlockFormattingContext::compute_height(Box const& box, AvailableSpace const& available_space)
|
||||
{
|
||||
auto const& computed_values = box.computed_values();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue