2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2021-02-21 08:45:26 -03:00
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-06-20 18:25:25 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2021-07-12 13:30:40 -03:00
|
|
|
#include <AK/NonnullRefPtr.h>
|
2024-10-08 08:06:53 -03:00
|
|
|
#include <LibWeb/CSS/CSSGroupingRule.h>
|
2021-03-13 16:11:33 -03:00
|
|
|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
2020-03-07 06:32:51 -03:00
|
|
|
#include <LibWeb/CSS/Selector.h>
|
2019-06-20 18:25:25 -03:00
|
|
|
|
2020-07-26 15:01:35 -03:00
|
|
|
namespace Web::CSS {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2024-10-08 08:06:53 -03:00
|
|
|
class CSSStyleRule final : public CSSGroupingRule {
|
|
|
|
|
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSGroupingRule);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(CSSStyleRule);
|
2020-06-10 11:41:30 -03:00
|
|
|
|
2019-06-20 18:25:25 -03:00
|
|
|
public:
|
2024-11-14 12:01:23 -03:00
|
|
|
[[nodiscard]] static GC::Ref<CSSStyleRule> create(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
2019-06-21 14:19:49 -03:00
|
|
|
|
2022-03-14 16:21:51 -03:00
|
|
|
virtual ~CSSStyleRule() override = default;
|
2019-06-20 18:25:25 -03:00
|
|
|
|
2024-10-17 08:01:13 -03:00
|
|
|
SelectorList const& selectors() const { return m_selectors; }
|
2024-10-17 08:26:37 -03:00
|
|
|
SelectorList const& absolutized_selectors() const;
|
2024-03-19 08:56:52 -03:00
|
|
|
PropertyOwningCSSStyleDeclaration const& declaration() const { return m_declaration; }
|
2019-06-25 01:31:47 -03:00
|
|
|
|
2023-12-01 13:55:52 -03:00
|
|
|
String selector_text() const;
|
2021-09-29 18:43:18 -03:00
|
|
|
void set_selector_text(StringView);
|
|
|
|
|
|
|
|
|
|
CSSStyleDeclaration* style();
|
|
|
|
|
|
2024-09-09 12:35:13 -03:00
|
|
|
[[nodiscard]] FlyString const& qualified_layer_name() const { return parent_layer_internal_qualified_name(); }
|
2024-09-04 13:43:18 -03:00
|
|
|
|
2019-06-20 18:25:25 -03:00
|
|
|
private:
|
2024-10-17 08:01:13 -03:00
|
|
|
CSSStyleRule(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
2022-08-28 08:42:07 -03:00
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-07 11:21:26 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2024-10-17 08:26:37 -03:00
|
|
|
virtual void clear_caches() override;
|
2023-11-20 07:16:39 -03:00
|
|
|
virtual String serialized() const override;
|
2021-10-01 14:57:45 -03:00
|
|
|
|
2024-11-08 14:50:38 -03:00
|
|
|
CSSStyleRule const* parent_style_rule() const;
|
|
|
|
|
|
2024-10-17 08:01:13 -03:00
|
|
|
SelectorList m_selectors;
|
2024-10-17 08:26:37 -03:00
|
|
|
mutable Optional<SelectorList> m_cached_absolutized_selectors;
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<PropertyOwningCSSStyleDeclaration> m_declaration;
|
2019-06-20 18:25:25 -03:00
|
|
|
};
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2021-03-18 17:50:52 -03:00
|
|
|
template<>
|
|
|
|
|
inline bool CSSRule::fast_is<CSSStyleRule>() const { return type() == CSSRule::Type::Style; }
|
|
|
|
|
|
2020-03-07 06:27:02 -03:00
|
|
|
}
|