diff options
Diffstat (limited to 'components/layout_thread')
-rw-r--r-- | components/layout_thread/dom_wrapper.rs | 20 | ||||
-rw-r--r-- | components/layout_thread/lib.rs | 13 |
2 files changed, 30 insertions, 3 deletions
diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index bbc023cf958..1aa9488c327 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -83,6 +83,7 @@ use style::dom::{DomChildren, LayoutIterator, NodeInfo, OpaqueNode}; use style::dom::{TDocument, TElement, TNode, TShadowRoot}; use style::element_state::*; use style::font_metrics::ServoMetricsProvider; +use style::media_queries::Device; use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::selector_parser::{extended_filtering, PseudoElement, SelectorImpl}; use style::selector_parser::{AttrValue as SelectorAttrValue, Lang, NonTSPseudoClass}; @@ -219,11 +220,16 @@ impl<'sr> ServoShadowRoot<'sr> { } } - pub fn flush_stylesheets(&self, guard: &SharedRwLockReadGuard) { + pub fn flush_stylesheets( + &self, + device: &Device, + quirks_mode: QuirksMode, + guard: &SharedRwLockReadGuard, + ) { unsafe { &self .shadow_root - .flush_stylesheets::<ServoLayoutElement>(guard) + .flush_stylesheets::<ServoLayoutElement>(device, quirks_mode, guard) }; } } @@ -425,6 +431,16 @@ impl<'ld> ServoLayoutDocument<'ld> { unsafe { self.document.style_shared_lock() } } + pub fn shadow_roots(&self) -> Vec<ServoShadowRoot> { + unsafe { + self.document + .shadow_roots() + .iter() + .map(|sr| ServoShadowRoot::from_layout_js(*sr)) + .collect() + } + } + pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> { ServoLayoutDocument { document: doc, diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 839fac79006..8c46fb90720 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -103,7 +103,7 @@ use std::time::Duration; use style::animation::Animation; use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters}; use style::context::{SharedStyleContext, ThreadLocalStyleContextCreationInfo}; -use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode}; +use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TDocument, TElement, TNode}; use style::driver; use style::error_reporting::RustLogReporter; use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL}; @@ -1346,6 +1346,17 @@ impl LayoutThread { } } + debug!( + "Shadow roots in document {:?}", + document.shadow_roots().len() + ); + + let device = Device::new(MediaType::screen(), initial_viewport, device_pixel_ratio); + // Flush shadow roots stylesheets if dirty. + for shadow_root in document.shadow_roots() { + shadow_root.flush_stylesheets(&device, document.quirks_mode(), guards.author.clone()); + } + let restyles = document.drain_pending_restyles(); debug!("Draining restyles: {}", restyles.len()); |