From 0701c0c9530dbb8381c5c43d96d8c0e3c98b0dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 21 Aug 2017 20:17:24 +0200 Subject: [PATCH] style: Add docs about the lack of device in the stylesheet set. Also add a few comments and similar about pending invalidation work, and avoid passing a device in script, since the work it performs scanning the stylesheet is just thrown away in the `flush_without_invalidations` call. --- components/script/dom/document.rs | 13 ++++++++----- components/style/stylesheet_set.rs | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 3105f0f4341..4629ff8814f 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2338,6 +2338,11 @@ impl Document { pub fn flush_stylesheets_for_reflow(&self) -> bool { // NOTE(emilio): The invalidation machinery is used on the replicated // list on the layout thread. + // + // FIXME(emilio): This really should differentiate between CSSOM changes + // and normal stylesheets additions / removals, because in the last case + // the layout thread already has that information and we could avoid + // dirtying the whole thing. let mut stylesheets = self.stylesheets.borrow_mut(); let have_changed = stylesheets.has_changed(); stylesheets.flush_without_invalidation(); @@ -2370,11 +2375,10 @@ impl Document { .unwrap(); let guard = s.shared_lock.read(); - let device = self.device(); // FIXME(emilio): Would be nice to remove the clone, etc. self.stylesheets.borrow_mut().remove_stylesheet( - device.as_ref(), + None, StyleSheetInDocument { sheet: s.clone(), owner: JS::from_ref(owner), @@ -2414,13 +2418,12 @@ impl Document { let lock = self.style_shared_lock(); let guard = lock.read(); - let device = self.device(); match insertion_point { Some(ip) => { - stylesheets.insert_stylesheet_before(device.as_ref(), sheet, ip, &guard); + stylesheets.insert_stylesheet_before(None, sheet, ip, &guard); } None => { - stylesheets.append_stylesheet(device.as_ref(), sheet, &guard); + stylesheets.append_stylesheet(None, sheet, &guard); } } } diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index 795aa60fea7..91e87cff239 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -106,6 +106,8 @@ where } /// Appends a new stylesheet to the current set. + /// + /// No device implies not computing invalidations. pub fn append_stylesheet( &mut self, device: Option<&Device>,