/* * Copyright (c) 2021, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::CSS { // https://drafts.csswg.org/cssom/#the-cssrulelist-interface class CSSRuleList : public RefCounted , public Bindings::Wrappable { public: using WrapperType = Bindings::CSSRuleListWrapper; static NonnullRefPtr create(NonnullRefPtrVector&& rules) { return adopt_ref(*new CSSRuleList(move(rules))); } ~CSSRuleList(); RefPtr item(size_t index) const { if (index >= length()) return nullptr; return m_rules[index]; } size_t length() const { return m_rules.size(); } using ConstIterator = AK::SimpleIterator> const, CSSRule const>; using Iterator = AK::SimpleIterator>, CSSRule>; ConstIterator const begin() const { return m_rules.begin(); } Iterator begin() { return m_rules.begin(); } ConstIterator const end() const { return m_rules.end(); } Iterator end() { return m_rules.end(); } bool is_supported_property_index(u32 index) const; DOM::ExceptionOr remove_a_css_rule(u32 index); DOM::ExceptionOr insert_a_css_rule(NonnullRefPtr, u32 index); void for_each_effective_style_rule(Function const& callback) const; bool for_first_not_loaded_import_rule(Function const& callback); void evaluate_media_queries(DOM::Window const&); private: explicit CSSRuleList(NonnullRefPtrVector&&); NonnullRefPtrVector m_rules; }; }