2021-02-21 13:45:26 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-21 13:45:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/RefCounted.h>
|
|
|
|
#include <AK/String.h>
|
2021-12-05 15:30:40 +01:00
|
|
|
#include <AK/Weakable.h>
|
2021-09-29 19:41:46 +02:00
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
2021-03-13 20:11:33 +01:00
|
|
|
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
2021-02-21 13:45:26 +02:00
|
|
|
#include <LibWeb/CSS/Selector.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2021-09-29 19:41:46 +02:00
|
|
|
class CSSRule
|
|
|
|
: public RefCounted<CSSRule>
|
2021-12-05 15:30:40 +01:00
|
|
|
, public Bindings::Wrappable
|
|
|
|
, public Weakable<CSSRule> {
|
2021-02-21 13:45:26 +02:00
|
|
|
public:
|
2021-09-29 19:41:46 +02:00
|
|
|
using WrapperType = Bindings::CSSRuleWrapper;
|
|
|
|
|
2022-03-14 13:21:51 -06:00
|
|
|
virtual ~CSSRule() = default;
|
2021-02-21 13:45:26 +02:00
|
|
|
|
2022-04-11 21:04:47 +02:00
|
|
|
// https://drafts.csswg.org/cssom/#dom-cssrule-type
|
|
|
|
enum class Type : u16 {
|
|
|
|
Style = 1,
|
|
|
|
Import = 3,
|
|
|
|
Media = 4,
|
|
|
|
FontFace = 5,
|
|
|
|
Supports = 12,
|
2021-02-21 13:45:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual StringView class_name() const = 0;
|
|
|
|
virtual Type type() const = 0;
|
|
|
|
|
2021-10-01 19:57:45 +02:00
|
|
|
String css_text() const;
|
|
|
|
void set_css_text(StringView);
|
|
|
|
|
2022-04-22 19:56:22 +01:00
|
|
|
CSSRule* parent_rule() { return m_parent_rule; }
|
|
|
|
void set_parent_rule(CSSRule*);
|
|
|
|
|
|
|
|
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
|
|
|
|
virtual void set_parent_style_sheet(CSSStyleSheet*);
|
|
|
|
|
2021-03-18 21:50:52 +01:00
|
|
|
template<typename T>
|
|
|
|
bool fast_is() const = delete;
|
|
|
|
|
2021-10-01 19:57:45 +02:00
|
|
|
protected:
|
|
|
|
virtual String serialized() const = 0;
|
2022-04-22 19:56:22 +01:00
|
|
|
|
|
|
|
WeakPtr<CSSRule> m_parent_rule;
|
|
|
|
WeakPtr<CSSStyleSheet> m_parent_style_sheet;
|
2021-02-21 13:45:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|