mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibWeb: Split BorderRadiusShorthandStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
1c03bc7a6f
commit
25114c159d
Notes:
sideshowbarker
2024-07-17 05:23:40 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/25114c159d Pull-request: https://github.com/SerenityOS/serenity/pull/18040
8 changed files with 81 additions and 46 deletions
|
@ -68,6 +68,7 @@ set(SOURCES
|
|||
CSS/StyleValues/BackgroundRepeatStyleValue.cpp
|
||||
CSS/StyleValues/BackgroundSizeStyleValue.cpp
|
||||
CSS/StyleValues/BackgroundStyleValue.cpp
|
||||
CSS/StyleValues/BorderRadiusShorthandStyleValue.cpp
|
||||
CSS/StyleValues/BorderStyleValue.cpp
|
||||
CSS/Supports.cpp
|
||||
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
|
@ -302,11 +303,6 @@ ErrorOr<String> BorderRadiusStyleValue::to_string() const
|
|||
return String::formatted("{} / {}", TRY(m_properties.horizontal_radius.to_string()), TRY(m_properties.vertical_radius.to_string()));
|
||||
}
|
||||
|
||||
ErrorOr<String> BorderRadiusShorthandStyleValue::to_string() const
|
||||
{
|
||||
return String::formatted("{} {} {} {} / {} {} {} {}", TRY(m_properties.top_left->horizontal_radius().to_string()), TRY(m_properties.top_right->horizontal_radius().to_string()), TRY(m_properties.bottom_right->horizontal_radius().to_string()), TRY(m_properties.bottom_left->horizontal_radius().to_string()), TRY(m_properties.top_left->vertical_radius().to_string()), TRY(m_properties.top_right->vertical_radius().to_string()), TRY(m_properties.bottom_right->vertical_radius().to_string()), TRY(m_properties.bottom_left->vertical_radius().to_string()));
|
||||
}
|
||||
|
||||
void CalculatedStyleValue::CalculationResult::add(CalculationResult const& other, Layout::Node const* layout_node, PercentageBasis const& percentage_basis)
|
||||
{
|
||||
add_or_subtract_internal(SumOperation::Add, other, layout_node, percentage_basis);
|
||||
|
|
|
@ -535,47 +535,6 @@ private:
|
|||
} m_properties;
|
||||
};
|
||||
|
||||
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 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 ErrorOr<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;
|
||||
};
|
||||
|
||||
class CalculatedStyleValue : public StyleValue {
|
||||
public:
|
||||
enum class ResolvedType {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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 {
|
||||
|
||||
ErrorOr<String> BorderRadiusShorthandStyleValue::to_string() const
|
||||
{
|
||||
return String::formatted("{} {} {} {} / {} {} {} {}", TRY(m_properties.top_left->horizontal_radius().to_string()), TRY(m_properties.top_right->horizontal_radius().to_string()), TRY(m_properties.bottom_right->horizontal_radius().to_string()), TRY(m_properties.bottom_left->horizontal_radius().to_string()), TRY(m_properties.top_left->vertical_radius().to_string()), TRY(m_properties.top_right->vertical_radius().to_string()), TRY(m_properties.bottom_right->vertical_radius().to_string()), TRY(m_properties.bottom_left->vertical_radius().to_string()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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 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 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 ErrorOr<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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue