From dd7196949fa24ea9f10eeb6df8b94d0507f6c425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 22 Oct 2017 03:14:13 +0200 Subject: [PATCH] style: Don't use the invalidation machinery unless we may get some benefit from it. MozReview-Commit-ID: 8Wpn2bjuHBQ --- components/style/dom_apis.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/style/dom_apis.rs b/components/style/dom_apis.rs index 8cfc6bf5754..5a096dac1a6 100644 --- a/components/style/dom_apis.rs +++ b/components/style/dom_apis.rs @@ -340,7 +340,14 @@ where let root_element = root.as_element(); matching_context.scope_element = root_element.map(|e| e.opaque()); - if root_element.is_some() { + // The invalidation mechanism is only useful in presence of combinators. + // + // We could do that check properly here, though checking the length of the + // selectors is a good heuristic. + let invalidation_may_be_useful = + selector_list.0.iter().any(|s| s.len() > 1); + + if root_element.is_some() || !invalidation_may_be_useful { query_selector_slow::( root, selector_list,