Auto merge of #17966 - emilio:less-id-revalidation-stuff, r=bzbarsky

style: Less ID revalidation selectors.

Avoid adding id selectors that are in the rule hash keyed by that ID to the list
of revalidation selectors.

This partially fixes bug 1369611 (we could look at the rule hash itself to avoid
inserting some more into the list of revalidation selectors).
This commit is contained in:
bors-servo 2017-08-06 06:16:12 -05:00 committed by GitHub
commit 16704bbaaa
2 changed files with 18 additions and 13 deletions

View file

@ -1484,16 +1484,23 @@ struct StylistSelectorVisitor<'a> {
state_dependencies: &'a mut ElementState,
}
fn component_needs_revalidation(c: &Component<SelectorImpl>) -> bool {
fn component_needs_revalidation(
c: &Component<SelectorImpl>,
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<SelectorImpl>) -> 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) => {

View file

@ -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",