mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibWeb: Disambiguate GridTrackPlacement API
- Ambiguous `raw_value()` method is replaced with `line_number()` and `span()`. - `line_name()` that before returned either line name or area name is replaced with `line_name()` and `area_name()`. - `Position` type is replaced with `Line` and `Area` type so we don't have to guess while doing layout. Affected test expectations: - `template-lines-and-areas` - improvement over what we had before. - `named-tracks` - rebaseline a giant test. will have to split it into smaller tests in the future.
This commit is contained in:
parent
29352f570a
commit
c03e025a32
7 changed files with 292 additions and 205 deletions
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
* Copyright (c) 2022-2023, Martin Falisse <mfalisse@outlook.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -128,10 +129,21 @@ int GridFormattingContext::count_of_repeated_auto_fill_or_fit_tracks(Vector<CSS:
|
|||
|
||||
void GridFormattingContext::place_item_with_row_and_column_position(Box const& child_box)
|
||||
{
|
||||
int row_start = child_box.computed_values().grid_row_start().raw_value() - 1;
|
||||
int row_end = child_box.computed_values().grid_row_end().raw_value() - 1;
|
||||
int column_start = child_box.computed_values().grid_column_start().raw_value() - 1;
|
||||
int column_end = child_box.computed_values().grid_column_end().raw_value() - 1;
|
||||
auto const& grid_row_start = child_box.computed_values().grid_row_start();
|
||||
auto const& grid_row_end = child_box.computed_values().grid_row_end();
|
||||
auto const& grid_column_start = child_box.computed_values().grid_column_start();
|
||||
auto const& grid_column_end = child_box.computed_values().grid_column_end();
|
||||
|
||||
int row_start = 0, row_end = 0, column_start = 0, column_end = 0;
|
||||
|
||||
if (grid_row_start.is_line())
|
||||
row_start = child_box.computed_values().grid_row_start().line_number() - 1;
|
||||
if (grid_row_end.is_line())
|
||||
row_end = child_box.computed_values().grid_row_end().line_number() - 1;
|
||||
if (grid_column_start.is_line())
|
||||
column_start = child_box.computed_values().grid_column_start().line_number() - 1;
|
||||
if (grid_column_end.is_line())
|
||||
column_end = child_box.computed_values().grid_column_end().line_number() - 1;
|
||||
|
||||
// https://www.w3.org/TR/css-grid-2/#line-placement
|
||||
// 8.3. Line-based Placement: the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties
|
||||
|
@ -162,16 +174,16 @@ void GridFormattingContext::place_item_with_row_and_column_position(Box const& c
|
|||
// grid-column-start line.
|
||||
size_t row_span = 1;
|
||||
size_t column_span = 1;
|
||||
if (child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_span())
|
||||
row_span = child_box.computed_values().grid_row_end().raw_value();
|
||||
if (child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_span())
|
||||
column_span = child_box.computed_values().grid_column_end().raw_value();
|
||||
if (child_box.computed_values().grid_row_end().is_position() && child_box.computed_values().grid_row_start().is_span()) {
|
||||
row_span = child_box.computed_values().grid_row_start().raw_value();
|
||||
if (grid_row_start.is_line() && grid_row_end.is_span())
|
||||
row_span = grid_row_end.span();
|
||||
if (grid_column_start.is_line() && grid_column_end.is_span())
|
||||
column_span = grid_column_end.span();
|
||||
if (grid_row_end.is_line() && child_box.computed_values().grid_row_start().is_span()) {
|
||||
row_span = grid_row_start.span();
|
||||
row_start = row_end - row_span;
|
||||
}
|
||||
if (child_box.computed_values().grid_column_end().is_position() && child_box.computed_values().grid_column_start().is_span()) {
|
||||
column_span = child_box.computed_values().grid_column_start().raw_value();
|
||||
if (grid_column_end.is_line() && grid_column_start.is_span()) {
|
||||
column_span = grid_column_start.span();
|
||||
column_start = column_end - column_span;
|
||||
}
|
||||
|
||||
|
@ -188,36 +200,54 @@ void GridFormattingContext::place_item_with_row_and_column_position(Box const& c
|
|||
// https://www.w3.org/TR/css-grid-2/#common-uses-named-lines
|
||||
// 8.1.3. Named Lines and Spans
|
||||
// Instead of counting lines by number, lines can be referenced by their line name:
|
||||
if (child_box.computed_values().grid_column_end().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_column_end().line_name()); maybe_grid_area.has_value())
|
||||
if (grid_column_end.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_column_end.area_name()); maybe_grid_area.has_value())
|
||||
column_end = maybe_grid_area->column_end;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_column_end().line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
else
|
||||
column_end = 1;
|
||||
column_start = column_end - 1;
|
||||
} else if (grid_column_end.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_column_end.line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
column_end = line_name_index;
|
||||
else
|
||||
column_end = 1;
|
||||
column_start = column_end - 1;
|
||||
}
|
||||
if (child_box.computed_values().grid_column_start().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_column_end().line_name()); maybe_grid_area.has_value())
|
||||
|
||||
if (grid_column_start.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_column_start.area_name()); maybe_grid_area.has_value())
|
||||
column_start = maybe_grid_area->column_start;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_column_start().line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
else
|
||||
column_start = 0;
|
||||
}
|
||||
if (grid_column_start.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_column_start.line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
column_start = line_name_index;
|
||||
else
|
||||
column_start = 0;
|
||||
}
|
||||
if (child_box.computed_values().grid_row_end().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_row_end().line_name()); maybe_grid_area.has_value())
|
||||
|
||||
if (grid_row_end.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_row_end.area_name()); maybe_grid_area.has_value())
|
||||
row_end = maybe_grid_area->row_end;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_row_end().line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
else
|
||||
row_end = 1;
|
||||
row_start = row_end - 1;
|
||||
} else if (grid_row_end.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_row_end.line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
row_end = line_name_index;
|
||||
else
|
||||
row_end = 1;
|
||||
row_start = row_end - 1;
|
||||
}
|
||||
if (child_box.computed_values().grid_row_start().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_row_end().line_name()); maybe_grid_area.has_value())
|
||||
|
||||
if (grid_row_start.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_row_start.area_name()); maybe_grid_area.has_value())
|
||||
row_start = maybe_grid_area->row_start;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_row_start().line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
else
|
||||
row_start = 0;
|
||||
} else if (grid_row_start.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_row_start.line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
row_start = line_name_index;
|
||||
else
|
||||
row_start = 0;
|
||||
|
@ -231,13 +261,13 @@ void GridFormattingContext::place_item_with_row_and_column_position(Box const& c
|
|||
// If the placement for a grid item contains two lines, and the start line is further end-ward than
|
||||
// the end line, swap the two lines. If the start line is equal to the end line, remove the end
|
||||
// line.
|
||||
if (child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_position()) {
|
||||
if (grid_row_start.is_positioned() && grid_row_end.is_positioned()) {
|
||||
if (row_start > row_end)
|
||||
swap(row_start, row_end);
|
||||
if (row_start != row_end)
|
||||
row_span = row_end - row_start;
|
||||
}
|
||||
if (child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_position()) {
|
||||
if (grid_column_start.is_positioned() && grid_column_end.is_positioned()) {
|
||||
if (column_start > column_end)
|
||||
swap(column_start, column_end);
|
||||
if (column_start != column_end)
|
||||
|
@ -246,10 +276,10 @@ void GridFormattingContext::place_item_with_row_and_column_position(Box const& c
|
|||
|
||||
// If the placement contains two spans, remove the one contributed by the end grid-placement
|
||||
// property.
|
||||
if (child_box.computed_values().grid_row_start().is_span() && child_box.computed_values().grid_row_end().is_span())
|
||||
row_span = child_box.computed_values().grid_row_start().raw_value();
|
||||
if (child_box.computed_values().grid_column_start().is_span() && child_box.computed_values().grid_column_end().is_span())
|
||||
column_span = child_box.computed_values().grid_column_start().raw_value();
|
||||
if (grid_row_start.is_span() && grid_row_end.is_span())
|
||||
row_span = grid_row_start.span();
|
||||
if (grid_column_start.is_span() && grid_column_end.is_span())
|
||||
column_span = grid_column_start.span();
|
||||
|
||||
// FIXME: If the placement contains only a span for a named line, replace it with a span of 1.
|
||||
|
||||
|
@ -265,8 +295,16 @@ void GridFormattingContext::place_item_with_row_and_column_position(Box const& c
|
|||
|
||||
void GridFormattingContext::place_item_with_row_position(Box const& child_box)
|
||||
{
|
||||
int row_start = child_box.computed_values().grid_row_start().raw_value() - 1;
|
||||
int row_end = child_box.computed_values().grid_row_end().raw_value() - 1;
|
||||
auto const& grid_row_start = child_box.computed_values().grid_row_start();
|
||||
auto const& grid_row_end = child_box.computed_values().grid_row_end();
|
||||
auto const& grid_column_start = child_box.computed_values().grid_column_start();
|
||||
|
||||
int row_start = 0, row_end = 0;
|
||||
|
||||
if (grid_row_start.is_line())
|
||||
row_start = grid_row_start.line_number() - 1;
|
||||
if (grid_row_end.is_line())
|
||||
row_end = grid_row_end.line_number() - 1;
|
||||
|
||||
// https://www.w3.org/TR/css-grid-2/#line-placement
|
||||
// 8.3. Line-based Placement: the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties
|
||||
|
@ -294,10 +332,10 @@ void GridFormattingContext::place_item_with_row_position(Box const& child_box)
|
|||
// grid-column-end: span 2 indicates the second grid line in the endward direction from the
|
||||
// grid-column-start line.
|
||||
size_t row_span = 1;
|
||||
if (child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_span())
|
||||
row_span = child_box.computed_values().grid_row_end().raw_value();
|
||||
if (child_box.computed_values().grid_row_end().is_position() && child_box.computed_values().grid_row_start().is_span()) {
|
||||
row_span = child_box.computed_values().grid_row_start().raw_value();
|
||||
if (grid_row_start.is_line() && grid_row_end.is_span())
|
||||
row_span = grid_row_end.span();
|
||||
if (grid_row_end.is_line() && grid_row_start.is_span()) {
|
||||
row_span = grid_row_start.span();
|
||||
row_start = row_end - row_span;
|
||||
// FIXME: Remove me once have implemented spans overflowing into negative indexes, e.g., grid-row: span 2 / 1
|
||||
if (row_start < 0)
|
||||
|
@ -317,19 +355,27 @@ void GridFormattingContext::place_item_with_row_position(Box const& child_box)
|
|||
// https://www.w3.org/TR/css-grid-2/#common-uses-named-lines
|
||||
// 8.1.3. Named Lines and Spans
|
||||
// Instead of counting lines by number, lines can be referenced by their line name:
|
||||
if (child_box.computed_values().grid_row_end().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_row_end().line_name()); maybe_grid_area.has_value())
|
||||
if (grid_row_end.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_row_end.area_name()); maybe_grid_area.has_value())
|
||||
row_end = maybe_grid_area->row_end;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_row_end().line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
row_end = line_name_index;
|
||||
else
|
||||
row_end = 1;
|
||||
row_start = row_end - 1;
|
||||
} else if (grid_row_end.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_row_end.line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
row_end = line_name_index - 1;
|
||||
else
|
||||
row_end = 1;
|
||||
row_start = row_end - 1;
|
||||
}
|
||||
if (child_box.computed_values().grid_row_start().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_row_end().line_name()); maybe_grid_area.has_value())
|
||||
|
||||
if (grid_row_start.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_row_start.area_name()); maybe_grid_area.has_value())
|
||||
row_start = maybe_grid_area->row_start;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_row_start().line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
else
|
||||
row_start = 0;
|
||||
} else if (grid_row_start.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_row_start.line_name(), grid_container().computed_values().grid_template_rows()); line_name_index > -1)
|
||||
row_start = line_name_index;
|
||||
else
|
||||
row_start = 0;
|
||||
|
@ -343,25 +389,25 @@ void GridFormattingContext::place_item_with_row_position(Box const& child_box)
|
|||
// If the placement for a grid item contains two lines, and the start line is further end-ward than
|
||||
// the end line, swap the two lines. If the start line is equal to the end line, remove the end
|
||||
// line.
|
||||
if (child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_position()) {
|
||||
if (grid_row_start.is_positioned() && grid_row_end.is_positioned()) {
|
||||
if (row_start > row_end)
|
||||
swap(row_start, row_end);
|
||||
if (row_start != row_end)
|
||||
row_span = row_end - row_start;
|
||||
}
|
||||
// FIXME: Have yet to find the spec for this.
|
||||
if (!child_box.computed_values().grid_row_start().is_position() && child_box.computed_values().grid_row_end().is_position() && row_end == 0)
|
||||
if (!grid_row_start.is_positioned() && grid_row_end.is_positioned() && row_end == 0)
|
||||
row_start = 0;
|
||||
|
||||
// If the placement contains two spans, remove the one contributed by the end grid-placement
|
||||
// property.
|
||||
if (child_box.computed_values().grid_row_start().is_span() && child_box.computed_values().grid_row_end().is_span())
|
||||
row_span = child_box.computed_values().grid_row_start().raw_value();
|
||||
if (grid_row_start.is_span() && grid_row_end.is_span())
|
||||
row_span = grid_row_start.span();
|
||||
|
||||
// FIXME: If the placement contains only a span for a named line, replace it with a span of 1.
|
||||
|
||||
int column_start = 0;
|
||||
size_t column_span = child_box.computed_values().grid_column_start().is_span() ? child_box.computed_values().grid_column_start().raw_value() : 1;
|
||||
size_t column_span = grid_column_start.is_span() ? grid_column_start.span() : 1;
|
||||
bool found_available_column = false;
|
||||
for (size_t column_index = column_start; column_index < m_occupation_grid.column_count(); column_index++) {
|
||||
if (!m_occupation_grid.is_occupied(column_index, row_start)) {
|
||||
|
@ -385,15 +431,21 @@ void GridFormattingContext::place_item_with_row_position(Box const& child_box)
|
|||
|
||||
void GridFormattingContext::place_item_with_column_position(Box const& child_box, int& auto_placement_cursor_x, int& auto_placement_cursor_y)
|
||||
{
|
||||
int column_start;
|
||||
if (child_box.computed_values().grid_column_start().raw_value() > 0) {
|
||||
column_start = child_box.computed_values().grid_column_start().raw_value() - 1;
|
||||
} else {
|
||||
auto const& grid_row_start = child_box.computed_values().grid_row_start();
|
||||
auto const& grid_column_start = child_box.computed_values().grid_column_start();
|
||||
auto const& grid_column_end = child_box.computed_values().grid_column_end();
|
||||
|
||||
int column_start = 0;
|
||||
if (grid_column_start.is_line() && grid_column_start.line_number() > 0) {
|
||||
column_start = grid_column_start.line_number() - 1;
|
||||
} else if (grid_column_start.is_line()) {
|
||||
// NOTE: Negative indexes count from the end side of the explicit grid
|
||||
column_start = m_explicit_columns_line_count + child_box.computed_values().grid_column_start().raw_value();
|
||||
column_start = m_explicit_columns_line_count + grid_column_start.line_number();
|
||||
}
|
||||
|
||||
int column_end = child_box.computed_values().grid_column_end().raw_value() - 1;
|
||||
int column_end = 0;
|
||||
if (grid_column_end.is_line())
|
||||
column_end = grid_column_end.line_number() - 1;
|
||||
|
||||
// https://www.w3.org/TR/css-grid-2/#line-placement
|
||||
// 8.3. Line-based Placement: the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties
|
||||
|
@ -421,18 +473,18 @@ void GridFormattingContext::place_item_with_column_position(Box const& child_box
|
|||
// grid-column-end: span 2 indicates the second grid line in the endward direction from the
|
||||
// grid-column-start line.
|
||||
size_t column_span = 1;
|
||||
size_t row_span = child_box.computed_values().grid_row_start().is_span() ? child_box.computed_values().grid_row_start().raw_value() : 1;
|
||||
if (child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_span())
|
||||
column_span = child_box.computed_values().grid_column_end().raw_value();
|
||||
if (child_box.computed_values().grid_column_end().is_position() && child_box.computed_values().grid_column_start().is_span()) {
|
||||
column_span = child_box.computed_values().grid_column_start().raw_value();
|
||||
size_t row_span = grid_row_start.is_span() ? grid_row_start.span() : 1;
|
||||
if (grid_column_start.is_line() && grid_column_end.is_span())
|
||||
column_span = grid_column_end.span();
|
||||
if (grid_column_end.is_line() && grid_column_start.is_span()) {
|
||||
column_span = grid_column_start.span();
|
||||
column_start = column_end - column_span;
|
||||
// FIXME: Remove me once have implemented spans overflowing into negative indexes, e.g., grid-column: span 2 / 1
|
||||
if (column_start < 0)
|
||||
column_start = 0;
|
||||
}
|
||||
// FIXME: Have yet to find the spec for this.
|
||||
if (!child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_position() && column_end == 0)
|
||||
if (!grid_column_start.is_positioned() && grid_column_end.is_positioned() && column_end == 0)
|
||||
column_start = 0;
|
||||
|
||||
// If a name is given as a <custom-ident>, only lines with that name are counted. If not enough
|
||||
|
@ -448,19 +500,28 @@ void GridFormattingContext::place_item_with_column_position(Box const& child_box
|
|||
// https://www.w3.org/TR/css-grid-2/#common-uses-named-lines
|
||||
// 8.1.3. Named Lines and Spans
|
||||
// Instead of counting lines by number, lines can be referenced by their line name:
|
||||
if (child_box.computed_values().grid_column_end().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_column_end().line_name()); maybe_grid_area.has_value())
|
||||
if (grid_column_end.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_column_end.area_name()); maybe_grid_area.has_value())
|
||||
column_end = maybe_grid_area->column_end;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_column_end().line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
else
|
||||
column_end = 1;
|
||||
column_start = column_end - 1;
|
||||
} else if (grid_column_end.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_column_end.line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
column_end = line_name_index;
|
||||
else
|
||||
column_end = 1;
|
||||
column_start = column_end - 1;
|
||||
}
|
||||
if (child_box.computed_values().grid_column_start().has_line_name()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(child_box.computed_values().grid_column_end().line_name()); maybe_grid_area.has_value())
|
||||
|
||||
if (grid_column_start.is_area()) {
|
||||
if (auto maybe_grid_area = m_grid_areas.get(grid_column_start.area_name()); maybe_grid_area.has_value())
|
||||
column_start = maybe_grid_area->column_start;
|
||||
else if (auto line_name_index = get_line_index_by_line_name(child_box.computed_values().grid_column_start().line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
else
|
||||
column_start = 0;
|
||||
}
|
||||
if (grid_column_start.has_line_name()) {
|
||||
if (auto line_name_index = get_line_index_by_line_name(grid_column_start.line_name(), grid_container().computed_values().grid_template_columns()); line_name_index > -1)
|
||||
column_start = line_name_index;
|
||||
else
|
||||
column_start = 0;
|
||||
|
@ -474,7 +535,7 @@ void GridFormattingContext::place_item_with_column_position(Box const& child_box
|
|||
// If the placement for a grid item contains two lines, and the start line is further end-ward than
|
||||
// the end line, swap the two lines. If the start line is equal to the end line, remove the end
|
||||
// line.
|
||||
if (child_box.computed_values().grid_column_start().is_position() && child_box.computed_values().grid_column_end().is_position()) {
|
||||
if (grid_column_start.is_positioned() && grid_column_end.is_positioned()) {
|
||||
if (column_start > column_end)
|
||||
swap(column_start, column_end);
|
||||
if (column_start != column_end)
|
||||
|
@ -483,8 +544,8 @@ void GridFormattingContext::place_item_with_column_position(Box const& child_box
|
|||
|
||||
// If the placement contains two spans, remove the one contributed by the end grid-placement
|
||||
// property.
|
||||
if (child_box.computed_values().grid_column_start().is_span() && child_box.computed_values().grid_column_end().is_span())
|
||||
column_span = child_box.computed_values().grid_column_start().raw_value();
|
||||
if (grid_column_start.is_span() && grid_column_end.is_span())
|
||||
column_span = grid_column_start.span();
|
||||
|
||||
// FIXME: If the placement contains only a span for a named line, replace it with a span of 1.
|
||||
|
||||
|
@ -516,22 +577,27 @@ void GridFormattingContext::place_item_with_column_position(Box const& child_box
|
|||
|
||||
void GridFormattingContext::place_item_with_no_declared_position(Box const& child_box, int& auto_placement_cursor_x, int& auto_placement_cursor_y)
|
||||
{
|
||||
auto const& grid_row_start = child_box.computed_values().grid_row_start();
|
||||
auto const& grid_row_end = child_box.computed_values().grid_row_end();
|
||||
auto const& grid_column_start = child_box.computed_values().grid_column_start();
|
||||
auto const& grid_column_end = child_box.computed_values().grid_column_end();
|
||||
|
||||
// 4.1.2.1. Increment the column position of the auto-placement cursor until either this item's grid
|
||||
// area does not overlap any occupied grid cells, or the cursor's column position, plus the item's
|
||||
// column span, overflow the number of columns in the implicit grid, as determined earlier in this
|
||||
// algorithm.
|
||||
auto column_start = 0;
|
||||
size_t column_span = 1;
|
||||
if (child_box.computed_values().grid_column_start().is_span())
|
||||
column_span = child_box.computed_values().grid_column_start().raw_value();
|
||||
else if (child_box.computed_values().grid_column_end().is_span())
|
||||
column_span = child_box.computed_values().grid_column_end().raw_value();
|
||||
if (grid_column_start.is_span())
|
||||
column_span = grid_column_start.span();
|
||||
else if (grid_column_end.is_span())
|
||||
column_span = grid_column_end.span();
|
||||
auto row_start = 0;
|
||||
size_t row_span = 1;
|
||||
if (child_box.computed_values().grid_row_start().is_span())
|
||||
row_span = child_box.computed_values().grid_row_start().raw_value();
|
||||
else if (child_box.computed_values().grid_row_end().is_span())
|
||||
row_span = child_box.computed_values().grid_row_end().raw_value();
|
||||
if (grid_row_start.is_span())
|
||||
row_span = grid_row_start.span();
|
||||
else if (grid_row_end.is_span())
|
||||
row_span = grid_row_end.span();
|
||||
auto found_unoccupied_area = false;
|
||||
|
||||
auto const& auto_flow = grid_container().computed_values().grid_auto_flow();
|
||||
|
@ -1395,11 +1461,14 @@ void GridFormattingContext::place_grid_items(AvailableSpace const& available_spa
|
|||
for (auto key : keys) {
|
||||
auto& boxes_to_place = order_item_bucket.get(key).value();
|
||||
for (auto const& child_box : boxes_to_place) {
|
||||
auto const& grid_column_start = child_box->computed_values().grid_column_start();
|
||||
auto const& grid_column_end = child_box->computed_values().grid_column_end();
|
||||
|
||||
int column_span = 1;
|
||||
if (child_box->computed_values().grid_column_start().is_span())
|
||||
column_span = child_box->computed_values().grid_column_start().raw_value();
|
||||
else if (child_box->computed_values().grid_column_end().is_span())
|
||||
column_span = child_box->computed_values().grid_column_end().raw_value();
|
||||
if (grid_column_start.is_span())
|
||||
column_span = grid_column_start.span();
|
||||
else if (grid_column_end.is_span())
|
||||
column_span = grid_column_end.span();
|
||||
|
||||
if (column_span - 1 > m_occupation_grid.max_column_index())
|
||||
m_occupation_grid.set_max_column_index(column_span - 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue