mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:27:43 +00:00
LibWeb: Split PercentageStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
f98634586e
commit
4b711932cc
11 changed files with 51 additions and 30 deletions
|
@ -155,6 +155,7 @@ ErrorOr<void> generate_implementation_file(JsonObject& properties, Core::File& f
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
#include <LibWeb/CSS/StyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/Infra/Strings.h>
|
#include <LibWeb/Infra/Strings.h>
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#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/OverflowStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.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>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/NumericStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/Layout/Viewport.h>
|
#include <LibWeb/Layout/Viewport.h>
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#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/OverflowStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.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>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridTrackSizeStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/FontCache.h>
|
#include <LibWeb/FontCache.h>
|
||||||
#include <LibWeb/Layout/BlockContainer.h>
|
#include <LibWeb/Layout/BlockContainer.h>
|
||||||
#include <LibWeb/Layout/Node.h>
|
#include <LibWeb/Layout/Node.h>
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#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/OverflowStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.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>
|
||||||
|
@ -1138,11 +1139,6 @@ ErrorOr<void> PositionValue::serialize(StringBuilder& builder) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<String> PercentageStyleValue::to_string() const
|
|
||||||
{
|
|
||||||
return m_percentage.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<String> PositionStyleValue::to_string() const
|
ErrorOr<String> PositionStyleValue::to_string() const
|
||||||
{
|
{
|
||||||
auto to_string = [](PositionEdge edge) {
|
auto to_string = [](PositionEdge edge) {
|
||||||
|
|
|
@ -627,31 +627,6 @@ private:
|
||||||
NonnullOwnPtr<CalcSum> m_expression;
|
NonnullOwnPtr<CalcSum> m_expression;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> {
|
|
||||||
public:
|
|
||||||
static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new PercentageStyleValue(move(percentage)));
|
|
||||||
}
|
|
||||||
virtual ~PercentageStyleValue() override = default;
|
|
||||||
|
|
||||||
Percentage const& percentage() const { return m_percentage; }
|
|
||||||
Percentage& percentage() { return m_percentage; }
|
|
||||||
|
|
||||||
virtual ErrorOr<String> to_string() const override;
|
|
||||||
|
|
||||||
bool properties_equal(PercentageStyleValue const& other) const { return m_percentage == other.m_percentage; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
PercentageStyleValue(Percentage&& percentage)
|
|
||||||
: StyleValueWithDefaultOperators(Type::Percentage)
|
|
||||||
, m_percentage(percentage)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Percentage m_percentage;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
|
class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<PositionStyleValue> create(PositionEdge edge_x, LengthPercentage const& offset_x, PositionEdge edge_y, LengthPercentage const& offset_y)
|
static ValueComparingNonnullRefPtr<PositionStyleValue> create(PositionEdge edge_x, LengthPercentage const& offset_x, PositionEdge edge_y, LengthPercentage const& offset_y)
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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/Percentage.h>
|
||||||
|
#include <LibWeb/CSS/StyleValue.h>
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> {
|
||||||
|
public:
|
||||||
|
static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new PercentageStyleValue(move(percentage)));
|
||||||
|
}
|
||||||
|
virtual ~PercentageStyleValue() override = default;
|
||||||
|
|
||||||
|
Percentage const& percentage() const { return m_percentage; }
|
||||||
|
Percentage& percentage() { return m_percentage; }
|
||||||
|
|
||||||
|
virtual ErrorOr<String> to_string() const override { return m_percentage.to_string(); }
|
||||||
|
|
||||||
|
bool properties_equal(PercentageStyleValue const& other) const { return m_percentage == other.m_percentage; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
PercentageStyleValue(Percentage&& percentage)
|
||||||
|
: StyleValueWithDefaultOperators(Type::Percentage)
|
||||||
|
, m_percentage(percentage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Percentage m_percentage;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
#include <LibTextCodec/Decoder.h>
|
#include <LibTextCodec/Decoder.h>
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/DOM/Comment.h>
|
#include <LibWeb/DOM/Comment.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/DocumentType.h>
|
#include <LibWeb/DOM/DocumentType.h>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <AK/TemporaryChange.h>
|
#include <AK/TemporaryChange.h>
|
||||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/DOM/ParentNode.h>
|
#include <LibWeb/DOM/ParentNode.h>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/StyleComputer.h>
|
#include <LibWeb/CSS/StyleComputer.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue