From 2beb441d04f23808dd7b4fea0794f32ba1e70958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 28 Nov 2017 12:05:30 +0100 Subject: [PATCH] style: Bail out from invalidation if we're the root and got tons of descendant invalidations. Bug: 1420741 Reviewed-by: heycam MozReview-Commit-ID: 4Kja20Ep9qD --- components/style/invalidation/element/collector.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/style/invalidation/element/collector.rs b/components/style/invalidation/element/collector.rs index 379fe471a87..145b441b3ba 100644 --- a/components/style/invalidation/element/collector.rs +++ b/components/style/invalidation/element/collector.rs @@ -229,6 +229,17 @@ where collector.invalidates_self }; + // If we generated a ton of descendant invalidations, it's probably not + // worth to go ahead and try to process them. + // + // Just restyle the descendants directly. + // + // This number is completely made-up, but the page that made us add this + // code generated 1960+ invalidations (bug 1420741). + if descendant_invalidations.len() > 150 { + self.data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS); + } + if invalidated_self { self.data.hint.insert(RestyleHint::RESTYLE_SELF); }