Support range media query syntax

This commit is contained in:
Basilisk-Dev 2026-05-11 17:54:07 -04:00 committed by wuggy
commit 667a753448
4 changed files with 62 additions and 6 deletions

View file

@ -283,6 +283,10 @@ nsMediaExpression::Matches(nsPresContext *aPresContext,
return cmp != 1;
case nsMediaExpression::eEqual:
return cmp == 0;
case nsMediaExpression::eMinExclusive:
return cmp == 1;
case nsMediaExpression::eMaxExclusive:
return cmp == -1;
}
NS_NOTREACHED("unexpected mRange");
return false;
@ -487,7 +491,13 @@ nsMediaQuery::AppendToString(nsAString& aString) const
aString.Append(nsDependentAtomString(*feature->mName));
if (expr.mValue.GetUnit() != eCSSUnit_Null) {
aString.AppendLiteral(": ");
if (expr.mRange == nsMediaExpression::eMinExclusive) {
aString.AppendLiteral(" > ");
} else if (expr.mRange == nsMediaExpression::eMaxExclusive) {
aString.AppendLiteral(" < ");
} else {
aString.AppendLiteral(": ");
}
switch (feature->mValueType) {
case nsMediaFeature::eLength:
NS_ASSERTION(expr.mValue.IsLengthUnit(), "bad unit");