2022-08-24 12:21:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GridTrackPlacement.h"
|
|
|
|
#include <AK/String.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2022-10-30 13:40:57 +01:00
|
|
|
GridTrackPlacement::GridTrackPlacement(int span_count_or_position, bool has_span)
|
2022-09-17 18:09:35 +02:00
|
|
|
: m_type(has_span ? Type::Span : Type::Position)
|
2022-10-30 13:40:57 +01:00
|
|
|
, m_span_count_or_position(span_count_or_position)
|
2022-08-24 12:21:58 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GridTrackPlacement::GridTrackPlacement()
|
2022-09-17 18:09:35 +02:00
|
|
|
: m_type(Type::Auto)
|
2022-08-24 12:21:58 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
String GridTrackPlacement::to_string() const
|
|
|
|
{
|
|
|
|
StringBuilder builder;
|
2022-10-30 13:40:57 +01:00
|
|
|
if (is_auto()) {
|
|
|
|
builder.append("auto"sv);
|
|
|
|
return builder.to_string();
|
|
|
|
}
|
|
|
|
if (is_span()) {
|
|
|
|
builder.append("span"sv);
|
|
|
|
builder.append(" "sv);
|
|
|
|
}
|
|
|
|
if (m_span_count_or_position != 0) {
|
|
|
|
builder.append(String::number(m_span_count_or_position));
|
|
|
|
builder.append(" "sv);
|
|
|
|
}
|
2022-08-24 12:21:58 +02:00
|
|
|
return builder.to_string();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|