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.
This commit is contained in:
Matt Brubeck 2017-12-07 16:45:04 -08:00
parent 1f22041f5f
commit 3e34c0295e

View file

@ -553,8 +553,9 @@ impl<E: TElement> SelectorFlagsMap<E> {
}
/// 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); }
}