diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index de815d11520..6b3bbb9bccc 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -656,6 +656,29 @@ impl StyleSharingCache { 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 StyleSharingCache { 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(