mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Consider all the pseudo-classes in a given compound selector when computing restyle hints, not just the rightmost one.
For some reason when I wrote this code I mixed up the rules for pseudo-elements (rightmost, maximum of one) with those of pseudo-classes (which have no such restriction). This caused a correctness issue which can be demonstrated with the associated reftest modification.
This commit is contained in:
parent
77c253fd43
commit
d89816bb5f
2 changed files with 16 additions and 11 deletions
|
@ -220,15 +220,16 @@ impl StateDependencySet {
|
||||||
let mut cur = selector;
|
let mut cur = selector;
|
||||||
let mut combinator: Option<Combinator> = None;
|
let mut combinator: Option<Combinator> = None;
|
||||||
loop {
|
loop {
|
||||||
if let Some(rightmost) = cur.simple_selectors.last() {
|
let mut deps = ElementState::empty();
|
||||||
let state_dep = selector_to_state(rightmost);
|
for s in &cur.simple_selectors {
|
||||||
if !state_dep.is_empty() {
|
deps.insert(selector_to_state(s));
|
||||||
self.deps.push(StateDependency {
|
}
|
||||||
selector: cur.clone(),
|
if !deps.is_empty() {
|
||||||
combinator: combinator,
|
self.deps.push(StateDependency {
|
||||||
state: state_dep,
|
selector: cur.clone(),
|
||||||
});
|
combinator: combinator,
|
||||||
}
|
state: deps,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cur = match cur.next {
|
cur = match cur.next {
|
||||||
|
|
|
@ -19,11 +19,15 @@ fieldset:enabled div {
|
||||||
fieldset:enabled > div {
|
fieldset:enabled > div {
|
||||||
background-color: yellow;
|
background-color: yellow;
|
||||||
}
|
}
|
||||||
fieldset:enabled ~ div {
|
|
||||||
|
/* Add an unnecessary :first-child to make sure that restyle hints see
|
||||||
|
* non-rightmost pseudo-selectors.
|
||||||
|
* */
|
||||||
|
fieldset:enabled:first-child ~ div {
|
||||||
color: pink;
|
color: pink;
|
||||||
background-color: purple;
|
background-color: purple;
|
||||||
}
|
}
|
||||||
fieldset:enabled + div {
|
fieldset:enabled:first-child + div {
|
||||||
color: brown;
|
color: brown;
|
||||||
background-color: orange;
|
background-color: orange;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue