mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:47:35 +00:00
LibWeb: Replace PlaceItemsStyleValue with ShorthandStyleValue
This commit is contained in:
parent
8143d48161
commit
6e311902de
10 changed files with 13 additions and 78 deletions
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "PlaceItemsStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String PlaceItemsStyleValue::to_string() const
|
||||
{
|
||||
auto align_items = m_properties.align_items->to_string();
|
||||
auto justify_items = m_properties.justify_items->to_string();
|
||||
if (align_items == justify_items)
|
||||
return MUST(String::formatted("{}", align_items));
|
||||
return MUST(String::formatted("{} {}", align_items, justify_items));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/StyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class PlaceItemsStyleValue final : public StyleValueWithDefaultOperators<PlaceItemsStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<PlaceItemsStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> align_items, ValueComparingNonnullRefPtr<StyleValue> justify_items)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) PlaceItemsStyleValue(move(align_items), move(justify_items)));
|
||||
}
|
||||
virtual ~PlaceItemsStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue> align_items() const { return m_properties.align_items; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> justify_items() const { return m_properties.justify_items; }
|
||||
|
||||
virtual String to_string() const override;
|
||||
|
||||
bool properties_equal(PlaceItemsStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
PlaceItemsStyleValue(ValueComparingNonnullRefPtr<StyleValue> align_items, ValueComparingNonnullRefPtr<StyleValue> justify_items)
|
||||
: StyleValueWithDefaultOperators(Type::PlaceItems)
|
||||
, m_properties { .align_items = move(align_items), .justify_items = move(justify_items) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<StyleValue> align_items;
|
||||
ValueComparingNonnullRefPtr<StyleValue> justify_items;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
|
@ -154,6 +154,13 @@ String ShorthandStyleValue::to_string() const
|
|||
return align_content;
|
||||
return MUST(String::formatted("{} {}", align_content, justify_content));
|
||||
}
|
||||
case PropertyID::PlaceItems: {
|
||||
auto align_items = longhand(PropertyID::AlignItems)->to_string();
|
||||
auto justify_items = longhand(PropertyID::JustifyItems)->to_string();
|
||||
if (align_items == justify_items)
|
||||
return align_items;
|
||||
return MUST(String::formatted("{} {}", align_items, justify_items));
|
||||
}
|
||||
case PropertyID::PlaceSelf: {
|
||||
auto align_self = longhand(PropertyID::AlignSelf)->to_string();
|
||||
auto justify_self = longhand(PropertyID::JustifySelf)->to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue