mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Enable all math functions on chrome code
They should be stable. Not sure this is worth writing a test for since the idea is that this code goes away eventually. Differential Revision: https://phabricator.services.mozilla.com/D176680
This commit is contained in:
parent
a523fffc9e
commit
1182296c4b
8 changed files with 15 additions and 12 deletions
|
@ -260,7 +260,7 @@ impl Angle {
|
|||
}
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
CalcNode::parse_angle(context, input, function)
|
||||
},
|
||||
Token::Number { value, .. } if value == 0. && allow_unitless_zero => Ok(Angle::zero()),
|
||||
|
|
|
@ -456,7 +456,7 @@ impl CalcNode {
|
|||
CalcNode::parse_argument(context, input, allowed_units)
|
||||
}),
|
||||
&Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
CalcNode::parse(context, input, function, allowed_units)
|
||||
},
|
||||
&Token::Ident(ref ident) => {
|
||||
|
@ -905,6 +905,7 @@ impl CalcNode {
|
|||
/// return a mathematical function corresponding to that name or an error.
|
||||
#[inline]
|
||||
pub fn math_function<'i>(
|
||||
context: &ParserContext,
|
||||
name: &CowRcStr<'i>,
|
||||
location: cssparser::SourceLocation,
|
||||
) -> Result<MathFunction, ParseError<'i>> {
|
||||
|
@ -917,7 +918,9 @@ impl CalcNode {
|
|||
},
|
||||
};
|
||||
|
||||
let enabled = if matches!(function, Sin | Cos | Tan | Asin | Acos | Atan | Atan2) {
|
||||
let enabled = if context.chrome_rules_enabled() {
|
||||
true
|
||||
} else if matches!(function, Sin | Cos | Tan | Asin | Acos | Atan | Atan2) {
|
||||
trig_enabled()
|
||||
} else if matches!(function, Round) {
|
||||
round_enabled()
|
||||
|
|
|
@ -556,7 +556,7 @@ impl<'a, 'b: 'a, 'i: 'a> ::cssparser::ColorParser<'i> for ColorParser<'a, 'b> {
|
|||
},
|
||||
Token::Number { value, .. } => Ok(AngleOrNumber::Number { value }),
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(self.0, name, location)?;
|
||||
CalcNode::parse_angle_or_number(self.0, input, function)
|
||||
},
|
||||
t => return Err(location.new_unexpected_token_error(t)),
|
||||
|
@ -585,7 +585,7 @@ impl<'a, 'b: 'a, 'i: 'a> ::cssparser::ColorParser<'i> for ColorParser<'a, 'b> {
|
|||
Ok(NumberOrPercentage::Percentage { unit_value })
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(self.0, name, location)?;
|
||||
CalcNode::parse_number_or_percentage(self.0, input, function)
|
||||
},
|
||||
ref t => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
|
|
|
@ -1307,7 +1307,7 @@ impl Length {
|
|||
))))
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
let calc = CalcNode::parse_length(context, input, num_context, function)?;
|
||||
Ok(Length::Calc(Box::new(calc)))
|
||||
},
|
||||
|
@ -1536,7 +1536,7 @@ impl LengthPercentage {
|
|||
}
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
let calc =
|
||||
CalcNode::parse_length_or_percentage(context, input, num_context, function)?;
|
||||
Ok(LengthPercentage::Calc(Box::new(calc)))
|
||||
|
|
|
@ -199,7 +199,7 @@ fn parse_number_with_clamping_mode<'i, 't>(
|
|||
})
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
let result = CalcNode::parse_number(context, input, function)?;
|
||||
Ok(Number {
|
||||
value: result.min(f32::MAX).max(f32::MIN),
|
||||
|
@ -633,7 +633,7 @@ impl Parse for Integer {
|
|||
int_value: Some(v), ..
|
||||
} => Ok(Integer::new(v)),
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
let result = CalcNode::parse_integer(context, input, function)?;
|
||||
Ok(Integer::from_calc(result))
|
||||
},
|
||||
|
|
|
@ -119,7 +119,7 @@ impl Percentage {
|
|||
Ok(Percentage::new(unit_value))
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
let value = CalcNode::parse_percentage(context, input, function)?;
|
||||
Ok(Percentage {
|
||||
value,
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Parse for Resolution {
|
|||
} => Self::parse_dimension(value, unit)
|
||||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
CalcNode::parse_resolution(context, input, function)
|
||||
},
|
||||
ref t => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
|
|
|
@ -109,7 +109,7 @@ impl Time {
|
|||
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
},
|
||||
Token::Function(ref name) => {
|
||||
let function = CalcNode::math_function(name, location)?;
|
||||
let function = CalcNode::math_function(context, name, location)?;
|
||||
CalcNode::parse_time(context, input, clamping_mode, function)
|
||||
},
|
||||
ref t => return Err(location.new_unexpected_token_error(t.clone())),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue