mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1850370 - [css-properties-values-api] Pass stylist to substitute_block r=zsun,emilio
This will be used in order to perform computed value-time validation. Differential Revision: https://phabricator.services.mozilla.com/D186966
This commit is contained in:
parent
a9a671d58b
commit
a4592ed7e4
@ -687,7 +687,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||
unparsed_value,
|
||||
map,
|
||||
self.inherited.map(|m| &**m),
|
||||
self.stylist.device(),
|
||||
self.stylist,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -982,7 +982,7 @@ fn substitute_all(
|
||||
&value,
|
||||
&mut context.map,
|
||||
context.inherited,
|
||||
context.stylist.device(),
|
||||
context.stylist,
|
||||
);
|
||||
|
||||
// All resolved, so return the signal value.
|
||||
@ -1012,7 +1012,7 @@ fn substitute_references_in_value_and_apply(
|
||||
value: &VariableValue,
|
||||
custom_properties: &mut CustomPropertiesMap,
|
||||
inherited: Option<&CustomPropertiesMap>,
|
||||
device: &Device,
|
||||
stylist: &Stylist,
|
||||
) {
|
||||
debug_assert!(value.has_references());
|
||||
|
||||
@ -1028,7 +1028,7 @@ fn substitute_references_in_value_and_apply(
|
||||
&mut position,
|
||||
&mut computed_value,
|
||||
custom_properties,
|
||||
device,
|
||||
stylist,
|
||||
);
|
||||
|
||||
let last_token_type = match last_token_type {
|
||||
@ -1099,7 +1099,7 @@ fn substitute_block<'i>(
|
||||
position: &mut (SourcePosition, TokenSerializationType),
|
||||
partial_computed_value: &mut ComputedValue,
|
||||
custom_properties: &CustomPropertiesMap,
|
||||
device: &Device,
|
||||
stylist: &Stylist,
|
||||
) -> Result<TokenSerializationType, ParseError<'i>> {
|
||||
let mut last_token_type = TokenSerializationType::nothing();
|
||||
let mut set_position_at_next_iteration = false;
|
||||
@ -1145,6 +1145,7 @@ fn substitute_block<'i>(
|
||||
|
||||
let env_value;
|
||||
let value = if is_env {
|
||||
let device = stylist.device();
|
||||
if let Some(v) = device.environment().get(&name, device) {
|
||||
env_value = v;
|
||||
Some(&env_value)
|
||||
@ -1179,7 +1180,7 @@ fn substitute_block<'i>(
|
||||
&mut position,
|
||||
partial_computed_value,
|
||||
custom_properties,
|
||||
device,
|
||||
stylist,
|
||||
)?;
|
||||
partial_computed_value.push_from(input, position, last_token_type)?;
|
||||
}
|
||||
@ -1197,7 +1198,7 @@ fn substitute_block<'i>(
|
||||
position,
|
||||
partial_computed_value,
|
||||
custom_properties,
|
||||
device,
|
||||
stylist,
|
||||
)
|
||||
})?;
|
||||
// It's the same type for CloseCurlyBracket and CloseSquareBracket.
|
||||
@ -1223,7 +1224,7 @@ pub fn substitute<'i>(
|
||||
input: &'i str,
|
||||
first_token_type: TokenSerializationType,
|
||||
computed_values_map: Option<&Arc<CustomPropertiesMap>>,
|
||||
device: &Device,
|
||||
stylist: &Stylist,
|
||||
) -> Result<String, ParseError<'i>> {
|
||||
let mut substituted = ComputedValue::empty();
|
||||
let mut input = ParserInput::new(input);
|
||||
@ -1239,7 +1240,7 @@ pub fn substitute<'i>(
|
||||
&mut position,
|
||||
&mut substituted,
|
||||
&custom_properties,
|
||||
device,
|
||||
stylist,
|
||||
)?;
|
||||
substituted.push_from(&input, position, last_token_type)?;
|
||||
Ok(substituted.css)
|
||||
|
@ -605,12 +605,16 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
debug_assert!(
|
||||
self.context.builder.stylist.is_some(),
|
||||
"Need a Stylist to substitute variables!"
|
||||
);
|
||||
declaration.value.substitute_variables(
|
||||
declaration.id,
|
||||
self.context.builder.writing_mode,
|
||||
self.context.builder.custom_properties(),
|
||||
self.context.quirks_mode,
|
||||
self.context.device(),
|
||||
self.context.builder.stylist.unwrap(),
|
||||
cache,
|
||||
)
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ impl PropertyDeclarationBlock {
|
||||
computed_values.writing_mode,
|
||||
custom_properties.as_ref(),
|
||||
QuirksMode::NoQuirks,
|
||||
stylist.device(),
|
||||
stylist,
|
||||
&mut Default::default(),
|
||||
)
|
||||
.to_css(dest)
|
||||
|
@ -368,12 +368,16 @@ impl AnimationValue {
|
||||
let custom_properties =
|
||||
extra_custom_properties.or_else(|| context.style().custom_properties());
|
||||
|
||||
debug_assert!(
|
||||
context.builder.stylist.is_some(),
|
||||
"Need a Stylist to substitute variables!"
|
||||
);
|
||||
declaration.value.substitute_variables(
|
||||
declaration.id,
|
||||
context.builder.writing_mode,
|
||||
custom_properties,
|
||||
context.quirks_mode,
|
||||
context.device(),
|
||||
context.builder.stylist.unwrap(),
|
||||
&mut cache,
|
||||
)
|
||||
};
|
||||
|
@ -1687,7 +1687,7 @@ impl UnparsedValue {
|
||||
writing_mode: WritingMode,
|
||||
custom_properties: Option<<&Arc<crate::custom_properties::CustomPropertiesMap>>,
|
||||
quirks_mode: QuirksMode,
|
||||
device: &Device,
|
||||
stylist: &Stylist,
|
||||
shorthand_cache: &'cache mut ShorthandsWithPropertyReferencesCache,
|
||||
) -> Cow<'cache, PropertyDeclaration> {
|
||||
let invalid_at_computed_value_time = || {
|
||||
@ -1714,7 +1714,7 @@ impl UnparsedValue {
|
||||
&self.css,
|
||||
self.first_token_type,
|
||||
custom_properties,
|
||||
device,
|
||||
stylist,
|
||||
) {
|
||||
Ok(css) => css,
|
||||
Err(..) => return invalid_at_computed_value_time(),
|
||||
|
Loading…
Reference in New Issue
Block a user