Serenity Operating System
at master 58 lines 1.4 kB view raw
1/* 2 * Copyright (c) 2021, the SerenityOS developers. 3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <AK/DeprecatedString.h> 11#include <LibJS/Heap/GCPtr.h> 12#include <LibWeb/Bindings/PlatformObject.h> 13#include <LibWeb/CSS/CSSStyleDeclaration.h> 14#include <LibWeb/CSS/Selector.h> 15 16namespace Web::CSS { 17 18class CSSRule : public Bindings::PlatformObject { 19 WEB_PLATFORM_OBJECT(CSSRule, Bindings::PlatformObject); 20 21public: 22 virtual ~CSSRule() = default; 23 24 // https://drafts.csswg.org/cssom/#dom-cssrule-type 25 enum class Type : u16 { 26 Style = 1, 27 Import = 3, 28 Media = 4, 29 FontFace = 5, 30 Supports = 12, 31 }; 32 33 virtual Type type() const = 0; 34 35 DeprecatedString css_text() const; 36 void set_css_text(StringView); 37 38 CSSRule* parent_rule() { return m_parent_rule.ptr(); } 39 void set_parent_rule(CSSRule*); 40 41 CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet.ptr(); } 42 virtual void set_parent_style_sheet(CSSStyleSheet*); 43 44 template<typename T> 45 bool fast_is() const = delete; 46 47protected: 48 explicit CSSRule(JS::Realm&); 49 50 virtual DeprecatedString serialized() const = 0; 51 52 virtual void visit_edges(Cell::Visitor&) override; 53 54 JS::GCPtr<CSSRule> m_parent_rule; 55 JS::GCPtr<CSSStyleSheet> m_parent_style_sheet; 56}; 57 58}