mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Issue #2713 - Check for NaN before std::min/max() in DOMQuad and DOMRect.
If there is a NaN involved we should not return 0 here.
This commit is contained in:
parent
8f2f4d8d3d
commit
f1c456c625
3 changed files with 35 additions and 10 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -450,6 +451,30 @@ EqualOrBothNaN(T aValue1, T aValue2)
|
|||
return aValue1 == aValue2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return NaN if either |aValue1| or |aValue2| is NaN, or the minimum of
|
||||
* |aValue1| and |aValue2| otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T NaNSafeMin(T aValue1, T aValue2) {
|
||||
if (IsNaN(aValue1) || IsNaN(aValue2)) {
|
||||
return UnspecifiedNaN<T>();
|
||||
}
|
||||
return std::min(aValue1, aValue2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return NaN if either |aValue1| or |aValue2| is NaN, or the maximum of
|
||||
* |aValue1| and |aValue2| otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T NaNSafeMax(T aValue1, T aValue2) {
|
||||
if (IsNaN(aValue1) || IsNaN(aValue2)) {
|
||||
return UnspecifiedNaN<T>();
|
||||
}
|
||||
return std::max(aValue1, aValue2);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue