mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Simplify style sharing code.
This commit is contained in:
parent
1eb24f1adc
commit
727be58b4a
4 changed files with 17 additions and 80 deletions
|
@ -110,7 +110,7 @@ impl<E: TElement> PartialEq<StyleSharingCandidate<E>> for StyleSharingCandidate<
|
|||
/// 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> {
|
||||
cache: LRUCache<StyleSharingCandidate<E>, ()>,
|
||||
cache: LRUCache<StyleSharingCandidate<E>>,
|
||||
}
|
||||
|
||||
/// A cache miss result.
|
||||
|
@ -366,7 +366,7 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
|
|||
}
|
||||
}
|
||||
|
||||
fn iter_mut(&mut self) -> IterMut<(StyleSharingCandidate<E>, ())> {
|
||||
fn iter_mut(&mut self) -> IterMut<StyleSharingCandidate<E>> {
|
||||
self.cache.iter_mut()
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
|
|||
element: unsafe { SendElement::new(*element) },
|
||||
common_style_affecting_attributes: None,
|
||||
class_attributes: None,
|
||||
}, ());
|
||||
});
|
||||
}
|
||||
|
||||
/// Touch a given index in the style sharing candidate cache.
|
||||
|
@ -881,8 +881,10 @@ pub trait MatchMethods : TElement {
|
|||
}
|
||||
|
||||
let mut should_clear_cache = false;
|
||||
for (i, &mut (ref mut candidate, ())) in style_sharing_candidate_cache.iter_mut().enumerate() {
|
||||
let sharing_result = self.share_style_with_candidate_if_possible(shared_context, candidate);
|
||||
for (i, candidate) in style_sharing_candidate_cache.iter_mut().enumerate() {
|
||||
let sharing_result =
|
||||
self.share_style_with_candidate_if_possible(shared_context,
|
||||
candidate);
|
||||
match sharing_result {
|
||||
Ok(shared_style) => {
|
||||
// Yay, cache hit. Share the style.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue