2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2021-03-08 13:40:53 +01:00
|
|
|
* Copyright (c) 2018-2021, 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
|
|
|
|
|
2022-08-07 13:14:54 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-03-08 11:22:18 +01:00
|
|
|
#include <LibWeb/Forward.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
|
|
|
|
2022-08-07 13:14:54 +02:00
|
|
|
class StyleSheet : public Bindings::PlatformObject {
|
|
|
|
JS_OBJECT(StyleSheet, Bindings::PlatformObject);
|
|
|
|
|
2019-06-20 23:25:25 +02:00
|
|
|
public:
|
2022-08-07 13:14:54 +02:00
|
|
|
StyleSheet& impl() { return *this; }
|
2021-03-08 11:22:18 +01:00
|
|
|
|
2021-03-07 16:14:04 +01:00
|
|
|
virtual ~StyleSheet() = default;
|
2019-06-21 19:19:49 +02:00
|
|
|
|
2021-03-08 16:16:28 +01:00
|
|
|
virtual String type() const = 0;
|
|
|
|
|
2021-03-08 13:40:53 +01:00
|
|
|
DOM::Element* owner_node() { return m_owner_node; }
|
|
|
|
void set_owner_node(DOM::Element*);
|
|
|
|
|
2022-03-09 19:56:08 +01:00
|
|
|
String href() const { return m_location; }
|
|
|
|
|
|
|
|
String location() const { return m_location; }
|
|
|
|
void set_location(String location) { m_location = move(location); }
|
|
|
|
|
2021-09-29 23:46:16 +02:00
|
|
|
String title() const { return m_title; }
|
|
|
|
void set_title(String title) { m_title = move(title); }
|
|
|
|
|
|
|
|
void set_type(String type) { m_type_string = move(type); }
|
|
|
|
void set_media(String media) { m_media_string = move(media); }
|
|
|
|
|
|
|
|
bool is_alternate() const { return m_alternate; }
|
|
|
|
void set_alternate(bool alternate) { m_alternate = alternate; }
|
|
|
|
|
|
|
|
void set_origin_clean(bool origin_clean) { m_origin_clean = origin_clean; }
|
|
|
|
|
|
|
|
bool disabled() const { return m_disabled; }
|
|
|
|
void set_disabled(bool disabled) { m_disabled = disabled; }
|
|
|
|
|
|
|
|
CSSStyleSheet* parent_style_sheet() { return m_parent_style_sheet; }
|
2021-12-05 15:33:49 +01:00
|
|
|
void set_parent_css_style_sheet(CSSStyleSheet*);
|
2021-09-29 23:46:16 +02:00
|
|
|
|
2021-03-07 16:14:04 +01:00
|
|
|
protected:
|
2022-08-07 13:14:54 +02:00
|
|
|
explicit StyleSheet(Bindings::WindowObject&);
|
2021-03-08 13:40:53 +01:00
|
|
|
|
|
|
|
private:
|
2022-08-07 13:14:54 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2021-03-08 13:40:53 +01:00
|
|
|
WeakPtr<DOM::Element> m_owner_node;
|
2021-09-29 23:46:16 +02:00
|
|
|
|
2022-08-07 13:14:54 +02:00
|
|
|
CSSStyleSheet* m_parent_style_sheet { nullptr };
|
2021-09-29 23:46:16 +02:00
|
|
|
|
2022-03-09 19:56:08 +01:00
|
|
|
String m_location;
|
2021-09-29 23:46:16 +02:00
|
|
|
String m_title;
|
|
|
|
String m_type_string;
|
|
|
|
String m_media_string;
|
|
|
|
|
|
|
|
bool m_disabled { false };
|
|
|
|
bool m_alternate { false };
|
|
|
|
bool m_origin_clean { true };
|
2019-06-20 23:25:25 +02:00
|
|
|
};
|
2020-03-07 10:27:02 +01:00
|
|
|
|
|
|
|
}
|
2022-08-07 13:14:54 +02:00
|
|
|
|
|
|
|
namespace Web::Bindings {
|
|
|
|
inline JS::Object* wrap(JS::Realm&, Web::CSS::StyleSheet& object) { return &object; }
|
|
|
|
using StyleSheetWrapper = Web::CSS::StyleSheet;
|
|
|
|
}
|