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