mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 17:05:10 +00:00
LibWeb: Split BorderStyleValue out of StyleValue.{h,cpp}
This commit is contained in:
parent
9d5296889f
commit
1c03bc7a6f
8 changed files with 84 additions and 42 deletions
|
@ -68,6 +68,7 @@ set(SOURCES
|
||||||
CSS/StyleValues/BackgroundRepeatStyleValue.cpp
|
CSS/StyleValues/BackgroundRepeatStyleValue.cpp
|
||||||
CSS/StyleValues/BackgroundSizeStyleValue.cpp
|
CSS/StyleValues/BackgroundSizeStyleValue.cpp
|
||||||
CSS/StyleValues/BackgroundStyleValue.cpp
|
CSS/StyleValues/BackgroundStyleValue.cpp
|
||||||
|
CSS/StyleValues/BorderStyleValue.cpp
|
||||||
CSS/Supports.cpp
|
CSS/Supports.cpp
|
||||||
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
CSS/SyntaxHighlighter/SyntaxHighlighter.cpp
|
||||||
CSS/Time.cpp
|
CSS/Time.cpp
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
#include <LibWeb/Infra/Strings.h>
|
#include <LibWeb/Infra/Strings.h>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <LibWeb/CSS/StyleComputer.h>
|
#include <LibWeb/CSS/StyleComputer.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/BorderStyleValue.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>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <LibWeb/CSS/StyleComputer.h>
|
#include <LibWeb/CSS/StyleComputer.h>
|
||||||
#include <LibWeb/CSS/StyleSheet.h>
|
#include <LibWeb/CSS/StyleSheet.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/BorderStyleValue.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>
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/BackgroundStyleValue.h>
|
||||||
|
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
#include <LibWeb/Loader/LoadRequest.h>
|
#include <LibWeb/Loader/LoadRequest.h>
|
||||||
|
@ -294,11 +295,6 @@ StyleValueList const& StyleValue::as_value_list() const
|
||||||
return static_cast<StyleValueList const&>(*this);
|
return static_cast<StyleValueList const&>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<String> BorderStyleValue::to_string() const
|
|
||||||
{
|
|
||||||
return String::formatted("{} {} {}", TRY(m_properties.border_width->to_string()), TRY(m_properties.border_style->to_string()), TRY(m_properties.border_color->to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<String> BorderRadiusStyleValue::to_string() const
|
ErrorOr<String> BorderRadiusStyleValue::to_string() const
|
||||||
{
|
{
|
||||||
if (m_properties.horizontal_radius == m_properties.vertical_radius)
|
if (m_properties.horizontal_radius == m_properties.vertical_radius)
|
||||||
|
|
|
@ -502,43 +502,6 @@ struct StyleValueWithDefaultOperators : public StyleValue {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> {
|
|
||||||
public:
|
|
||||||
static ValueComparingNonnullRefPtr<BorderStyleValue> create(
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_width,
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_style,
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_color)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new BorderStyleValue(move(border_width), move(border_style), move(border_color)));
|
|
||||||
}
|
|
||||||
virtual ~BorderStyleValue() override = default;
|
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_width() const { return m_properties.border_width; }
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_style() const { return m_properties.border_style; }
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_color() const { return m_properties.border_color; }
|
|
||||||
|
|
||||||
virtual ErrorOr<String> to_string() const override;
|
|
||||||
|
|
||||||
bool properties_equal(BorderStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
BorderStyleValue(
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_width,
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_style,
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_color)
|
|
||||||
: StyleValueWithDefaultOperators(Type::Border)
|
|
||||||
, m_properties { .border_width = move(border_width), .border_style = move(border_style), .border_color = move(border_color) }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Properties {
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_width;
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_style;
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> border_color;
|
|
||||||
bool operator==(Properties const&) const = default;
|
|
||||||
} m_properties;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
|
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
|
||||||
public:
|
public:
|
||||||
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
|
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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 "BorderStyleValue.h"
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
BorderStyleValue::BorderStyleValue(
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_width,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_style,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_color)
|
||||||
|
: StyleValueWithDefaultOperators(Type::Border)
|
||||||
|
, m_properties { .border_width = move(border_width), .border_style = move(border_style), .border_color = move(border_color) }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BorderStyleValue::~BorderStyleValue() = default;
|
||||||
|
|
||||||
|
ErrorOr<String> BorderStyleValue::to_string() const
|
||||||
|
{
|
||||||
|
return String::formatted("{} {} {}", TRY(m_properties.border_width->to_string()), TRY(m_properties.border_style->to_string()), TRY(m_properties.border_color->to_string()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
Userland/Libraries/LibWeb/CSS/StyleValues/BorderStyleValue.h
Normal file
49
Userland/Libraries/LibWeb/CSS/StyleValues/BorderStyleValue.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> {
|
||||||
|
public:
|
||||||
|
static ValueComparingNonnullRefPtr<BorderStyleValue> create(
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_width,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_style,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_color)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new BorderStyleValue(move(border_width), move(border_style), move(border_color)));
|
||||||
|
}
|
||||||
|
virtual ~BorderStyleValue() override;
|
||||||
|
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_width() const { return m_properties.border_width; }
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_style() const { return m_properties.border_style; }
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_color() const { return m_properties.border_color; }
|
||||||
|
|
||||||
|
virtual ErrorOr<String> to_string() const override;
|
||||||
|
|
||||||
|
bool properties_equal(BorderStyleValue const& other) const { return m_properties == other.m_properties; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
BorderStyleValue(
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_width,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_style,
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_color);
|
||||||
|
|
||||||
|
struct Properties {
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_width;
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_style;
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue> border_color;
|
||||||
|
bool operator==(Properties const&) const = default;
|
||||||
|
} m_properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue