зеркало из https://github.com/mozilla/gecko-dev.git
Bug 641426. Part 1: Create Point and Size templates. r=joe,sr=cjones
This commit is contained in:
Родитель
7b717f5250
Коммит
3c866720cc
|
@ -42,7 +42,8 @@ class nsIDOMElement;
|
|||
class nsHTMLCanvasElement;
|
||||
class imgIRequest;
|
||||
class gfxASurface;
|
||||
struct gfxIntSize;
|
||||
|
||||
#include "gfxPoint.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASEPOINT_H_
|
||||
#define MOZILLA_BASEPOINT_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BasePoint {
|
||||
T x, y;
|
||||
|
||||
// Constructors
|
||||
BasePoint() : x(0), y(0) {}
|
||||
BasePoint(T aX, T aY) : x(aX), y(aY) {}
|
||||
|
||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aPoint) const {
|
||||
return x == aPoint.x && y == aPoint.y;
|
||||
}
|
||||
bool operator!=(const Sub& aPoint) const {
|
||||
return x != aPoint.x || y != aPoint.y;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aPoint) const {
|
||||
return Sub(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
Sub operator-(const Sub& aPoint) const {
|
||||
return Sub(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
Sub& operator+=(const Sub& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(x * aScale, y * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(x / aScale, y / aScale);
|
||||
}
|
||||
|
||||
Sub operator-() const {
|
||||
return Sub(-x, -y);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASEPOINT_H_ */
|
|
@ -0,0 +1,101 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Corporation code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Robert O'Callahan <robert@ocallahan.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MOZILLA_BASESIZE_H_
|
||||
#define MOZILLA_BASESIZE_H_
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Do not use this class directly. Subclass it, pass that subclass as the
|
||||
* Sub parameter, and only use that subclass. This allows methods to safely
|
||||
* cast 'this' to 'Sub*'.
|
||||
*/
|
||||
template <class T, class Sub>
|
||||
struct BaseSize {
|
||||
T width, height;
|
||||
|
||||
// Constructors
|
||||
BaseSize() : width(0), height(0) {}
|
||||
BaseSize(T aWidth, T aHeight) : width(aWidth), height(aHeight) {}
|
||||
|
||||
void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; }
|
||||
|
||||
// Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
|
||||
bool operator==(const Sub& aSize) const {
|
||||
return width == aSize.width && height == aSize.height;
|
||||
}
|
||||
bool operator!=(const Sub& aSize) const {
|
||||
return width != aSize.width || height != aSize.height;
|
||||
}
|
||||
bool operator<=(const Sub& aSize) const {
|
||||
return width <= aSize.width && height <= aSize.height;
|
||||
}
|
||||
bool operator<(const Sub& aSize) const {
|
||||
return *this <= aSize && *this != aSize;
|
||||
}
|
||||
|
||||
Sub operator+(const Sub& aSize) const {
|
||||
return Sub(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
Sub operator-(const Sub& aSize) const {
|
||||
return Sub(width - aSize.width, height - aSize.height);
|
||||
}
|
||||
Sub& operator+=(const Sub& aSize) {
|
||||
width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
Sub& operator-=(const Sub& aSize) {
|
||||
width -= aSize.width;
|
||||
height -= aSize.height;
|
||||
return *static_cast<Sub*>(this);
|
||||
}
|
||||
|
||||
Sub operator*(T aScale) const {
|
||||
return Sub(width * aScale, height * aScale);
|
||||
}
|
||||
Sub operator/(T aScale) const {
|
||||
return Sub(width / aScale, height / aScale);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_BASESIZE_H_ */
|
|
@ -59,8 +59,16 @@ XPIDLSRCS = \
|
|||
gfxidltypes.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_NAMESPACES = mozilla
|
||||
|
||||
EXPORTS_mozilla = \
|
||||
BasePoint.h \
|
||||
BaseSize.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
gfxCore.h \
|
||||
gfxCrashReporterUtils.h \
|
||||
nsColor.h \
|
||||
nsColorNames.h \
|
||||
nsColorNameList.h \
|
||||
|
@ -79,13 +87,11 @@ EXPORTS = \
|
|||
nsIRegion.h \
|
||||
nsITheme.h \
|
||||
nsThemeConstants.h \
|
||||
gfxCrashReporterUtils.h \
|
||||
nsBoundingMetrics.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11
|
||||
EXPORTS_NAMESPACES = mozilla
|
||||
EXPORTS_mozilla = X11Util.h
|
||||
EXPORTS_mozilla += X11Util.h
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
|
|
|
@ -39,48 +39,18 @@
|
|||
#define NSPOINT_H
|
||||
|
||||
#include "nsCoord.h"
|
||||
#include "mozilla/BaseSize.h"
|
||||
#include "mozilla/BasePoint.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
struct nsIntPoint;
|
||||
|
||||
struct nsPoint {
|
||||
nscoord x, y;
|
||||
struct nsPoint : public mozilla::BasePoint<nscoord, nsPoint> {
|
||||
typedef mozilla::BasePoint<nscoord, nsPoint> Super;
|
||||
|
||||
// Constructors
|
||||
nsPoint() {}
|
||||
nsPoint(const nsPoint& aPoint) { x = aPoint.x; y = aPoint.y;}
|
||||
nsPoint(nscoord aX, nscoord aY) { VERIFY_COORD(aX); VERIFY_COORD(aY); x = aX; y = aY;}
|
||||
|
||||
void MoveTo(nscoord aX, nscoord aY) {x = aX; y = aY;}
|
||||
void MoveBy(nscoord aDx, nscoord aDy) {x += aDx; y += aDy;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsPoint& aPoint) const {
|
||||
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
|
||||
}
|
||||
PRBool operator!=(const nsPoint& aPoint) const {
|
||||
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
|
||||
}
|
||||
nsPoint operator+(const nsPoint& aPoint) const {
|
||||
return nsPoint(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
nsPoint operator-(const nsPoint& aPoint) const {
|
||||
return nsPoint(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
nsPoint& operator+=(const nsPoint& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
nsPoint& operator-=(const nsPoint& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nsPoint operator-() const {
|
||||
return nsPoint(-x, -y);
|
||||
}
|
||||
nsPoint() : Super() {}
|
||||
nsPoint(const nsPoint& aPoint) : Super(aPoint) {}
|
||||
nsPoint(nscoord aX, nscoord aY) : Super(aX, aY) {}
|
||||
|
||||
inline nsIntPoint ToNearestPixels(nscoord aAppUnitsPerPixel) const;
|
||||
|
||||
|
@ -88,40 +58,12 @@ struct nsPoint {
|
|||
inline nsPoint ConvertAppUnits(PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
||||
};
|
||||
|
||||
struct nsIntPoint {
|
||||
PRInt32 x, y;
|
||||
struct nsIntPoint : public mozilla::BasePoint<PRInt32, nsIntPoint> {
|
||||
typedef mozilla::BasePoint<PRInt32, nsIntPoint> Super;
|
||||
|
||||
// Constructors
|
||||
nsIntPoint() {}
|
||||
nsIntPoint(const nsIntPoint& aPoint) { x = aPoint.x; y = aPoint.y;}
|
||||
nsIntPoint(PRInt32 aX, PRInt32 aY) { x = aX; y = aY;}
|
||||
|
||||
PRBool operator==(const nsIntPoint& aPoint) const {
|
||||
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
|
||||
}
|
||||
PRBool operator!=(const nsIntPoint& aPoint) const {
|
||||
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
|
||||
}
|
||||
nsIntPoint operator+(const nsIntPoint& aPoint) const {
|
||||
return nsIntPoint(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
nsIntPoint operator-(const nsIntPoint& aPoint) const {
|
||||
return nsIntPoint(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
nsIntPoint& operator+=(const nsIntPoint& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
nsIntPoint& operator-=(const nsIntPoint& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
nsIntPoint operator-() const {
|
||||
return nsIntPoint(-x, -y);
|
||||
}
|
||||
void MoveTo(PRInt32 aX, PRInt32 aY) {x = aX; y = aY;}
|
||||
nsIntPoint() : Super() {}
|
||||
nsIntPoint(const nsIntPoint& aPoint) : Super(aPoint) {}
|
||||
nsIntPoint(PRInt32 aX, PRInt32 aY) : Super(aX, aY) {}
|
||||
};
|
||||
|
||||
inline nsIntPoint
|
||||
|
|
|
@ -39,65 +39,28 @@
|
|||
#define NSSIZE_H
|
||||
|
||||
#include "nsCoord.h"
|
||||
#include "mozilla/BaseSize.h"
|
||||
|
||||
// Maximum allowable size
|
||||
#define NS_MAXSIZE nscoord_MAX
|
||||
|
||||
struct nsSize {
|
||||
nscoord width, height;
|
||||
struct nsSize : public mozilla::BaseSize<nscoord, nsSize> {
|
||||
typedef mozilla::BaseSize<nscoord, nsSize> Super;
|
||||
|
||||
// Constructors
|
||||
nsSize() {}
|
||||
nsSize(const nsSize& aSize) {width = aSize.width; height = aSize.height;}
|
||||
nsSize(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
|
||||
|
||||
void SizeTo(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
|
||||
void SizeBy(nscoord aDeltaWidth, nscoord aDeltaHeight) {width += aDeltaWidth;
|
||||
height += aDeltaHeight;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsSize& aSize) const {
|
||||
return (PRBool) ((width == aSize.width) && (height == aSize.height));
|
||||
}
|
||||
PRBool operator!=(const nsSize& aSize) const {
|
||||
return (PRBool) ((width != aSize.width) || (height != aSize.height));
|
||||
}
|
||||
nsSize operator+(const nsSize& aSize) const {
|
||||
return nsSize(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
nsSize& operator+=(const nsSize& aSize) {width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *this;}
|
||||
nsSize() : Super() {}
|
||||
nsSize(const nsSize& aSize) : Super(aSize) {}
|
||||
nsSize(nscoord aWidth, nscoord aHeight) : Super(aWidth, aHeight) {}
|
||||
|
||||
// Converts this size from aFromAPP, an appunits per pixel ratio, to aToAPP.
|
||||
inline nsSize ConvertAppUnits(PRInt32 aFromAPP, PRInt32 aToAPP) const;
|
||||
};
|
||||
|
||||
struct nsIntSize {
|
||||
PRInt32 width, height;
|
||||
struct nsIntSize : public mozilla::BaseSize<PRInt32, nsIntSize> {
|
||||
typedef mozilla::BaseSize<PRInt32, nsIntSize> Super;
|
||||
|
||||
nsIntSize() {}
|
||||
nsIntSize(const nsIntSize& aSize) {width = aSize.width; height = aSize.height;}
|
||||
nsIntSize(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsIntSize& aSize) const {
|
||||
return (PRBool) ((width == aSize.width) && (height == aSize.height));
|
||||
}
|
||||
PRBool operator!=(const nsIntSize& aSize) const {
|
||||
return (PRBool) ((width != aSize.width) || (height != aSize.height));
|
||||
}
|
||||
PRBool operator<(const nsIntSize& aSize) const {
|
||||
return (PRBool) (operator<=(aSize) &&
|
||||
(width < aSize.width || height < aSize.height));
|
||||
}
|
||||
PRBool operator<=(const nsIntSize& aSize) const {
|
||||
return (PRBool) ((width <= aSize.width) && (height <= aSize.height));
|
||||
}
|
||||
|
||||
void SizeTo(PRInt32 aWidth, PRInt32 aHeight) {width = aWidth; height = aHeight;}
|
||||
nsIntSize() : Super() {}
|
||||
nsIntSize(const nsIntSize& aSize) : Super(aSize) {}
|
||||
nsIntSize(PRInt32 aWidth, PRInt32 aHeight) : Super(aWidth, aHeight) {}
|
||||
};
|
||||
|
||||
inline nsSize
|
||||
|
|
|
@ -254,7 +254,7 @@ void
|
|||
gfxContext::Ellipse(const gfxPoint& center, const gfxSize& dimensions)
|
||||
{
|
||||
gfxSize halfDim = dimensions / 2.0;
|
||||
gfxRect r(center - halfDim, dimensions);
|
||||
gfxRect r(center - gfxPoint(halfDim.width, halfDim.height), dimensions);
|
||||
gfxCornerSizes c(halfDim, halfDim, halfDim, halfDim);
|
||||
|
||||
RoundedRectangle (r, c);
|
||||
|
@ -430,9 +430,9 @@ gfxContext::UserToDevicePixelSnapped(gfxRect& rect, PRBool ignoreScale) const
|
|||
return PR_FALSE;
|
||||
#undef WITHIN_E
|
||||
|
||||
gfxPoint p1 = UserToDevice(rect.pos);
|
||||
gfxPoint p2 = UserToDevice(rect.pos + gfxSize(rect.size.width, 0.0));
|
||||
gfxPoint p3 = UserToDevice(rect.pos + rect.size);
|
||||
gfxPoint p1 = UserToDevice(rect.TopLeft());
|
||||
gfxPoint p2 = UserToDevice(rect.TopRight());
|
||||
gfxPoint p3 = UserToDevice(rect.BottomRight());
|
||||
|
||||
// Check that the rectangle is axis-aligned. For an axis-aligned rectangle,
|
||||
// two opposite corners define the entire rectangle. So check if
|
||||
|
|
|
@ -39,125 +39,30 @@
|
|||
#define GFX_POINT_H
|
||||
|
||||
#include "nsMathUtils.h"
|
||||
#include "mozilla/BaseSize.h"
|
||||
#include "mozilla/BasePoint.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsPoint.h"
|
||||
|
||||
#include "gfxTypes.h"
|
||||
|
||||
/*
|
||||
* gfxSize and gfxIntSize -- please keep their member functions in sync.
|
||||
* also note: gfxIntSize may be replaced by nsIntSize at some point...
|
||||
*/
|
||||
struct THEBES_API gfxIntSize {
|
||||
PRInt32 width, height;
|
||||
typedef nsIntSize gfxIntSize;
|
||||
|
||||
gfxIntSize() {}
|
||||
gfxIntSize(PRInt32 _width, PRInt32 _height) : width(_width), height(_height) {}
|
||||
struct THEBES_API gfxSize : public mozilla::BaseSize<gfxFloat, gfxSize> {
|
||||
typedef mozilla::BaseSize<gfxFloat, gfxSize> Super;
|
||||
|
||||
void SizeTo(PRInt32 _width, PRInt32 _height) {width = _width; height = _height;}
|
||||
|
||||
int operator==(const gfxIntSize& s) const {
|
||||
return ((width == s.width) && (height == s.height));
|
||||
}
|
||||
int operator!=(const gfxIntSize& s) const {
|
||||
return ((width != s.width) || (height != s.height));
|
||||
}
|
||||
bool operator<(const gfxIntSize& s) const {
|
||||
return (operator<=(s) &&
|
||||
(width < s.width || height < s.height));
|
||||
}
|
||||
bool operator<=(const gfxIntSize& s) const {
|
||||
return (width <= s.width) && (height <= s.height);
|
||||
}
|
||||
gfxIntSize operator+(const gfxIntSize& s) const {
|
||||
return gfxIntSize(width + s.width, height + s.height);
|
||||
}
|
||||
gfxIntSize operator-() const {
|
||||
return gfxIntSize(- width, - height);
|
||||
}
|
||||
gfxIntSize operator-(const gfxIntSize& s) const {
|
||||
return gfxIntSize(width - s.width, height - s.height);
|
||||
}
|
||||
gfxIntSize operator*(const PRInt32 v) const {
|
||||
return gfxIntSize(width * v, height * v);
|
||||
}
|
||||
gfxIntSize operator/(const PRInt32 v) const {
|
||||
return gfxIntSize(width / v, height / v);
|
||||
}
|
||||
gfxSize() : Super() {}
|
||||
gfxSize(gfxFloat aWidth, gfxFloat aHeight) : Super(aWidth, aHeight) {}
|
||||
gfxSize(const nsIntSize& aSize) : Super(aSize.width, aSize.height) {}
|
||||
};
|
||||
|
||||
struct THEBES_API gfxSize {
|
||||
gfxFloat width, height;
|
||||
struct THEBES_API gfxPoint : public mozilla::BasePoint<gfxFloat, gfxPoint> {
|
||||
typedef mozilla::BasePoint<gfxFloat, gfxPoint> Super;
|
||||
|
||||
gfxSize() {}
|
||||
gfxSize(gfxFloat _width, gfxFloat _height) : width(_width), height(_height) {}
|
||||
gfxSize(const gfxIntSize& size) : width(size.width), height(size.height) {}
|
||||
gfxPoint() : Super() {}
|
||||
gfxPoint(gfxFloat aX, gfxFloat aY) : Super(aX, aY) {}
|
||||
gfxPoint(const nsIntPoint& aPoint) : Super(aPoint.x, aPoint.y) {}
|
||||
|
||||
void SizeTo(gfxFloat _width, gfxFloat _height) {width = _width; height = _height;}
|
||||
|
||||
int operator==(const gfxSize& s) const {
|
||||
return ((width == s.width) && (height == s.height));
|
||||
}
|
||||
int operator!=(const gfxSize& s) const {
|
||||
return ((width != s.width) || (height != s.height));
|
||||
}
|
||||
gfxSize operator+(const gfxSize& s) const {
|
||||
return gfxSize(width + s.width, height + s.height);
|
||||
}
|
||||
gfxSize operator-() const {
|
||||
return gfxSize(- width, - height);
|
||||
}
|
||||
gfxSize operator-(const gfxSize& s) const {
|
||||
return gfxSize(width - s.width, height - s.height);
|
||||
}
|
||||
gfxSize operator*(const gfxFloat v) const {
|
||||
return gfxSize(width * v, height * v);
|
||||
}
|
||||
gfxSize operator/(const gfxFloat v) const {
|
||||
return gfxSize(width / v, height / v);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct THEBES_API gfxPoint {
|
||||
gfxFloat x, y;
|
||||
|
||||
gfxPoint() { }
|
||||
gfxPoint(gfxFloat _x, gfxFloat _y) : x(_x), y(_y) {}
|
||||
|
||||
void MoveTo(gfxFloat aX, gfxFloat aY) { x = aX; y = aY; }
|
||||
|
||||
int operator==(const gfxPoint& p) const {
|
||||
return ((x == p.x) && (y == p.y));
|
||||
}
|
||||
int operator!=(const gfxPoint& p) const {
|
||||
return ((x != p.x) || (y != p.y));
|
||||
}
|
||||
const gfxPoint& operator+=(const gfxPoint& p) {
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
gfxPoint operator+(const gfxPoint& p) const {
|
||||
return gfxPoint(x + p.x, y + p.y);
|
||||
}
|
||||
gfxPoint operator+(const gfxSize& s) const {
|
||||
return gfxPoint(x + s.width, y + s.height);
|
||||
}
|
||||
gfxPoint operator-(const gfxPoint& p) const {
|
||||
return gfxPoint(x - p.x, y - p.y);
|
||||
}
|
||||
gfxPoint operator-(const gfxSize& s) const {
|
||||
return gfxPoint(x - s.width, y - s.height);
|
||||
}
|
||||
gfxPoint operator-() const {
|
||||
return gfxPoint(- x, - y);
|
||||
}
|
||||
gfxPoint operator*(const gfxFloat v) const {
|
||||
return gfxPoint(x * v, y * v);
|
||||
}
|
||||
gfxPoint operator/(const gfxFloat v) const {
|
||||
return gfxPoint(x / v, y / v);
|
||||
}
|
||||
// Round() is *not* rounding to nearest integer if the values are negative.
|
||||
// They are always rounding as floor(n + 0.5).
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=410748#c14
|
||||
|
|
|
@ -192,9 +192,10 @@ struct THEBES_API gfxRect {
|
|||
|
||||
// grabbing specific points
|
||||
gfxPoint TopLeft() const { return gfxPoint(pos); }
|
||||
gfxPoint TopRight() const { return pos + gfxSize(size.width, 0.0); }
|
||||
gfxPoint BottomLeft() const { return pos + gfxSize(0.0, size.height); }
|
||||
gfxPoint BottomRight() const { return pos + size; }
|
||||
gfxPoint TopRight() const { return pos + gfxPoint(size.width, 0.0); }
|
||||
gfxPoint BottomLeft() const { return pos + gfxPoint(0.0, size.height); }
|
||||
gfxPoint BottomRight() const { return pos + gfxPoint(size.width, size.height); }
|
||||
gfxPoint Center() const { return pos + gfxPoint(size.width, size.height)/2.0; }
|
||||
|
||||
gfxPoint AtCorner(mozilla::css::Corner corner) const {
|
||||
switch (corner) {
|
||||
|
|
|
@ -687,24 +687,6 @@ struct ParamTraits<nsRect>
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<gfxIntSize>
|
||||
{
|
||||
typedef gfxIntSize paramType;
|
||||
|
||||
static void Write(Message* msg, const paramType& param)
|
||||
{
|
||||
WriteParam(msg, param.width);
|
||||
WriteParam(msg, param.height);
|
||||
}
|
||||
|
||||
static bool Read(const Message* msg, void** iter, paramType* result)
|
||||
{
|
||||
return (ReadParam(msg, iter, &result->width) &&
|
||||
ReadParam(msg, iter, &result->height));
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace IPC */
|
||||
|
||||
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */
|
||||
|
|
|
@ -490,7 +490,7 @@ nsCSSBorderRenderer::DoSideClipSubPath(mozilla::css::Side aSide)
|
|||
else if (endIsDashed && isDashed)
|
||||
endType = SIDE_CLIP_RECTANGLE;
|
||||
|
||||
gfxPoint midPoint = mInnerRect.pos + mInnerRect.size / 2.0;
|
||||
gfxPoint midPoint = mInnerRect.Center();
|
||||
|
||||
start[0] = mOuterRect.CCWCorner(aSide);
|
||||
start[1] = mInnerRect.CCWCorner(aSide);
|
||||
|
|
|
@ -4258,7 +4258,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
|
|||
#ifdef XP_MACOSX
|
||||
|
||||
#ifndef NP_NO_CARBON
|
||||
static void InitializeEventRecord(EventRecord* event, Point* aMousePosition)
|
||||
static void InitializeEventRecord(EventRecord* event, ::Point* aMousePosition)
|
||||
{
|
||||
memset(event, 0, sizeof(EventRecord));
|
||||
if (aMousePosition) {
|
||||
|
@ -5283,7 +5283,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
|
|||
presContext->AppUnitsToDevPixels(pt.y));
|
||||
#ifndef NP_NO_CARBON
|
||||
nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
|
||||
Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
|
||||
::Point carbonPt = { ptPx.y + geckoScreenCoords.y, ptPx.x + geckoScreenCoords.x };
|
||||
if (eventModel == NPEventModelCarbon) {
|
||||
if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
|
||||
static_cast<EventRecord*>(event)->where = carbonPt;
|
||||
|
|
|
@ -784,7 +784,7 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
|
|||
switch(mType)
|
||||
{
|
||||
case NOTATION_CIRCLE:
|
||||
gfxCtx->Ellipse(rect.pos + rect.size / 2.0, rect.size);
|
||||
gfxCtx->Ellipse(rect.Center(), rect.size);
|
||||
break;
|
||||
|
||||
case NOTATION_ROUNDEDBOX:
|
||||
|
|
|
@ -613,7 +613,7 @@ void nsDisplayMathMLSlash::Paint(nsDisplayListBuilder* aBuilder,
|
|||
|
||||
// draw the slash as a parallelogram
|
||||
gfxContext *gfxCtx = aCtx->ThebesContext();
|
||||
gfxSize delta = gfxSize(presContext->AppUnitsToGfxUnits(mThickness), 0);
|
||||
gfxPoint delta = gfxPoint(presContext->AppUnitsToGfxUnits(mThickness), 0);
|
||||
gfxCtx->NewPath();
|
||||
gfxCtx->MoveTo(rect.BottomLeft());
|
||||
gfxCtx->LineTo(rect.BottomLeft() + delta);
|
||||
|
|
|
@ -72,7 +72,6 @@ class gfxASurface;
|
|||
class gfxPattern;
|
||||
class gfxImageSurface;
|
||||
struct gfxSize;
|
||||
struct gfxIntSize;
|
||||
struct nsStyleFont;
|
||||
class nsSVGEnum;
|
||||
class nsISVGChildFrame;
|
||||
|
|
Загрузка…
Ссылка в новой задаче