mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Fix container query evaluation on unsupported axis
We were falling back to viewport size, which is not what the spec says. Differential Revision: https://phabricator.services.mozilla.com/D161132
This commit is contained in:
parent
aba0a4bce0
commit
81ae588ec9
3 changed files with 47 additions and 35 deletions
|
@ -591,6 +591,14 @@ impl QueryFeatureExpression {
|
|||
self.kind
|
||||
.evaluate(v, |v| expect!(Length, v).to_computed_value(context))
|
||||
},
|
||||
Evaluator::OptionalLength(eval) => {
|
||||
let v = match eval(context) {
|
||||
Some(v) => v,
|
||||
None => return false,
|
||||
};
|
||||
self.kind
|
||||
.evaluate(v, |v| expect!(Length, v).to_computed_value(context))
|
||||
},
|
||||
Evaluator::Integer(eval) => {
|
||||
let v = eval(context);
|
||||
self.kind.evaluate(v, |v| *expect!(Integer, v))
|
||||
|
@ -608,6 +616,15 @@ impl QueryFeatureExpression {
|
|||
self.kind
|
||||
.evaluate(ratio, |v| expect!(NumberRatio, v).used_value())
|
||||
},
|
||||
Evaluator::OptionalNumberRatio(eval) => {
|
||||
let ratio = match eval(context) {
|
||||
Some(v) => v,
|
||||
None => return false,
|
||||
};
|
||||
// See above for subtleties here.
|
||||
self.kind
|
||||
.evaluate(ratio, |v| expect!(NumberRatio, v).used_value())
|
||||
},
|
||||
Evaluator::Resolution(eval) => {
|
||||
let v = eval(context).dppx();
|
||||
self.kind.evaluate(v, |v| {
|
||||
|
@ -686,7 +703,7 @@ impl QueryExpressionValue {
|
|||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<QueryExpressionValue, ParseError<'i>> {
|
||||
Ok(match for_feature.evaluator {
|
||||
Evaluator::Length(..) => {
|
||||
Evaluator::OptionalLength(..) | Evaluator::Length(..) => {
|
||||
let length = Length::parse_non_negative(context, input)?;
|
||||
QueryExpressionValue::Length(length)
|
||||
},
|
||||
|
@ -706,7 +723,7 @@ impl QueryExpressionValue {
|
|||
let number = Number::parse(context, input)?;
|
||||
QueryExpressionValue::Float(number.get())
|
||||
},
|
||||
Evaluator::NumberRatio(..) => {
|
||||
Evaluator::OptionalNumberRatio(..) | Evaluator::NumberRatio(..) => {
|
||||
use crate::values::specified::Ratio as SpecifiedRatio;
|
||||
let ratio = SpecifiedRatio::parse(context, input)?;
|
||||
QueryExpressionValue::NumberRatio(Ratio::new(ratio.0.get(), ratio.1.get()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue