Use a RwLock to cache inline_content_sizes() (#34232)

In order to support size keywords in block layout, we may need to call
`inline_content_sizes()` in order to compute the min/max-content sizes.
But this required a mutable reference in order the update the cache,
and in various places we already had mutable references.

So this switches the cache into a RwLock to avoid needing mutable refs.
Note OnceCell wouldn't work because it's not thread-safe.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-11-13 10:56:02 +01:00 committed by GitHub
parent c00804190c
commit 9102644470
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 76 additions and 74 deletions

View file

@ -137,7 +137,7 @@ impl Table {
IndependentFormattingContext::NonReplaced(NonReplacedFormattingContext {
base_fragment_info: (&anonymous_info).into(),
style: grid_and_wrapper_style,
content_sizes_result: None,
content_sizes_result: Default::default(),
contents: NonReplacedFormattingContextContents::Table(table),
})
}
@ -858,7 +858,7 @@ where
context: ArcRefCell::new(NonReplacedFormattingContext {
style: info.style.clone(),
base_fragment_info: info.into(),
content_sizes_result: None,
content_sizes_result: Default::default(),
contents,
}),
};