diff options
Diffstat (limited to 'components/layout_2020/context.rs')
-rw-r--r-- | components/layout_2020/context.rs | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/components/layout_2020/context.rs b/components/layout_2020/context.rs index 8ffc3386e3e..500f16093b1 100644 --- a/components/layout_2020/context.rs +++ b/components/layout_2020/context.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use std::cell::RefCell; use std::sync::{Arc, Mutex}; use fnv::FnvHashMap; @@ -12,7 +11,7 @@ use msg::constellation_msg::PipelineId; use net_traits::image_cache::{ ImageCache, ImageCacheResult, ImageOrMetadataAvailable, UsePlaceholder, }; -use parking_lot::{ReentrantMutex, RwLock}; +use parking_lot::RwLock; use script_layout_interface::{PendingImage, PendingImageState}; use servo_url::{ImmutableOrigin, ServoUrl}; use style::context::SharedStyleContext; @@ -20,8 +19,6 @@ use style::dom::OpaqueNode; use crate::display_list::WebRenderImageInfo; -thread_local!(static FONT_CONTEXT: RefCell<Option<FontContext<FontCacheThread>>> = RefCell::new(None)); - pub struct LayoutContext<'a> { pub id: PipelineId, pub use_rayon: bool, @@ -31,7 +28,7 @@ pub struct LayoutContext<'a> { pub style_context: SharedStyleContext<'a>, /// A FontContext to be used during layout. - pub font_cache_thread: Arc<ReentrantMutex<FontCacheThread>>, + pub font_context: Arc<FontContext<FontCacheThread>>, /// Reference to the script thread image cache. pub image_cache: Arc<dyn ImageCache>, @@ -133,27 +130,4 @@ impl<'a> LayoutContext<'a> { None | Some(ImageOrMetadataAvailable::MetadataAvailable(_)) => None, } } - - pub fn with_font_context<F, R>(&self, callback: F) -> R - where - F: FnOnce(&mut FontContext<FontCacheThread>) -> R, - { - with_thread_local_font_context(&self.font_cache_thread, callback) - } -} - -pub fn with_thread_local_font_context<F, R>( - font_cache_thread: &ReentrantMutex<FontCacheThread>, - callback: F, -) -> R -where - F: FnOnce(&mut FontContext<FontCacheThread>) -> R, -{ - FONT_CONTEXT.with(|font_context| { - callback( - font_context - .borrow_mut() - .get_or_insert_with(|| FontContext::new(font_cache_thread.lock().clone())), - ) - }) } |