mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
LibWeb: Replace FlexFlowStyleValue with ShorthandStyleValue
This commit is contained in:
parent
aa45b3dfe3
commit
1ae515c0b7
10 changed files with 5 additions and 79 deletions
|
@ -1,19 +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 "FlexFlowStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String FlexFlowStyleValue::to_string() const
|
||||
{
|
||||
return MUST(String::formatted("{} {}", m_properties.flex_direction->to_string(), m_properties.flex_wrap->to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +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 FlexFlowStyleValue final : public StyleValueWithDefaultOperators<FlexFlowStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<FlexFlowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) FlexFlowStyleValue(move(flex_direction), move(flex_wrap)));
|
||||
}
|
||||
virtual ~FlexFlowStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue> flex_direction() const { return m_properties.flex_direction; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> flex_wrap() const { return m_properties.flex_wrap; }
|
||||
|
||||
virtual String to_string() const override;
|
||||
|
||||
bool properties_equal(FlexFlowStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
FlexFlowStyleValue(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
|
||||
: StyleValueWithDefaultOperators(Type::FlexFlow)
|
||||
, m_properties { .flex_direction = move(flex_direction), .flex_wrap = move(flex_wrap) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<StyleValue> flex_direction;
|
||||
ValueComparingNonnullRefPtr<StyleValue> flex_wrap;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
|
@ -37,6 +37,8 @@ String ShorthandStyleValue::to_string() const
|
|||
switch (m_properties.shorthand_property) {
|
||||
case PropertyID::Flex:
|
||||
return MUST(String::formatted("{} {} {}", longhand(PropertyID::FlexGrow)->to_string(), longhand(PropertyID::FlexShrink)->to_string(), longhand(PropertyID::FlexBasis)->to_string()));
|
||||
case PropertyID::FlexFlow:
|
||||
return MUST(String::formatted("{} {}", longhand(PropertyID::FlexDirection)->to_string(), longhand(PropertyID::FlexWrap)->to_string()));
|
||||
default:
|
||||
StringBuilder builder;
|
||||
auto first = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue