mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Return used values for grid tracks in getComputedStyle()
That's awkward, but getComputedStyle needs to return used track values for gridTemplateColumns and gridTemplateRows properties. This change implements it by saving style values with used values into layout state, so it could be assigned to paintables during LayoutState::commit() and later accessed by style_value_for_property(). I haven't seen it used in the wild, but WPT grid tests extensively use it. For example this change helps to go from 0/10 to 8/10 on this test: https://wpt.live/css/css-grid/layout-algorithm/grid-fit-content-percentage.html
This commit is contained in:
parent
34fdd0d44f
commit
68fcc37531
Notes:
github-actions[bot]
2024-09-09 10:48:59 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 68fcc37531
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1342
7 changed files with 74 additions and 0 deletions
|
@ -1873,6 +1873,23 @@ void GridFormattingContext::run(Box const&, LayoutMode, AvailableSpace const& av
|
|||
if (auto independent_formatting_context = layout_inside(grid_item.box, LayoutMode::Normal, available_space_for_children))
|
||||
independent_formatting_context->parent_context_did_dimension_child_root_box();
|
||||
}
|
||||
|
||||
Vector<Variant<CSS::ExplicitGridTrack, CSS::GridLineNames>> grid_track_columns;
|
||||
grid_track_columns.ensure_capacity(m_grid_columns.size());
|
||||
for (auto const& column : m_grid_columns) {
|
||||
grid_track_columns.append(CSS::ExplicitGridTrack { CSS::GridSize { CSS::LengthPercentage(CSS::Length::make_px(column.base_size)) } });
|
||||
}
|
||||
|
||||
Vector<Variant<CSS::ExplicitGridTrack, CSS::GridLineNames>> grid_track_rows;
|
||||
grid_track_rows.ensure_capacity(m_grid_rows.size());
|
||||
for (auto const& row : m_grid_rows) {
|
||||
grid_track_rows.append(CSS::ExplicitGridTrack { CSS::GridSize { CSS::LengthPercentage(CSS::Length::make_px(row.base_size)) } });
|
||||
}
|
||||
|
||||
// getComputedStyle() needs to return the resolved values of grid-template-columns and grid-template-rows
|
||||
// so they need to be saved in the state, and then assigned to paintables in LayoutState::commit()
|
||||
m_state.get_mutable(grid_container()).set_grid_template_columns(CSS::GridTrackSizeListStyleValue::create(move(grid_track_columns)));
|
||||
m_state.get_mutable(grid_container()).set_grid_template_rows(CSS::GridTrackSizeListStyleValue::create(move(grid_track_rows)));
|
||||
}
|
||||
|
||||
void GridFormattingContext::layout_absolutely_positioned_element(Box const& box, AvailableSpace const& available_space)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue