Bug 1357583: style: Recurse into @import rules when looking at the added rules. r?heycam
Apparently my whole conception of how the list of sheets in the styleset looked
like was flawled, and we only ever get one append_sheet for the topmost
stylesheet, instead of one for each.
MozReview-Commit-ID: FMClygMJkTc
--- a/servo/components/style/invalidation/mod.rs
+++ b/servo/components/style/invalidation/mod.rs
@@ -175,16 +175,19 @@ impl StylesheetInvalidationSet {
element);
unsafe { element.set_dirty_descendants() }
}
return any_children_invalid
}
/// Collects invalidations for a given list of CSS rules.
+ ///
+ /// TODO(emilio): Convert stylesheet.effective_rules into an iterator to
+ /// share code. This needs the ability to stop ASAP.
fn collect_invalidations_for_rule_list(
&mut self,
rules: &CssRules,
stylist: &Stylist,
guard: &SharedRwLockReadGuard)
{
for rule in &rules.0 {
if !self.collect_invalidations_for_rule(rule, stylist, guard) {
@@ -286,18 +289,30 @@ impl StylesheetInvalidationSet {
if self.fully_invalid {
return false;
}
}
}
Namespace(..) => {
// Irrelevant to which selector scopes match.
}
- Import(..) => {
- // We'll visit the appropriate stylesheet if/when it matters.
+ // NB: We need to do it here, we won't visit the appropriate sheet
+ // otherwise!
+ Import(ref lock) => {
+ let import_rule = lock.read_with(guard);
+
+ let mq = import_rule.stylesheet.media.read_with(guard);
+ if !mq.evaluate(stylist.device(), stylist.quirks_mode()) {
+ return true;
+ }
+
+ self.collect_invalidations_for_rule_list(
+ import_rule.stylesheet.rules.read_with(guard),
+ stylist,
+ guard);
}
Media(ref lock) => {
let media_rule = lock.read_with(guard);
let mq = media_rule.media_queries.read_with(guard);
if !mq.evaluate(stylist.device(), stylist.quirks_mode()) {
return true;
}