1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

LibWeb: Replace PlaceContentStyleValue with ShorthandStyleValue

This commit is contained in:
Sam Atkins 2023-09-20 15:06:48 +01:00 committed by Sam Atkins
parent 6758decc74
commit 1b0939b418
10 changed files with 13 additions and 78 deletions

View file

@ -1,20 +0,0 @@
/*
* Copyright (c) 2023, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PlaceContentStyleValue.h"
namespace Web::CSS {
String PlaceContentStyleValue::to_string() const
{
auto align_content = m_properties.align_content->to_string();
auto justify_content = m_properties.justify_content->to_string();
if (align_content == justify_content)
return MUST(String::formatted("{}", align_content));
return MUST(String::formatted("{} {}", align_content, justify_content));
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2023, Hunter Salyer <thefalsehonesty@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
class PlaceContentStyleValue final : public StyleValueWithDefaultOperators<PlaceContentStyleValue> {
public:
static ValueComparingNonnullRefPtr<PlaceContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content)
{
return adopt_ref(*new (nothrow) PlaceContentStyleValue(move(align_content), move(justify_content)));
}
virtual ~PlaceContentStyleValue() override = default;
ValueComparingNonnullRefPtr<StyleValue> align_content() const { return m_properties.align_content; }
ValueComparingNonnullRefPtr<StyleValue> justify_content() const { return m_properties.justify_content; }
virtual String to_string() const override;
bool properties_equal(PlaceContentStyleValue const& other) const { return m_properties == other.m_properties; }
private:
PlaceContentStyleValue(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content)
: StyleValueWithDefaultOperators(Type::PlaceContent)
, m_properties { .align_content = move(align_content), .justify_content = move(justify_content) }
{
}
struct Properties {
ValueComparingNonnullRefPtr<StyleValue> align_content;
ValueComparingNonnullRefPtr<StyleValue> justify_content;
bool operator==(Properties const&) const = default;
} m_properties;
};
}

View file

@ -147,6 +147,13 @@ String ShorthandStyleValue::to_string() const
}
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: {
auto align_content = longhand(PropertyID::AlignContent)->to_string();
auto justify_content = longhand(PropertyID::JustifyContent)->to_string();
if (align_content == justify_content)
return align_content;
return MUST(String::formatted("{} {}", align_content, justify_content));
}
default:
StringBuilder builder;
auto first = true;