style: Reorder style sharing checks so that cheaper and broader ones are earlier.

This commit is contained in:
Emilio Cobos Álvarez 2018-03-08 22:50:34 +01:00
parent 4c797dfb52
commit a37bb8e6aa
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -656,6 +656,29 @@ impl<E: TElement> StyleSharingCache<E> {
return None;
}
if target.local_name() != candidate.element.local_name() {
trace!("Miss: Local Name");
return None;
}
if target.namespace() != candidate.element.namespace() {
trace!("Miss: Namespace");
return None;
}
// We do not ignore visited state here, because Gecko needs to store
// extra bits on visited style contexts, so these contexts cannot be
// shared.
if target.element.state() != candidate.state() {
trace!("Miss: User and Author State");
return None;
}
if target.is_link() != candidate.element.is_link() {
trace!("Miss: Link");
return None;
}
// Note that in the XBL case, we should be able to assert that the
// scopes are different, since two elements with different XBL bindings
// need to necessarily have different style (and thus children of them
@ -676,35 +699,12 @@ impl<E: TElement> StyleSharingCache<E> {
return None;
}
if target.local_name() != candidate.element.local_name() {
trace!("Miss: Local Name");
return None;
}
if target.namespace() != candidate.element.namespace() {
trace!("Miss: Namespace");
return None;
}
if target.is_link() != candidate.element.is_link() {
trace!("Miss: Link");
return None;
}
if target.matches_user_and_author_rules() !=
candidate.element.matches_user_and_author_rules() {
trace!("Miss: User and Author Rules");
return None;
}
// We do not ignore visited state here, because Gecko
// needs to store extra bits on visited style contexts,
// so these contexts cannot be shared
if target.element.state() != candidate.state() {
trace!("Miss: User and Author State");
return None;
}
// It's possible that there are no styles for either id.
let may_match_different_id_rules =
checks::may_match_different_id_rules(