Auto merge of #16093 - emilio:state, r=bholley,heycam

Bug 1349553: Account for negations of state-dependent selectors.
This commit is contained in:
bors-servo 2017-03-23 01:52:43 -07:00 committed by GitHub
commit 301ba366b8
3 changed files with 22 additions and 1 deletions

View file

@ -154,6 +154,9 @@ macro_rules! pseudo_class_name {
$s_name(Box<[u16]>),
)*
/// The non-standard `:-moz-any` pseudo-class.
///
/// TODO(emilio): We disallow combinators and pseudos here, so we
/// should use SimpleSelector instead
MozAny(Vec<ComplexSelector<SelectorImpl>>),
}
}

View file

@ -358,7 +358,8 @@ impl<'a, E> Element for ElementWrapper<'a, E>
}
}
/// Returns the union of any `ElementState` flags for components of a `ComplexSelector`
/// Returns the union of any `ElementState` flags for components of a
/// `ComplexSelector`.
pub fn complex_selector_to_state(sel: &ComplexSelector<SelectorImpl>) -> ElementState {
sel.compound_selector.iter().fold(ElementState::empty(), |state, s| {
state | selector_to_state(s)
@ -368,6 +369,11 @@ pub fn complex_selector_to_state(sel: &ComplexSelector<SelectorImpl>) -> Element
fn selector_to_state(sel: &SimpleSelector<SelectorImpl>) -> ElementState {
match *sel {
SimpleSelector::NonTSPseudoClass(ref pc) => SelectorImpl::pseudo_class_state_flag(pc),
SimpleSelector::Negation(ref negated) => {
negated.iter().fold(ElementState::empty(), |state, s| {
state | complex_selector_to_state(s)
})
}
_ => ElementState::empty(),
}
}
@ -502,6 +508,15 @@ impl DependencySet {
if !sensitivities.attrs {
sensitivities.attrs = is_attr_selector(s);
}
// NOTE(emilio): I haven't thought this thoroughly, but we may
// not need to do anything for combinators inside negations.
//
// Or maybe we do, and need to call note_selector recursively
// here to account for them correctly, but keep the
// sensitivities of the parent?
//
// In any case, perhaps we should just drop it, see bug 1348802.
}
if !sensitivities.is_empty() {
self.add_dependency(Dependency {

View file

@ -567,6 +567,7 @@ fn preprocess_children<E, D>(traversal: &D,
where E: TElement,
D: DomTraversal<E>
{
trace!("preprocess_children: {:?}", element);
// Loop over all the children.
for child in element.as_node().children() {
// FIXME(bholley): Add TElement::element_children instead of this.
@ -599,6 +600,8 @@ fn preprocess_children<E, D>(traversal: &D,
// Handle element snapshots and sibling restyle hints.
let stylist = &traversal.shared_context().stylist;
let later_siblings = restyle_data.compute_final_hint(child, stylist);
trace!(" > {:?} -> {:?}, later_siblings: {:?}",
child, restyle_data.hint, later_siblings);
if later_siblings {
propagated_hint.insert(&(RESTYLE_SELF | RESTYLE_DESCENDANTS).into());
}