mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
LibWeb: Split GridAreaShorthandStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
4dc99e49a1
commit
675cb3b9da
8 changed files with 100 additions and 55 deletions
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GridAreaShorthandStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> GridAreaShorthandStyleValue::create(
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_start,
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_start,
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_end,
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_end)
|
||||
{
|
||||
return adopt_ref(*new GridAreaShorthandStyleValue(row_start, column_start, row_end, column_end));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> GridAreaShorthandStyleValue::create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end)
|
||||
{
|
||||
return adopt_ref(*new GridAreaShorthandStyleValue(GridTrackPlacementStyleValue::create(row_start), GridTrackPlacementStyleValue::create(column_start), GridTrackPlacementStyleValue::create(row_end), GridTrackPlacementStyleValue::create(column_end)));
|
||||
}
|
||||
|
||||
ErrorOr<String> GridAreaShorthandStyleValue::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
if (!m_properties.row_start->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
TRY(builder.try_appendff("{}", TRY(m_properties.row_start->as_grid_track_placement().grid_track_placement().to_string())));
|
||||
if (!m_properties.column_start->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
TRY(builder.try_appendff(" / {}", TRY(m_properties.column_start->as_grid_track_placement().grid_track_placement().to_string())));
|
||||
if (!m_properties.row_end->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
TRY(builder.try_appendff(" / {}", TRY(m_properties.row_end->as_grid_track_placement().grid_track_placement().to_string())));
|
||||
if (!m_properties.column_end->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
TRY(builder.try_appendff(" / {}", TRY(m_properties.column_end->as_grid_track_placement().grid_track_placement().to_string())));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
bool GridAreaShorthandStyleValue::Properties::operator==(GridAreaShorthandStyleValue::Properties const&) const = default;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue