mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibWeb: Replace GridTrackPlacementShorthandStyleValue with ShorthandSV
This commit is contained in:
parent
8efac89a16
commit
e905072e47
12 changed files with 81 additions and 153 deletions
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* 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 "GridTrackPlacementShorthandStyleValue.h"
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> GridTrackPlacementShorthandStyleValue::create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) GridTrackPlacementShorthandStyleValue(move(start), move(end)));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> GridTrackPlacementShorthandStyleValue::create(GridTrackPlacement start)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) GridTrackPlacementShorthandStyleValue(
|
||||
GridTrackPlacementStyleValue::create(start),
|
||||
GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto())));
|
||||
}
|
||||
|
||||
String GridTrackPlacementShorthandStyleValue::to_string() const
|
||||
{
|
||||
if (m_properties.end->grid_track_placement().is_auto())
|
||||
return MUST(String::formatted("{}", m_properties.start->grid_track_placement().to_string()));
|
||||
return MUST(String::formatted("{} / {}", m_properties.start->grid_track_placement().to_string(), m_properties.end->grid_track_placement().to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class GridTrackPlacementShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementShorthandStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end);
|
||||
static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(GridTrackPlacement start);
|
||||
virtual ~GridTrackPlacementShorthandStyleValue() override = default;
|
||||
|
||||
auto start() const { return m_properties.start; }
|
||||
auto end() const { return m_properties.end; }
|
||||
|
||||
virtual String to_string() const override;
|
||||
|
||||
bool properties_equal(GridTrackPlacementShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
GridTrackPlacementShorthandStyleValue(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end)
|
||||
: StyleValueWithDefaultOperators(Type::GridTrackPlacementShorthand)
|
||||
, m_properties { .start = move(start), .end = move(end) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start;
|
||||
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
|
@ -145,6 +145,20 @@ String ShorthandStyleValue::to_string() const
|
|||
return MUST(String::formatted("{}", construct_rows_string()));
|
||||
return MUST(String::formatted("{} / {}", construct_rows_string(), columns.grid_track_size_list().to_string()));
|
||||
}
|
||||
case PropertyID::GridColumn: {
|
||||
auto start = longhand(PropertyID::GridColumnStart);
|
||||
auto end = longhand(PropertyID::GridColumnEnd);
|
||||
if (end->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
return start->to_string();
|
||||
return MUST(String::formatted("{} / {}", start->to_string(), end->to_string()));
|
||||
}
|
||||
case PropertyID::GridRow: {
|
||||
auto start = longhand(PropertyID::GridRowStart);
|
||||
auto end = longhand(PropertyID::GridRowEnd);
|
||||
if (end->as_grid_track_placement().grid_track_placement().is_auto())
|
||||
return start->to_string();
|
||||
return MUST(String::formatted("{} / {}", start->to_string(), end->to_string()));
|
||||
}
|
||||
case PropertyID::ListStyle:
|
||||
return MUST(String::formatted("{} {} {}", longhand(PropertyID::ListStylePosition)->to_string(), longhand(PropertyID::ListStyleImage)->to_string(), longhand(PropertyID::ListStyleType)->to_string()));
|
||||
case PropertyID::PlaceContent: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue