mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Make AuthorStylesEnabled an enum.
Chances are we need to pass it around in a bit. Also invert the boolean because I don't want to reason about double negations, even if they're simple. MozReview-Commit-ID: KhX4lDKwDoj
This commit is contained in:
parent
4cc5717116
commit
438251cbfc
3 changed files with 33 additions and 20 deletions
|
@ -124,6 +124,16 @@ impl Default for DataValidity {
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether author styles are enabled.
|
||||
///
|
||||
/// This is used to support Gecko.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum AuthorStylesEnabled {
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
||||
/// A struct to iterate over the different stylesheets to be flushed.
|
||||
pub struct StylesheetFlusher<'a, S>
|
||||
where
|
||||
|
@ -132,7 +142,7 @@ where
|
|||
origins_dirty: OriginSet,
|
||||
collections: &'a mut PerOrigin<SheetCollection<S>>,
|
||||
origin_data_validity: PerOrigin<DataValidity>,
|
||||
author_style_disabled: bool,
|
||||
author_styles_enabled: AuthorStylesEnabled,
|
||||
had_invalidations: bool,
|
||||
}
|
||||
|
||||
|
@ -199,7 +209,9 @@ where
|
|||
"origin_data_validity should be a subset of origins_dirty!"
|
||||
);
|
||||
|
||||
if self.author_style_disabled && origin == Origin::Author {
|
||||
if self.author_styles_enabled == AuthorStylesEnabled::No &&
|
||||
origin == Origin::Author
|
||||
{
|
||||
return PerOriginFlusher {
|
||||
iter: [].iter_mut(),
|
||||
validity,
|
||||
|
@ -400,8 +412,8 @@ where
|
|||
/// The invalidations for stylesheets added or removed from this document.
|
||||
invalidations: StylesheetInvalidationSet,
|
||||
|
||||
/// Has author style been disabled?
|
||||
author_style_disabled: bool,
|
||||
/// Whether author styles are enabled.
|
||||
author_styles_enabled: AuthorStylesEnabled,
|
||||
}
|
||||
|
||||
impl<S> DocumentStylesheetSet<S>
|
||||
|
@ -413,7 +425,7 @@ where
|
|||
Self {
|
||||
collections: Default::default(),
|
||||
invalidations: StylesheetInvalidationSet::new(),
|
||||
author_style_disabled: false,
|
||||
author_styles_enabled: AuthorStylesEnabled::Yes,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,12 +439,6 @@ where
|
|||
self.collections.borrow_for_origin(&origin).get(index)
|
||||
}
|
||||
|
||||
/// Returns whether author styles have been disabled for the current
|
||||
/// stylesheet set.
|
||||
pub fn author_style_disabled(&self) -> bool {
|
||||
self.author_style_disabled
|
||||
}
|
||||
|
||||
fn collect_invalidations_for(
|
||||
&mut self,
|
||||
device: Option<&Device>,
|
||||
|
@ -505,12 +511,12 @@ where
|
|||
}
|
||||
|
||||
/// Notes that the author style has been disabled for this document.
|
||||
pub fn set_author_style_disabled(&mut self, disabled: bool) {
|
||||
debug!("DocumentStylesheetSet::set_author_style_disabled");
|
||||
if self.author_style_disabled == disabled {
|
||||
pub fn set_author_styles_enabled(&mut self, enabled: AuthorStylesEnabled) {
|
||||
debug!("DocumentStylesheetSet::set_author_styles_enabled");
|
||||
if self.author_styles_enabled == enabled {
|
||||
return;
|
||||
}
|
||||
self.author_style_disabled = disabled;
|
||||
self.author_styles_enabled = enabled;
|
||||
self.invalidations.invalidate_fully();
|
||||
self.collections.borrow_mut_for_origin(&Origin::Author)
|
||||
.set_data_validity_at_least(DataValidity::FullyInvalid)
|
||||
|
@ -554,7 +560,7 @@ where
|
|||
|
||||
StylesheetFlusher {
|
||||
collections: &mut self.collections,
|
||||
author_style_disabled: self.author_style_disabled,
|
||||
author_styles_enabled: self.author_styles_enabled,
|
||||
had_invalidations,
|
||||
origins_dirty,
|
||||
origin_data_validity,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue