diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index fbad32d8d9f..0277842262e 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -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>, origin_data_validity: PerOrigin, - 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 DocumentStylesheetSet @@ -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, diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 6494b4f35b6..160c70df673 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -41,7 +41,7 @@ use smallvec::SmallVec; use std::ops; use std::sync::Mutex; use style_traits::viewport::ViewportConstraints; -use stylesheet_set::{DataValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher}; +use stylesheet_set::{AuthorStylesEnabled, DataValidity, SheetRebuildKind, DocumentStylesheetSet, StylesheetFlusher}; #[cfg(feature = "gecko")] use stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule}; use stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter}; @@ -592,8 +592,8 @@ impl Stylist { } /// Sets whether author style is enabled or not. - pub fn set_author_style_disabled(&mut self, disabled: bool) { - self.stylesheets.set_author_style_disabled(disabled); + pub fn set_author_styles_enabled(&mut self, enabled: AuthorStylesEnabled) { + self.stylesheets.set_author_styles_enabled(enabled); } /// Returns whether we've recorded any stylesheet change so far. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index f2b3cd531d2..94a46e3395f 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -135,6 +135,7 @@ use style::selector_parser::{PseudoElementCascadeType, SelectorImpl}; use style::shared_lock::{SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked}; use style::string_cache::{Atom, WeakAtom}; use style::style_adjuster::StyleAdjuster; +use style::stylesheet_set::AuthorStylesEnabled; use style::stylesheets::{CssRule, CssRules, CssRuleType, CssRulesHelpers, DocumentRule}; use style::stylesheets::{FontFeatureValuesRule, ImportRule, KeyframesRule, MediaRule}; use style::stylesheets::{NamespaceRule, Origin, OriginSet, PageRule, StyleRule}; @@ -1252,7 +1253,13 @@ pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged( ) { let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut(); data.stylist.force_stylesheet_origins_dirty(OriginSet::from(changed_origins)); - data.stylist.set_author_style_disabled(author_style_disabled); + let enabled = + if author_style_disabled { + AuthorStylesEnabled::No + } else { + AuthorStylesEnabled::Yes + }; + data.stylist.set_author_styles_enabled(enabled); } #[no_mangle]