Skip to content

Commit

Permalink
Make DomRefCell not mutate the borrow flag non-atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed May 18, 2020
1 parent 45f1316 commit 15db317
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions components/script/dom/bindings/cell.rs
Expand Up @@ -45,11 +45,12 @@ impl<T> DomRefCell<T> {
&mut *self.value.as_ptr()
}

/// Version of the above that we use during restyle while the script thread
/// is blocked.
pub fn borrow_mut_for_layout(&self) -> RefMut<T> {
/// Mutably borrow a cell for layout. Ideally this would use
/// `RefCell::try_borrow_mut_unguarded` but that doesn't exist yet.
#[allow(unsafe_code)]
pub unsafe fn borrow_mut_for_layout(&self) -> &mut T {
debug_assert!(thread_state::get().is_layout());
self.value.borrow_mut()
&mut *self.value.as_ptr()
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/shadowroot.rs
Expand Up @@ -281,7 +281,7 @@ impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
quirks_mode: QuirksMode,
guard: &SharedRwLockReadGuard,
) {
let mut author_styles = (*self.unsafe_get()).author_styles.borrow_mut_for_layout();
let author_styles = self.unsafe_get().author_styles.borrow_mut_for_layout();
if author_styles.stylesheets.dirty() {
author_styles.flush::<E>(device, quirks_mode, guard);
}
Expand Down

0 comments on commit 15db317

Please sign in to comment.