mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Replace Stylesheet::set_media with a constructor argument
This commit is contained in:
parent
f4dcc38816
commit
236c575c50
8 changed files with 29 additions and 31 deletions
|
@ -174,15 +174,17 @@ impl Stylesheet {
|
|||
base_url: ServoUrl,
|
||||
protocol_encoding_label: Option<&str>,
|
||||
environment_encoding: Option<EncodingRef>,
|
||||
origin: Origin, error_reporter: Box<ParseErrorReporter + Send>,
|
||||
origin: Origin,
|
||||
media: MediaList,
|
||||
error_reporter: Box<ParseErrorReporter + Send>,
|
||||
extra_data: ParserContextExtraData)
|
||||
-> Stylesheet {
|
||||
let (string, _) = decode_stylesheet_bytes(
|
||||
bytes, protocol_encoding_label, environment_encoding);
|
||||
Stylesheet::from_str(&string, base_url, origin, error_reporter, extra_data)
|
||||
Stylesheet::from_str(&string, base_url, origin, media, error_reporter, extra_data)
|
||||
}
|
||||
|
||||
pub fn from_str(css: &str, base_url: ServoUrl, origin: Origin,
|
||||
pub fn from_str(css: &str, base_url: ServoUrl, origin: Origin, media: MediaList,
|
||||
error_reporter: Box<ParseErrorReporter + Send>,
|
||||
extra_data: ParserContextExtraData) -> Stylesheet {
|
||||
let rule_parser = TopLevelRuleParser {
|
||||
|
@ -212,17 +214,12 @@ impl Stylesheet {
|
|||
Stylesheet {
|
||||
origin: origin,
|
||||
rules: rules.into(),
|
||||
media: Arc::new(RwLock::new(Default::default())),
|
||||
media: Arc::new(RwLock::new(media)),
|
||||
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.write() = media;
|
||||
}
|
||||
|
||||
/// Returns whether the style-sheet applies for the current device depending
|
||||
/// on the associated MediaList.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue