--- a/servo/components/style/stylesheet_set.rs
+++ b/servo/components/style/stylesheet_set.rs
@@ -100,43 +100,43 @@ where
self.current = None;
}
}
}
/// The validity of the data in a given cascade origin.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
-pub enum OriginValidity {
+pub enum DataValidity {
/// The origin is clean, all the data already there is valid, though we may
/// have new sheets at the end.
Valid = 0,
/// The cascade data is invalid, but not the invalidation data (which is
/// order-independent), and thus only the cascade data should be inserted.
CascadeInvalid = 1,
/// Everything needs to be rebuilt.
FullyInvalid = 2,
}
-impl Default for OriginValidity {
+impl Default for DataValidity {
fn default() -> Self {
- OriginValidity::Valid
+ DataValidity::Valid
}
}
/// A struct to iterate over the different stylesheets to be flushed.
pub struct StylesheetFlusher<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
origins_dirty: OriginSet,
collections: &'a mut PerOrigin<SheetCollection<S>>,
- origin_data_validity: PerOrigin<OriginValidity>,
+ origin_data_validity: PerOrigin<DataValidity>,
author_style_disabled: bool,
had_invalidations: bool,
}
/// The type of rebuild that we need to do for a given stylesheet.
#[derive(Clone, Copy, Debug)]
pub enum SheetRebuildKind {
/// A full rebuild, of both cascade data and invalidation data.
@@ -152,17 +152,17 @@ impl SheetRebuildKind {
}
}
impl<'a, S> StylesheetFlusher<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
/// The data validity for a given origin.
- pub fn origin_validity(&self, origin: Origin) -> OriginValidity {
+ pub fn data_validity(&self, origin: Origin) -> DataValidity {
*self.origin_data_validity.borrow_for_origin(&origin)
}
/// Whether the origin data is dirty in any way.
pub fn origin_dirty(&self, origin: Origin) -> bool {
self.origins_dirty.contains(origin.into())
}
@@ -186,21 +186,21 @@ where
self.collections.borrow_for_origin(&origin).iter()
}
/// Returns a flusher for the dirty origin `origin`.
pub fn origin_sheets<'b>(&'b mut self, origin: Origin) -> PerOriginFlusher<'b, S>
where
'a: 'b
{
- let validity = self.origin_validity(origin);
+ let validity = self.data_validity(origin);
let origin_dirty = self.origins_dirty.contains(origin.into());
debug_assert!(
- origin_dirty || validity == OriginValidity::Valid,
+ origin_dirty || validity == DataValidity::Valid,
"origin_data_validity should be a subset of origins_dirty!"
);
if self.author_style_disabled && origin == Origin::Author {
return PerOriginFlusher {
iter: [].iter_mut(),
validity,
}
@@ -225,17 +225,17 @@ where
/// A flusher struct for a given origin, that takes care of returning the
/// appropriate stylesheets that need work.
pub struct PerOriginFlusher<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static
{
iter: slice::IterMut<'a, StylesheetSetEntry<S>>,
- validity: OriginValidity,
+ validity: DataValidity,
}
impl<'a, S> Iterator for PerOriginFlusher<'a, S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
type Item = (&'a S, SheetRebuildKind);
@@ -248,19 +248,19 @@ where
let committed = mem::replace(&mut potential_sheet.committed, true);
if !committed {
// If the sheet was uncommitted, we need to do a full rebuild
// anyway.
return Some((&potential_sheet.sheet, SheetRebuildKind::Full))
}
let rebuild_kind = match self.validity {
- OriginValidity::Valid => continue,
- OriginValidity::CascadeInvalid => SheetRebuildKind::CascadeOnly,
- OriginValidity::FullyInvalid => SheetRebuildKind::Full,
+ DataValidity::Valid => continue,
+ DataValidity::CascadeInvalid => SheetRebuildKind::CascadeOnly,
+ DataValidity::FullyInvalid => SheetRebuildKind::Full,
};
return Some((&potential_sheet.sheet, rebuild_kind));
}
}
}
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
@@ -272,35 +272,35 @@ where
///
/// This is only a list of top-level stylesheets, and as such it doesn't
/// include recursive `@import` rules.
entries: Vec<StylesheetSetEntry<S>>,
/// The validity of the data that was already there for a given origin.
///
/// Note that an origin may appear on `origins_dirty`, but still have
- /// `OriginValidity::Valid`, if only sheets have been appended into it (in
+ /// `DataValidity::Valid`, if only sheets have been appended into it (in
/// which case the existing data is valid, but the origin needs to be
/// rebuilt).
- data_validity: OriginValidity,
+ data_validity: DataValidity,
/// Whether anything in the collection has changed. Note that this is
/// different from `data_validity`, in the sense that after a sheet append,
/// the data validity is still `Valid`, but we need to be marked as dirty.
dirty: bool,
}
impl<S> Default for SheetCollection<S>
where
S: StylesheetInDocument + PartialEq + 'static,
{
fn default() -> Self {
Self {
entries: vec![],
- data_validity: OriginValidity::Valid,
+ data_validity: DataValidity::Valid,
dirty: false,
}
}
}
impl<S> SheetCollection<S>
where
S: StylesheetInDocument + PartialEq + 'static,
@@ -325,17 +325,17 @@ where
}
let sheet = self.entries.remove(index.unwrap());
// Removing sheets makes us tear down the whole cascade and invalidation
// data, but only if the sheet has been involved in at least one flush.
// Checking whether the sheet has been committed allows us to avoid
// rebuilding the world when sites quickly append and remove a stylesheet.
// See bug 1434756.
if sheet.committed {
- self.set_data_validity_at_least(OriginValidity::FullyInvalid);
+ self.set_data_validity_at_least(DataValidity::FullyInvalid);
} else {
self.dirty = true;
}
}
fn contains(&self, sheet: &S) -> bool {
self.entries.iter().any(|e| e.sheet == *sheet)
}
@@ -356,34 +356,34 @@ where
debug_assert!(!self.contains(&sheet));
let index = self.entries.iter().position(|entry| {
entry.sheet == *before_sheet
}).expect("`before_sheet` stylesheet not found");
// Inserting stylesheets somewhere but at the end changes the validity
// of the cascade data, but not the invalidation data.
- self.set_data_validity_at_least(OriginValidity::CascadeInvalid);
+ self.set_data_validity_at_least(DataValidity::CascadeInvalid);
self.entries.insert(index, StylesheetSetEntry::new(sheet));
}
- fn set_data_validity_at_least(&mut self, validity: OriginValidity) {
+ fn set_data_validity_at_least(&mut self, validity: DataValidity) {
use std::cmp;
- debug_assert_ne!(validity, OriginValidity::Valid);
+ debug_assert_ne!(validity, DataValidity::Valid);
self.dirty = true;
self.data_validity = cmp::max(validity, self.data_validity);
}
fn prepend(&mut self, sheet: S) {
debug_assert!(!self.contains(&sheet));
// Inserting stylesheets somewhere but at the end changes the validity
// of the cascade data, but not the invalidation data.
- self.set_data_validity_at_least(OriginValidity::CascadeInvalid);
+ self.set_data_validity_at_least(DataValidity::CascadeInvalid);
self.entries.insert(0, StylesheetSetEntry::new(sheet));
}
/// Returns an iterator over the current list of stylesheets.
fn iter(&self) -> StylesheetCollectionIterator<S> {
StylesheetCollectionIterator(self.entries.iter())
}
}
@@ -508,17 +508,17 @@ where
pub fn set_author_style_disabled(&mut self, disabled: bool) {
debug!("DocumentStylesheetSet::set_author_style_disabled");
if self.author_style_disabled == disabled {
return;
}
self.author_style_disabled = disabled;
self.invalidations.invalidate_fully();
self.collections.borrow_mut_for_origin(&Origin::Author)
- .set_data_validity_at_least(OriginValidity::FullyInvalid)
+ .set_data_validity_at_least(DataValidity::FullyInvalid)
}
/// Returns whether the given set has changed from the last flush.
pub fn has_changed(&self) -> bool {
self.collections.iter_origins().any(|(collection, _)| collection.dirty)
}
/// Flush the current set, unmarking it as dirty, and returns a
@@ -534,27 +534,27 @@ where
use std::mem;
debug!("DocumentStylesheetSet::flush");
let had_invalidations =
self.invalidations.flush(document_element, snapshots);
let mut origins_dirty = OriginSet::empty();
- let mut origin_data_validity = PerOrigin::<OriginValidity>::default();
+ let mut origin_data_validity = PerOrigin::<DataValidity>::default();
for (collection, origin) in self.collections.iter_mut_origins() {
let was_dirty = mem::replace(&mut collection.dirty, false);
if !was_dirty {
- debug_assert_eq!(collection.data_validity, OriginValidity::Valid);
+ debug_assert_eq!(collection.data_validity, DataValidity::Valid);
continue;
}
origins_dirty |= origin;
*origin_data_validity.borrow_mut_for_origin(&origin) =
- mem::replace(&mut collection.data_validity, OriginValidity::Valid);
+ mem::replace(&mut collection.data_validity, DataValidity::Valid);
}
StylesheetFlusher {
collections: &mut self.collections,
author_style_disabled: self.author_style_disabled,
had_invalidations,
origins_dirty,
origin_data_validity,
@@ -589,12 +589,12 @@ where
/// Mark the stylesheets for the specified origin as dirty, because
/// something external may have invalidated it.
pub fn force_dirty(&mut self, origins: OriginSet) {
self.invalidations.invalidate_fully();
for origin in origins.iter() {
// We don't know what happened, assume the worse.
self.collections
.borrow_mut_for_origin(&origin)
- .set_data_validity_at_least(OriginValidity::FullyInvalid);
+ .set_data_validity_at_least(DataValidity::FullyInvalid);
}
}
}
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -36,17 +36,17 @@ use selectors::parser::{SelectorIter, Vi
use selectors::visitor::SelectorVisitor;
use servo_arc::{Arc, ArcBorrow};
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use smallbitvec::SmallBitVec;
use smallvec::SmallVec;
use std::ops;
use std::sync::Mutex;
use style_traits::viewport::ViewportConstraints;
-use stylesheet_set::{OriginValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher};
+use stylesheet_set::{DataValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher};
#[cfg(feature = "gecko")]
use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter};
use stylesheets::StyleRule;
use stylesheets::StylesheetInDocument;
use stylesheets::keyframes_rule::KeyframesAnimation;
use stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
use thread_state::{self, ThreadState};
@@ -235,22 +235,22 @@ impl DocumentCascadeData {
origin: Origin,
cascade_data: &mut CascadeData,
) -> Result<(), FailedAllocationError>
where
S: StylesheetInDocument + ToMediaListKey + PartialEq + 'static,
{
debug_assert_ne!(origin, Origin::UserAgent);
- let validity = flusher.origin_validity(origin);
+ let validity = flusher.data_validity(origin);
match validity {
- OriginValidity::Valid => {},
- OriginValidity::CascadeInvalid => cascade_data.clear_cascade_data(),
- OriginValidity::FullyInvalid => cascade_data.clear(),
+ DataValidity::Valid => {},
+ DataValidity::CascadeInvalid => cascade_data.clear_cascade_data(),
+ DataValidity::FullyInvalid => cascade_data.clear(),
}
let guard = guards.for_origin(origin);
for (stylesheet, rebuild_kind) in flusher.origin_sheets(origin) {
cascade_data.add_stylesheet(
device,
quirks_mode,
stylesheet,