mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibWeb: Add GridTrackSizeStyleValue
Add GridTrackSizeStyleValue for the use of CSS properties grid-template-columns, grid-template-rows.
This commit is contained in:
parent
ca286fc220
commit
0148260b5f
3 changed files with 55 additions and 0 deletions
|
@ -150,6 +150,12 @@ LengthStyleValue const& StyleValue::as_length() const
|
||||||
return static_cast<LengthStyleValue const&>(*this);
|
return static_cast<LengthStyleValue const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GridTrackSizeStyleValue const& StyleValue::as_grid_track_size() const
|
||||||
|
{
|
||||||
|
VERIFY(is_grid_track_size());
|
||||||
|
return static_cast<GridTrackSizeStyleValue const&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
LinearGradientStyleValue const& StyleValue::as_linear_gradient() const
|
LinearGradientStyleValue const& StyleValue::as_linear_gradient() const
|
||||||
{
|
{
|
||||||
VERIFY(is_linear_gradient());
|
VERIFY(is_linear_gradient());
|
||||||
|
@ -1198,6 +1204,25 @@ bool FrequencyStyleValue::equals(StyleValue const& other) const
|
||||||
return m_frequency == other.as_frequency().m_frequency;
|
return m_frequency == other.as_frequency().m_frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String GridTrackSizeStyleValue::to_string() const
|
||||||
|
{
|
||||||
|
StringBuilder builder;
|
||||||
|
for (size_t i = 0; i < m_grid_track.size(); i++) {
|
||||||
|
builder.append(m_grid_track[i].to_string());
|
||||||
|
if (i != m_grid_track.size() - 1)
|
||||||
|
builder.append(" "sv);
|
||||||
|
}
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GridTrackSizeStyleValue::equals(StyleValue const& other) const
|
||||||
|
{
|
||||||
|
if (type() != other.type())
|
||||||
|
return false;
|
||||||
|
auto const& typed_other = other.as_grid_track_size();
|
||||||
|
return m_grid_track == typed_other.grid_track_size();
|
||||||
|
}
|
||||||
|
|
||||||
String IdentifierStyleValue::to_string() const
|
String IdentifierStyleValue::to_string() const
|
||||||
{
|
{
|
||||||
return CSS::string_from_value_id(m_id);
|
return CSS::string_from_value_id(m_id);
|
||||||
|
@ -1906,6 +1931,11 @@ NonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
||||||
return adopt_ref(*new ColorStyleValue(color));
|
return adopt_ref(*new ColorStyleValue(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NonnullRefPtr<GridTrackSizeStyleValue> GridTrackSizeStyleValue::create(Vector<CSS::GridTrackSize> grid_track_size)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new GridTrackSizeStyleValue(grid_track_size));
|
||||||
|
}
|
||||||
|
|
||||||
NonnullRefPtr<RectStyleValue> RectStyleValue::create(EdgeRect rect)
|
NonnullRefPtr<RectStyleValue> RectStyleValue::create(EdgeRect rect)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new RectStyleValue(rect));
|
return adopt_ref(*new RectStyleValue(rect));
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <LibWeb/CSS/Display.h>
|
#include <LibWeb/CSS/Display.h>
|
||||||
#include <LibWeb/CSS/Enums.h>
|
#include <LibWeb/CSS/Enums.h>
|
||||||
#include <LibWeb/CSS/Frequency.h>
|
#include <LibWeb/CSS/Frequency.h>
|
||||||
|
#include <LibWeb/CSS/GridTrackSize.h>
|
||||||
#include <LibWeb/CSS/Length.h>
|
#include <LibWeb/CSS/Length.h>
|
||||||
#include <LibWeb/CSS/Number.h>
|
#include <LibWeb/CSS/Number.h>
|
||||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||||
|
@ -130,6 +131,7 @@ public:
|
||||||
FlexFlow,
|
FlexFlow,
|
||||||
Font,
|
Font,
|
||||||
Frequency,
|
Frequency,
|
||||||
|
GridTrackSize,
|
||||||
Identifier,
|
Identifier,
|
||||||
Image,
|
Image,
|
||||||
Inherit,
|
Inherit,
|
||||||
|
@ -171,6 +173,7 @@ public:
|
||||||
bool is_flex_flow() const { return type() == Type::FlexFlow; }
|
bool is_flex_flow() const { return type() == Type::FlexFlow; }
|
||||||
bool is_font() const { return type() == Type::Font; }
|
bool is_font() const { return type() == Type::Font; }
|
||||||
bool is_frequency() const { return type() == Type::Frequency; }
|
bool is_frequency() const { return type() == Type::Frequency; }
|
||||||
|
bool is_grid_track_size() const { return type() == Type::GridTrackSize; }
|
||||||
bool is_identifier() const { return type() == Type::Identifier; }
|
bool is_identifier() const { return type() == Type::Identifier; }
|
||||||
bool is_image() const { return type() == Type::Image; }
|
bool is_image() const { return type() == Type::Image; }
|
||||||
bool is_inherit() const { return type() == Type::Inherit; }
|
bool is_inherit() const { return type() == Type::Inherit; }
|
||||||
|
@ -210,6 +213,7 @@ public:
|
||||||
FlexStyleValue const& as_flex() const;
|
FlexStyleValue const& as_flex() const;
|
||||||
FontStyleValue const& as_font() const;
|
FontStyleValue const& as_font() const;
|
||||||
FrequencyStyleValue const& as_frequency() const;
|
FrequencyStyleValue const& as_frequency() const;
|
||||||
|
GridTrackSizeStyleValue const& as_grid_track_size() const;
|
||||||
IdentifierStyleValue const& as_identifier() const;
|
IdentifierStyleValue const& as_identifier() const;
|
||||||
ImageStyleValue const& as_image() const;
|
ImageStyleValue const& as_image() const;
|
||||||
InheritStyleValue const& as_inherit() const;
|
InheritStyleValue const& as_inherit() const;
|
||||||
|
@ -247,6 +251,7 @@ public:
|
||||||
FlexStyleValue& as_flex() { return const_cast<FlexStyleValue&>(const_cast<StyleValue const&>(*this).as_flex()); }
|
FlexStyleValue& as_flex() { return const_cast<FlexStyleValue&>(const_cast<StyleValue const&>(*this).as_flex()); }
|
||||||
FontStyleValue& as_font() { return const_cast<FontStyleValue&>(const_cast<StyleValue const&>(*this).as_font()); }
|
FontStyleValue& as_font() { return const_cast<FontStyleValue&>(const_cast<StyleValue const&>(*this).as_font()); }
|
||||||
FrequencyStyleValue& as_frequency() { return const_cast<FrequencyStyleValue&>(const_cast<StyleValue const&>(*this).as_frequency()); }
|
FrequencyStyleValue& as_frequency() { return const_cast<FrequencyStyleValue&>(const_cast<StyleValue const&>(*this).as_frequency()); }
|
||||||
|
GridTrackSizeStyleValue& as_grid_track_size() { return const_cast<GridTrackSizeStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_track_size()); }
|
||||||
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<StyleValue const&>(*this).as_identifier()); }
|
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<StyleValue const&>(*this).as_identifier()); }
|
||||||
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<StyleValue const&>(*this).as_image()); }
|
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<StyleValue const&>(*this).as_image()); }
|
||||||
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<StyleValue const&>(*this).as_inherit()); }
|
InheritStyleValue& as_inherit() { return const_cast<InheritStyleValue&>(const_cast<StyleValue const&>(*this).as_inherit()); }
|
||||||
|
@ -897,6 +902,25 @@ private:
|
||||||
Frequency m_frequency;
|
Frequency m_frequency;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GridTrackSizeStyleValue final : public StyleValue {
|
||||||
|
public:
|
||||||
|
static NonnullRefPtr<GridTrackSizeStyleValue> create(Vector<CSS::GridTrackSize> grid_track_size);
|
||||||
|
virtual ~GridTrackSizeStyleValue() override = default;
|
||||||
|
|
||||||
|
Vector<CSS::GridTrackSize> grid_track_size() const { return m_grid_track; }
|
||||||
|
virtual String to_string() const override;
|
||||||
|
virtual bool equals(StyleValue const& other) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit GridTrackSizeStyleValue(Vector<CSS::GridTrackSize> grid_track_size)
|
||||||
|
: StyleValue(Type::GridTrackSize)
|
||||||
|
, m_grid_track(grid_track_size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<CSS::GridTrackSize> m_grid_track;
|
||||||
|
};
|
||||||
|
|
||||||
class IdentifierStyleValue final : public StyleValue {
|
class IdentifierStyleValue final : public StyleValue {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<IdentifierStyleValue> create(CSS::ValueID id)
|
static NonnullRefPtr<IdentifierStyleValue> create(CSS::ValueID id)
|
||||||
|
|
|
@ -59,6 +59,7 @@ class FrequencyPercentage;
|
||||||
class FrequencyStyleValue;
|
class FrequencyStyleValue;
|
||||||
class GridTrackPlacement;
|
class GridTrackPlacement;
|
||||||
class GridTrackSize;
|
class GridTrackSize;
|
||||||
|
class GridTrackSizeStyleValue;
|
||||||
class IdentifierStyleValue;
|
class IdentifierStyleValue;
|
||||||
class ImageStyleValue;
|
class ImageStyleValue;
|
||||||
class InheritStyleValue;
|
class InheritStyleValue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue