pub struct StyleSharingCache<E: TElement> { /* private fields */ }Expand description
A set of LRU caches of the last few nodes seen, one per DOM depth, so that we can try to aggressively try to share their styles.
We key the candidates by DOM depth, because sharing requires an identical inheritance parent
(see test_candidate), which in practice means the candidates worth testing are the ones at the
target’s own depth.
Note that these caches only live for the duration of one traversal 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,
inputs: &CascadeInputs,
target: E,
dom_depth: usize,
) -> Option<PrimaryStyle>
pub fn lookup_by_rules( &mut self, shared_context: &SharedStyleContext<'_>, inherited: &ComputedValues, inputs: &CascadeInputs, target: E, dom_depth: usize, ) -> 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§
Source§impl<E: TElement> Default for StyleSharingCache<E>
impl<E: TElement> Default for StyleSharingCache<E>
Source§impl<E: TElement> Drop for StyleSharingCache<E>
impl<E: TElement> Drop for StyleSharingCache<E>
Auto Trait Implementations§
impl<E> !RefUnwindSafe for StyleSharingCache<E>
impl<E> !UnwindSafe for StyleSharingCache<E>
impl<E> Freeze for StyleSharingCache<E>
impl<E> Send for StyleSharingCache<E>
impl<E> Sync for StyleSharingCache<E>
impl<E> Unpin for StyleSharingCache<E>
impl<E> UnsafeUnpin 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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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 more