mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibWeb/CSS: Use SelectorList type instead of Vector<NNRP<Selector>>
This commit is contained in:
parent
d935a00413
commit
74c448d744
Notes:
github-actions[bot]
2024-10-17 18:57:20 +00:00
Author: https://github.com/AtkinsSJ
Commit: 74c448d744
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1842
Reviewed-by: https://github.com/awesomekling
5 changed files with 9 additions and 9 deletions
|
@ -16,12 +16,12 @@ namespace Web::CSS {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, Vector<NonnullRefPtr<Web::CSS::Selector>>&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
JS::NonnullGCPtr<CSSStyleRule> CSSStyleRule::create(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
{
|
||||
return realm.heap().allocate<CSSStyleRule>(realm, realm, move(selectors), declaration, nested_rules);
|
||||
}
|
||||
|
||||
CSSStyleRule::CSSStyleRule(JS::Realm& realm, Vector<NonnullRefPtr<Selector>>&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
CSSStyleRule::CSSStyleRule(JS::Realm& realm, SelectorList&& selectors, PropertyOwningCSSStyleDeclaration& declaration, CSSRuleList& nested_rules)
|
||||
: CSSGroupingRule(realm, nested_rules)
|
||||
, m_selectors(move(selectors))
|
||||
, m_declaration(declaration)
|
||||
|
|
|
@ -19,11 +19,11 @@ class CSSStyleRule final : public CSSGroupingRule {
|
|||
JS_DECLARE_ALLOCATOR(CSSStyleRule);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleRule> create(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
|
||||
virtual ~CSSStyleRule() override = default;
|
||||
|
||||
Vector<NonnullRefPtr<Selector>> const& selectors() const { return m_selectors; }
|
||||
SelectorList const& selectors() const { return m_selectors; }
|
||||
PropertyOwningCSSStyleDeclaration const& declaration() const { return m_declaration; }
|
||||
|
||||
virtual Type type() const override { return Type::Style; }
|
||||
|
@ -36,13 +36,13 @@ public:
|
|||
[[nodiscard]] FlyString const& qualified_layer_name() const { return parent_layer_internal_qualified_name(); }
|
||||
|
||||
private:
|
||||
CSSStyleRule(JS::Realm&, Vector<NonnullRefPtr<Selector>>&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
CSSStyleRule(JS::Realm&, SelectorList&&, PropertyOwningCSSStyleDeclaration&, CSSRuleList&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
|
||||
Vector<NonnullRefPtr<Selector>> m_selectors;
|
||||
SelectorList m_selectors;
|
||||
JS::NonnullGCPtr<PropertyOwningCSSStyleDeclaration> m_declaration;
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ Parser::ParseErrorOr<SelectorList> Parser::parse_a_selector_list(TokenStream<T>&
|
|||
{
|
||||
auto comma_separated_lists = parse_a_comma_separated_list_of_component_values(tokens);
|
||||
|
||||
Vector<NonnullRefPtr<Selector>> selectors;
|
||||
SelectorList selectors;
|
||||
for (auto& selector_parts : comma_separated_lists) {
|
||||
auto stream = TokenStream(selector_parts);
|
||||
auto selector = parse_complex_selector(stream, mode);
|
||||
|
|
|
@ -407,7 +407,7 @@ String Selector::serialize() const
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom/#serialize-a-group-of-selectors
|
||||
String serialize_a_group_of_selectors(Vector<NonnullRefPtr<Selector>> const& selectors)
|
||||
String serialize_a_group_of_selectors(SelectorList const& selectors)
|
||||
{
|
||||
// To serialize a group of selectors serialize each selector in the group of selectors and then serialize a comma-separated list of these serializations.
|
||||
return MUST(String::join(", "sv, selectors));
|
||||
|
|
|
@ -257,7 +257,7 @@ private:
|
|||
Array<u32, 8> m_ancestor_hashes;
|
||||
};
|
||||
|
||||
String serialize_a_group_of_selectors(Vector<NonnullRefPtr<Selector>> const& selectors);
|
||||
String serialize_a_group_of_selectors(SelectorList const& selectors);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue