mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 08:17:34 +00:00
LibWeb: Split OverflowStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
7f6add1c6e
commit
f98634586e
7 changed files with 68 additions and 34 deletions
|
@ -89,6 +89,7 @@ set(SOURCES
|
||||||
CSS/StyleValues/LinearGradientStyleValue.cpp
|
CSS/StyleValues/LinearGradientStyleValue.cpp
|
||||||
CSS/StyleValues/ListStyleStyleValue.cpp
|
CSS/StyleValues/ListStyleStyleValue.cpp
|
||||||
CSS/StyleValues/NumericStyleValue.cpp
|
CSS/StyleValues/NumericStyleValue.cpp
|
||||||
|
CSS/StyleValues/OverflowStyleValue.cpp
|
||||||
CSS/StyleValues/RadialGradientStyleValue.cpp
|
CSS/StyleValues/RadialGradientStyleValue.cpp
|
||||||
CSS/Supports.cpp
|
CSS/Supports.cpp
|
||||||
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/OverflowStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/OverflowStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/FontCache.h>
|
#include <LibWeb/FontCache.h>
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/ListStyleStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/OverflowStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
|
@ -1137,11 +1138,6 @@ ErrorOr<void> PositionValue::serialize(StringBuilder& builder) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<String> OverflowStyleValue::to_string() const
|
|
||||||
{
|
|
||||||
return String::formatted("{} {}", TRY(m_properties.overflow_x->to_string()), TRY(m_properties.overflow_y->to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<String> PercentageStyleValue::to_string() const
|
ErrorOr<String> PercentageStyleValue::to_string() const
|
||||||
{
|
{
|
||||||
return m_percentage.to_string();
|
return m_percentage.to_string();
|
||||||
|
|
|
@ -627,35 +627,6 @@ private:
|
||||||
NonnullOwnPtr<CalcSum> m_expression;
|
NonnullOwnPtr<CalcSum> m_expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> {
|
|
||||||
public:
|
|
||||||
static ValueComparingNonnullRefPtr<OverflowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y)));
|
|
||||||
}
|
|
||||||
virtual ~OverflowStyleValue() override = default;
|
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> overflow_x() const { return m_properties.overflow_x; }
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> overflow_y() const { return m_properties.overflow_y; }
|
|
||||||
|
|
||||||
virtual ErrorOr<String> to_string() const override;
|
|
||||||
|
|
||||||
bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
OverflowStyleValue(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
|
|
||||||
: StyleValueWithDefaultOperators(Type::Overflow)
|
|
||||||
, m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Properties {
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> overflow_x;
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> overflow_y;
|
|
||||||
bool operator==(Properties const&) const = default;
|
|
||||||
} m_properties;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> {
|
class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage)
|
static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage)
|
||||||
|
|
|
@ -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 "OverflowStyleValue.h"
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
ErrorOr<String> OverflowStyleValue::to_string() const
|
||||||
|
{
|
||||||
|
return String::formatted("{} {}", TRY(m_properties.overflow_x->to_string()), TRY(m_properties.overflow_y->to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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 OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> {
|
||||||
|
public:
|
||||||
|
static ValueComparingNonnullRefPtr<OverflowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new OverflowStyleValue(move(overflow_x), move(overflow_y)));
|
||||||
|
}
|
||||||
|
virtual ~OverflowStyleValue() override = default;
|
||||||
|
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> overflow_x() const { return m_properties.overflow_x; }
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> overflow_y() const { return m_properties.overflow_y; }
|
||||||
|
|
||||||
|
virtual ErrorOr<String> to_string() const override;
|
||||||
|
|
||||||
|
bool properties_equal(OverflowStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
OverflowStyleValue(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
|
||||||
|
: StyleValueWithDefaultOperators(Type::Overflow)
|
||||||
|
, m_properties { .overflow_x = move(overflow_x), .overflow_y = move(overflow_y) }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Properties {
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> overflow_x;
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> overflow_y;
|
||||||
|
bool operator==(Properties const&) const = default;
|
||||||
|
} m_properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue