mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Further changes required by Servo
This commit is contained in:
parent
060d74ba3b
commit
60e206143c
8 changed files with 21 additions and 46 deletions
|
@ -96,7 +96,7 @@ use std::time::Duration;
|
||||||
use style::animation::{AnimationSetKey, DocumentAnimationSet, ElementAnimationSet};
|
use style::animation::{AnimationSetKey, DocumentAnimationSet, ElementAnimationSet};
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters};
|
use style::context::{QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters};
|
||||||
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TDocument, TElement, TNode};
|
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
|
||||||
use style::driver;
|
use style::driver;
|
||||||
use style::error_reporting::RustLogReporter;
|
use style::error_reporting::RustLogReporter;
|
||||||
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
|
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
|
||||||
|
@ -1285,11 +1285,7 @@ impl LayoutThread {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Flush shadow roots stylesheets if dirty.
|
// Flush shadow roots stylesheets if dirty.
|
||||||
document.flush_shadow_roots_stylesheets(
|
document.flush_shadow_roots_stylesheets(&mut self.stylist, guards.author.clone());
|
||||||
&self.stylist.device(),
|
|
||||||
document.quirks_mode(),
|
|
||||||
guards.author.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let restyles = std::mem::take(&mut data.pending_restyles);
|
let restyles = std::mem::take(&mut data.pending_restyles);
|
||||||
debug!("Draining restyles: {}", restyles.len());
|
debug!("Draining restyles: {}", restyles.len());
|
||||||
|
|
|
@ -82,7 +82,7 @@ use style::animation::DocumentAnimationSet;
|
||||||
use style::context::{
|
use style::context::{
|
||||||
QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters, SharedStyleContext,
|
QuirksMode, RegisteredSpeculativePainter, RegisteredSpeculativePainters, SharedStyleContext,
|
||||||
};
|
};
|
||||||
use style::dom::{TDocument, TElement, TNode};
|
use style::dom::{TElement, TNode};
|
||||||
use style::driver;
|
use style::driver;
|
||||||
use style::error_reporting::RustLogReporter;
|
use style::error_reporting::RustLogReporter;
|
||||||
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
|
use style::global_style_data::{GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
|
||||||
|
@ -943,11 +943,7 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush shadow roots stylesheets if dirty.
|
// Flush shadow roots stylesheets if dirty.
|
||||||
document.flush_shadow_roots_stylesheets(
|
document.flush_shadow_roots_stylesheets(&mut self.stylist, guards.author.clone());
|
||||||
&self.stylist.device(),
|
|
||||||
document.quirks_mode(),
|
|
||||||
guards.author.clone(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let restyles = std::mem::take(&mut data.pending_restyles);
|
let restyles = std::mem::take(&mut data.pending_restyles);
|
||||||
debug!("Draining restyles: {}", restyles.len());
|
debug!("Draining restyles: {}", restyles.len());
|
||||||
|
|
|
@ -20,11 +20,10 @@ use servo_arc::Arc;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style::context::QuirksMode;
|
|
||||||
use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||||
use style::media_queries::MediaList;
|
use style::media_queries::MediaList;
|
||||||
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
|
use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard};
|
||||||
use style::stylesheets::{CssRule, Origin, Stylesheet};
|
use style::stylesheets::{Stylesheet, StylesheetContents};
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
#[derive(Clone, JSTraceable, MallocSizeOf)]
|
||||||
#[unrooted_must_root_lint::must_root]
|
#[unrooted_must_root_lint::must_root]
|
||||||
|
@ -48,19 +47,11 @@ impl PartialEq for StyleSheetInDocument {
|
||||||
|
|
||||||
impl ToMediaListKey for StyleSheetInDocument {
|
impl ToMediaListKey for StyleSheetInDocument {
|
||||||
fn to_media_list_key(&self) -> MediaListKey {
|
fn to_media_list_key(&self) -> MediaListKey {
|
||||||
self.sheet.to_media_list_key()
|
self.sheet.contents.to_media_list_key()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument {
|
impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument {
|
||||||
fn origin(&self, guard: &SharedRwLockReadGuard) -> Origin {
|
|
||||||
self.sheet.origin(guard)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn quirks_mode(&self, guard: &SharedRwLockReadGuard) -> QuirksMode {
|
|
||||||
self.sheet.quirks_mode(guard)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enabled(&self) -> bool {
|
fn enabled(&self) -> bool {
|
||||||
self.sheet.enabled()
|
self.sheet.enabled()
|
||||||
}
|
}
|
||||||
|
@ -69,8 +60,8 @@ impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument {
|
||||||
self.sheet.media(guard)
|
self.sheet.media(guard)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rules<'a, 'b: 'a>(&'a self, guard: &'b SharedRwLockReadGuard) -> &'a [CssRule] {
|
fn contents(&self) -> &StylesheetContents {
|
||||||
self.sheet.rules(guard)
|
self.sheet.contents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,13 @@ use crate::dom::stylesheetlist::{StyleSheetList, StyleSheetListOwner};
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::stylesheet_set::StylesheetSetRef;
|
use crate::stylesheet_set::StylesheetSetRef;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use selectors::context::QuirksMode;
|
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use servo_atoms::Atom;
|
use servo_atoms::Atom;
|
||||||
use style::author_styles::AuthorStyles;
|
use style::author_styles::AuthorStyles;
|
||||||
use style::dom::TElement;
|
use style::dom::TElement;
|
||||||
use style::media_queries::Device;
|
|
||||||
use style::shared_lock::SharedRwLockReadGuard;
|
use style::shared_lock::SharedRwLockReadGuard;
|
||||||
use style::stylesheets::Stylesheet;
|
use style::stylesheets::Stylesheet;
|
||||||
use style::stylist::CascadeData;
|
use style::stylist::{CascadeData, Stylist};
|
||||||
|
|
||||||
/// Whether a shadow root hosts an User Agent widget.
|
/// Whether a shadow root hosts an User Agent widget.
|
||||||
#[derive(JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
|
@ -245,8 +243,7 @@ pub trait LayoutShadowRootHelpers<'dom> {
|
||||||
fn get_style_data_for_layout(self) -> &'dom CascadeData;
|
fn get_style_data_for_layout(self) -> &'dom CascadeData;
|
||||||
unsafe fn flush_stylesheets<E: TElement>(
|
unsafe fn flush_stylesheets<E: TElement>(
|
||||||
self,
|
self,
|
||||||
device: &Device,
|
stylist: &mut Stylist,
|
||||||
quirks_mode: QuirksMode,
|
|
||||||
guard: &SharedRwLockReadGuard,
|
guard: &SharedRwLockReadGuard,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -277,13 +274,12 @@ impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn flush_stylesheets<E: TElement>(
|
unsafe fn flush_stylesheets<E: TElement>(
|
||||||
self,
|
self,
|
||||||
device: &Device,
|
stylist: &mut Stylist,
|
||||||
quirks_mode: QuirksMode,
|
|
||||||
guard: &SharedRwLockReadGuard,
|
guard: &SharedRwLockReadGuard,
|
||||||
) {
|
) {
|
||||||
let author_styles = self.unsafe_get().author_styles.borrow_mut_for_layout();
|
let author_styles = self.unsafe_get().author_styles.borrow_mut_for_layout();
|
||||||
if author_styles.stylesheets.dirty() {
|
if author_styles.stylesheets.dirty() {
|
||||||
author_styles.flush::<E>(device, quirks_mode, guard);
|
author_styles.flush::<E>(stylist, guard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ use script_layout_interface::wrapper_traits::LayoutDataTrait;
|
||||||
use selectors::matching::QuirksMode;
|
use selectors::matching::QuirksMode;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use style::dom::{TDocument, TNode};
|
use style::dom::{TDocument, TNode};
|
||||||
use style::media_queries::Device;
|
|
||||||
use style::shared_lock::{
|
use style::shared_lock::{
|
||||||
SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard as StyleSharedRwLockReadGuard,
|
SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuard as StyleSharedRwLockReadGuard,
|
||||||
};
|
};
|
||||||
|
use style::stylist::Stylist;
|
||||||
|
|
||||||
// A wrapper around documents that ensures ayout can only ever access safe properties.
|
// A wrapper around documents that ensures ayout can only ever access safe properties.
|
||||||
pub struct ServoLayoutDocument<'dom, LayoutDataType: LayoutDataTrait> {
|
pub struct ServoLayoutDocument<'dom, LayoutDataType: LayoutDataTrait> {
|
||||||
|
@ -90,8 +90,7 @@ impl<'ld, LayoutDataType: LayoutDataTrait> ServoLayoutDocument<'ld, LayoutDataTy
|
||||||
|
|
||||||
pub fn flush_shadow_roots_stylesheets(
|
pub fn flush_shadow_roots_stylesheets(
|
||||||
&self,
|
&self,
|
||||||
device: &Device,
|
stylist: &mut Stylist,
|
||||||
quirks_mode: QuirksMode,
|
|
||||||
guard: &StyleSharedRwLockReadGuard,
|
guard: &StyleSharedRwLockReadGuard,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -100,7 +99,7 @@ impl<'ld, LayoutDataType: LayoutDataTrait> ServoLayoutDocument<'ld, LayoutDataTy
|
||||||
}
|
}
|
||||||
self.document.flush_shadow_roots_stylesheets();
|
self.document.flush_shadow_roots_stylesheets();
|
||||||
for shadow_root in self.shadow_roots() {
|
for shadow_root in self.shadow_roots() {
|
||||||
shadow_root.flush_stylesheets(device, quirks_mode, guard);
|
shadow_root.flush_stylesheets(stylist, guard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ use crate::dom::shadowroot::{LayoutShadowRootHelpers, ShadowRoot};
|
||||||
use crate::layout_dom::ServoLayoutElement;
|
use crate::layout_dom::ServoLayoutElement;
|
||||||
use crate::layout_dom::ServoLayoutNode;
|
use crate::layout_dom::ServoLayoutNode;
|
||||||
use script_layout_interface::wrapper_traits::LayoutDataTrait;
|
use script_layout_interface::wrapper_traits::LayoutDataTrait;
|
||||||
use selectors::matching::QuirksMode;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use style::dom::TShadowRoot;
|
use style::dom::TShadowRoot;
|
||||||
use style::media_queries::Device;
|
|
||||||
use style::shared_lock::SharedRwLockReadGuard as StyleSharedRwLockReadGuard;
|
use style::shared_lock::SharedRwLockReadGuard as StyleSharedRwLockReadGuard;
|
||||||
use style::stylist::CascadeData;
|
use style::stylist::{CascadeData, Stylist};
|
||||||
|
|
||||||
pub struct ServoShadowRoot<'dom, LayoutDataType: LayoutDataTrait> {
|
pub struct ServoShadowRoot<'dom, LayoutDataType: LayoutDataTrait> {
|
||||||
/// The wrapped private DOM ShadowRoot.
|
/// The wrapped private DOM ShadowRoot.
|
||||||
|
@ -74,11 +72,10 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ServoShadowRoot<'dom, LayoutDataType
|
||||||
|
|
||||||
pub unsafe fn flush_stylesheets(
|
pub unsafe fn flush_stylesheets(
|
||||||
&self,
|
&self,
|
||||||
device: &Device,
|
stylist: &mut Stylist,
|
||||||
quirks_mode: QuirksMode,
|
|
||||||
guard: &StyleSharedRwLockReadGuard,
|
guard: &StyleSharedRwLockReadGuard,
|
||||||
) {
|
) {
|
||||||
self.shadow_root
|
self.shadow_root
|
||||||
.flush_stylesheets::<ServoLayoutElement<LayoutDataType>>(device, quirks_mode, guard)
|
.flush_stylesheets::<ServoLayoutElement<LayoutDataType>>(stylist, guard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,11 @@
|
||||||
//!
|
//!
|
||||||
//! [import]: https://drafts.csswg.org/css-cascade-3/#at-import
|
//! [import]: https://drafts.csswg.org/css-cascade-3/#at-import
|
||||||
|
|
||||||
use crate::context::QuirksMode;
|
|
||||||
use crate::media_queries::MediaList;
|
use crate::media_queries::MediaList;
|
||||||
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock};
|
use crate::shared_lock::{DeepCloneParams, DeepCloneWithLock};
|
||||||
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
use crate::shared_lock::{SharedRwLock, SharedRwLockReadGuard, ToCssWithGuard};
|
||||||
use crate::str::CssStringWriter;
|
use crate::str::CssStringWriter;
|
||||||
use crate::stylesheets::{CssRule, Origin, StylesheetInDocument};
|
use crate::stylesheets::{CssRule, StylesheetInDocument};
|
||||||
use crate::values::CssUrl;
|
use crate::values::CssUrl;
|
||||||
use cssparser::SourceLocation;
|
use cssparser::SourceLocation;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
@ -112,7 +111,7 @@ impl ImportSheet {
|
||||||
|
|
||||||
/// Returns the rules for this import rule.
|
/// Returns the rules for this import rule.
|
||||||
pub fn rules<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> &'a [CssRule] {
|
pub fn rules<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> &'a [CssRule] {
|
||||||
self.0.rules()
|
self.0.rules(guard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,7 @@ pub struct Stylist {
|
||||||
stylesheets: StylistStylesheetSet,
|
stylesheets: StylistStylesheetSet,
|
||||||
|
|
||||||
/// A cache of CascadeDatas for AuthorStylesheetSets (i.e., shadow DOM).
|
/// A cache of CascadeDatas for AuthorStylesheetSets (i.e., shadow DOM).
|
||||||
|
#[cfg_attr(feature = "servo", ignore_malloc_size_of = "XXX: how to handle this?")]
|
||||||
author_data_cache: CascadeDataCache<CascadeData>,
|
author_data_cache: CascadeDataCache<CascadeData>,
|
||||||
|
|
||||||
/// If true, the quirks-mode stylesheet is applied.
|
/// If true, the quirks-mode stylesheet is applied.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue