зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1145345
- Account for a greater variety of rounding errors when comparing coordinates. r=kats
--HG-- extra : source : af3b6caa84116a5f95783ed9262326f4917b6b90
This commit is contained in:
Родитель
3b412c43dd
Коммит
9bef23d187
|
@ -372,8 +372,8 @@ static bool IsCloseToVertical(float aAngle, float aThreshold)
|
|||
template <typename Units>
|
||||
static bool IsZero(const gfx::PointTyped<Units>& aPoint)
|
||||
{
|
||||
return FuzzyEqualsMultiplicative(aPoint.x, 0.0f)
|
||||
&& FuzzyEqualsMultiplicative(aPoint.y, 0.0f);
|
||||
return FuzzyEqualsAdditive(aPoint.x, 0.0f)
|
||||
&& FuzzyEqualsAdditive(aPoint.y, 0.0f);
|
||||
}
|
||||
|
||||
static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const char* aDesc, const char* aColor, const CSSRect& aRect)
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
bool FuzzyEqualsCoordinate(float aValue1, float aValue2)
|
||||
{
|
||||
return FuzzyEqualsAdditive(aValue1, aValue2, COORDINATE_EPSILON)
|
||||
|| FuzzyEqualsMultiplicative(aValue1, aValue2);
|
||||
}
|
||||
|
||||
extern StaticAutoPtr<ComputedTimingFunction> gVelocityCurveFunction;
|
||||
|
||||
Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
|
||||
|
@ -180,8 +186,8 @@ void Axis::OverscrollBy(ParentLayerCoord aOverscroll) {
|
|||
aOverscroll = ApplyResistance(aOverscroll);
|
||||
if (aOverscroll > 0) {
|
||||
#ifdef DEBUG
|
||||
if (!FuzzyEqualsAdditive(GetCompositionEnd().value, GetPageEnd().value, COORDINATE_EPSILON)) {
|
||||
nsPrintfCString message("composition end (%f) is not within COORDINATE_EPISLON of page end (%f)\n",
|
||||
if (!FuzzyEqualsCoordinate(GetCompositionEnd().value, GetPageEnd().value)) {
|
||||
nsPrintfCString message("composition end (%f) is not equal (within error) to page end (%f)\n",
|
||||
GetCompositionEnd().value, GetPageEnd().value);
|
||||
NS_ASSERTION(false, message.get());
|
||||
MOZ_CRASH();
|
||||
|
@ -190,8 +196,8 @@ void Axis::OverscrollBy(ParentLayerCoord aOverscroll) {
|
|||
MOZ_ASSERT(mOverscroll >= 0);
|
||||
} else if (aOverscroll < 0) {
|
||||
#ifdef DEBUG
|
||||
if (!FuzzyEqualsAdditive(GetOrigin().value, GetPageStart().value, COORDINATE_EPSILON)) {
|
||||
nsPrintfCString message("composition origin (%f) is not within COORDINATE_EPISLON of page origin (%f)\n",
|
||||
if (!FuzzyEqualsCoordinate(GetOrigin().value, GetPageStart().value)) {
|
||||
nsPrintfCString message("composition origin (%f) is not equal (within error) to page origin (%f)\n",
|
||||
GetOrigin().value, GetPageStart().value);
|
||||
NS_ASSERTION(false, message.get());
|
||||
MOZ_CRASH();
|
||||
|
|
|
@ -25,6 +25,16 @@ const float EPSILON = 0.0001f;
|
|||
// isn't too large.
|
||||
const float COORDINATE_EPSILON = 0.01f;
|
||||
|
||||
/**
|
||||
* Compare two coordinates for equality, accounting for rounding error.
|
||||
* Use both FuzzyEqualsAdditive() with COORDINATE_EPISLON, which accounts for
|
||||
* things like the error introduced by rounding during a round-trip to app
|
||||
* units, and FuzzyEqualsMultiplicative(), which accounts for accumulated error
|
||||
* due to floating-point operations (which can be larger than COORDINATE_EPISLON
|
||||
* for sufficiently large coordinate values).
|
||||
*/
|
||||
bool FuzzyEqualsCoordinate(float aValue1, float aValue2);
|
||||
|
||||
struct FrameMetrics;
|
||||
class AsyncPanZoomController;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче