style: Always use CssEnvironment from media query's device.

Although CssEnvironment is in Device of media query implementation, some code
creates CssEnvironment instance without Device. So I would like always to use it from Device of media query.

Differential Revision: https://phabricator.services.mozilla.com/D52506
This commit is contained in:
Makoto Kato 2020-01-08 11:55:28 +00:00 committed by Emilio Cobos Álvarez
parent 88fe64d845
commit c5bd98354d
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A

View file

@ -778,6 +778,7 @@ impl PropertyDeclarationBlock {
dest: &mut CssStringWriter, dest: &mut CssStringWriter,
computed_values: Option<&ComputedValues>, computed_values: Option<&ComputedValues>,
custom_properties_block: Option<&PropertyDeclarationBlock>, custom_properties_block: Option<&PropertyDeclarationBlock>,
environment: &CssEnvironment,
) -> fmt::Result { ) -> fmt::Result {
if let Ok(shorthand) = property.as_shorthand() { if let Ok(shorthand) = property.as_shorthand() {
return self.shorthand_to_css(shorthand, dest); return self.shorthand_to_css(shorthand, dest);
@ -790,19 +791,13 @@ impl PropertyDeclarationBlock {
None => return Err(fmt::Error), None => return Err(fmt::Error),
}; };
// TODO(emilio): When we implement any environment variable without
// hard-coding the values we're going to need to get something
// meaningful out of here... All this code path is so terribly hacky
// ;_;.
let env = CssEnvironment;
let custom_properties = if let Some(cv) = computed_values { let custom_properties = if let Some(cv) = computed_values {
// If there are extra custom properties for this declaration block, // If there are extra custom properties for this declaration block,
// factor them in too. // factor them in too.
if let Some(block) = custom_properties_block { if let Some(block) = custom_properties_block {
// FIXME(emilio): This is not super-efficient here, and all this // FIXME(emilio): This is not super-efficient here, and all this
// feels like a hack anyway... // feels like a hack anyway...
block.cascade_custom_properties(cv.custom_properties(), &env) block.cascade_custom_properties(cv.custom_properties(), environment)
} else { } else {
cv.custom_properties().cloned() cv.custom_properties().cloned()
} }
@ -825,7 +820,7 @@ impl PropertyDeclarationBlock {
declaration.id, declaration.id,
custom_properties.as_ref(), custom_properties.as_ref(),
QuirksMode::NoQuirks, QuirksMode::NoQuirks,
&env, environment,
) )
.to_css(dest) .to_css(dest)
}, },