/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::CSS { struct MatchingRule { RefPtr rule; size_t style_sheet_index { 0 }; size_t rule_index { 0 }; size_t selector_index { 0 }; u32 specificity { 0 }; }; class StyleResolver { public: explicit StyleResolver(DOM::Document&); ~StyleResolver(); DOM::Document& document() { return m_document; } const DOM::Document& document() const { return m_document; } NonnullRefPtr resolve_style(DOM::Element&) const; Vector collect_matching_rules(const DOM::Element&) const; void sort_matching_rules(Vector&) const; struct CustomPropertyResolutionTuple { Optional style {}; u32 specificity { 0 }; }; CustomPropertyResolutionTuple resolve_custom_property_with_specificity(DOM::Element&, const String&) const; Optional resolve_custom_property(DOM::Element&, const String&) const; static bool is_inherited_property(CSS::PropertyID); private: template void for_each_stylesheet(Callback) const; DOM::Document& m_document; }; }