mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibWeb: Parse grid-template-areas
CSS property
This commit is contained in:
parent
0448547553
commit
a6548c4d80
10 changed files with 101 additions and 0 deletions
|
@ -140,6 +140,12 @@ GridTrackPlacementShorthandStyleValue const& StyleValue::as_grid_track_placement
|
|||
return static_cast<GridTrackPlacementShorthandStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
GridTemplateAreaStyleValue const& StyleValue::as_grid_template_area() const
|
||||
{
|
||||
VERIFY(is_grid_template_area());
|
||||
return static_cast<GridTemplateAreaStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
GridTrackPlacementStyleValue const& StyleValue::as_grid_track_placement() const
|
||||
{
|
||||
VERIFY(is_grid_track_placement());
|
||||
|
@ -1434,6 +1440,29 @@ bool GridTrackPlacementStyleValue::equals(StyleValue const& other) const
|
|||
return m_grid_track_placement == typed_other.grid_track_placement();
|
||||
}
|
||||
|
||||
ErrorOr<String> GridTemplateAreaStyleValue::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t y = 0; y < m_grid_template_area.size(); ++y) {
|
||||
for (size_t x = 0; x < m_grid_template_area[y].size(); ++x) {
|
||||
builder.appendff("{}", m_grid_template_area[y][x]);
|
||||
if (x < m_grid_template_area[y].size() - 1)
|
||||
builder.append(" "sv);
|
||||
}
|
||||
if (y < m_grid_template_area.size() - 1)
|
||||
builder.append(", "sv);
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
bool GridTemplateAreaStyleValue::equals(StyleValue const& other) const
|
||||
{
|
||||
if (type() != other.type())
|
||||
return false;
|
||||
auto const& typed_other = other.as_grid_template_area();
|
||||
return m_grid_template_area == typed_other.grid_template_area();
|
||||
}
|
||||
|
||||
ErrorOr<String> GridTrackSizeStyleValue::to_string() const
|
||||
{
|
||||
return m_grid_track_size_list.to_string();
|
||||
|
@ -2528,6 +2557,11 @@ NonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
|||
return adopt_ref(*new ColorStyleValue(color));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GridTemplateAreaStyleValue> GridTemplateAreaStyleValue::create(Vector<Vector<String>> grid_template_area)
|
||||
{
|
||||
return adopt_ref(*new GridTemplateAreaStyleValue(grid_template_area));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GridTrackPlacementStyleValue> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement)
|
||||
{
|
||||
return adopt_ref(*new GridTrackPlacementStyleValue(grid_track_placement));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue