mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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:
parent
1748150497
commit
0ea58d1ffa
9 changed files with 161 additions and 312 deletions
|
@ -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 ¤t.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, // >
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue