Bug 1860205 - Swap Up/Down rounding strategy when negating a Round calc node. r=firefox-style-system-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D192742
This commit is contained in:
Jonathan Kew 2023-11-03 22:29:06 +00:00
parent 8c314b4aff
commit 092e43b900

View File

@ -566,10 +566,23 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
}
},
CalcNode::Round {
ref mut strategy,
ref mut value,
ref mut step,
..
} => {
match *strategy {
RoundingStrategy::Nearest => {
// Nearest is tricky because we'd have to swap the
// behavior at the half-way point from using the upper
// to lower bound.
// Simpler to just wrap self in a negate node.
wrap_self_in_negate(self);
return;
},
RoundingStrategy::Up => *strategy = RoundingStrategy::Down,
RoundingStrategy::Down => *strategy = RoundingStrategy::Up,
RoundingStrategy::ToZero => (),
}
value.negate();
step.negate();
},