ladybird/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
martinfalisse 236795e931 LibWeb+Base: Re-implement grid track span
Implement span correctly when indicated in the grid-column-start,
grid-row-start, etc. CSS properties. Previously it had been implemented
as if span was something that went alongside the position property, but
actually it seems like if you do 'span 3' in the grid-column-start
property, for example, this means it literally spans 3 blocks, and the
3 has nothing to do with position.
2022-10-06 21:16:01 +02:00

32 lines
638 B
C++

/*
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "GridTrackPlacement.h"
#include <AK/String.h>
namespace Web::CSS {
GridTrackPlacement::GridTrackPlacement(int span_or_position, bool has_span)
: m_type(has_span ? Type::Span : Type::Position)
, m_value(span_or_position)
{
}
GridTrackPlacement::GridTrackPlacement()
: m_type(Type::Auto)
{
}
String GridTrackPlacement::to_string() const
{
StringBuilder builder;
if (is_span())
builder.append("span "sv);
builder.append(String::number(m_value));
return builder.to_string();
}
}