1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

LibWeb: Implement the CSS revert keyword

This is a universal value like `initial` and `inherit` and works by
reverting the current value to whatever we had at the start of the
current cascade origin.

The implementation is somewhat inefficient as we make a copy of all
current values at the start of each origin. I'm sure we can come up with
a way to make this faster eventually.
This commit is contained in:
Andreas Kling 2023-07-29 17:14:18 +02:00
parent 13d5d47b56
commit 8f29bdb62c
8 changed files with 257 additions and 187 deletions

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
class RevertStyleValue final : public StyleValueWithDefaultOperators<RevertStyleValue> {
public:
static ErrorOr<ValueComparingNonnullRefPtr<RevertStyleValue>> the()
{
static ValueComparingNonnullRefPtr<RevertStyleValue> instance = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) RevertStyleValue));
return instance;
}
virtual ~RevertStyleValue() override = default;
ErrorOr<String> to_string() const override { return "revert"_string; }
bool properties_equal(RevertStyleValue const&) const { return true; }
private:
RevertStyleValue()
: StyleValueWithDefaultOperators(Type::Revert)
{
}
};
}