Skip to content

Commit

Permalink
Defend against bugs in SelectorFlagsMap
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mbrubeck committed Dec 8, 2017
1 parent 1f22041 commit 3e34c02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/style/context.rs
Expand Up @@ -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); }
}
Expand Down

0 comments on commit 3e34c02

Please sign in to comment.