Skip to content

Commit

Permalink
CSSOM: Add Arc<RwLock<_>> around Stylesheet.media
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Nov 18, 2016
1 parent cc06363 commit 8eeaef5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/style/stylesheets.rs
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8eeaef5

Please sign in to comment.