commit 08fa533840dda2c1a7c9a107b34474bd61603328
parent 49d763425ff58112e112e4d22d398a9962248baf
Author: noriaki watanabe <nabeyang@gmail.com>
Date: Mon, 15 Dec 2025 11:54:26 +0000
Bug 2005964 - Refactor selector builder to use SelectorData alias instead of ThinArc r=emilio,firefox-style-system-reviewers
Replace explicit returns of `ThinArc<SpecificityAndFlags, Component<Impl>>`
with the `SelectorData<Impl>` alias in both builder and parser modules.
Widen the alias visibility to `pub(super)` to allow shared usage without
repeating the concrete pointer type.
This improves consistency and maintainability of selector-related APIs by
centralizing the smart pointer type behind a named alias. There is no
functional change; behavior and existing client code remain unchanged.
Differential Revision: https://phabricator.services.mozilla.com/D276395
Diffstat:
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/servo/components/selectors/builder.rs b/servo/components/selectors/builder.rs
@@ -24,12 +24,12 @@
//! module encapsulates those details and presents an easy-to-use API for the parser.
use crate::parser::{
- Combinator, Component, ParseRelative, RelativeSelector, Selector, SelectorImpl,
+ Combinator, Component, ParseRelative, RelativeSelector, Selector, SelectorData, SelectorImpl,
};
use crate::sink::Push;
use bitflags::bitflags;
use derive_more::{Add, AddAssign};
-use servo_arc::{Arc, ThinArc};
+use servo_arc::Arc;
use smallvec::SmallVec;
use std::cmp;
use std::slice;
@@ -90,10 +90,7 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
/// Consumes the builder, producing a Selector.
#[inline(always)]
- pub fn build(
- &mut self,
- parse_relative: ParseRelative,
- ) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
+ pub fn build(&mut self, parse_relative: ParseRelative) -> SelectorData<Impl> {
// Compute the specificity and flags.
let sf = specificity_and_flags(
self.components.iter(),
@@ -109,7 +106,7 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
&mut self,
mut spec: SpecificityAndFlags,
parse_relative: ParseRelative,
- ) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
+ ) -> SelectorData<Impl> {
let implicit_addition = match parse_relative {
ParseRelative::ForNesting if !spec.flags.intersects(SelectorFlags::HAS_PARENT) => {
Some((Component::ParentSelector, SelectorFlags::HAS_PARENT))
diff --git a/servo/components/selectors/parser.rs b/servo/components/selectors/parser.rs
@@ -793,7 +793,7 @@ pub fn namespace_empty_string<Impl: SelectorImpl>() -> Impl::NamespaceUrl {
Impl::NamespaceUrl::default()
}
-type SelectorData<Impl> = ThinArc<SpecificityAndFlags, Component<Impl>>;
+pub(super) type SelectorData<Impl> = ThinArc<SpecificityAndFlags, Component<Impl>>;
/// Whether a selector may match a featureless host element, and whether it may match other
/// elements.