diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 18c6ce1be8a..a488ae461e9 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -1484,16 +1484,23 @@ struct StylistSelectorVisitor<'a> { state_dependencies: &'a mut ElementState, } -fn component_needs_revalidation(c: &Component) -> bool { +fn component_needs_revalidation( + c: &Component, + passed_rightmost_selector: bool, +) -> bool { match *c { + Component::ID(_) => { + // TODO(emilio): This could also check that the ID is not already in + // the rule hash. In that case, we could avoid making this a + // revalidation selector too. + // + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1369611 + passed_rightmost_selector + } Component::AttributeInNoNamespaceExists { .. } | Component::AttributeInNoNamespace { .. } | Component::AttributeOther(_) | Component::Empty | - // FIXME(bz) We really only want to do this for some cases of id - // selectors. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=1369611 - Component::ID(_) | Component::FirstChild | Component::LastChild | Component::OnlyChild | @@ -1557,7 +1564,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> { fn visit_simple_selector(&mut self, s: &Component) -> bool { self.needs_revalidation = - self.needs_revalidation || component_needs_revalidation(s); + self.needs_revalidation || + component_needs_revalidation(s, self.passed_rightmost_selector); match *s { Component::NonTSPseudoClass(ref p) => { diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs index 53269b40522..dcc288a20b4 100644 --- a/tests/unit/style/stylist.rs +++ b/tests/unit/style/stylist.rs @@ -83,13 +83,12 @@ fn test_revalidation_selectors() { "div > span", // ID selectors. - "#foo1", // FIXME(bz) This one should not be a revalidation - // selector once we fix - // https://bugzilla.mozilla.org/show_bug.cgi?id=1369611 + "#foo1", "#foo2::before", "#foo3 > span", - "#foo1 > span", // FIXME(bz) This one should not be a - // revalidation selector either. + "#foo1 > span", // FIXME(bz): This one should not be a + // revalidation selector, since #foo1 should be in the + // rule hash. // Attribute selectors. "div[foo]", @@ -131,8 +130,6 @@ fn test_revalidation_selectors() { let reference = parse_selectors(&[ // ID selectors. - "#foo1", - "#foo2::before", "#foo3 > span", "#foo1 > span",