Serenity Operating System
at master 77 lines 2.1 kB view raw
1/* 2 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2021, the SerenityOS developers. 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <LibWeb/Bindings/PlatformObject.h> 11#include <LibWeb/CSS/MediaList.h> 12#include <LibWeb/Forward.h> 13 14namespace Web::CSS { 15 16class StyleSheet : public Bindings::PlatformObject { 17 WEB_PLATFORM_OBJECT(StyleSheet, Bindings::PlatformObject); 18 19public: 20 virtual ~StyleSheet() = default; 21 22 virtual DeprecatedString type() const = 0; 23 24 DOM::Element* owner_node() { return m_owner_node; } 25 void set_owner_node(DOM::Element*); 26 27 DeprecatedString href() const { return m_location; } 28 29 DeprecatedString location() const { return m_location; } 30 void set_location(DeprecatedString location) { m_location = move(location); } 31 32 DeprecatedString title() const { return m_title; } 33 void set_title(DeprecatedString title) { m_title = move(title); } 34 35 void set_type(DeprecatedString type) { m_type_string = move(type); } 36 37 MediaList* media() const 38 { 39 return &m_media; 40 } 41 42 void set_media(DeprecatedString media) 43 { 44 m_media.set_media_text(media); 45 } 46 47 bool is_alternate() const { return m_alternate; } 48 void set_alternate(bool alternate) { m_alternate = alternate; } 49 50 void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; } 51 52 bool disabled() const { return m_disabled; } 53 void set_disabled(bool disabled) { m_disabled = disabled; } 54 55 CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; } 56 void set_parent_css_style_sheet(CSSStyleSheet*); 57 58protected: 59 explicit StyleSheet(JS::Realm&, MediaList& media); 60 virtual void visit_edges(Cell::Visitor&) override; 61 62 MediaList& m_media; 63 64private: 65 JS::GCPtr<DOM::Element> m_owner_node; 66 JS::GCPtr<CSSStyleSheet> m_parent_style_sheet; 67 68 DeprecatedString m_location; 69 DeprecatedString m_title; 70 DeprecatedString m_type_string; 71 72 bool m_disabled { false }; 73 bool m_alternate { false }; 74 bool m_origin_clean { true }; 75}; 76 77}