style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.

Also, simplify all the pre-snapshot attribute hacks in the script and style
code.

MozReview-Commit-ID: 6c9ipeb7Tnr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-04-07 03:17:29 +02:00
parent 1748150497
commit 0ea58d1ffa
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
9 changed files with 161 additions and 312 deletions

View file

@ -145,15 +145,16 @@ impl<Impl: SelectorImpl> SelectorMethods for Selector<Impl> {
}
}
impl<Impl: SelectorImpl> SelectorMethods for ComplexSelector<Impl> {
impl<Impl: SelectorImpl> SelectorMethods for Arc<ComplexSelector<Impl>> {
type Impl = Impl;
fn visit<V>(&self, visitor: &mut V) -> bool
where V: SelectorVisitor<Impl = Impl>,
{
let mut current = self;
let mut combinator = None;
loop {
if !visitor.visit_complex_selector(current) {
if !visitor.visit_complex_selector(current, combinator) {
return false;
}
@ -164,7 +165,10 @@ impl<Impl: SelectorImpl> SelectorMethods for ComplexSelector<Impl> {
}
match current.next {
Some((ref next, _)) => current = next,
Some((ref next, next_combinator)) => {
current = next;
combinator = Some(next_combinator);
}
None => break,
}
}
@ -222,30 +226,6 @@ pub struct ComplexSelector<Impl: SelectorImpl> {
pub next: Option<(Arc<ComplexSelector<Impl>>, Combinator)>, // c.next is left of c
}
impl<Impl: SelectorImpl> ComplexSelector<Impl> {
/// Visits this selectors and all the ones to the left of it, until a
/// visitor method returns `false`.
pub fn visit<V>(&self, visitor: &mut V) -> bool
where V: SelectorVisitor<Impl = Impl>,
{
let mut current = self;
loop {
for selector in &current.compound_selector {
if !selector.visit(visitor) {
return false;
}
}
match current.next {
Some((ref next, _)) => current = next,
None => break,
}
}
true
}
}
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)]
pub enum Combinator {
Child, // >