Bug 1496194 - Fix the MoveBy(Point) implementation in RectAbsolute. r=botond

RectAbsolute contained a MoveBy(Point) function where Point was not a
template parameter but the actual gfx::Point type. This seems to be an
unintentional copy/paste error. This patch fixes it to be properly
templated.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2018-12-21 22:11:26 +00:00
Родитель 1424a0b4a5
Коммит 04689eb8ea
2 изменённых файлов: 13 добавлений и 14 удалений

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

@ -11,6 +11,7 @@
#include <cstdint>
#include "mozilla/Attributes.h"
#include "Point.h"
#include "Rect.h"
#include "Types.h"
@ -33,7 +34,7 @@ namespace gfx {
* Do not use this class directly. Subclass it, pass that subclass as the
* Sub parameter, and only use that subclass.
*/
template <class T, class Sub, class Rect>
template <class T, class Sub, class Point, class Rect>
struct BaseRectAbsolute {
protected:
T left, top, right, bottom;
@ -243,12 +244,12 @@ struct BaseRectAbsolute {
template <class Units>
struct IntRectAbsoluteTyped
: public BaseRectAbsolute<int32_t, IntRectAbsoluteTyped<Units>,
IntRectTyped<Units>>,
IntPointTyped<Units>, IntRectTyped<Units>>,
public Units {
static_assert(IsPixel<Units>::value,
"'units' must be a coordinate system tag");
typedef BaseRectAbsolute<int32_t, IntRectAbsoluteTyped<Units>,
IntRectTyped<Units>>
IntPointTyped<Units>, IntRectTyped<Units>>
Super;
typedef IntParam<int32_t> ToInt;
@ -260,11 +261,12 @@ struct IntRectAbsoluteTyped
template <class Units>
struct RectAbsoluteTyped
: public BaseRectAbsolute<Float, RectAbsoluteTyped<Units>,
RectTyped<Units>>,
PointTyped<Units>, RectTyped<Units>>,
public Units {
static_assert(IsPixel<Units>::value,
"'units' must be a coordinate system tag");
typedef BaseRectAbsolute<Float, RectAbsoluteTyped<Units>, RectTyped<Units>>
typedef BaseRectAbsolute<Float, RectAbsoluteTyped<Units>, PointTyped<Units>,
RectTyped<Units>>
Super;
RectAbsoluteTyped() : Super() {}

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

@ -9,11 +9,15 @@
#include "mozilla/gfx/RectAbsolute.h"
#include "nsCoord.h"
#include "nsPoint.h"
#include "nsRect.h"
struct nsRectAbsolute
: public mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsRect> {
typedef mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsRect> Super;
: public mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsPoint,
nsRect> {
typedef mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsPoint,
nsRect>
Super;
nsRectAbsolute() : Super() {}
nsRectAbsolute(nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2)
@ -40,13 +44,6 @@ struct nsRectAbsolute
return Super::Union(aRect);
}
MOZ_ALWAYS_INLINE void MoveBy(const nsPoint& aPoint) {
left += aPoint.x;
right += aPoint.x;
top += aPoint.y;
bottom += aPoint.y;
}
void Inflate(const nsMargin& aMargin) {
left -= aMargin.left;
top -= aMargin.top;