style: Move the StyleSheetSet into the Stylist.

This will allow tracking whether there have been only additions to the
stylesheet set, and in that case don't destroy and completely rebuild the
invalidation map.
This commit is contained in:
Emilio Cobos Álvarez 2017-08-21 15:13:06 +02:00
parent 02b203891f
commit cbf388a5fd
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 399 additions and 316 deletions

View file

@ -16,7 +16,6 @@ use media_queries::{Device, MediaList};
use properties::ComputedValues;
use servo_arc::Arc;
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
use stylesheet_set::StylesheetSet;
use stylesheets::{PerOrigin, StylesheetContents, StylesheetInDocument};
use stylist::{ExtraStyleData, Stylist};
@ -24,6 +23,8 @@ use stylist::{ExtraStyleData, Stylist};
#[derive(PartialEq, Eq, Debug)]
pub struct GeckoStyleSheet(*const ServoStyleSheet);
unsafe impl Sync for GeckoStyleSheet {}
impl ToMediaListKey for ::gecko::data::GeckoStyleSheet {
fn to_media_list_key(&self) -> MediaListKey {
use std::mem;
@ -114,9 +115,6 @@ pub struct PerDocumentStyleDataImpl {
/// Rule processor.
pub stylist: Stylist,
/// List of stylesheets, mirrored from Gecko.
pub stylesheets: StylesheetSet<GeckoStyleSheet>,
/// List of effective @font-face and @counter-style rules.
pub extra_style_data: PerOrigin<ExtraStyleData>,
}
@ -135,7 +133,6 @@ impl PerDocumentStyleData {
PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Stylist::new(device, quirks_mode.into()),
stylesheets: StylesheetSet::new(),
extra_style_data: Default::default(),
}))
}
@ -153,26 +150,20 @@ impl PerDocumentStyleData {
impl PerDocumentStyleDataImpl {
/// Recreate the style data if the stylesheets have changed.
pub fn flush_stylesheets<E>(&mut self,
guard: &SharedRwLockReadGuard,
document_element: Option<E>)
where E: TElement,
pub fn flush_stylesheets<E>(
&mut self,
guard: &SharedRwLockReadGuard,
document_element: Option<E>,
)
where
E: TElement,
{
if !self.stylesheets.has_changed() {
return;
}
let author_style_disabled = self.stylesheets.author_style_disabled();
let (iter, dirty_origins) = self.stylesheets.flush(document_element);
self.stylist.rebuild(
iter,
self.stylist.flush(
&StylesheetGuards::same(guard),
/* ua_sheets = */ None,
author_style_disabled,
&mut self.extra_style_data,
dirty_origins,
);
document_element,
)
}
/// Returns whether private browsing is enabled.