ladybird/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

51 lines
1.4 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/NonnullRefPtrVector.h>
#include <LibWeb/CSS/CSSRule.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/Selector.h>
namespace Web::CSS {
class CSSStyleRule final : public CSSRule {
WEB_PLATFORM_OBJECT(CSSStyleRule, CSSRule);
public:
static CSSStyleRule* create(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
virtual ~CSSStyleRule() override = default;
NonnullRefPtrVector<Selector> const& selectors() const { return m_selectors; }
CSSStyleDeclaration const& declaration() const { return m_declaration; }
virtual Type type() const override { return Type::Style; };
String selector_text() const;
void set_selector_text(StringView);
CSSStyleDeclaration* style();
private:
CSSStyleRule(HTML::Window&, NonnullRefPtrVector<Selector>&&, CSSStyleDeclaration&);
virtual void visit_edges(Cell::Visitor&) override;
virtual String serialized() const override;
NonnullRefPtrVector<Selector> m_selectors;
CSSStyleDeclaration& m_declaration;
};
template<>
inline bool CSSRule::fast_is<CSSStyleRule>() const { return type() == CSSRule::Type::Style; }
}
WRAPPER_HACK(CSSStyleRule, Web::CSS)