1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00
serenity/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
martinfalisse 1a4f2dca38 LibWeb: Refactor GridTrackPlacement
Refactor this class for quality-of-life reasons as well as to better
prepare for the addition of line names.
2022-11-01 11:19:41 +01:00

45 lines
1.1 KiB
C++

/*
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
namespace Web::CSS {
class GridTrackPlacement {
public:
enum class Type {
Span,
Position,
Auto
};
GridTrackPlacement(int span_count_or_position, bool has_span = false);
GridTrackPlacement();
static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
bool is_span() const { return m_type == Type::Span; }
bool is_position() const { return m_type == Type::Position; }
bool is_auto() const { return m_type == Type::Auto; }
bool is_auto_positioned() const { return m_type == Type::Auto || m_type == Type::Span; }
int raw_value() const { return m_span_count_or_position; }
Type type() const { return m_type; }
String to_string() const;
bool operator==(GridTrackPlacement const& other) const
{
return m_type == other.type() && m_span_count_or_position == other.raw_value();
}
private:
Type m_type;
int m_span_count_or_position { 0 };
};
}