mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Shorten the naming around the style sharing cache.
MozReview-Commit-ID: EcVQDLoxwFP
This commit is contained in:
parent
6623b1f80d
commit
db67cd1759
3 changed files with 11 additions and 11 deletions
|
@ -26,7 +26,7 @@ use selectors::matching::ElementSelectorFlags;
|
|||
use servo_arc::Arc;
|
||||
#[cfg(feature = "servo")] use servo_atoms::Atom;
|
||||
use shared_lock::StylesheetGuards;
|
||||
use sharing::StyleSharingCandidateCache;
|
||||
use sharing::StyleSharingCache;
|
||||
use std::fmt;
|
||||
use std::ops;
|
||||
#[cfg(feature = "servo")] use std::sync::Mutex;
|
||||
|
@ -679,7 +679,7 @@ impl StackLimitChecker {
|
|||
/// thread in order to be able to mutate it without locking.
|
||||
pub struct ThreadLocalStyleContext<E: TElement> {
|
||||
/// A cache to share style among siblings.
|
||||
pub style_sharing_candidate_cache: StyleSharingCandidateCache<E>,
|
||||
pub sharing_cache: StyleSharingCache<E>,
|
||||
/// The bloom filter used to fast-reject selector-matching.
|
||||
pub bloom_filter: StyleBloom<E>,
|
||||
/// A channel on which new animations that have been triggered by style
|
||||
|
@ -716,7 +716,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
|
|||
#[cfg(feature = "servo")]
|
||||
pub fn new(shared: &SharedStyleContext) -> Self {
|
||||
ThreadLocalStyleContext {
|
||||
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
|
||||
sharing_cache: StyleSharingCache::new(),
|
||||
bloom_filter: StyleBloom::new(),
|
||||
new_animations_sender: shared.local_context_creation_data.lock().unwrap().new_animations_sender.clone(),
|
||||
tasks: SequentialTaskList(Vec::new()),
|
||||
|
@ -733,7 +733,7 @@ impl<E: TElement> ThreadLocalStyleContext<E> {
|
|||
/// Creates a new `ThreadLocalStyleContext` from a shared one.
|
||||
pub fn new(shared: &SharedStyleContext) -> Self {
|
||||
ThreadLocalStyleContext {
|
||||
style_sharing_candidate_cache: StyleSharingCandidateCache::new(),
|
||||
sharing_cache: StyleSharingCache::new(),
|
||||
bloom_filter: StyleBloom::new(),
|
||||
tasks: SequentialTaskList(Vec::new()),
|
||||
selector_flags: SelectorFlagsMap::new(),
|
||||
|
|
|
@ -343,7 +343,7 @@ impl<E: TElement> StyleSharingTarget<E> {
|
|||
&mut self,
|
||||
context: &mut StyleContext<E>,
|
||||
) -> StyleSharingResult {
|
||||
let cache = &mut context.thread_local.style_sharing_candidate_cache;
|
||||
let cache = &mut context.thread_local.sharing_cache;
|
||||
let shared_context = &context.shared;
|
||||
let selector_flags_map = &mut context.thread_local.selector_flags;
|
||||
let bloom_filter = &context.thread_local.bloom_filter;
|
||||
|
@ -436,7 +436,7 @@ thread_local!(static SHARING_CACHE_KEY: StoredSharingCache =
|
|||
///
|
||||
/// Note that this cache is flushed every time we steal work from the queue, so
|
||||
/// storing nodes here temporarily is safe.
|
||||
pub struct StyleSharingCandidateCache<E: TElement> {
|
||||
pub struct StyleSharingCache<E: TElement> {
|
||||
/// The LRU cache, with the type cast away to allow persisting the allocation.
|
||||
cache_typeless: OwningHandle<StoredSharingCache, AtomicRefMut<'static, TypelessSharingCache>>,
|
||||
/// Bind this structure to the lifetime of E, since that's what we effectively store.
|
||||
|
@ -447,13 +447,13 @@ pub struct StyleSharingCandidateCache<E: TElement> {
|
|||
dom_depth: usize,
|
||||
}
|
||||
|
||||
impl<E: TElement> Drop for StyleSharingCandidateCache<E> {
|
||||
impl<E: TElement> Drop for StyleSharingCache<E> {
|
||||
fn drop(&mut self) {
|
||||
self.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: TElement> StyleSharingCandidateCache<E> {
|
||||
impl<E: TElement> StyleSharingCache<E> {
|
||||
fn cache(&self) -> &SharingCache<E> {
|
||||
let base: &TypelessSharingCache = &*self.cache_typeless;
|
||||
unsafe { mem::transmute(base) }
|
||||
|
@ -472,7 +472,7 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
|
|||
let cache = OwningHandle::new_with_fn(cache_arc, |x| unsafe { x.as_ref() }.unwrap().borrow_mut());
|
||||
debug_assert_eq!(cache.num_entries(), 0);
|
||||
|
||||
StyleSharingCandidateCache {
|
||||
StyleSharingCache {
|
||||
cache_typeless: cache,
|
||||
marker: PhantomData,
|
||||
dom_depth: 0,
|
||||
|
|
|
@ -658,7 +658,7 @@ where
|
|||
match target.share_style_if_possible(context) {
|
||||
StyleWasShared(index, styles) => {
|
||||
context.thread_local.statistics.styles_shared += 1;
|
||||
context.thread_local.style_sharing_candidate_cache.touch(index);
|
||||
context.thread_local.sharing_cache.touch(index);
|
||||
styles
|
||||
}
|
||||
CannotShare => {
|
||||
|
@ -677,7 +677,7 @@ where
|
|||
};
|
||||
|
||||
context.thread_local
|
||||
.style_sharing_candidate_cache
|
||||
.sharing_cache
|
||||
.insert_if_possible(
|
||||
&element,
|
||||
new_styles.primary(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue