mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Collapse Selector, SelectorInner, and ComplexSelector into a single Selector.
The refcounting is still internal. We'll fix that up next. MozReview-Commit-ID: CTxZNaR3Qgj
This commit is contained in:
parent
713c9a63f6
commit
5ddabef636
7 changed files with 71 additions and 147 deletions
|
@ -8,7 +8,7 @@ use cssparser::{Parser, ToCss};
|
|||
use element_state::ElementState;
|
||||
use gecko_bindings::structs::CSSPseudoClassType;
|
||||
use selector_parser::{SelectorParser, PseudoElementCascadeType};
|
||||
use selectors::parser::{ComplexSelector, SelectorMethods};
|
||||
use selectors::parser::{Selector, SelectorMethods};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt;
|
||||
|
@ -47,7 +47,7 @@ macro_rules! pseudo_class_name {
|
|||
///
|
||||
/// TODO(emilio): We disallow combinators and pseudos here, so we
|
||||
/// should use SimpleSelector instead
|
||||
MozAny(Box<[ComplexSelector<SelectorImpl>]>),
|
||||
MozAny(Box<[Selector<SelectorImpl>]>),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> {
|
|||
}, )*
|
||||
"-moz-any" => {
|
||||
let selectors = parser.parse_comma_separated(|input| {
|
||||
ComplexSelector::parse(self, input)
|
||||
Selector::parse(self, input)
|
||||
})?;
|
||||
// Selectors inside `:-moz-any` may not include combinators.
|
||||
if selectors.iter().flat_map(|x| x.iter_raw()).any(|s| s.is_combinator()) {
|
||||
|
|
|
@ -218,7 +218,7 @@ impl StylesheetInvalidationSet {
|
|||
let mut scope: Option<InvalidationScope> = None;
|
||||
|
||||
let mut scan = true;
|
||||
let mut iter = selector.inner.complex.iter();
|
||||
let mut iter = selector.iter();
|
||||
|
||||
loop {
|
||||
for component in &mut iter {
|
||||
|
|
|
@ -23,7 +23,7 @@ use selectors::attr::{AttrSelectorOperation, NamespaceConstraint};
|
|||
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode};
|
||||
use selectors::matching::{RelevantLinkStatus, VisitedHandlingMode, matches_selector};
|
||||
use selectors::parser::{AncestorHashes, Combinator, Component};
|
||||
use selectors::parser::{Selector, SelectorAndHashes, SelectorInner, SelectorMethods};
|
||||
use selectors::parser::{Selector, SelectorAndHashes, SelectorMethods};
|
||||
use selectors::visitor::SelectorVisitor;
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::Cell;
|
||||
|
@ -949,7 +949,7 @@ impl DependencySet {
|
|||
/// Adds a selector to this `DependencySet`.
|
||||
pub fn note_selector(&mut self, selector_and_hashes: &SelectorAndHashes<SelectorImpl>) {
|
||||
let mut combinator = None;
|
||||
let mut iter = selector_and_hashes.selector.inner.complex.iter();
|
||||
let mut iter = selector_and_hashes.selector.iter();
|
||||
let mut index = 0;
|
||||
let mut child_combinators_seen = 0;
|
||||
let mut saw_descendant_combinator = false;
|
||||
|
@ -1001,14 +1001,9 @@ impl DependencySet {
|
|||
|
||||
let (dep_selector, hashes) = if sequence_start == 0 {
|
||||
// Reuse the bloom hashes if this is the base selector.
|
||||
(selector_and_hashes.selector.clone(),
|
||||
selector_and_hashes.hashes.clone())
|
||||
|
||||
(selector_and_hashes.selector.clone(), selector_and_hashes.hashes.clone())
|
||||
} else {
|
||||
let inner = SelectorInner::new(selector_and_hashes.selector
|
||||
.inner
|
||||
.complex.slice_from(sequence_start));
|
||||
let selector = Selector { inner: inner };
|
||||
let selector = selector_and_hashes.selector.slice_from(sequence_start);
|
||||
let hashes = AncestorHashes::new(&selector);
|
||||
(selector, hashes)
|
||||
};
|
||||
|
@ -1145,7 +1140,7 @@ impl DependencySet {
|
|||
MatchingContext::new_for_visited(MatchingMode::Normal, None,
|
||||
VisitedHandlingMode::AllLinksUnvisited);
|
||||
let matched_then =
|
||||
matches_selector(&dep.selector.inner,
|
||||
matches_selector(&dep.selector,
|
||||
&dep.hashes,
|
||||
&snapshot_el,
|
||||
&mut then_context,
|
||||
|
@ -1154,7 +1149,7 @@ impl DependencySet {
|
|||
MatchingContext::new_for_visited(MatchingMode::Normal, bloom_filter,
|
||||
VisitedHandlingMode::AllLinksUnvisited);
|
||||
let matches_now =
|
||||
matches_selector(&dep.selector.inner,
|
||||
matches_selector(&dep.selector,
|
||||
&dep.hashes,
|
||||
el,
|
||||
&mut now_context,
|
||||
|
@ -1181,14 +1176,14 @@ impl DependencySet {
|
|||
dep.sensitivities.states.intersects(IN_VISITED_OR_UNVISITED_STATE) {
|
||||
then_context.visited_handling = VisitedHandlingMode::RelevantLinkVisited;
|
||||
let matched_then =
|
||||
matches_selector(&dep.selector.inner,
|
||||
matches_selector(&dep.selector,
|
||||
&dep.hashes,
|
||||
&snapshot_el,
|
||||
&mut then_context,
|
||||
&mut |_, _| {});
|
||||
now_context.visited_handling = VisitedHandlingMode::RelevantLinkVisited;
|
||||
let matches_now =
|
||||
matches_selector(&dep.selector.inner,
|
||||
matches_selector(&dep.selector,
|
||||
&dep.hashes,
|
||||
el,
|
||||
&mut now_context,
|
||||
|
|
|
@ -231,7 +231,7 @@ impl SelectorMap<Rule> {
|
|||
F: FnMut(&E, ElementSelectorFlags),
|
||||
{
|
||||
for rule in rules {
|
||||
if matches_selector(&rule.selector.inner,
|
||||
if matches_selector(&rule.selector,
|
||||
&rule.hashes,
|
||||
element,
|
||||
context,
|
||||
|
@ -403,7 +403,7 @@ fn find_from_right<F, R>(selector: &Selector<SelectorImpl>,
|
|||
-> Option<R>
|
||||
where F: FnMut(&Component<SelectorImpl>) -> Option<R>,
|
||||
{
|
||||
let mut iter = selector.inner.complex.iter();
|
||||
let mut iter = selector.iter();
|
||||
for ss in &mut iter {
|
||||
if let Some(r) = f(ss) {
|
||||
return Some(r)
|
||||
|
|
|
@ -1133,7 +1133,7 @@ impl Stylist {
|
|||
// this in the caller by asserting that the bitvecs are same-length.
|
||||
let mut results = BitVec::new();
|
||||
self.selectors_for_cache_revalidation.lookup(*element, &mut |selector_and_hashes| {
|
||||
results.push(matches_selector(&selector_and_hashes.selector.inner,
|
||||
results.push(matches_selector(&selector_and_hashes.selector,
|
||||
&selector_and_hashes.hashes,
|
||||
element,
|
||||
&mut matching_context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue