mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
LibWeb: Replace BorderRadiusShorthandStyleValue with ShorthandStyleValue
This commit is contained in:
parent
34e0899ab0
commit
34591549b1
11 changed files with 24 additions and 104 deletions
|
@ -1,27 +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 "BorderRadiusShorthandStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String BorderRadiusShorthandStyleValue::to_string() const
|
||||
{
|
||||
return MUST(String::formatted("{} {} {} {} / {} {} {} {}",
|
||||
m_properties.top_left->horizontal_radius().to_string(),
|
||||
m_properties.top_right->horizontal_radius().to_string(),
|
||||
m_properties.bottom_right->horizontal_radius().to_string(),
|
||||
m_properties.bottom_left->horizontal_radius().to_string(),
|
||||
m_properties.top_left->vertical_radius().to_string(),
|
||||
m_properties.top_right->vertical_radius().to_string(),
|
||||
m_properties.bottom_right->vertical_radius().to_string(),
|
||||
m_properties.bottom_left->vertical_radius().to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +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>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class BorderRadiusShorthandStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusShorthandStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<BorderRadiusShorthandStyleValue> create(
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left)));
|
||||
}
|
||||
virtual ~BorderRadiusShorthandStyleValue() override = default;
|
||||
|
||||
auto top_left() const { return m_properties.top_left; }
|
||||
auto top_right() const { return m_properties.top_right; }
|
||||
auto bottom_right() const { return m_properties.bottom_right; }
|
||||
auto bottom_left() const { return m_properties.bottom_left; }
|
||||
|
||||
virtual String to_string() const override;
|
||||
|
||||
bool properties_equal(BorderRadiusShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||
|
||||
private:
|
||||
BorderRadiusShorthandStyleValue(
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right,
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left)
|
||||
: StyleValueWithDefaultOperators(Type::BorderRadiusShorthand)
|
||||
, m_properties { .top_left = move(top_left), .top_right = move(top_right), .bottom_right = move(bottom_right), .bottom_left = move(bottom_left) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left;
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right;
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right;
|
||||
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left;
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ShorthandStyleValue.h"
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
@ -72,6 +74,22 @@ String ShorthandStyleValue::to_string() const
|
|||
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
case PropertyID::BorderRadius: {
|
||||
auto& top_left = longhand(PropertyID::BorderTopLeftRadius)->as_border_radius();
|
||||
auto& top_right = longhand(PropertyID::BorderTopRightRadius)->as_border_radius();
|
||||
auto& bottom_right = longhand(PropertyID::BorderBottomRightRadius)->as_border_radius();
|
||||
auto& bottom_left = longhand(PropertyID::BorderBottomLeftRadius)->as_border_radius();
|
||||
|
||||
return MUST(String::formatted("{} {} {} {} / {} {} {} {}",
|
||||
top_left.horizontal_radius().to_string(),
|
||||
top_right.horizontal_radius().to_string(),
|
||||
bottom_right.horizontal_radius().to_string(),
|
||||
bottom_left.horizontal_radius().to_string(),
|
||||
top_left.vertical_radius().to_string(),
|
||||
top_right.vertical_radius().to_string(),
|
||||
bottom_right.vertical_radius().to_string(),
|
||||
bottom_left.vertical_radius().to_string()));
|
||||
}
|
||||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue