style: Simplify style sharing code.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-09 15:23:42 +01:00
parent 1eb24f1adc
commit 727be58b4a
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 17 additions and 80 deletions

View file

@ -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.