mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +00:00
Both of these are supposed to be set when the CSSRule is created. The spec is silent on setting it when a CSSRule is added to a parent. So, this is a bit ad-hoc. The parent rule gets set whenever a rule is added to a new parent. The parent stylesheet gets set whenever the rule or one of its ancestors is added to a different stylesheet. There may be some nuance there that I'm missing, but I'm sure we'll find out quickly once we have WPT running!
42 lines
995 B
C++
42 lines
995 B
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/CSS/CSSRule.h>
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
// https://www.w3.org/TR/cssom/#dom-cssrule-csstext
|
|
String CSSRule::css_text() const
|
|
{
|
|
// The cssText attribute must return a serialization of the CSS rule.
|
|
return serialized();
|
|
}
|
|
|
|
// https://www.w3.org/TR/cssom/#dom-cssrule-csstext
|
|
void CSSRule::set_css_text(StringView)
|
|
{
|
|
// On setting the cssText attribute must do nothing.
|
|
}
|
|
|
|
void CSSRule::set_parent_rule(CSSRule* parent_rule)
|
|
{
|
|
if (parent_rule)
|
|
m_parent_rule = parent_rule->make_weak_ptr();
|
|
else
|
|
m_parent_rule = nullptr;
|
|
}
|
|
|
|
void CSSRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
|
|
{
|
|
if (parent_style_sheet)
|
|
m_parent_style_sheet = parent_style_sheet->make_weak_ptr();
|
|
else
|
|
m_parent_style_sheet = nullptr;
|
|
}
|
|
|
|
}
|