mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb: Implement CSSNestedDeclarations type
This is basically a list of properties, without a block around it. It'll be part of CSSStyleRules' contents.
This commit is contained in:
parent
5b4d1b5b05
commit
9c66ab356a
Notes:
github-actions[bot]
2024-10-17 18:57:40 +00:00
Author: https://github.com/AtkinsSJ
Commit: 9c66ab356a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1842
Reviewed-by: https://github.com/awesomekling
13 changed files with 155 additions and 26 deletions
53
Userland/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp
Normal file
53
Userland/Libraries/LibWeb/CSS/CSSNestedDeclarations.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "CSSNestedDeclarations.h"
|
||||
#include <LibWeb/Bindings/CSSNestedDeclarationsPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(CSSNestedDeclarations);
|
||||
|
||||
JS::NonnullGCPtr<CSSNestedDeclarations> CSSNestedDeclarations::create(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)
|
||||
{
|
||||
return realm.heap().allocate<CSSNestedDeclarations>(realm, realm, declaration);
|
||||
}
|
||||
|
||||
CSSNestedDeclarations::CSSNestedDeclarations(JS::Realm& realm, PropertyOwningCSSStyleDeclaration& declaration)
|
||||
: CSSRule(realm)
|
||||
, m_declaration(declaration)
|
||||
{
|
||||
m_declaration->set_parent_rule(*this);
|
||||
}
|
||||
|
||||
void CSSNestedDeclarations::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSNestedDeclarations);
|
||||
}
|
||||
|
||||
void CSSNestedDeclarations::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_declaration);
|
||||
}
|
||||
|
||||
CSSStyleDeclaration* CSSNestedDeclarations::style()
|
||||
{
|
||||
return m_declaration;
|
||||
}
|
||||
|
||||
String CSSNestedDeclarations::serialized() const
|
||||
{
|
||||
// NOTE: There's no proper spec for this yet, only this note:
|
||||
// "The CSSNestedDeclarations rule serializes as if its declaration block had been serialized directly."
|
||||
// - https://drafts.csswg.org/css-nesting-1/#ref-for-cssnesteddeclarations%E2%91%A1
|
||||
// So, we'll do the simple thing and hope it's good.
|
||||
return m_declaration->serialized();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue