mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb: Add GridTrackPlacement for grid-[column/row]-[start/end]
Add GridTrackPlacement to use with grid-column-start and related CSS properties.
This commit is contained in:
parent
fc36970973
commit
ca286fc220
4 changed files with 76 additions and 0 deletions
|
@ -40,6 +40,7 @@ set(SOURCES
|
||||||
CSS/Display.cpp
|
CSS/Display.cpp
|
||||||
CSS/FontFace.cpp
|
CSS/FontFace.cpp
|
||||||
CSS/Frequency.cpp
|
CSS/Frequency.cpp
|
||||||
|
CSS/GridTrackPlacement.cpp
|
||||||
CSS/GridTrackSize.cpp
|
CSS/GridTrackSize.cpp
|
||||||
CSS/Length.cpp
|
CSS/Length.cpp
|
||||||
CSS/MediaList.cpp
|
CSS/MediaList.cpp
|
||||||
|
|
36
Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
Normal file
36
Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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 position, bool has_span)
|
||||||
|
: m_position(position)
|
||||||
|
, m_has_span(has_span)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GridTrackPlacement::GridTrackPlacement(int position)
|
||||||
|
: m_position(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GridTrackPlacement::GridTrackPlacement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
String GridTrackPlacement::to_string() const
|
||||||
|
{
|
||||||
|
StringBuilder builder;
|
||||||
|
if (m_has_span)
|
||||||
|
builder.append("span "sv);
|
||||||
|
builder.append(String::number(m_position));
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
Normal file
38
Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
GridTrackPlacement(int, bool);
|
||||||
|
GridTrackPlacement(int);
|
||||||
|
GridTrackPlacement();
|
||||||
|
|
||||||
|
static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
|
||||||
|
|
||||||
|
void set_position(int position) { m_position = position; }
|
||||||
|
int position() const { return m_position; }
|
||||||
|
|
||||||
|
void set_has_span(bool has_span) { m_has_span = has_span; }
|
||||||
|
bool has_span() const { return m_has_span; }
|
||||||
|
|
||||||
|
String to_string() const;
|
||||||
|
bool operator==(GridTrackPlacement const& other) const
|
||||||
|
{
|
||||||
|
return m_position == other.position() && m_has_span == other.has_span();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_position { 0 };
|
||||||
|
bool m_has_span { false };
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -57,6 +57,7 @@ class FontStyleValue;
|
||||||
class Frequency;
|
class Frequency;
|
||||||
class FrequencyPercentage;
|
class FrequencyPercentage;
|
||||||
class FrequencyStyleValue;
|
class FrequencyStyleValue;
|
||||||
|
class GridTrackPlacement;
|
||||||
class GridTrackSize;
|
class GridTrackSize;
|
||||||
class IdentifierStyleValue;
|
class IdentifierStyleValue;
|
||||||
class ImageStyleValue;
|
class ImageStyleValue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue