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