2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2021-03-08 15:40:53 +03:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2021-02-21 14:45:26 +03:00
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-06-21 00:25:25 +03:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-07 14:14:54 +03:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2022-10-23 21:05:34 +03:00
|
|
|
#include <LibWeb/CSS/MediaList.h>
|
2021-03-08 13:22:18 +03:00
|
|
|
#include <LibWeb/Forward.h>
|
2019-06-21 00:25:25 +03:00
|
|
|
|
2020-07-26 21:01:35 +03:00
|
|
|
namespace Web::CSS {
|
2020-03-07 12:27:02 +03:00
|
|
|
|
2022-08-07 14:14:54 +03:00
|
|
|
class StyleSheet : public Bindings::PlatformObject {
|
2022-08-28 14:42:07 +03:00
|
|
|
WEB_PLATFORM_OBJECT(StyleSheet, Bindings::PlatformObject);
|
2022-08-07 14:14:54 +03:00
|
|
|
|
2019-06-21 00:25:25 +03:00
|
|
|
public:
|
2021-03-07 18:14:04 +03:00
|
|
|
virtual ~StyleSheet() = default;
|
2019-06-21 20:19:49 +03:00
|
|
|
|
2023-09-03 05:19:49 +03:00
|
|
|
virtual String type() const = 0;
|
2021-03-08 18:16:28 +03:00
|
|
|
|
2021-03-08 15:40:53 +03:00
|
|
|
DOM::Element* owner_node() { return m_owner_node; }
|
|
|
|
void set_owner_node(DOM::Element*);
|
|
|
|
|
2023-09-03 05:19:49 +03:00
|
|
|
Optional<String> href() const { return m_location; }
|
2022-03-09 21:56:08 +03:00
|
|
|
|
2023-09-03 05:19:49 +03:00
|
|
|
Optional<String> location() const { return m_location; }
|
|
|
|
void set_location(Optional<String> location) { m_location = move(location); }
|
2022-03-09 21:56:08 +03:00
|
|
|
|
2024-04-28 16:32:52 +03:00
|
|
|
String title() const { return m_title; }
|
|
|
|
Optional<String> title_for_bindings() const;
|
|
|
|
void set_title(String title) { m_title = move(title); }
|
2021-09-30 00:46:16 +03:00
|
|
|
|
2023-09-03 05:19:49 +03:00
|
|
|
void set_type(String type) { m_type_string = move(type); }
|
2022-10-23 21:05:34 +03:00
|
|
|
|
|
|
|
MediaList* media() const
|
|
|
|
{
|
2023-02-27 02:09:02 +03:00
|
|
|
return m_media;
|
2022-10-23 21:05:34 +03:00
|
|
|
}
|
|
|
|
|
2023-12-01 19:54:48 +03:00
|
|
|
void set_media(String media)
|
2022-10-23 21:05:34 +03:00
|
|
|
{
|
2023-02-27 02:09:02 +03:00
|
|
|
m_media->set_media_text(media);
|
2022-10-23 21:05:34 +03:00
|
|
|
}
|
2021-09-30 00:46:16 +03:00
|
|
|
|
|
|
|
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 17:33:49 +03:00
|
|
|
void set_parent_css_style_sheet(CSSStyleSheet*);
|
2021-09-30 00:46:16 +03:00
|
|
|
|
2021-03-07 18:14:04 +03:00
|
|
|
protected:
|
2022-10-23 21:05:34 +03:00
|
|
|
explicit StyleSheet(JS::Realm&, MediaList& media);
|
2022-08-07 14:14:54 +03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2023-02-27 02:09:02 +03:00
|
|
|
JS::NonnullGCPtr<MediaList> m_media;
|
2022-10-23 21:05:34 +03:00
|
|
|
|
2022-08-07 14:29:49 +03:00
|
|
|
private:
|
2022-09-03 16:44:44 +03:00
|
|
|
JS::GCPtr<DOM::Element> m_owner_node;
|
|
|
|
JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
|
2021-09-30 00:46:16 +03:00
|
|
|
|
2023-09-03 05:19:49 +03:00
|
|
|
Optional<String> m_location;
|
2024-04-28 16:32:52 +03:00
|
|
|
String m_title;
|
2023-09-03 05:19:49 +03:00
|
|
|
String m_type_string;
|
2021-09-30 00:46:16 +03:00
|
|
|
|
|
|
|
bool m_disabled { false };
|
|
|
|
bool m_alternate { false };
|
|
|
|
bool m_origin_clean { true };
|
2019-06-21 00:25:25 +03:00
|
|
|
};
|
2020-03-07 12:27:02 +03:00
|
|
|
|
|
|
|
}
|