зеркало из https://github.com/mozilla/gecko-dev.git
Bug 865735 - Add a units template parameter to the gfx Point, Size, and Rect classes. r=bas,roc
This commit is contained in:
Родитель
464ef01edb
Коммит
d44a465803
|
@ -20,12 +20,12 @@
|
|||
#include "mozilla/dom/CanvasGradient.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
#include "mozilla/dom/CanvasPattern.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
|
||||
class nsXULElement;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
struct Rect;
|
||||
class SourceSurface;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "nsICanvasElementExternal.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
|
||||
class nsICanvasRenderingContextInternal;
|
||||
class nsIDOMFile;
|
||||
|
@ -28,10 +29,6 @@ class CanvasLayer;
|
|||
class LayerManager;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
struct Rect;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
class HTMLCanvasPrintState;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#define mozilla_BrowserElementHelpers_h
|
||||
|
||||
#include "nsAString.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/gfx/Rect.h"
|
||||
|
||||
class nsIDOMWindow;
|
||||
class nsIURI;
|
||||
|
@ -16,11 +18,6 @@ namespace dom {
|
|||
class TabParent;
|
||||
}
|
||||
|
||||
namespace gfx{
|
||||
struct Rect;
|
||||
struct Size;
|
||||
}
|
||||
|
||||
/**
|
||||
* BrowserElementParent implements a portion of the parent-process side of
|
||||
* <iframe mozbrowser>.
|
||||
|
|
|
@ -13,40 +13,55 @@
|
|||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
struct IntPoint :
|
||||
public BasePoint<int32_t, IntPoint> {
|
||||
typedef BasePoint<int32_t, IntPoint> Super;
|
||||
// This should only be used by the typedefs below.
|
||||
struct UnknownUnits {};
|
||||
|
||||
IntPoint() : Super() {}
|
||||
IntPoint(int32_t aX, int32_t aY) : Super(aX, aY) {}
|
||||
template<class units>
|
||||
struct IntPointTyped :
|
||||
public BasePoint< int32_t, IntPointTyped<units> >,
|
||||
public units {
|
||||
typedef BasePoint< int32_t, IntPointTyped<units> > Super;
|
||||
|
||||
IntPointTyped() : Super() {}
|
||||
IntPointTyped(int32_t aX, int32_t aY) : Super(aX, aY) {}
|
||||
};
|
||||
typedef IntPointTyped<UnknownUnits> IntPoint;
|
||||
|
||||
struct Point :
|
||||
public BasePoint<Float, Point> {
|
||||
typedef BasePoint<Float, Point> Super;
|
||||
template<class units>
|
||||
struct PointTyped :
|
||||
public BasePoint< Float, PointTyped<units> >,
|
||||
public units {
|
||||
typedef BasePoint< Float, PointTyped<units> > Super;
|
||||
|
||||
Point() : Super() {}
|
||||
Point(Float aX, Float aY) : Super(aX, aY) {}
|
||||
Point(const IntPoint& point) : Super(float(point.x), float(point.y)) {}
|
||||
PointTyped() : Super() {}
|
||||
PointTyped(Float aX, Float aY) : Super(aX, aY) {}
|
||||
PointTyped(const IntPointTyped<units>& point) : Super(float(point.x), float(point.y)) {}
|
||||
};
|
||||
typedef PointTyped<UnknownUnits> Point;
|
||||
|
||||
struct IntSize :
|
||||
public BaseSize<int32_t, IntSize> {
|
||||
typedef BaseSize<int32_t, IntSize> Super;
|
||||
template<class units>
|
||||
struct IntSizeTyped :
|
||||
public BaseSize< int32_t, IntSizeTyped<units> >,
|
||||
public units {
|
||||
typedef BaseSize< int32_t, IntSizeTyped<units> > Super;
|
||||
|
||||
IntSize() : Super() {}
|
||||
IntSize(int32_t aWidth, int32_t aHeight) : Super(aWidth, aHeight) {}
|
||||
IntSizeTyped() : Super() {}
|
||||
IntSizeTyped(int32_t aWidth, int32_t aHeight) : Super(aWidth, aHeight) {}
|
||||
};
|
||||
typedef IntSizeTyped<UnknownUnits> IntSize;
|
||||
|
||||
struct Size :
|
||||
public BaseSize<Float, Size> {
|
||||
typedef BaseSize<Float, Size> Super;
|
||||
template<class units>
|
||||
struct SizeTyped :
|
||||
public BaseSize< Float, SizeTyped<units> >,
|
||||
public units {
|
||||
typedef BaseSize< Float, SizeTyped<units> > Super;
|
||||
|
||||
Size() : Super() {}
|
||||
Size(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {}
|
||||
explicit Size(const IntSize& size) :
|
||||
SizeTyped() : Super() {}
|
||||
SizeTyped(Float aWidth, Float aHeight) : Super(aWidth, aHeight) {}
|
||||
explicit SizeTyped(const IntSizeTyped<units>& size) :
|
||||
Super(float(size.width), float(size.height)) {}
|
||||
};
|
||||
typedef SizeTyped<UnknownUnits> Size;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Rect.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
void Rect::NudgeToIntegers()
|
||||
{
|
||||
NudgeToInteger(&x);
|
||||
NudgeToInteger(&y);
|
||||
NudgeToInteger(&width);
|
||||
NudgeToInteger(&height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
#include "BaseRect.h"
|
||||
#include "BaseMargin.h"
|
||||
#include "Point.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
|
@ -24,14 +25,16 @@ struct Margin :
|
|||
: Super(aTop, aRight, aBottom, aLeft) {}
|
||||
};
|
||||
|
||||
struct IntRect :
|
||||
public BaseRect<int32_t, IntRect, IntPoint, IntSize, Margin> {
|
||||
typedef BaseRect<int32_t, IntRect, IntPoint, mozilla::gfx::IntSize, Margin> Super;
|
||||
template<class units>
|
||||
struct IntRectTyped :
|
||||
public BaseRect<int32_t, IntRectTyped<units>, IntPointTyped<units>, IntSizeTyped<units>, Margin>,
|
||||
public units {
|
||||
typedef BaseRect<int32_t, IntRectTyped<units>, IntPointTyped<units>, IntSizeTyped<units>, Margin> Super;
|
||||
|
||||
IntRect() : Super() {}
|
||||
IntRect(IntPoint aPos, mozilla::gfx::IntSize aSize) :
|
||||
IntRectTyped() : Super() {}
|
||||
IntRectTyped(IntPointTyped<units> aPos, IntSizeTyped<units> aSize) :
|
||||
Super(aPos, aSize) {}
|
||||
IntRect(int32_t _x, int32_t _y, int32_t _width, int32_t _height) :
|
||||
IntRectTyped(int32_t _x, int32_t _y, int32_t _width, int32_t _height) :
|
||||
Super(_x, _y, _width, _height) {}
|
||||
|
||||
// Rounding isn't meaningful on an integer rectangle.
|
||||
|
@ -39,30 +42,41 @@ struct IntRect :
|
|||
void RoundIn() {}
|
||||
void RoundOut() {}
|
||||
};
|
||||
typedef IntRectTyped<UnknownUnits> IntRect;
|
||||
|
||||
struct Rect :
|
||||
public BaseRect<Float, Rect, Point, Size, Margin> {
|
||||
typedef BaseRect<Float, Rect, Point, mozilla::gfx::Size, Margin> Super;
|
||||
template<class units>
|
||||
struct RectTyped :
|
||||
public BaseRect<Float, RectTyped<units>, PointTyped<units>, SizeTyped<units>, Margin>,
|
||||
public units {
|
||||
typedef BaseRect<Float, RectTyped<units>, PointTyped<units>, SizeTyped<units>, Margin> Super;
|
||||
|
||||
Rect() : Super() {}
|
||||
Rect(Point aPos, mozilla::gfx::Size aSize) :
|
||||
RectTyped() : Super() {}
|
||||
RectTyped(PointTyped<units> aPos, SizeTyped<units> aSize) :
|
||||
Super(aPos, aSize) {}
|
||||
Rect(Float _x, Float _y, Float _width, Float _height) :
|
||||
RectTyped(Float _x, Float _y, Float _width, Float _height) :
|
||||
Super(_x, _y, _width, _height) {}
|
||||
explicit Rect(const IntRect& rect) :
|
||||
explicit RectTyped(const IntRectTyped<units>& rect) :
|
||||
Super(float(rect.x), float(rect.y),
|
||||
float(rect.width), float(rect.height)) {}
|
||||
|
||||
GFX2D_API void NudgeToIntegers();
|
||||
|
||||
bool ToIntRect(IntRect *aOut) const
|
||||
GFX2D_API void NudgeToIntegers()
|
||||
{
|
||||
*aOut = IntRect(int32_t(X()), int32_t(Y()),
|
||||
int32_t(Width()), int32_t(Height()));
|
||||
return Rect(Float(aOut->x), Float(aOut->y),
|
||||
Float(aOut->width), Float(aOut->height)).IsEqualEdges(*this);
|
||||
NudgeToInteger(&(this->x));
|
||||
NudgeToInteger(&(this->y));
|
||||
NudgeToInteger(&(this->width));
|
||||
NudgeToInteger(&(this->height));
|
||||
}
|
||||
|
||||
bool ToIntRect(IntRectTyped<units> *aOut) const
|
||||
{
|
||||
*aOut = IntRectTyped<units>(int32_t(this->X()), int32_t(this->Y()),
|
||||
int32_t(this->Width()), int32_t(this->Height()));
|
||||
return RectTyped<units>(Float(aOut->x), Float(aOut->y),
|
||||
Float(aOut->width), Float(aOut->height))
|
||||
.IsEqualEdges(*this);
|
||||
}
|
||||
};
|
||||
typedef RectTyped<UnknownUnits> Rect;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ CPP_SOURCES += [
|
|||
'PathCairo.cpp',
|
||||
'PathRecording.cpp',
|
||||
'RecordedEvent.cpp',
|
||||
'Rect.cpp',
|
||||
'Scale.cpp',
|
||||
'ScaledFontBase.cpp',
|
||||
'SourceSurfaceCairo.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче