diff options
author | Oriol Brufau <obrufau@igalia.com> | 2024-11-13 10:56:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-13 09:56:02 +0000 |
commit | 91026444701cfd68658beb21fbf446f6ed8723e6 (patch) | |
tree | c74a51dd95d3832fcc4201e74e48dbf9ac9ba3d6 /components/layout_2020/table/layout.rs | |
parent | c00804190cdc256183ade8f050d5f0408b550303 (diff) | |
download | servo-91026444701cfd68658beb21fbf446f6ed8723e6.tar.gz servo-91026444701cfd68658beb21fbf446f6ed8723e6.zip |
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>
Diffstat (limited to 'components/layout_2020/table/layout.rs')
-rw-r--r-- | components/layout_2020/table/layout.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/components/layout_2020/table/layout.rs b/components/layout_2020/table/layout.rs index da49cc00015..12519849c21 100644 --- a/components/layout_2020/table/layout.rs +++ b/components/layout_2020/table/layout.rs @@ -772,7 +772,7 @@ impl<'a> TableLayout<'a> { } /// Compute CAPMIN: <https://drafts.csswg.org/css-tables/#capmin> - fn compute_caption_minimum_inline_size(&mut self, layout_context: &LayoutContext) -> Au { + fn compute_caption_minimum_inline_size(&self, layout_context: &LayoutContext) -> Au { let containing_block = IndefiniteContainingBlock { size: LogicalVec2 { inline: AuOrAuto::Auto, @@ -784,7 +784,7 @@ impl<'a> TableLayout<'a> { .captions .iter() .map(|caption| { - let mut context = caption.context.borrow_mut(); + let context = caption.context.borrow(); context .outer_inline_content_sizes( layout_context, @@ -1605,7 +1605,7 @@ impl<'a> TableLayout<'a> { } fn layout_caption( - &mut self, + &self, caption: &TableCaption, table_pbm: &PaddingBorderMargin, layout_context: &LayoutContext, @@ -2186,7 +2186,7 @@ impl<'a> TableLayout<'a> { } fn make_fragments_for_columns_and_column_groups( - &mut self, + &self, dimensions: &TableAndTrackDimensions, fragments: &mut Vec<Fragment>, ) { @@ -2630,7 +2630,7 @@ impl Table { ) )] pub(crate) fn inline_content_sizes( - &mut self, + &self, layout_context: &LayoutContext, constraint_space: &ConstraintSpace, ) -> InlineContentSizesResult { |