diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index 8dc06aad9cb..bbc023cf958 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -86,7 +86,9 @@ use style::font_metrics::ServoMetricsProvider; use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::selector_parser::{extended_filtering, PseudoElement, SelectorImpl}; use style::selector_parser::{AttrValue as SelectorAttrValue, Lang, NonTSPseudoClass}; -use style::shared_lock::{Locked as StyleLocked, SharedRwLock as StyleSharedRwLock}; +use style::shared_lock::{ + Locked as StyleLocked, SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard, +}; use style::str::is_whitespace; use style::stylist::CascadeData; use style::CaseSensitivityExt; @@ -216,6 +218,14 @@ impl<'sr> ServoShadowRoot<'sr> { chain: PhantomData, } } + + pub fn flush_stylesheets(&self, guard: &SharedRwLockReadGuard) { + unsafe { + &self + .shadow_root + .flush_stylesheets::(guard) + }; + } } impl<'ln> TNode for ServoLayoutNode<'ln> { diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index d99f0c86493..7f06b486b1d 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -21,6 +21,7 @@ use dom_struct::dom_struct; use servo_arc::Arc; use style::author_styles::AuthorStyles; use style::dom::TElement; +use style::shared_lock::SharedRwLockReadGuard; use style::stylesheets::Stylesheet; // https://dom.spec.whatwg.org/#interface-shadowroot @@ -122,6 +123,7 @@ pub trait LayoutShadowRootHelpers { unsafe fn get_style_data_for_layout<'a, E: TElement>( &self, ) -> &'a AuthorStyles; + unsafe fn flush_stylesheets(&self, guard: &SharedRwLockReadGuard); } impl LayoutShadowRootHelpers for LayoutDom { @@ -136,14 +138,16 @@ impl LayoutShadowRootHelpers for LayoutDom { unsafe fn get_style_data_for_layout<'a, E: TElement>( &self, ) -> &'a AuthorStyles { - { - let mut author_styles = (*self.unsafe_get()).author_styles.borrow_mut_for_layout(); - // let document = &(*self.unsafe_get()).document; - // let guard = document.style_shared_lock().read(); - // author_styles.flush::(&document.device(), document.quirks_mode(), &guard); - } (*self.unsafe_get()).author_styles.borrow_for_layout() } + + #[inline] + #[allow(unsafe_code)] + unsafe fn flush_stylesheets(&self, guard: &SharedRwLockReadGuard) { + let document = &(*self.unsafe_get()).document; + let mut author_styles = (*self.unsafe_get()).author_styles.borrow_mut_for_layout(); + author_styles.flush::(&document.device(), document.quirks_mode(), guard); + } } impl StyleSheetListOwner for Dom {