mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb/CSS: Implement guaranteed-invalid value
This is a special value produced when var/attr substitution fails, and is also the initial value for custom properties.
This commit is contained in:
parent
804c1eeeed
commit
d1dadd43a1
Notes:
github-actions[bot]
2025-05-14 10:48:18 +00:00
Author: https://github.com/AtkinsSJ
Commit: d1dadd43a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4209
Reviewed-by: https://github.com/awesomekling
4 changed files with 46 additions and 0 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GuaranteedInvalidStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
|
@ -240,6 +241,12 @@ GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() cons
|
|||
return static_cast<GridTrackSizeListStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
GuaranteedInvalidStyleValue const& CSSStyleValue::as_guaranteed_invalid() const
|
||||
{
|
||||
VERIFY(is_guaranteed_invalid());
|
||||
return static_cast<GuaranteedInvalidStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
CSSKeywordValue const& CSSStyleValue::as_keyword() const
|
||||
{
|
||||
VERIFY(is_keyword());
|
||||
|
|
|
@ -113,6 +113,7 @@ public:
|
|||
GridTemplateArea,
|
||||
GridTrackPlacement,
|
||||
GridTrackSizeList,
|
||||
GuaranteedInvalid,
|
||||
Image,
|
||||
Integer,
|
||||
Keyword,
|
||||
|
@ -258,6 +259,10 @@ public:
|
|||
GridTrackSizeListStyleValue const& as_grid_track_size_list() const;
|
||||
GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_size_list()); }
|
||||
|
||||
bool is_guaranteed_invalid() const { return type() == Type::GuaranteedInvalid; }
|
||||
GuaranteedInvalidStyleValue const& as_guaranteed_invalid() const;
|
||||
GuaranteedInvalidStyleValue& as_guaranteed_invalid() { return const_cast<GuaranteedInvalidStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_guaranteed_invalid()); }
|
||||
|
||||
bool is_image() const { return type() == Type::Image; }
|
||||
ImageStyleValue const& as_image() const;
|
||||
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_image()); }
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
// https://drafts.csswg.org/css-variables/#guaranteed-invalid-value
|
||||
class GuaranteedInvalidStyleValue final : public StyleValueWithDefaultOperators<GuaranteedInvalidStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<GuaranteedInvalidStyleValue> create()
|
||||
{
|
||||
static ValueComparingNonnullRefPtr<GuaranteedInvalidStyleValue> instance = adopt_ref(*new (nothrow) GuaranteedInvalidStyleValue());
|
||||
return instance;
|
||||
}
|
||||
virtual ~GuaranteedInvalidStyleValue() override = default;
|
||||
virtual String to_string(SerializationMode) const override { return {}; }
|
||||
|
||||
bool properties_equal(GuaranteedInvalidStyleValue const&) const { return true; }
|
||||
|
||||
private:
|
||||
GuaranteedInvalidStyleValue()
|
||||
: StyleValueWithDefaultOperators(Type::GuaranteedInvalid)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -245,6 +245,7 @@ class GridTrackPlacement;
|
|||
class GridTrackPlacementStyleValue;
|
||||
class GridTrackSizeList;
|
||||
class GridTrackSizeListStyleValue;
|
||||
class GuaranteedInvalidStyleValue;
|
||||
class ImageStyleValue;
|
||||
class IntegerOrCalculated;
|
||||
class IntegerStyleValue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue