mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +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
|
@ -8,12 +8,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class Selector {
|
||||
class Selector : public RefCounted<Selector> {
|
||||
public:
|
||||
struct SimpleSelector {
|
||||
enum class Type {
|
||||
|
@ -112,7 +113,11 @@ public:
|
|||
CompoundSelector compound_selector;
|
||||
};
|
||||
|
||||
explicit Selector(Vector<ComplexSelector>&&);
|
||||
static NonnullRefPtr<Selector> create(Vector<ComplexSelector>&& complex_selectors)
|
||||
{
|
||||
return adopt_ref(*new Selector(move(complex_selectors)));
|
||||
}
|
||||
|
||||
~Selector();
|
||||
|
||||
Vector<ComplexSelector> const& complex_selectors() const { return m_complex_selectors; }
|
||||
|
@ -120,6 +125,8 @@ public:
|
|||
u32 specificity() const;
|
||||
|
||||
private:
|
||||
explicit Selector(Vector<ComplexSelector>&&);
|
||||
|
||||
Vector<ComplexSelector> m_complex_selectors;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue