mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 18:28:57 +00:00
LibWeb: Rename ColorStyleValue -> CSSColorValue
This matches the name in the CSS Typed OM spec. https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue This is not (yet) the same as the CSSColorValue, but one step at a time.
This commit is contained in:
parent
8952764267
commit
581d00293c
Notes:
github-actions[bot]
2024-08-21 09:53:16 +00:00
Author: https://github.com/AtkinsSJ
Commit: 581d00293c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1091
17 changed files with 52 additions and 51 deletions
|
@ -1,38 +1,38 @@
|
|||
/*
|
||||
* 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) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ColorStyleValue.h"
|
||||
#include "CSSColorValue.h"
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
||||
ValueComparingNonnullRefPtr<CSSColorValue> CSSColorValue::create(Color color)
|
||||
{
|
||||
if (color.value() == 0) {
|
||||
static auto transparent = adopt_ref(*new (nothrow) ColorStyleValue(color));
|
||||
static auto transparent = adopt_ref(*new (nothrow) CSSColorValue(color));
|
||||
return transparent;
|
||||
}
|
||||
|
||||
if (color == Color::from_rgb(0x000000)) {
|
||||
static auto black = adopt_ref(*new (nothrow) ColorStyleValue(color));
|
||||
static auto black = adopt_ref(*new (nothrow) CSSColorValue(color));
|
||||
return black;
|
||||
}
|
||||
|
||||
if (color == Color::from_rgb(0xffffff)) {
|
||||
static auto white = adopt_ref(*new (nothrow) ColorStyleValue(color));
|
||||
static auto white = adopt_ref(*new (nothrow) CSSColorValue(color));
|
||||
return white;
|
||||
}
|
||||
|
||||
return adopt_ref(*new (nothrow) ColorStyleValue(color));
|
||||
return adopt_ref(*new (nothrow) CSSColorValue(color));
|
||||
}
|
||||
|
||||
String ColorStyleValue::to_string() const
|
||||
String CSSColorValue::to_string() const
|
||||
{
|
||||
return serialize_a_srgb_value(m_color);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* 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) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -14,20 +14,21 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class ColorStyleValue : public StyleValueWithDefaultOperators<ColorStyleValue> {
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csscolorvalue
|
||||
class CSSColorValue : public StyleValueWithDefaultOperators<CSSColorValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<ColorStyleValue> create(Color color);
|
||||
virtual ~ColorStyleValue() override = default;
|
||||
static ValueComparingNonnullRefPtr<CSSColorValue> create(Color color);
|
||||
virtual ~CSSColorValue() override = default;
|
||||
|
||||
Color color() const { return m_color; }
|
||||
virtual String to_string() const override;
|
||||
virtual bool has_color() const override { return true; }
|
||||
virtual Color to_color(Optional<Layout::NodeWithStyle const&>) const override { return m_color; }
|
||||
|
||||
bool properties_equal(ColorStyleValue const& other) const { return m_color == other.m_color; }
|
||||
bool properties_equal(CSSColorValue const& other) const { return m_color == other.m_color; }
|
||||
|
||||
private:
|
||||
explicit ColorStyleValue(Color color)
|
||||
explicit CSSColorValue(Color color)
|
||||
: StyleValueWithDefaultOperators(Type::Color)
|
||||
, m_color(color)
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue