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 19:44:17 +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
|
|
|
*/
|
|
|
|
|
2024-04-27 03:09:58 +03:00
|
|
|
#include <LibWeb/Bindings/HTMLStyleElementPrototype.h>
|
2020-07-28 20:20:11 +03:00
|
|
|
#include <LibWeb/HTML/HTMLStyleElement.h>
|
2019-09-29 18:43:30 +03:00
|
|
|
|
2020-07-28 19:20:36 +03:00
|
|
|
namespace Web::HTML {
|
2020-03-07 12:27:02 +03:00
|
|
|
|
2023-11-19 21:47:52 +03:00
|
|
|
JS_DEFINE_ALLOCATOR(HTMLStyleElement);
|
|
|
|
|
2022-02-18 23:00:52 +03:00
|
|
|
HTMLStyleElement::HTMLStyleElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
2021-02-07 13:20:15 +03:00
|
|
|
: HTMLElement(document, move(qualified_name))
|
2019-09-29 18:43:30 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-14 22:21:51 +03:00
|
|
|
HTMLStyleElement::~HTMLStyleElement() = default;
|
2019-09-29 18:43:30 +03:00
|
|
|
|
2023-08-07 09:41:28 +03:00
|
|
|
void HTMLStyleElement::initialize(JS::Realm& realm)
|
2023-01-10 14:28:20 +03:00
|
|
|
{
|
2023-08-07 09:41:28 +03:00
|
|
|
Base::initialize(realm);
|
2024-03-16 15:13:08 +03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLStyleElement);
|
2023-01-10 14:28:20 +03:00
|
|
|
}
|
|
|
|
|
2022-08-28 14:42:07 +03:00
|
|
|
void HTMLStyleElement::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2023-06-08 18:07:12 +03:00
|
|
|
visitor.visit(m_style_element_utils.sheet());
|
2022-08-28 14:42:07 +03:00
|
|
|
}
|
|
|
|
|
2020-04-04 00:06:09 +03:00
|
|
|
void HTMLStyleElement::children_changed()
|
2019-09-29 18:43:30 +03:00
|
|
|
{
|
2023-06-08 18:07:12 +03:00
|
|
|
m_style_element_utils.update_a_style_block(*this);
|
|
|
|
Base::children_changed();
|
2019-09-29 18:43:30 +03:00
|
|
|
}
|
|
|
|
|
2022-02-26 00:05:42 +03:00
|
|
|
void HTMLStyleElement::inserted()
|
|
|
|
{
|
2023-06-08 18:07:12 +03:00
|
|
|
m_style_element_utils.update_a_style_block(*this);
|
|
|
|
Base::inserted();
|
2022-02-26 00:05:42 +03:00
|
|
|
}
|
|
|
|
|
2021-04-06 19:58:20 +03:00
|
|
|
void HTMLStyleElement::removed_from(Node* old_parent)
|
2019-09-29 18:43:30 +03:00
|
|
|
{
|
2023-06-08 18:07:12 +03:00
|
|
|
m_style_element_utils.update_a_style_block(*this);
|
|
|
|
Base::removed_from(old_parent);
|
2022-08-07 14:14:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
|
|
|
|
CSS::CSSStyleSheet* HTMLStyleElement::sheet()
|
|
|
|
{
|
|
|
|
// The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
|
2023-06-08 18:07:12 +03:00
|
|
|
return m_style_element_utils.sheet();
|
2021-09-30 00:46:16 +03:00
|
|
|
}
|
|
|
|
|
2021-10-15 21:38:39 +03:00
|
|
|
// https://www.w3.org/TR/cssom/#dom-linkstyle-sheet
|
2022-08-07 14:14:54 +03:00
|
|
|
CSS::CSSStyleSheet const* HTMLStyleElement::sheet() const
|
2021-10-01 02:13:56 +03:00
|
|
|
{
|
|
|
|
// The sheet attribute must return the associated CSS style sheet for the node or null if there is no associated CSS style sheet.
|
2023-06-08 18:07:12 +03:00
|
|
|
return m_style_element_utils.sheet();
|
2021-10-01 02:13:56 +03:00
|
|
|
}
|
|
|
|
|
2020-03-07 12:27:02 +03:00
|
|
|
}
|