Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSSOM: Make Stylesheet fields have their own synchronization #14232

Merged
merged 5 commits into from Nov 22, 2016
Next

CSSOM: Add Arc<RwLock<_>> around Stylesheet.media

  • Loading branch information
SimonSapin committed Nov 18, 2016
commit 8eeaef5b1ca572249e476258eb45cadd1f04cfb2
@@ -57,7 +57,7 @@ pub struct Stylesheet {
/// cascading order)
pub rules: CssRules,
/// List of media associated with the Stylesheet.
pub media: MediaList,
pub media: Arc<RwLock<MediaList>>,
pub origin: Origin,
pub dirty_on_viewport_size_change: bool,
}
@@ -228,23 +228,23 @@ impl Stylesheet {
Stylesheet {
origin: origin,
rules: rules.into(),
media: Default::default(),
media: Arc::new(RwLock::new(Default::default())),
dirty_on_viewport_size_change:
input.seen_viewport_percentages(),
}
}

/// Set the MediaList associated with the style-sheet.
pub fn set_media(&mut self, media: MediaList) {
self.media = media;
*self.media.write() = media;
}

/// Returns whether the style-sheet applies for the current device depending
/// on the associated MediaList.
///
/// Always true if no associated MediaList exists.
pub fn is_effective_for_device(&self, device: &Device) -> bool {
self.media.evaluate(device)
self.media.read().evaluate(device)
}

/// Return an iterator over the effective rules within the style-sheet, as
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.