mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Rename OriginValidity to DataValidity.
MozReview-Commit-ID: FpsYUlWLWTt
This commit is contained in:
parent
01915d84db
commit
bbc6857c06
2 changed files with 29 additions and 29 deletions
|
@ -105,7 +105,7 @@ where
|
||||||
/// The validity of the data in a given cascade origin.
|
/// The validity of the data in a given cascade origin.
|
||||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
#[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
|
/// The origin is clean, all the data already there is valid, though we may
|
||||||
/// have new sheets at the end.
|
/// have new sheets at the end.
|
||||||
Valid = 0,
|
Valid = 0,
|
||||||
|
@ -118,9 +118,9 @@ pub enum OriginValidity {
|
||||||
FullyInvalid = 2,
|
FullyInvalid = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OriginValidity {
|
impl Default for DataValidity {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
OriginValidity::Valid
|
DataValidity::Valid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ where
|
||||||
{
|
{
|
||||||
origins_dirty: OriginSet,
|
origins_dirty: OriginSet,
|
||||||
collections: &'a mut PerOrigin<SheetCollection<S>>,
|
collections: &'a mut PerOrigin<SheetCollection<S>>,
|
||||||
origin_data_validity: PerOrigin<OriginValidity>,
|
origin_data_validity: PerOrigin<DataValidity>,
|
||||||
author_style_disabled: bool,
|
author_style_disabled: bool,
|
||||||
had_invalidations: bool,
|
had_invalidations: bool,
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ where
|
||||||
S: StylesheetInDocument + PartialEq + 'static,
|
S: StylesheetInDocument + PartialEq + 'static,
|
||||||
{
|
{
|
||||||
/// The data validity for a given origin.
|
/// 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)
|
*self.origin_data_validity.borrow_for_origin(&origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,11 +191,11 @@ where
|
||||||
where
|
where
|
||||||
'a: 'b
|
'a: 'b
|
||||||
{
|
{
|
||||||
let validity = self.origin_validity(origin);
|
let validity = self.data_validity(origin);
|
||||||
let origin_dirty = self.origins_dirty.contains(origin.into());
|
let origin_dirty = self.origins_dirty.contains(origin.into());
|
||||||
|
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
origin_dirty || validity == OriginValidity::Valid,
|
origin_dirty || validity == DataValidity::Valid,
|
||||||
"origin_data_validity should be a subset of origins_dirty!"
|
"origin_data_validity should be a subset of origins_dirty!"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ where
|
||||||
S: StylesheetInDocument + PartialEq + 'static
|
S: StylesheetInDocument + PartialEq + 'static
|
||||||
{
|
{
|
||||||
iter: slice::IterMut<'a, StylesheetSetEntry<S>>,
|
iter: slice::IterMut<'a, StylesheetSetEntry<S>>,
|
||||||
validity: OriginValidity,
|
validity: DataValidity,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S> Iterator for PerOriginFlusher<'a, S>
|
impl<'a, S> Iterator for PerOriginFlusher<'a, S>
|
||||||
|
@ -253,9 +253,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let rebuild_kind = match self.validity {
|
let rebuild_kind = match self.validity {
|
||||||
OriginValidity::Valid => continue,
|
DataValidity::Valid => continue,
|
||||||
OriginValidity::CascadeInvalid => SheetRebuildKind::CascadeOnly,
|
DataValidity::CascadeInvalid => SheetRebuildKind::CascadeOnly,
|
||||||
OriginValidity::FullyInvalid => SheetRebuildKind::Full,
|
DataValidity::FullyInvalid => SheetRebuildKind::Full,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Some((&potential_sheet.sheet, rebuild_kind));
|
return Some((&potential_sheet.sheet, rebuild_kind));
|
||||||
|
@ -277,10 +277,10 @@ where
|
||||||
/// The validity of the data that was already there for a given origin.
|
/// 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
|
/// 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
|
/// which case the existing data is valid, but the origin needs to be
|
||||||
/// rebuilt).
|
/// rebuilt).
|
||||||
data_validity: OriginValidity,
|
data_validity: DataValidity,
|
||||||
|
|
||||||
/// Whether anything in the collection has changed. Note that this is
|
/// Whether anything in the collection has changed. Note that this is
|
||||||
/// different from `data_validity`, in the sense that after a sheet append,
|
/// different from `data_validity`, in the sense that after a sheet append,
|
||||||
|
@ -295,7 +295,7 @@ where
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
entries: vec![],
|
entries: vec![],
|
||||||
data_validity: OriginValidity::Valid,
|
data_validity: DataValidity::Valid,
|
||||||
dirty: false,
|
dirty: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ where
|
||||||
// rebuilding the world when sites quickly append and remove a stylesheet.
|
// rebuilding the world when sites quickly append and remove a stylesheet.
|
||||||
// See bug 1434756.
|
// See bug 1434756.
|
||||||
if sheet.committed {
|
if sheet.committed {
|
||||||
self.set_data_validity_at_least(OriginValidity::FullyInvalid);
|
self.set_data_validity_at_least(DataValidity::FullyInvalid);
|
||||||
} else {
|
} else {
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -361,14 +361,14 @@ where
|
||||||
|
|
||||||
// Inserting stylesheets somewhere but at the end changes the validity
|
// Inserting stylesheets somewhere but at the end changes the validity
|
||||||
// of the cascade data, but not the invalidation data.
|
// 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));
|
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;
|
use std::cmp;
|
||||||
|
|
||||||
debug_assert_ne!(validity, OriginValidity::Valid);
|
debug_assert_ne!(validity, DataValidity::Valid);
|
||||||
|
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
self.data_validity = cmp::max(validity, self.data_validity);
|
self.data_validity = cmp::max(validity, self.data_validity);
|
||||||
|
@ -378,7 +378,7 @@ where
|
||||||
debug_assert!(!self.contains(&sheet));
|
debug_assert!(!self.contains(&sheet));
|
||||||
// Inserting stylesheets somewhere but at the end changes the validity
|
// Inserting stylesheets somewhere but at the end changes the validity
|
||||||
// of the cascade data, but not the invalidation data.
|
// 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));
|
self.entries.insert(0, StylesheetSetEntry::new(sheet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ where
|
||||||
self.author_style_disabled = disabled;
|
self.author_style_disabled = disabled;
|
||||||
self.invalidations.invalidate_fully();
|
self.invalidations.invalidate_fully();
|
||||||
self.collections.borrow_mut_for_origin(&Origin::Author)
|
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.
|
/// Returns whether the given set has changed from the last flush.
|
||||||
|
@ -539,17 +539,17 @@ where
|
||||||
self.invalidations.flush(document_element, snapshots);
|
self.invalidations.flush(document_element, snapshots);
|
||||||
|
|
||||||
let mut origins_dirty = OriginSet::empty();
|
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() {
|
for (collection, origin) in self.collections.iter_mut_origins() {
|
||||||
let was_dirty = mem::replace(&mut collection.dirty, false);
|
let was_dirty = mem::replace(&mut collection.dirty, false);
|
||||||
if !was_dirty {
|
if !was_dirty {
|
||||||
debug_assert_eq!(collection.data_validity, OriginValidity::Valid);
|
debug_assert_eq!(collection.data_validity, DataValidity::Valid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
origins_dirty |= origin;
|
origins_dirty |= origin;
|
||||||
*origin_data_validity.borrow_mut_for_origin(&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 {
|
StylesheetFlusher {
|
||||||
|
@ -594,7 +594,7 @@ where
|
||||||
// We don't know what happened, assume the worse.
|
// We don't know what happened, assume the worse.
|
||||||
self.collections
|
self.collections
|
||||||
.borrow_mut_for_origin(&origin)
|
.borrow_mut_for_origin(&origin)
|
||||||
.set_data_validity_at_least(OriginValidity::FullyInvalid);
|
.set_data_validity_at_least(DataValidity::FullyInvalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ use smallvec::SmallVec;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use style_traits::viewport::ViewportConstraints;
|
use style_traits::viewport::ViewportConstraints;
|
||||||
use stylesheet_set::{OriginValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher};
|
use stylesheet_set::{DataValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
|
use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
|
||||||
use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter};
|
use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter};
|
||||||
|
@ -240,12 +240,12 @@ impl DocumentCascadeData {
|
||||||
{
|
{
|
||||||
debug_assert_ne!(origin, Origin::UserAgent);
|
debug_assert_ne!(origin, Origin::UserAgent);
|
||||||
|
|
||||||
let validity = flusher.origin_validity(origin);
|
let validity = flusher.data_validity(origin);
|
||||||
|
|
||||||
match validity {
|
match validity {
|
||||||
OriginValidity::Valid => {},
|
DataValidity::Valid => {},
|
||||||
OriginValidity::CascadeInvalid => cascade_data.clear_cascade_data(),
|
DataValidity::CascadeInvalid => cascade_data.clear_cascade_data(),
|
||||||
OriginValidity::FullyInvalid => cascade_data.clear(),
|
DataValidity::FullyInvalid => cascade_data.clear(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let guard = guards.for_origin(origin);
|
let guard = guards.for_origin(origin);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue