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
|
|
|
*/
|
|
|
|
|
|
2024-04-26 21:09:58 -03:00
|
|
|
#include <LibWeb/Bindings/StyleSheetPrototype.h>
|
2021-12-05 11:33:49 -03:00
|
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
2020-03-07 06:32:51 -03:00
|
|
|
#include <LibWeb/CSS/StyleSheet.h>
|
2021-03-08 09:40:53 -03:00
|
|
|
#include <LibWeb/DOM/Element.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
|
|
|
|
2022-10-23 15:05:34 -03:00
|
|
|
StyleSheet::StyleSheet(JS::Realm& realm, MediaList& media)
|
2022-09-24 19:34:04 -03:00
|
|
|
: PlatformObject(realm)
|
2022-10-23 15:05:34 -03:00
|
|
|
, m_media(media)
|
2022-08-07 08:14:54 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StyleSheet::visit_edges(Cell::Visitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
Base::visit_edges(visitor);
|
2022-09-03 10:44:44 -03:00
|
|
|
visitor.visit(m_owner_node);
|
2022-08-07 08:14:54 -03:00
|
|
|
visitor.visit(m_parent_style_sheet);
|
2022-10-23 15:05:34 -03:00
|
|
|
visitor.visit(m_media);
|
2022-08-07 08:14:54 -03:00
|
|
|
}
|
|
|
|
|
|
2021-03-08 09:40:53 -03:00
|
|
|
void StyleSheet::set_owner_node(DOM::Element* element)
|
|
|
|
|
{
|
2022-09-03 10:44:44 -03:00
|
|
|
m_owner_node = element;
|
2021-03-08 09:40:53 -03:00
|
|
|
}
|
|
|
|
|
|
2021-12-05 11:33:49 -03:00
|
|
|
void StyleSheet::set_parent_css_style_sheet(CSSStyleSheet* parent)
|
|
|
|
|
{
|
|
|
|
|
m_parent_style_sheet = parent;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-28 10:32:52 -03:00
|
|
|
// https://drafts.csswg.org/cssom/#dom-stylesheet-title
|
|
|
|
|
Optional<String> StyleSheet::title_for_bindings() const
|
|
|
|
|
{
|
|
|
|
|
// The title attribute must return the title or null if title is the empty string.
|
|
|
|
|
if (m_title.is_empty())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
return m_title;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-07 06:27:02 -03:00
|
|
|
}
|