mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Make LOCAL_CONTEXT_KEY safe and non-leaky.
`LOCAL_CONTEXT_KEY` is currently a `Cell<*mut LocalLayoutContext>`. The use of the raw pointer means that the `LocalLayoutContext` is not dropped when the thread dies; this leaks FreeType instances and probably other things. There are also some unsafe getter functions in `LayoutContext` (`font_context`, `applicable_declarations_cache` and `style_sharing_candidate_cache`) that @eddyb says involve undefined behaviour. This changeset changes `LOCAL_CONTEXT_KEY` to `RefCell<Option<Rc<LocalLayoutContext>>>`. This fixes the leak and also results in safe getters. (Fixes #6282.)
This commit is contained in:
parent
2ca606aaba
commit
9b4d39d6d1
7 changed files with 38 additions and 48 deletions
|
@ -106,7 +106,7 @@ impl Flow for ListItemFlow {
|
|||
marker.assign_replaced_block_size_if_necessary(containing_block_block_size);
|
||||
|
||||
let font_metrics =
|
||||
text::font_metrics_for_style(layout_context.font_context(),
|
||||
text::font_metrics_for_style(&mut layout_context.font_context(),
|
||||
marker.style.get_font_arc());
|
||||
let line_height = text::line_height_from_style(&*marker.style, &font_metrics);
|
||||
let item_inline_metrics = InlineMetrics::from_font_metrics(&font_metrics, line_height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue