mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Don't simplify percentages that resolve to lengths in min/max/clamp
Those can't be ordered at specified / computed value time, since the percentage basis could be negative. Needs tests of course, running through try atm. Differential Revision: https://phabricator.services.mozilla.com/D115591
This commit is contained in:
parent
204cb7a9c0
commit
908c952ab0
2 changed files with 8 additions and 15 deletions
|
@ -607,22 +607,11 @@ impl CalcLengthPercentageLeaf {
|
||||||
impl PartialOrd for CalcLengthPercentageLeaf {
|
impl PartialOrd for CalcLengthPercentageLeaf {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
use self::CalcLengthPercentageLeaf::*;
|
use self::CalcLengthPercentageLeaf::*;
|
||||||
|
// NOTE: Percentages can't be compared reasonably here because the
|
||||||
if std::mem::discriminant(self) != std::mem::discriminant(other) {
|
// percentage basis might be negative, see bug 1709018.
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(&Length(ref one), &Length(ref other)) => one.partial_cmp(other),
|
(&Length(ref one), &Length(ref other)) => one.partial_cmp(other),
|
||||||
(&Percentage(ref one), &Percentage(ref other)) => one.partial_cmp(other),
|
_ => None,
|
||||||
_ => {
|
|
||||||
match *self {
|
|
||||||
Length(..) | Percentage(..) => {},
|
|
||||||
}
|
|
||||||
unsafe {
|
|
||||||
debug_unreachable!("Forgot a branch?");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,12 @@ impl PartialOrd for Leaf {
|
||||||
}
|
}
|
||||||
|
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
|
// NOTE: Percentages can't be compared reasonably here because the
|
||||||
|
// percentage basis might be negative, see bug 1709018.
|
||||||
|
// Conveniently, we only use this for <length-percentage> (for raw
|
||||||
|
// percentages, we go through resolve()).
|
||||||
|
(&Percentage(..), &Percentage(..)) => None,
|
||||||
(&Length(ref one), &Length(ref other)) => one.partial_cmp(other),
|
(&Length(ref one), &Length(ref other)) => one.partial_cmp(other),
|
||||||
(&Percentage(ref one), &Percentage(ref other)) => one.partial_cmp(other),
|
|
||||||
(&Angle(ref one), &Angle(ref other)) => one.degrees().partial_cmp(&other.degrees()),
|
(&Angle(ref one), &Angle(ref other)) => one.degrees().partial_cmp(&other.degrees()),
|
||||||
(&Time(ref one), &Time(ref other)) => one.seconds().partial_cmp(&other.seconds()),
|
(&Time(ref one), &Time(ref other)) => one.seconds().partial_cmp(&other.seconds()),
|
||||||
(&Number(ref one), &Number(ref other)) => one.partial_cmp(other),
|
(&Number(ref one), &Number(ref other)) => one.partial_cmp(other),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue