Expose a way to flush shadow root stylesheets from layout

This commit is contained in:
Fernando Jiménez Moreno 2019-02-12 10:38:29 +01:00
parent e9f0e76d3c
commit cd07574235
2 changed files with 21 additions and 7 deletions

View file

@ -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::<ServoLayoutElement>(guard)
};
}
}
impl<'ln> TNode for ServoLayoutNode<'ln> {

View file

@ -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<StyleSheetInDocument>;
unsafe fn flush_stylesheets<E: TElement>(&self, guard: &SharedRwLockReadGuard);
}
impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> {
@ -136,14 +138,16 @@ impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> {
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()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn flush_stylesheets<E: TElement>(&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::<E>(&document.device(), document.quirks_mode(), guard);
}
}
impl StyleSheetListOwner for Dom<ShadowRoot> {