mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
LibWeb: Make CSS::Selector reference counted
The end goal is to make the PseudoClass::not_selector be a Selector instead of a String that is repeatedly re-parsed. But since Selector contains a Vector of ComplexSelectors, which each have a Vector of SimpleSelectors, it's probably a good idea to not be passing them around by value anyway. :^)
This commit is contained in:
parent
8cae79cc8d
commit
776b1f4548
9 changed files with 48 additions and 38 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
|
@ -19,23 +20,23 @@ class CSSStyleRule : public CSSRule {
|
|||
AK_MAKE_NONMOVABLE(CSSStyleRule);
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<CSSStyleRule> create(Vector<Selector>&& selectors, NonnullRefPtr<CSSStyleDeclaration>&& declaration)
|
||||
static NonnullRefPtr<CSSStyleRule> create(NonnullRefPtrVector<Selector>&& selectors, NonnullRefPtr<CSSStyleDeclaration>&& declaration)
|
||||
{
|
||||
return adopt_ref(*new CSSStyleRule(move(selectors), move(declaration)));
|
||||
}
|
||||
|
||||
~CSSStyleRule();
|
||||
|
||||
const Vector<Selector>& selectors() const { return m_selectors; }
|
||||
const NonnullRefPtrVector<Selector>& selectors() const { return m_selectors; }
|
||||
const CSSStyleDeclaration& declaration() const { return m_declaration; }
|
||||
|
||||
virtual StringView class_name() const { return "CSSStyleRule"; };
|
||||
virtual Type type() const { return Type::Style; };
|
||||
|
||||
private:
|
||||
CSSStyleRule(Vector<Selector>&&, NonnullRefPtr<CSSStyleDeclaration>&&);
|
||||
CSSStyleRule(NonnullRefPtrVector<Selector>&&, NonnullRefPtr<CSSStyleDeclaration>&&);
|
||||
|
||||
Vector<Selector> m_selectors;
|
||||
NonnullRefPtrVector<Selector> m_selectors;
|
||||
NonnullRefPtr<CSSStyleDeclaration> m_declaration;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue