diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-02-11 10:20:42 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-04-26 10:17:47 +0200 |
commit | e9f0e76d3c53888683fca4c9330f4b5884238f01 (patch) | |
tree | f96d66cd36d45fef71bc93f4f9a3b8b4745a8ecf /components/script/dom/shadowroot.rs | |
parent | 23b92d54d48274f4e80521c427a959cfd4cb646c (diff) | |
download | servo-e9f0e76d3c53888683fca4c9330f4b5884238f01.tar.gz servo-e9f0e76d3c53888683fca4c9330f4b5884238f01.zip |
Implement TShadowRoot::style_data
Diffstat (limited to 'components/script/dom/shadowroot.rs')
-rw-r--r-- | components/script/dom/shadowroot.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 7790423fb0a..d99f0c86493 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -20,6 +20,7 @@ use crate::dom::window::Window; use dom_struct::dom_struct; use servo_arc::Arc; use style::author_styles::AuthorStyles; +use style::dom::TElement; use style::stylesheets::Stylesheet; // https://dom.spec.whatwg.org/#interface-shadowroot @@ -29,8 +30,7 @@ pub struct ShadowRoot { document_or_shadow_root: DocumentOrShadowRoot, document: Dom<Document>, host: Dom<Element>, - /// List of stylesheets associated with nodes in this shadow tree. - /// |None| if the list needs to be refreshed. + /// List of author styles associated with nodes in this shadow tree. author_styles: DomRefCell<AuthorStyles<StyleSheetInDocument>>, stylesheet_list: MutNullableDom<StyleSheetList>, window: Dom<Window>, @@ -119,6 +119,9 @@ impl ShadowRootMethods for ShadowRoot { #[allow(unsafe_code)] pub trait LayoutShadowRootHelpers { unsafe fn get_host_for_layout(&self) -> LayoutDom<Element>; + unsafe fn get_style_data_for_layout<'a, E: TElement>( + &self, + ) -> &'a AuthorStyles<StyleSheetInDocument>; } impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> { @@ -127,6 +130,20 @@ impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> { unsafe fn get_host_for_layout(&self) -> LayoutDom<Element> { (*self.unsafe_get()).host.to_layout() } + + #[inline] + #[allow(unsafe_code)] + unsafe fn get_style_data_for_layout<'a, E: TElement>( + &self, + ) -> &'a AuthorStyles<StyleSheetInDocument> { + { + 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::<E>(&document.device(), document.quirks_mode(), &guard); + } + (*self.unsafe_get()).author_styles.borrow_for_layout() + } } impl StyleSheetListOwner for Dom<ShadowRoot> { |