mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Simplify code for keeping alive shared memory until all sheets go away.
The existing code wasn't sound, as CSSOM objects also needed to go away before the shared memory goes away (as they keep references to them). This is sound assuming no presence of reference cycles introduced by CSSOM. We may want to live with this and rely on chrome code not writing cycles like this with UA stylesheet DOM objects. We could explicitly drop all potentially-static objects... That seems pretty error prone though. Or we could also just leak the shared memory buffer, is there any reason why we may not want to do that? Differential Revision: https://phabricator.services.mozilla.com/D51870
This commit is contained in:
parent
9c1dd4b3ea
commit
cceb0bcb73
2 changed files with 13 additions and 4 deletions
|
@ -124,6 +124,7 @@ impl StylesheetContents {
|
|||
url_data: UrlExtraData,
|
||||
quirks_mode: QuirksMode,
|
||||
) -> Self {
|
||||
debug_assert!(rules.is_static());
|
||||
Self {
|
||||
rules,
|
||||
origin,
|
||||
|
@ -144,6 +145,9 @@ impl StylesheetContents {
|
|||
/// Measure heap usage.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
|
||||
if self.rules.is_static() {
|
||||
return 0;
|
||||
}
|
||||
// Measurement of other fields may be added later.
|
||||
self.rules.unconditional_shallow_size_of(ops) +
|
||||
self.rules.read_with(guard).size_of(guard, ops)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue