/* * Copyright (c) 2024, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include namespace Web::CSS { class CascadedProperties final : public JS::Cell { GC_CELL(CascadedProperties, JS::Cell); GC_DECLARE_ALLOCATOR(CascadedProperties); public: virtual ~CascadedProperties() override; [[nodiscard]] RefPtr property(PropertyID) const; [[nodiscard]] PropertyID property_with_higher_priority(PropertyID, PropertyID) const; [[nodiscard]] GC::Ptr property_source(PropertyID) const; [[nodiscard]] GC::Ptr property_source_shadow_root(PropertyID) const; [[nodiscard]] Optional style_property(PropertyID) const; void set_property(PropertyID, NonnullRefPtr, Important, CascadeOrigin, Optional layer_name, GC::Ptr source, GC::Ptr source_shadow_root); void set_property_from_presentational_hint(PropertyID, NonnullRefPtr); void revert_property(PropertyID, Important, CascadeOrigin); void revert_layer_property(PropertyID, Important, Optional layer_name); void resolve_unresolved_properties(DOM::AbstractElement); private: CascadedProperties(); virtual void visit_edges(Visitor&) override; struct Entry { StyleProperty property; size_t cascade_index { 0 }; CascadeOrigin origin; Optional layer_name; GC::Ptr source; GC::Ptr source_shadow_root; }; HashMap> m_properties; size_t m_next_cascade_index { 0 }; AK::FixedBitmap m_contained_properties_cache { false }; }; }