From a37bb8e6aaa49a8797b96ad8a09f6d8164dd1a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 8 Mar 2018 22:50:34 +0100 Subject: [PATCH] style: Reorder style sharing checks so that cheaper and broader ones are earlier. --- components/style/sharing/mod.rs | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) 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(