mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
Registered custom properties only accept "computationally independent" values for their initial value
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
#include <LibWeb/CSS/URL.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> {
|
|
public:
|
|
static ValueComparingNonnullRefPtr<URLStyleValue const> create(URL const& url, ValueComparingRefPtr<StyleValue const> paint_fallback = {})
|
|
{
|
|
return adopt_ref(*new (nothrow) URLStyleValue(url, move(paint_fallback)));
|
|
}
|
|
|
|
virtual ~URLStyleValue() override = default;
|
|
|
|
URL const& url() const { return m_url; }
|
|
|
|
ValueComparingRefPtr<StyleValue const> const& paint_fallback() const { return m_paint_fallback; }
|
|
|
|
bool properties_equal(URLStyleValue const& other) const { return m_url == other.m_url && m_paint_fallback == other.m_paint_fallback; }
|
|
|
|
virtual bool is_computationally_independent() const override { return !m_paint_fallback || m_paint_fallback->is_computationally_independent(); }
|
|
|
|
virtual void serialize(StringBuilder& builder, SerializationMode mode) const override
|
|
{
|
|
builder.append(m_url.to_string());
|
|
if (m_paint_fallback) {
|
|
builder.append(' ');
|
|
m_paint_fallback->serialize(builder, mode);
|
|
}
|
|
}
|
|
|
|
private:
|
|
URLStyleValue(URL const& url, ValueComparingRefPtr<StyleValue const> paint_fallback = {})
|
|
: StyleValueWithDefaultOperators(Type::URL)
|
|
, m_url(url)
|
|
, m_paint_fallback(move(paint_fallback))
|
|
{
|
|
}
|
|
|
|
URL m_url;
|
|
ValueComparingRefPtr<StyleValue const> m_paint_fallback;
|
|
};
|
|
|
|
}
|