ladybird/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
Aliaksandr Kalenik c03e025a32 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.
2023-08-26 13:16:17 +02:00

34 lines
852 B
C++

/*
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "GridTrackPlacement.h"
#include <AK/StringBuilder.h>
namespace Web::CSS {
String GridTrackPlacement::to_string() const
{
StringBuilder builder;
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());
}
}