mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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:
parent
a6369149dc
commit
f74675639d
2 changed files with 18 additions and 13 deletions
|
@ -1484,16 +1484,23 @@ struct StylistSelectorVisitor<'a> {
|
||||||
state_dependencies: &'a mut ElementState,
|
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 {
|
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::AttributeInNoNamespaceExists { .. } |
|
||||||
Component::AttributeInNoNamespace { .. } |
|
Component::AttributeInNoNamespace { .. } |
|
||||||
Component::AttributeOther(_) |
|
Component::AttributeOther(_) |
|
||||||
Component::Empty |
|
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::FirstChild |
|
||||||
Component::LastChild |
|
Component::LastChild |
|
||||||
Component::OnlyChild |
|
Component::OnlyChild |
|
||||||
|
@ -1557,7 +1564,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> {
|
||||||
|
|
||||||
fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool {
|
fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool {
|
||||||
self.needs_revalidation =
|
self.needs_revalidation =
|
||||||
self.needs_revalidation || component_needs_revalidation(s);
|
self.needs_revalidation ||
|
||||||
|
component_needs_revalidation(s, self.passed_rightmost_selector);
|
||||||
|
|
||||||
match *s {
|
match *s {
|
||||||
Component::NonTSPseudoClass(ref p) => {
|
Component::NonTSPseudoClass(ref p) => {
|
||||||
|
|
|
@ -83,13 +83,12 @@ fn test_revalidation_selectors() {
|
||||||
"div > span",
|
"div > span",
|
||||||
|
|
||||||
// ID selectors.
|
// ID selectors.
|
||||||
"#foo1", // FIXME(bz) This one should not be a revalidation
|
"#foo1",
|
||||||
// selector once we fix
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1369611
|
|
||||||
"#foo2::before",
|
"#foo2::before",
|
||||||
"#foo3 > span",
|
"#foo3 > span",
|
||||||
"#foo1 > span", // FIXME(bz) This one should not be a
|
"#foo1 > span", // FIXME(bz): This one should not be a
|
||||||
// revalidation selector either.
|
// revalidation selector, since #foo1 should be in the
|
||||||
|
// rule hash.
|
||||||
|
|
||||||
// Attribute selectors.
|
// Attribute selectors.
|
||||||
"div[foo]",
|
"div[foo]",
|
||||||
|
@ -131,8 +130,6 @@ fn test_revalidation_selectors() {
|
||||||
|
|
||||||
let reference = parse_selectors(&[
|
let reference = parse_selectors(&[
|
||||||
// ID selectors.
|
// ID selectors.
|
||||||
"#foo1",
|
|
||||||
"#foo2::before",
|
|
||||||
"#foo3 > span",
|
"#foo3 > span",
|
||||||
"#foo1 > span",
|
"#foo1 > span",
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue