diff options
-rw-r--r-- | components/style/restyle_hints.rs | 19 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/restyle_hints_state.css | 8 |
2 files changed, 16 insertions, 11 deletions
diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs index acb521b0f10..fe143c3e315 100644 --- a/components/style/restyle_hints.rs +++ b/components/style/restyle_hints.rs @@ -220,15 +220,16 @@ impl StateDependencySet { let mut cur = selector; let mut combinator: Option<Combinator> = None; loop { - if let Some(rightmost) = cur.simple_selectors.last() { - let state_dep = selector_to_state(rightmost); - if !state_dep.is_empty() { - self.deps.push(StateDependency { - selector: cur.clone(), - combinator: combinator, - state: state_dep, - }); - } + let mut deps = ElementState::empty(); + for s in &cur.simple_selectors { + deps.insert(selector_to_state(s)); + } + if !deps.is_empty() { + self.deps.push(StateDependency { + selector: cur.clone(), + combinator: combinator, + state: deps, + }); } cur = match cur.next { diff --git a/tests/wpt/mozilla/tests/css/restyle_hints_state.css b/tests/wpt/mozilla/tests/css/restyle_hints_state.css index 673ac25d572..6a152778e42 100644 --- a/tests/wpt/mozilla/tests/css/restyle_hints_state.css +++ b/tests/wpt/mozilla/tests/css/restyle_hints_state.css @@ -19,11 +19,15 @@ fieldset:enabled div { fieldset:enabled > div { 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; background-color: purple; } -fieldset:enabled + div { +fieldset:enabled:first-child + div { color: brown; background-color: orange; } |