mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Add GridTrackPlacementStyleValue
Add GridTrackPlacementStyleValue for the use of CSS properties grid-column-start, grid-column-end, grid-row-start, grid-row-end.
This commit is contained in:
parent
0148260b5f
commit
08b832eb69
Notes:
sideshowbarker
2024-07-17 07:45:49 +09:00
Author: https://github.com/martinfalisse Commit: https://github.com/SerenityOS/serenity/commit/08b832eb69 Pull-request: https://github.com/SerenityOS/serenity/pull/14996
3 changed files with 49 additions and 0 deletions
|
@ -120,6 +120,12 @@ FrequencyStyleValue const& StyleValue::as_frequency() const
|
|||
return static_cast<FrequencyStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
GridTrackPlacementStyleValue const& StyleValue::as_grid_track_placement() const
|
||||
{
|
||||
VERIFY(is_grid_track_placement());
|
||||
return static_cast<GridTrackPlacementStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
IdentifierStyleValue const& StyleValue::as_identifier() const
|
||||
{
|
||||
VERIFY(is_identifier());
|
||||
|
@ -1204,6 +1210,19 @@ bool FrequencyStyleValue::equals(StyleValue const& other) const
|
|||
return m_frequency == other.as_frequency().m_frequency;
|
||||
}
|
||||
|
||||
String GridTrackPlacementStyleValue::to_string() const
|
||||
{
|
||||
return m_grid_track_placement.to_string();
|
||||
}
|
||||
|
||||
bool GridTrackPlacementStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
auto const& typed_other = other.as_grid_track_placement();
|
||||
return m_grid_track_placement == typed_other.grid_track_placement();
|
||||
}
|
||||
|
||||
String GridTrackSizeStyleValue::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
@ -1931,6 +1950,11 @@ NonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
|||
return adopt_ref(*new ColorStyleValue(color));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GridTrackPlacementStyleValue> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement)
|
||||
{
|
||||
return adopt_ref(*new GridTrackPlacementStyleValue(grid_track_placement));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GridTrackSizeStyleValue> GridTrackSizeStyleValue::create(Vector<CSS::GridTrackSize> grid_track_size)
|
||||
{
|
||||
return adopt_ref(*new GridTrackSizeStyleValue(grid_track_size));
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <LibWeb/CSS/Display.h>
|
||||
#include <LibWeb/CSS/Enums.h>
|
||||
#include <LibWeb/CSS/Frequency.h>
|
||||
#include <LibWeb/CSS/GridTrackPlacement.h>
|
||||
#include <LibWeb/CSS/GridTrackSize.h>
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/CSS/Number.h>
|
||||
|
@ -131,6 +132,7 @@ public:
|
|||
FlexFlow,
|
||||
Font,
|
||||
Frequency,
|
||||
GridTrackPlacement,
|
||||
GridTrackSize,
|
||||
Identifier,
|
||||
Image,
|
||||
|
@ -173,6 +175,7 @@ public:
|
|||
bool is_flex_flow() const { return type() == Type::FlexFlow; }
|
||||
bool is_font() const { return type() == Type::Font; }
|
||||
bool is_frequency() const { return type() == Type::Frequency; }
|
||||
bool is_grid_track_placement() const { return type() == Type::GridTrackPlacement; }
|
||||
bool is_grid_track_size() const { return type() == Type::GridTrackSize; }
|
||||
bool is_identifier() const { return type() == Type::Identifier; }
|
||||
bool is_image() const { return type() == Type::Image; }
|
||||
|
@ -213,6 +216,7 @@ public:
|
|||
FlexStyleValue const& as_flex() const;
|
||||
FontStyleValue const& as_font() const;
|
||||
FrequencyStyleValue const& as_frequency() const;
|
||||
GridTrackPlacementStyleValue const& as_grid_track_placement() const;
|
||||
GridTrackSizeStyleValue const& as_grid_track_size() const;
|
||||
IdentifierStyleValue const& as_identifier() const;
|
||||
ImageStyleValue const& as_image() const;
|
||||
|
@ -251,6 +255,7 @@ public:
|
|||
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()); }
|
||||
FrequencyStyleValue& as_frequency() { return const_cast<FrequencyStyleValue&>(const_cast<StyleValue const&>(*this).as_frequency()); }
|
||||
GridTrackPlacementStyleValue& as_grid_track_placement() { return const_cast<GridTrackPlacementStyleValue&>(const_cast<StyleValue const&>(*this).as_grid_track_placement()); }
|
||||
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()); }
|
||||
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<StyleValue const&>(*this).as_image()); }
|
||||
|
@ -902,6 +907,25 @@ private:
|
|||
Frequency m_frequency;
|
||||
};
|
||||
|
||||
class GridTrackPlacementStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<GridTrackPlacementStyleValue> create(CSS::GridTrackPlacement grid_track_placement);
|
||||
virtual ~GridTrackPlacementStyleValue() override = default;
|
||||
|
||||
CSS::GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; }
|
||||
virtual String to_string() const override;
|
||||
virtual bool equals(StyleValue const& other) const override;
|
||||
|
||||
private:
|
||||
explicit GridTrackPlacementStyleValue(CSS::GridTrackPlacement grid_track_placement)
|
||||
: StyleValue(Type::GridTrackPlacement)
|
||||
, m_grid_track_placement(grid_track_placement)
|
||||
{
|
||||
}
|
||||
|
||||
CSS::GridTrackPlacement m_grid_track_placement;
|
||||
};
|
||||
|
||||
class GridTrackSizeStyleValue final : public StyleValue {
|
||||
public:
|
||||
static NonnullRefPtr<GridTrackSizeStyleValue> create(Vector<CSS::GridTrackSize> grid_track_size);
|
||||
|
|
|
@ -58,6 +58,7 @@ class Frequency;
|
|||
class FrequencyPercentage;
|
||||
class FrequencyStyleValue;
|
||||
class GridTrackPlacement;
|
||||
class GridTrackPlacementStyleValue;
|
||||
class GridTrackSize;
|
||||
class GridTrackSizeStyleValue;
|
||||
class IdentifierStyleValue;
|
||||
|
|
Loading…
Reference in a new issue