mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Split FontStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
e24679f870
commit
87f920a299
Notes:
sideshowbarker
2024-07-18 02:13:10 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/87f920a299 Pull-request: https://github.com/SerenityOS/serenity/pull/18040
@ -76,6 +76,7 @@ set(SOURCES
|
||||
CSS/StyleValues/FilterValueListStyleValue.cpp
|
||||
CSS/StyleValues/FlexFlowStyleValue.cpp
|
||||
CSS/StyleValues/FlexStyleValue.cpp
|
||||
CSS/StyleValues/FontStyleValue.cpp
|
||||
CSS/Supports.cpp
|
||||
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||
CSS/Time.cpp
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/FontCache.h>
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Loader/LoadRequest.h>
|
||||
@ -1025,11 +1026,6 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalcNumberSumPartW
|
||||
return value->resolve(layout_node, percentage_basis);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
ErrorOr<String> GridTrackPlacementShorthandStyleValue::to_string() const
|
||||
{
|
||||
if (m_properties.end->grid_track_placement().is_auto())
|
||||
|
@ -661,44 +661,6 @@ private:
|
||||
NonnullOwnPtr<CalcSum> m_expression;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class FrequencyStyleValue : public StyleValueWithDefaultOperators<FrequencyStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<FrequencyStyleValue> create(Frequency frequency)
|
||||
|
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…
Reference in New Issue
Block a user