Bug 1549301 - Import style system changes for Servo's Shadow DOM support.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 05 May 2019 13:33:53 +0200
changeset 472666 6cd597096672810d108eb89d7f65fbdf5474306b
parent 472665 c818610cbef536fcff8e3ec58643d8ff8323a4e8
child 472667 a72ba580785282913ff100fc6184e4c584a79950
push id35976
push useropoprus@mozilla.com
push dateMon, 06 May 2019 21:44:12 +0000
treeherdermozilla-central@e9f5f01d8b8e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1549301
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549301 - Import style system changes for Servo's Shadow DOM support.
servo/components/style/author_styles.rs
servo/components/style/stylesheet_set.rs
--- a/servo/components/style/author_styles.rs
+++ b/servo/components/style/author_styles.rs
@@ -13,16 +13,17 @@ use crate::invalidation::media_queries::
 use crate::media_queries::Device;
 use crate::shared_lock::SharedRwLockReadGuard;
 use crate::stylesheet_set::AuthorStylesheetSet;
 use crate::stylesheets::StylesheetInDocument;
 use crate::stylist::CascadeData;
 
 /// A set of author stylesheets and their computed representation, such as the
 /// ones used for ShadowRoot.
+#[derive(MallocSizeOf)]
 pub struct AuthorStyles<S>
 where
     S: StylesheetInDocument + PartialEq + 'static,
 {
     /// The sheet collection, which holds the sheet pointers, the invalidations,
     /// and all that stuff.
     pub stylesheets: AuthorStylesheetSet<S>,
     /// The actual cascade data computed from the stylesheets.
--- a/servo/components/style/stylesheet_set.rs
+++ b/servo/components/style/stylesheet_set.rs
@@ -587,16 +587,26 @@ where
         self.collection.dirty
     }
 
     /// Whether the collection is empty.
     pub fn is_empty(&self) -> bool {
         self.collection.len() == 0
     }
 
+    /// Returns the `index`th stylesheet in the collection of author styles if present.
+    pub fn get(&self, index: usize) -> Option<&S> {
+        self.collection.get(index)
+    }
+
+    /// Returns the number of author stylesheets.
+    pub fn len(&self) -> usize {
+        self.collection.len()
+    }
+
     fn collection_for(
         &mut self,
         _sheet: &S,
         _guard: &SharedRwLockReadGuard,
     ) -> &mut SheetCollection<S> {
         &mut self.collection
     }