aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout_thread/dom_wrapper.rs7
-rw-r--r--components/script/dom/documentorshadowroot.rs7
-rw-r--r--components/script/dom/shadowroot.rs21
3 files changed, 32 insertions, 3 deletions
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs
index 580965b91d0..8dc06aad9cb 100644
--- a/components/layout_thread/dom_wrapper.rs
+++ b/components/layout_thread/dom_wrapper.rs
@@ -200,7 +200,12 @@ impl<'sr> TShadowRoot for ServoShadowRoot<'sr> {
where
Self: 'a,
{
- None
+ Some(unsafe {
+ &self
+ .shadow_root
+ .get_style_data_for_layout::<ServoLayoutElement>()
+ .data
+ })
}
}
diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs
index 577df4bfd51..80b0e0022ba 100644
--- a/components/script/dom/documentorshadowroot.rs
+++ b/components/script/dom/documentorshadowroot.rs
@@ -18,6 +18,7 @@ use script_traits::UntrustedNodeAddress;
use servo_arc::Arc;
use std::fmt;
use style::context::QuirksMode;
+use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use style::media_queries::MediaList;
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
use style::stylesheet_set::StylesheetSet;
@@ -43,6 +44,12 @@ impl PartialEq for StyleSheetInDocument {
}
}
+impl ToMediaListKey for StyleSheetInDocument {
+ fn to_media_list_key(&self) -> MediaListKey {
+ self.sheet.to_media_list_key()
+ }
+}
+
impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument {
fn origin(&self, guard: &SharedRwLockReadGuard) -> Origin {
self.sheet.origin(guard)
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> {