From 36fed07b1ce3010ec798ca4ec0903c5b2c56fe03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 18 Sep 2017 02:46:27 +0200 Subject: [PATCH] style: avoid testing against ourselves in lookup_for_rules. There's a path in finish_restyle, where we can recascade a style for a given element, in get_after_change_style. I haven't been able to construct a test-case for this, but this is the only coherent story I have for crashes like: https://crash-stats.mozilla.com/report/index/bcdfe629-ca1f-4e4d-aa17-27f890170917#tab-details --- components/style/sharing/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index a9c6a06181d..eba45236551 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -735,8 +735,8 @@ impl StyleSharingCache { debug_assert!(target.has_current_styles_for_traversal( &candidate.element.borrow_data().unwrap(), - shared.traversal_flags) - ); + shared.traversal_flags, + )); debug!("Sharing allowed between {:?} and {:?}", target.element, candidate.element); true @@ -751,6 +751,9 @@ impl StyleSharingCache { target: E, ) -> Option { self.cache_mut().lookup(|candidate| { + if candidate.element == target { + return false; + } if !candidate.parent_style_identity().eq(inherited) { return false; }