Bug 893331 - Relax assert checking if value is within range for nsRangeFrame. r=TYLin

GetValueAsFractionOfRange asserts that input == minimum if the range has maximum
<= minimum. This assert is sane at face value, but floating point rounding
issues can cause it to be triggered when input is essentially minimum.

This changeset relaxes the assertion to check the input is within an epsilon
value of minimum.

Differential Revision: https://phabricator.services.mozilla.com/D10648

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bryce Van Dyk 2018-11-02 21:30:49 +00:00
Родитель cd9f025985
Коммит 2f64c0934b
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -493,7 +493,10 @@ nsRangeFrame::GetValueAsFractionOfRange()
"type=range should have a default maximum/minimum");
if (maximum <= minimum) {
MOZ_ASSERT(value == minimum, "Unsanitized value");
// Avoid rounding triggering the assert by checking against an epsilon.
MOZ_ASSERT((value - minimum).abs().toDouble() <
std::numeric_limits<float>::epsilon(),
"Unsanitized value");
return 0.0;
}