mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
style: Share CascadeData instances across ShadowRoots
This should be both a memory and speed win for pages using a lot of Shadow DOM. In order to make the cache properly work we need to start keying media query results on the actual StyleSheetContents, as that's what we share on Gecko, but that should all be fine. Differential Revision: https://phabricator.services.mozilla.com/D107266
This commit is contained in:
parent
11153c63fa
commit
060d74ba3b
11 changed files with 175 additions and 178 deletions
|
@ -420,7 +420,7 @@ macro_rules! sheet_set_methods {
|
|||
) {
|
||||
debug!(concat!($set_name, "::append_stylesheet"));
|
||||
self.collect_invalidations_for(device, &sheet, guard);
|
||||
let collection = self.collection_for(&sheet, guard);
|
||||
let collection = self.collection_for(&sheet);
|
||||
collection.append(sheet);
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ macro_rules! sheet_set_methods {
|
|||
debug!(concat!($set_name, "::insert_stylesheet_before"));
|
||||
self.collect_invalidations_for(device, &sheet, guard);
|
||||
|
||||
let collection = self.collection_for(&sheet, guard);
|
||||
let collection = self.collection_for(&sheet);
|
||||
collection.insert_before(sheet, &before_sheet);
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,7 @@ macro_rules! sheet_set_methods {
|
|||
debug!(concat!($set_name, "::remove_stylesheet"));
|
||||
self.collect_invalidations_for(device, &sheet, guard);
|
||||
|
||||
let collection = self.collection_for(&sheet, guard);
|
||||
let collection = self.collection_for(&sheet);
|
||||
collection.remove(&sheet)
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ macro_rules! sheet_set_methods {
|
|||
RuleChangeKind::StyleRuleDeclarations => DataValidity::FullyInvalid,
|
||||
};
|
||||
|
||||
let collection = self.collection_for(&sheet, guard);
|
||||
let collection = self.collection_for(&sheet);
|
||||
collection.set_data_validity_at_least(validity);
|
||||
}
|
||||
};
|
||||
|
@ -517,12 +517,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn collection_for(
|
||||
&mut self,
|
||||
sheet: &S,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
) -> &mut SheetCollection<S> {
|
||||
let origin = sheet.origin(guard);
|
||||
fn collection_for(&mut self, sheet: &S) -> &mut SheetCollection<S> {
|
||||
let origin = sheet.contents().origin;
|
||||
self.collections.borrow_mut_for_origin(&origin)
|
||||
}
|
||||
|
||||
|
@ -670,11 +666,7 @@ where
|
|||
self.collection.len()
|
||||
}
|
||||
|
||||
fn collection_for(
|
||||
&mut self,
|
||||
_sheet: &S,
|
||||
_guard: &SharedRwLockReadGuard,
|
||||
) -> &mut SheetCollection<S> {
|
||||
fn collection_for(&mut self, _sheet: &S) -> &mut SheetCollection<S> {
|
||||
&mut self.collection
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue