mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
LibWeb: Split FontStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
e24679f870
commit
87f920a299
7 changed files with 77 additions and 43 deletions
19
Userland/Libraries/LibWeb/CSS/StyleValues/FontStyleValue.cpp
Normal file
19
Userland/Libraries/LibWeb/CSS/StyleValues/FontStyleValue.cpp
Normal file
|
@ -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 "FontStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ErrorOr<String> FontStyleValue::to_string() const
|
||||
{
|
||||
return String::formatted("{} {} {} / {} {}", TRY(m_properties.font_style->to_string()), TRY(m_properties.font_weight->to_string()), TRY(m_properties.font_size->to_string()), TRY(m_properties.line_height->to_string()), TRY(m_properties.font_families->to_string()));
|
||||
}
|
||||
|
||||
}
|
54
Userland/Libraries/LibWeb/CSS/StyleValues/FontStyleValue.h
Normal file
54
Userland/Libraries/LibWeb/CSS/StyleValues/FontStyleValue.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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 FontStyleValue final : public StyleValueWithDefaultOperators<FontStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<FontStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> font_stretch, ValueComparingNonnullRefPtr<StyleValue> font_style, ValueComparingNonnullRefPtr<StyleValue> font_weight, ValueComparingNonnullRefPtr<StyleValue> font_size, ValueComparingNonnullRefPtr<StyleValue> line_height, ValueComparingNonnullRefPtr<StyleValue> font_families)
|
||||
{
|
||||
return adopt_ref(*new FontStyleValue(move(font_stretch), move(font_style), move(font_weight), move(font_size), move(line_height), move(font_families)));
|
||||
}
|
||||
virtual ~FontStyleValue() override = default;
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_stretch() const { return m_properties.font_stretch; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_style() const { return m_properties.font_style; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_weight() const { return m_properties.font_weight; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_size() const { return m_properties.font_size; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> line_height() const { return m_properties.line_height; }
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_families() const { return m_properties.font_families; }
|
||||
|
||||
virtual ErrorOr<String> to_string() const override;
|
||||
|
||||
bool properties_equal(FontStyleValue const& other) const { return m_properties == other.m_properties; };
|
||||
|
||||
private:
|
||||
FontStyleValue(ValueComparingNonnullRefPtr<StyleValue> font_stretch, ValueComparingNonnullRefPtr<StyleValue> font_style, ValueComparingNonnullRefPtr<StyleValue> font_weight, ValueComparingNonnullRefPtr<StyleValue> font_size, ValueComparingNonnullRefPtr<StyleValue> line_height, ValueComparingNonnullRefPtr<StyleValue> font_families)
|
||||
: StyleValueWithDefaultOperators(Type::Font)
|
||||
, m_properties { .font_stretch = move(font_stretch), .font_style = move(font_style), .font_weight = move(font_weight), .font_size = move(font_size), .line_height = move(line_height), .font_families = move(font_families) }
|
||||
{
|
||||
}
|
||||
|
||||
struct Properties {
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_stretch;
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_style;
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_weight;
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_size;
|
||||
ValueComparingNonnullRefPtr<StyleValue> line_height;
|
||||
ValueComparingNonnullRefPtr<StyleValue> font_families;
|
||||
// FIXME: Implement font-variant.
|
||||
bool operator==(Properties const&) const = default;
|
||||
} m_properties;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue