Sort the cached class list in ValidationInfo.

MozReview-Commit-ID: 3vsfP5ECzds
This commit is contained in:
Bobby Holley 2017-05-30 11:32:16 -07:00
parent c018340a13
commit 6d8455a916
2 changed files with 11 additions and 2 deletions

View file

@ -90,8 +90,15 @@ impl ValidationData {
where E: TElement, where E: TElement,
{ {
if self.class_list.is_none() { if self.class_list.is_none() {
let mut class_list = SmallVec::new(); let mut class_list = SmallVec::<[Atom; 5]>::new();
element.each_class(|c| class_list.push(c.clone())); element.each_class(|c| class_list.push(c.clone()));
// Assuming there are a reasonable number of classes (we use the
// inline capacity as "reasonable number"), sort them to so that
// we don't mistakenly reject sharing candidates when one element
// has "foo bar" and the other has "bar foo".
if !class_list.spilled() {
class_list.sort_by(|a, b| a.get_hash().cmp(&b.get_hash()));
}
self.class_list = Some(class_list); self.class_list = Some(class_list);
} }
&*self.class_list.as_ref().unwrap() &*self.class_list.as_ref().unwrap()

View file

@ -966,7 +966,9 @@ impl Stylist {
assert_eq!(declaration.level, CascadeLevel::PresHints); assert_eq!(declaration.level, CascadeLevel::PresHints);
} }
} }
// Never share style for elements with preshints // Note the existence of presentational attributes so that the
// style sharing cache can avoid re-querying them if they don't
// exist.
context.relations |= AFFECTED_BY_PRESENTATIONAL_HINTS; context.relations |= AFFECTED_BY_PRESENTATIONAL_HINTS;
} }
debug!("preshints: {:?}", context.relations); debug!("preshints: {:?}", context.relations);