ladybird/Libraries/LibWeb/CSS/CascadedProperties.h
Sam Atkins c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00

52 lines
1.6 KiB
C++

/*
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGC/CellAllocator.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/CSS/CascadeOrigin.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/CSS/StyleProperty.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
class CascadedProperties final : public JS::Cell {
GC_CELL(CascadedProperties, JS::Cell);
GC_DECLARE_ALLOCATOR(CascadedProperties);
public:
virtual ~CascadedProperties() override;
[[nodiscard]] RefPtr<StyleValue const> property(PropertyID) const;
[[nodiscard]] GC::Ptr<CSSStyleDeclaration const> property_source(PropertyID) const;
[[nodiscard]] bool is_property_important(PropertyID) const;
void set_property(PropertyID, NonnullRefPtr<StyleValue const>, Important, CascadeOrigin, Optional<FlyString> layer_name, GC::Ptr<CSS::CSSStyleDeclaration const> source);
void set_property_from_presentational_hint(PropertyID, NonnullRefPtr<StyleValue const>);
void revert_property(PropertyID, Important, CascadeOrigin);
void revert_layer_property(PropertyID, Important, Optional<FlyString> layer_name);
void resolve_unresolved_properties(GC::Ref<DOM::Element>, Optional<PseudoElement>);
private:
CascadedProperties();
virtual void visit_edges(Visitor&) override;
struct Entry {
StyleProperty property;
CascadeOrigin origin;
Optional<FlyString> layer_name;
GC::Ptr<CSS::CSSStyleDeclaration const> source;
};
HashMap<PropertyID, Vector<Entry>> m_properties;
};
}