mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Implement StyleSheet.disabled.
This commit is contained in:
parent
4529435f96
commit
64ff6dc103
10 changed files with 62 additions and 16 deletions
|
@ -113,6 +113,7 @@ pub struct Stylesheet {
|
|||
pub media: Arc<RwLock<MediaList>>,
|
||||
pub origin: Origin,
|
||||
pub dirty_on_viewport_size_change: AtomicBool,
|
||||
pub disabled: AtomicBool,
|
||||
}
|
||||
|
||||
|
||||
|
@ -402,6 +403,7 @@ impl Stylesheet {
|
|||
rules: rules.into(),
|
||||
media: Arc::new(RwLock::new(media)),
|
||||
dirty_on_viewport_size_change: AtomicBool::new(input.seen_viewport_percentages()),
|
||||
disabled: AtomicBool::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,6 +444,20 @@ impl Stylesheet {
|
|||
pub fn effective_rules<F>(&self, device: &Device, mut f: F) where F: FnMut(&CssRule) {
|
||||
effective_rules(&self.rules.0.read(), device, &mut f);
|
||||
}
|
||||
|
||||
/// Returns whether the stylesheet has been explicitly disabled through the CSSOM.
|
||||
pub fn disabled(&self) -> bool {
|
||||
self.disabled.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
/// Records that the stylesheet has been explicitly disabled through the CSSOM.
|
||||
/// Returns whether the the call resulted in a change in disabled state.
|
||||
///
|
||||
/// Disabled stylesheets remain in the document, but their rules are not added to
|
||||
/// the Stylist.
|
||||
pub fn set_disabled(&self, disabled: bool) -> bool {
|
||||
self.disabled.swap(disabled, Ordering::SeqCst) != disabled
|
||||
}
|
||||
}
|
||||
|
||||
fn effective_rules<F>(rules: &[CssRule], device: &Device, f: &mut F) where F: FnMut(&CssRule) {
|
||||
|
|
|
@ -169,7 +169,7 @@ impl Stylist {
|
|||
}
|
||||
|
||||
fn add_stylesheet(&mut self, stylesheet: &Stylesheet) {
|
||||
if !stylesheet.is_effective_for_device(&self.device) {
|
||||
if stylesheet.disabled() || !stylesheet.is_effective_for_device(&self.device) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue