LibWeb: Split AngleStyleValue out of StyleValue.{h,cpp}

This commit is contained in:
Sam Atkins 2023-03-23 17:26:13 +00:00 committed by Linus Groh
parent 36c5afdfb2
commit 777d3e73f9
Notes: sideshowbarker 2024-07-17 06:29:49 +09:00
7 changed files with 74 additions and 25 deletions

View File

@ -64,6 +64,7 @@ set(SOURCES
CSS/StyleSheet.cpp
CSS/StyleSheetList.cpp
CSS/StyleValue.cpp
CSS/StyleValues/AngleStyleValue.cpp
CSS/Supports.cpp
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
CSS/Time.cpp

View File

@ -29,6 +29,7 @@
#include <LibWeb/CSS/Parser/Rule.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Infra/Strings.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -9,6 +9,7 @@
#include <LibCore/DirIterator.h>
#include <LibWeb/CSS/Clip.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/FontCache.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/Node.h>

View File

@ -11,6 +11,7 @@
#include <LibGfx/Palette.h>
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/BrowsingContext.h>
#include <LibWeb/Loader/LoadRequest.h>

View File

@ -502,30 +502,6 @@ struct StyleValueWithDefaultOperators : public StyleValue {
}
};
class AngleStyleValue : public StyleValueWithDefaultOperators<AngleStyleValue> {
public:
static ValueComparingNonnullRefPtr<AngleStyleValue> create(Angle angle)
{
return adopt_ref(*new AngleStyleValue(move(angle)));
}
virtual ~AngleStyleValue() override { }
Angle const& angle() const { return m_angle; }
virtual ErrorOr<String> to_string() const override { return m_angle.to_string(); }
bool properties_equal(AngleStyleValue const& other) const { return m_angle == other.m_angle; }
private:
explicit AngleStyleValue(Angle angle)
: StyleValueWithDefaultOperators(Type::Angle)
, m_angle(move(angle))
{
}
Angle m_angle;
};
class BackgroundStyleValue final : public StyleValueWithDefaultOperators<BackgroundStyleValue> {
public:
static ValueComparingNonnullRefPtr<BackgroundStyleValue> create(

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "AngleStyleValue.h"
namespace Web::CSS {
AngleStyleValue::AngleStyleValue(Angle angle)
: StyleValueWithDefaultOperators(Type::Angle)
, m_angle(move(angle))
{
}
AngleStyleValue::~AngleStyleValue() = default;
ErrorOr<String> AngleStyleValue::to_string() const
{
return m_angle.to_string();
}
bool AngleStyleValue::properties_equal(AngleStyleValue const& other) const
{
return m_angle == other.m_angle;
}
}

View File

@ -0,0 +1,37 @@
/*
* 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/Angle.h>
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
class AngleStyleValue : public StyleValueWithDefaultOperators<AngleStyleValue> {
public:
static ValueComparingNonnullRefPtr<AngleStyleValue> create(Angle angle)
{
return adopt_ref(*new AngleStyleValue(move(angle)));
}
virtual ~AngleStyleValue() override;
Angle const& angle() const { return m_angle; }
virtual ErrorOr<String> to_string() const override;
bool properties_equal(AngleStyleValue const& other) const;
private:
explicit AngleStyleValue(Angle angle);
Angle m_angle;
};
}