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, Martin Falisse <mfalisse@outlook.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -9,48 +10,24 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
GridTrackPlacement::GridTrackPlacement(int span_count_or_position, bool has_span)
|
||||
: m_type(has_span ? Type::Span : Type::Position)
|
||||
, m_span_count_or_position(span_count_or_position)
|
||||
{
|
||||
}
|
||||
|
||||
GridTrackPlacement::GridTrackPlacement(String line_name, int span_count_or_position, bool has_span)
|
||||
: m_type(has_span ? Type::Span : Type::Position)
|
||||
, m_span_count_or_position(span_count_or_position)
|
||||
, m_line_name(line_name)
|
||||
{
|
||||
}
|
||||
|
||||
GridTrackPlacement::GridTrackPlacement(String line_name, bool has_span)
|
||||
: m_type(has_span ? Type::Span : Type::Position)
|
||||
, m_line_name(line_name)
|
||||
{
|
||||
}
|
||||
|
||||
GridTrackPlacement::GridTrackPlacement()
|
||||
: m_type(Type::Auto)
|
||||
{
|
||||
}
|
||||
|
||||
String GridTrackPlacement::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (is_auto()) {
|
||||
builder.append("auto"sv);
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
if (is_span()) {
|
||||
builder.append("span"sv);
|
||||
builder.append(" "sv);
|
||||
}
|
||||
if (m_span_count_or_position != 0) {
|
||||
builder.append(MUST(String::number(m_span_count_or_position)));
|
||||
builder.append(" "sv);
|
||||
}
|
||||
if (has_line_name()) {
|
||||
builder.append(m_line_name);
|
||||
}
|
||||
m_value.visit(
|
||||
[&](Auto const&) {
|
||||
builder.append("auto"sv);
|
||||
},
|
||||
[&](Area const& area) {
|
||||
builder.append(area.name);
|
||||
},
|
||||
[&](Line const& line) {
|
||||
builder.appendff("{}", line.value);
|
||||
if (line.name.has_value())
|
||||
builder.appendff(" {}", line.name.value());
|
||||
},
|
||||
[&](Span const& span) {
|
||||
builder.appendff("span {}", span.value);
|
||||
});
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue