pub struct StyleSharingCache<E: TElement> { /* private fields */ }Expand description
An LRU cache of the last few nodes seen, so that we can aggressively try to reuse their styles.
Note that this cache is flushed every time we steal work from the queue, so storing nodes here temporarily is safe.
Implementations§
Source§impl<E: TElement> StyleSharingCache<E>
impl<E: TElement> StyleSharingCache<E>
Sourcepub fn insert_if_possible(
&mut self,
element: &E,
style: &PrimaryStyle,
validation_data_holder: Option<&mut StyleSharingTarget<E>>,
dom_depth: usize,
shared_context: &SharedStyleContext<'_>,
)
pub fn insert_if_possible( &mut self, element: &E, style: &PrimaryStyle, validation_data_holder: Option<&mut StyleSharingTarget<E>>, dom_depth: usize, shared_context: &SharedStyleContext<'_>, )
Tries to insert an element in the style sharing cache.
Fails if we know it should never be in the cache.
NB: We pass a source for the validation data, rather than the data itself, to avoid memmoving at each function call. See rust issue #42763.
Sourcepub fn lookup_by_rules(
&mut self,
shared_context: &SharedStyleContext<'_>,
inherited: &ComputedValues,
rules: &StrongRuleNode,
visited_rules: Option<&StrongRuleNode>,
target: E,
) -> Option<PrimaryStyle>
pub fn lookup_by_rules( &mut self, shared_context: &SharedStyleContext<'_>, inherited: &ComputedValues, rules: &StrongRuleNode, visited_rules: Option<&StrongRuleNode>, target: E, ) -> Option<PrimaryStyle>
Attempts to find an element in the cache with the given primary rule node and parent.
FIXME(emilio): re-measure this optimization, and remove if it’s not very useful… It’s probably not worth the complexity / obscure bugs.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for StyleSharingCache<E>
impl<E> !RefUnwindSafe for StyleSharingCache<E>
impl<E> Send for StyleSharingCache<E>
impl<E> Sync for StyleSharingCache<E>where
E: Sync,
impl<E> Unpin for StyleSharingCache<E>where
E: Unpin,
impl<E> !UnwindSafe for StyleSharingCache<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert