Make LayoutShadowRootHelpers::get_style_data_for_layout return a &CascadeData

That return type is Sync, which thus means that the method can be safe.
This commit is contained in:
Anthony Ramine 2020-04-01 11:25:39 +02:00
parent ebd2892158
commit 295f120425
3 changed files with 8 additions and 5 deletions

View file

@ -27,6 +27,7 @@ use style::dom::TElement;
use style::media_queries::Device;
use style::shared_lock::SharedRwLockReadGuard;
use style::stylesheets::Stylesheet;
use style::stylist::CascadeData;
/// Whether a shadow root hosts an User Agent widget.
#[derive(JSTraceable, MallocSizeOf, PartialEq)]
@ -241,7 +242,7 @@ impl ShadowRootMethods for ShadowRoot {
#[allow(unsafe_code)]
pub trait LayoutShadowRootHelpers<'dom> {
fn get_host_for_layout(self) -> LayoutDom<'dom, Element>;
unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles<StyleSheetInDocument>;
fn get_style_data_for_layout(self) -> &'dom CascadeData;
unsafe fn flush_stylesheets<E: TElement>(
self,
device: &Device,
@ -264,8 +265,10 @@ impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
#[inline]
#[allow(unsafe_code)]
unsafe fn get_style_data_for_layout(self) -> &'dom AuthorStyles<StyleSheetInDocument> {
(*self.unsafe_get()).author_styles.borrow_for_layout()
fn get_style_data_for_layout(self) -> &'dom CascadeData {
fn is_sync<T: Sync>() {}
let _ = is_sync::<CascadeData>;
unsafe { &self.unsafe_get().author_styles.borrow_for_layout().data }
}
#[inline]