From 3e34c0295e1289df92f0813cd174cc0f878af978 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 7 Dec 2017 16:45:04 -0800 Subject: [PATCH] Defend against bugs in SelectorFlagsMap * Make `SelectorFlagsMap::apply_flags` private so it's easier to ensure it is called from the correct thread. * Clear the cache and the map at the same time; otherwise it leaves `SelectorFlagsMap` in an inconsistent state. --- components/style/context.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/style/context.rs b/components/style/context.rs index 7843c424046..a40537a5a9b 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -553,8 +553,9 @@ impl SelectorFlagsMap { } /// Applies the flags. Must be called on the main thread. - pub fn apply_flags(&mut self) { + fn apply_flags(&mut self) { debug_assert!(thread_state::get() == ThreadState::LAYOUT); + self.cache.evict_all(); for (el, flags) in self.map.drain() { unsafe { el.set_selector_flags(flags); } }