зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1800530 - Add CoordTyped overloads of FuzzyEqualsAdditive/Multiplicative. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D162221
This commit is contained in:
Родитель
f24fdbc09c
Коммит
5cc3982303
|
@ -8,6 +8,7 @@
|
|||
#define MOZILLA_GFX_COORD_H_
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "Types.h"
|
||||
#include "BaseCoord.h"
|
||||
|
||||
|
@ -152,6 +153,24 @@ struct MOZ_EMPTY_BASES CoordTyped
|
|||
typedef CoordTyped<UnknownUnits> Coord;
|
||||
|
||||
} // namespace gfx
|
||||
|
||||
template <class Units, class F>
|
||||
static MOZ_ALWAYS_INLINE bool FuzzyEqualsAdditive(
|
||||
gfx::CoordTyped<Units, F> aValue1, gfx::CoordTyped<Units, F> aValue2,
|
||||
gfx::CoordTyped<Units, F> aEpsilon =
|
||||
detail::FuzzyEqualsEpsilon<F>::value()) {
|
||||
return FuzzyEqualsAdditive(aValue1.value, aValue2.value, aEpsilon.value);
|
||||
}
|
||||
|
||||
template <class Units, class F>
|
||||
static MOZ_ALWAYS_INLINE bool FuzzyEqualsMultiplicative(
|
||||
gfx::CoordTyped<Units, F> aValue1, gfx::CoordTyped<Units, F> aValue2,
|
||||
gfx::CoordTyped<Units, F> aEpsilon =
|
||||
detail::FuzzyEqualsEpsilon<F>::value()) {
|
||||
return FuzzyEqualsMultiplicative(aValue1.value, aValue2.value,
|
||||
aEpsilon.value);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* MOZILLA_GFX_COORD_H_ */
|
||||
|
|
|
@ -77,8 +77,8 @@ inline bool ScrollSourceAllowsOverscroll(ScrollSource aSource) {
|
|||
const CSSCoord COORDINATE_EPSILON = 0.01f;
|
||||
|
||||
inline bool IsZero(const CSSPoint& aPoint) {
|
||||
return FuzzyEqualsAdditive(aPoint.x.value, 0.0f, COORDINATE_EPSILON.value) &&
|
||||
FuzzyEqualsAdditive(aPoint.y.value, 0.0f, COORDINATE_EPSILON.value);
|
||||
return FuzzyEqualsAdditive(aPoint.x, CSSCoord(), COORDINATE_EPSILON) &&
|
||||
FuzzyEqualsAdditive(aPoint.y, CSSCoord(), COORDINATE_EPSILON);
|
||||
}
|
||||
|
||||
// Represents async transforms consisting of a scale and a translation.
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
#include "mozilla/layers/APZPublicUtils.h" // for GetScrollMode
|
||||
#include "mozilla/mozalloc.h" // for operator new, etc
|
||||
#include "mozilla/Unused.h" // for unused
|
||||
#include "mozilla/FloatingPoint.h" // for FuzzyEquals*
|
||||
#include "nsAlgorithm.h" // for clamped
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsDebug.h" // for NS_WARNING
|
||||
|
@ -564,8 +563,7 @@ bool AsyncPanZoomController::IsZero(ParentLayerCoord aCoord) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
return FuzzyEqualsAdditive((aCoord / zoom).value, 0.0f,
|
||||
COORDINATE_EPSILON.value);
|
||||
return FuzzyEqualsAdditive((aCoord / zoom), CSSCoord(), COORDINATE_EPSILON);
|
||||
}
|
||||
|
||||
bool AsyncPanZoomController::FuzzyGreater(ParentLayerCoord aCoord1,
|
||||
|
@ -5216,11 +5214,10 @@ void AsyncPanZoomController::NotifyLayersUpdated(
|
|||
// XXX Suspicious comparison between layout and visual scroll offsets.
|
||||
// This may not do the right thing when we're zoomed in.
|
||||
CSSPoint lastScrollOffset = mLastContentPaintMetrics.GetLayoutScrollOffset();
|
||||
bool userScrolled =
|
||||
!FuzzyEqualsAdditive(Metrics().GetVisualScrollOffset().x.value,
|
||||
lastScrollOffset.x.value) ||
|
||||
!FuzzyEqualsAdditive(Metrics().GetVisualScrollOffset().y.value,
|
||||
lastScrollOffset.y.value);
|
||||
bool userScrolled = !FuzzyEqualsAdditive(Metrics().GetVisualScrollOffset().x,
|
||||
lastScrollOffset.x) ||
|
||||
!FuzzyEqualsAdditive(Metrics().GetVisualScrollOffset().y,
|
||||
lastScrollOffset.y);
|
||||
|
||||
if (aScrollMetadata.DidContentGetPainted()) {
|
||||
mLastContentPaintMetadata = aScrollMetadata;
|
||||
|
@ -5340,9 +5337,8 @@ void AsyncPanZoomController::NotifyLayersUpdated(
|
|||
// TODO: Rely entirely on |aScrollMetadata.IsResolutionUpdated()| to
|
||||
// determine which branch to take, and drop the other conditions.
|
||||
if (FuzzyEqualsAdditive(
|
||||
Metrics().GetCompositionBoundsWidthIgnoringScrollbars().value,
|
||||
aLayerMetrics.GetCompositionBoundsWidthIgnoringScrollbars()
|
||||
.value) &&
|
||||
Metrics().GetCompositionBoundsWidthIgnoringScrollbars(),
|
||||
aLayerMetrics.GetCompositionBoundsWidthIgnoringScrollbars()) &&
|
||||
Metrics().GetDevPixelsPerCSSPixel() ==
|
||||
aLayerMetrics.GetDevPixelsPerCSSPixel() &&
|
||||
!viewportSizeUpdated && !aScrollMetadata.IsResolutionUpdated()) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread
|
||||
#include "mozilla/mozalloc.h" // for operator new
|
||||
#include "mozilla/FloatingPoint.h" // for FuzzyEqualsAdditive
|
||||
#include "nsMathUtils.h" // for NS_lround
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
#include "nsThreadUtils.h" // for NS_DispatchToMainThread, etc
|
||||
|
@ -31,9 +30,8 @@ namespace mozilla {
|
|||
namespace layers {
|
||||
|
||||
bool FuzzyEqualsCoordinate(CSSCoord aValue1, CSSCoord aValue2) {
|
||||
return FuzzyEqualsAdditive(aValue1.value, aValue2.value,
|
||||
COORDINATE_EPSILON.value) ||
|
||||
FuzzyEqualsMultiplicative(aValue1.value, aValue2.value);
|
||||
return FuzzyEqualsAdditive(aValue1, aValue2, COORDINATE_EPSILON) ||
|
||||
FuzzyEqualsMultiplicative(aValue1, aValue2);
|
||||
}
|
||||
|
||||
Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
|
||||
|
|
|
@ -92,10 +92,8 @@ void SampledAPZCState::RemoveFractionalAsyncDelta() {
|
|||
const ParentLayerCoord EPSILON = 0.01;
|
||||
ParentLayerPoint paintedOffset = mLayoutViewport.TopLeft() * mZoom;
|
||||
ParentLayerPoint asyncOffset = mVisualScrollOffset * mZoom;
|
||||
if (FuzzyEqualsAdditive(paintedOffset.x.value, asyncOffset.x.value,
|
||||
EPSILON.value) &&
|
||||
FuzzyEqualsAdditive(paintedOffset.y.value, asyncOffset.y.value,
|
||||
EPSILON.value)) {
|
||||
if (FuzzyEqualsAdditive(paintedOffset.x, asyncOffset.x, EPSILON) &&
|
||||
FuzzyEqualsAdditive(paintedOffset.y, asyncOffset.y, EPSILON)) {
|
||||
mVisualScrollOffset = mLayoutViewport.TopLeft();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -879,10 +879,10 @@ struct PaintLinearGradient : public PaintPatternBase {
|
|||
p2 += v * firstStop;
|
||||
}
|
||||
Point p3;
|
||||
if (FuzzyEqualsMultiplicative(p2.y.value, p0.y.value)) {
|
||||
if (FuzzyEqualsMultiplicative(p2.y, p0.y)) {
|
||||
// rotation vector is horizontal
|
||||
p3 = Point(p0.x, p1.y);
|
||||
} else if (FuzzyEqualsMultiplicative(p2.x.value, p0.x.value)) {
|
||||
} else if (FuzzyEqualsMultiplicative(p2.x, p0.x)) {
|
||||
// rotation vector is vertical
|
||||
p3 = Point(p1.x, p0.y);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче