2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2001-03-08 05:41:16 +03:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/* representation of length values in computed style data */
|
|
|
|
|
2012-08-27 08:08:32 +04:00
|
|
|
#include "mozilla/HashFunctions.h"
|
2014-06-19 07:18:03 +04:00
|
|
|
#include "mozilla/PodOperations.h"
|
2001-03-08 05:41:16 +03:00
|
|
|
|
2017-02-21 14:27:58 +03:00
|
|
|
// nsStyleCoord.h must not be the first header in a unified source file,
|
|
|
|
// otherwise it may not build with MSVC due to a bug in our STL wrapper.
|
|
|
|
// See bug 1331102.
|
|
|
|
#include "nsStyleCoord.h"
|
|
|
|
|
2016-12-01 21:37:44 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2001-03-08 05:41:16 +03:00
|
|
|
nsStyleCoord::nsStyleCoord(nsStyleUnit aUnit)
|
|
|
|
: mUnit(aUnit)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aUnit < eStyleUnit_Percent, "not a valueless unit");
|
|
|
|
if (aUnit >= eStyleUnit_Percent) {
|
|
|
|
mUnit = eStyleUnit_Null;
|
|
|
|
}
|
|
|
|
mValue.mInt = 0;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsStyleCoord::nsStyleCoord(int32_t aValue, nsStyleUnit aUnit)
|
2001-03-08 05:41:16 +03:00
|
|
|
: mUnit(aUnit)
|
|
|
|
{
|
|
|
|
//if you want to pass in eStyleUnit_Coord, don't. instead, use the
|
|
|
|
//constructor just above this one... MMP
|
2007-05-11 10:00:26 +04:00
|
|
|
NS_ASSERTION((aUnit == eStyleUnit_Enumerated) ||
|
2001-03-08 05:41:16 +03:00
|
|
|
(aUnit == eStyleUnit_Integer), "not an int value");
|
2007-05-11 10:00:26 +04:00
|
|
|
if ((aUnit == eStyleUnit_Enumerated) ||
|
2001-03-08 05:41:16 +03:00
|
|
|
(aUnit == eStyleUnit_Integer)) {
|
|
|
|
mValue.mInt = aValue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mUnit = eStyleUnit_Null;
|
|
|
|
mValue.mInt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleCoord::nsStyleCoord(float aValue, nsStyleUnit aUnit)
|
|
|
|
: mUnit(aUnit)
|
|
|
|
{
|
2009-11-02 22:36:43 +03:00
|
|
|
if (aUnit < eStyleUnit_Percent || aUnit >= eStyleUnit_Coord) {
|
|
|
|
NS_NOTREACHED("not a float value");
|
2014-06-19 07:18:03 +04:00
|
|
|
mUnit = eStyleUnit_Null;
|
|
|
|
mValue.mInt = 0;
|
2009-11-02 22:36:43 +03:00
|
|
|
} else {
|
2001-03-08 05:41:16 +03:00
|
|
|
mValue.mFloat = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleCoord::operator==(const nsStyleCoord& aOther) const
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2010-08-31 20:05:12 +04:00
|
|
|
if (mUnit != aOther.mUnit) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
2010-08-31 20:05:12 +04:00
|
|
|
switch (mUnit) {
|
|
|
|
case eStyleUnit_Null:
|
|
|
|
case eStyleUnit_Normal:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
case eStyleUnit_None:
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-08-31 20:05:12 +04:00
|
|
|
case eStyleUnit_Percent:
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
case eStyleUnit_Degree:
|
|
|
|
case eStyleUnit_Grad:
|
|
|
|
case eStyleUnit_Radian:
|
2012-02-04 09:01:23 +04:00
|
|
|
case eStyleUnit_Turn:
|
2014-03-11 02:54:13 +04:00
|
|
|
case eStyleUnit_FlexFraction:
|
2010-08-31 20:05:12 +04:00
|
|
|
return mValue.mFloat == aOther.mValue.mFloat;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
case eStyleUnit_Integer:
|
|
|
|
case eStyleUnit_Enumerated:
|
|
|
|
return mValue.mInt == aOther.mValue.mInt;
|
|
|
|
case eStyleUnit_Calc:
|
2010-09-11 20:27:13 +04:00
|
|
|
return *this->GetCalcValue() == *aOther.GetCalcValue();
|
2010-08-31 20:05:12 +04:00
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "unexpected unit");
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
|
|
|
|
2012-08-27 08:08:32 +04:00
|
|
|
uint32_t nsStyleCoord::HashValue(uint32_t aHash = 0) const
|
|
|
|
{
|
|
|
|
aHash = mozilla::AddToHash(aHash, mUnit);
|
|
|
|
|
|
|
|
switch (mUnit) {
|
|
|
|
case eStyleUnit_Null:
|
|
|
|
case eStyleUnit_Normal:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
case eStyleUnit_None:
|
|
|
|
return mozilla::AddToHash(aHash, true);
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
case eStyleUnit_Degree:
|
|
|
|
case eStyleUnit_Grad:
|
|
|
|
case eStyleUnit_Radian:
|
|
|
|
case eStyleUnit_Turn:
|
2014-03-11 02:54:13 +04:00
|
|
|
case eStyleUnit_FlexFraction:
|
2012-08-27 08:08:32 +04:00
|
|
|
return mozilla::AddToHash(aHash, mValue.mFloat);
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
case eStyleUnit_Integer:
|
|
|
|
case eStyleUnit_Enumerated:
|
|
|
|
return mozilla::AddToHash(aHash, mValue.mInt);
|
|
|
|
case eStyleUnit_Calc:
|
|
|
|
Calc* calcValue = GetCalcValue();
|
|
|
|
aHash = mozilla::AddToHash(aHash, calcValue->mLength);
|
|
|
|
if (HasPercent()) {
|
|
|
|
return mozilla::AddToHash(aHash, calcValue->mPercent);
|
|
|
|
}
|
|
|
|
return aHash;
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(false, "unexpected unit");
|
2012-08-27 08:08:32 +04:00
|
|
|
return aHash;
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleCoord::Reset()
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset(mUnit, mValue);
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsStyleCoord::SetCoordValue(nscoord aValue)
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2001-03-08 05:41:16 +03:00
|
|
|
mUnit = eStyleUnit_Coord;
|
|
|
|
mValue.mInt = aValue;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsStyleCoord::SetIntValue(int32_t aValue, nsStyleUnit aUnit)
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2007-05-11 10:00:26 +04:00
|
|
|
NS_ASSERTION((aUnit == eStyleUnit_Enumerated) ||
|
2001-03-08 05:41:16 +03:00
|
|
|
(aUnit == eStyleUnit_Integer), "not an int value");
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2007-05-11 10:00:26 +04:00
|
|
|
if ((aUnit == eStyleUnit_Enumerated) ||
|
2001-03-08 05:41:16 +03:00
|
|
|
(aUnit == eStyleUnit_Integer)) {
|
|
|
|
mUnit = aUnit;
|
|
|
|
mValue.mInt = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStyleCoord::SetPercentValue(float aValue)
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2001-03-08 05:41:16 +03:00
|
|
|
mUnit = eStyleUnit_Percent;
|
|
|
|
mValue.mFloat = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStyleCoord::SetFactorValue(float aValue)
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2001-03-08 05:41:16 +03:00
|
|
|
mUnit = eStyleUnit_Factor;
|
|
|
|
mValue.mFloat = aValue;
|
|
|
|
}
|
|
|
|
|
2009-11-02 22:36:43 +03:00
|
|
|
void nsStyleCoord::SetAngleValue(float aValue, nsStyleUnit aUnit)
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2009-11-02 22:36:43 +03:00
|
|
|
if (aUnit == eStyleUnit_Degree ||
|
|
|
|
aUnit == eStyleUnit_Grad ||
|
2012-02-04 09:01:23 +04:00
|
|
|
aUnit == eStyleUnit_Radian ||
|
|
|
|
aUnit == eStyleUnit_Turn) {
|
2009-11-02 22:36:43 +03:00
|
|
|
mUnit = aUnit;
|
|
|
|
mValue.mFloat = aValue;
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("not an angle value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:13 +04:00
|
|
|
void nsStyleCoord::SetFlexFractionValue(float aValue)
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2014-03-11 02:54:13 +04:00
|
|
|
mUnit = eStyleUnit_FlexFraction;
|
|
|
|
mValue.mFloat = aValue;
|
|
|
|
}
|
|
|
|
|
2010-09-11 20:27:13 +04:00
|
|
|
void nsStyleCoord::SetCalcValue(Calc* aValue)
|
2010-07-03 08:18:55 +04:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2010-09-11 20:27:13 +04:00
|
|
|
mUnit = eStyleUnit_Calc;
|
|
|
|
mValue.mPointer = aValue;
|
2014-06-19 07:18:03 +04:00
|
|
|
aValue->AddRef();
|
2010-07-03 08:18:55 +04:00
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleCoord::SetNormalValue()
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2001-03-08 05:41:16 +03:00
|
|
|
mUnit = eStyleUnit_Normal;
|
|
|
|
mValue.mInt = 0;
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleCoord::SetAutoValue()
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2001-03-08 05:41:16 +03:00
|
|
|
mUnit = eStyleUnit_Auto;
|
|
|
|
mValue.mInt = 0;
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleCoord::SetNoneValue()
|
2007-05-11 10:01:31 +04:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
Reset();
|
2007-05-11 10:01:31 +04:00
|
|
|
mUnit = eStyleUnit_None;
|
|
|
|
mValue.mInt = 0;
|
|
|
|
}
|
|
|
|
|
2009-11-02 22:36:43 +03:00
|
|
|
// accessors that are not inlined
|
|
|
|
|
2014-08-21 02:46:59 +04:00
|
|
|
double
|
|
|
|
nsStyleCoord::GetAngleValueInDegrees() const
|
|
|
|
{
|
|
|
|
return GetAngleValueInRadians() * (180.0 / M_PI);
|
|
|
|
}
|
|
|
|
|
2009-11-02 22:36:43 +03:00
|
|
|
double
|
|
|
|
nsStyleCoord::GetAngleValueInRadians() const
|
|
|
|
{
|
|
|
|
double angle = mValue.mFloat;
|
|
|
|
|
|
|
|
switch (GetUnit()) {
|
|
|
|
case eStyleUnit_Radian: return angle;
|
2012-02-04 09:01:23 +04:00
|
|
|
case eStyleUnit_Turn: return angle * 2 * M_PI;
|
2009-11-02 22:36:43 +03:00
|
|
|
case eStyleUnit_Degree: return angle * M_PI / 180.0;
|
|
|
|
case eStyleUnit_Grad: return angle * M_PI / 200.0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unrecognized angular unit");
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
nsStyleSides::nsStyleSides()
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
NS_FOR_CSS_SIDES(i) {
|
|
|
|
mUnits[i] = eStyleUnit_Null;
|
|
|
|
}
|
|
|
|
mozilla::PodArrayZero(mValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSides::nsStyleSides(const nsStyleSides& aOther)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(i) {
|
|
|
|
mUnits[i] = eStyleUnit_Null;
|
|
|
|
}
|
|
|
|
*this = aOther;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSides::~nsStyleSides()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSides&
|
|
|
|
nsStyleSides::operator=(const nsStyleSides& aCopy)
|
|
|
|
{
|
|
|
|
if (this != &aCopy) {
|
|
|
|
NS_FOR_CSS_SIDES(i) {
|
|
|
|
nsStyleCoord::SetValue(mUnits[i], mValues[i],
|
|
|
|
aCopy.mUnits[i], aCopy.mValues[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleSides::operator==(const nsStyleSides& aOther) const
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2008-10-01 09:50:52 +04:00
|
|
|
NS_FOR_CSS_SIDES(i) {
|
2012-07-31 06:25:28 +04:00
|
|
|
if (nsStyleCoord(mValues[i], (nsStyleUnit)mUnits[i]) !=
|
|
|
|
nsStyleCoord(aOther.mValues[i], (nsStyleUnit)aOther.mUnits[i])) {
|
|
|
|
return false;
|
|
|
|
}
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleSides::Reset()
|
2001-03-08 05:41:16 +03:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
NS_FOR_CSS_SIDES(i) {
|
|
|
|
nsStyleCoord::Reset(mUnits[i], mValues[i]);
|
|
|
|
}
|
2001-03-08 05:41:16 +03:00
|
|
|
}
|
|
|
|
|
2008-10-01 09:50:52 +04:00
|
|
|
nsStyleCorners::nsStyleCorners()
|
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
|
|
|
mUnits[i] = eStyleUnit_Null;
|
|
|
|
}
|
|
|
|
mozilla::PodArrayZero(mValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleCorners::nsStyleCorners(const nsStyleCorners& aOther)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
|
|
|
mUnits[i] = eStyleUnit_Null;
|
|
|
|
}
|
|
|
|
*this = aOther;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleCorners::~nsStyleCorners()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleCorners&
|
|
|
|
nsStyleCorners::operator=(const nsStyleCorners& aCopy)
|
|
|
|
{
|
|
|
|
if (this != &aCopy) {
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
|
|
|
nsStyleCoord::SetValue(mUnits[i], mValues[i],
|
|
|
|
aCopy.mUnits[i], aCopy.mValues[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-10-01 09:50:52 +04:00
|
|
|
nsStyleCorners::operator==(const nsStyleCorners& aOther) const
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
2012-07-31 06:25:28 +04:00
|
|
|
if (nsStyleCoord(mValues[i], (nsStyleUnit)mUnits[i]) !=
|
|
|
|
nsStyleCoord(aOther.mValues[i], (nsStyleUnit)aOther.mUnits[i])) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
|
|
|
|
2010-05-11 19:49:44 +04:00
|
|
|
void nsStyleCorners::Reset()
|
2008-10-01 09:50:52 +04:00
|
|
|
{
|
2014-06-19 07:18:03 +04:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
|
|
|
nsStyleCoord::Reset(mUnits[i], mValues[i]);
|
|
|
|
}
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
|
|
|
|
2017-01-05 11:07:02 +03:00
|
|
|
// Validation of SideIsVertical.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(side, result) \
|
2017-01-05 11:07:02 +03:00
|
|
|
static_assert(SideIsVertical(side) == result, \
|
|
|
|
"SideIsVertical is wrong")
|
2016-11-18 13:12:25 +03:00
|
|
|
CASE(eSideTop, false);
|
|
|
|
CASE(eSideRight, true);
|
|
|
|
CASE(eSideBottom, false);
|
|
|
|
CASE(eSideLeft, true);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|
|
|
|
|
2017-01-05 09:30:14 +03:00
|
|
|
// Validation of HalfCornerIsX.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(corner, result) \
|
2017-01-05 09:30:14 +03:00
|
|
|
static_assert(HalfCornerIsX(corner) == result, \
|
|
|
|
"HalfCornerIsX is wrong")
|
2017-01-05 06:31:38 +03:00
|
|
|
CASE(eCornerTopLeftX, true);
|
|
|
|
CASE(eCornerTopLeftY, false);
|
|
|
|
CASE(eCornerTopRightX, true);
|
|
|
|
CASE(eCornerTopRightY, false);
|
|
|
|
CASE(eCornerBottomRightX, true);
|
|
|
|
CASE(eCornerBottomRightY, false);
|
|
|
|
CASE(eCornerBottomLeftX, true);
|
|
|
|
CASE(eCornerBottomLeftY, false);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|
|
|
|
|
2017-01-05 09:39:58 +03:00
|
|
|
// Validation of HalfToFullCorner.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(corner, result) \
|
2017-01-05 09:39:58 +03:00
|
|
|
static_assert(HalfToFullCorner(corner) == result, \
|
|
|
|
"HalfToFullCorner is wrong")
|
2017-01-05 06:31:38 +03:00
|
|
|
CASE(eCornerTopLeftX, eCornerTopLeft);
|
|
|
|
CASE(eCornerTopLeftY, eCornerTopLeft);
|
|
|
|
CASE(eCornerTopRightX, eCornerTopRight);
|
|
|
|
CASE(eCornerTopRightY, eCornerTopRight);
|
|
|
|
CASE(eCornerBottomRightX, eCornerBottomRight);
|
|
|
|
CASE(eCornerBottomRightY, eCornerBottomRight);
|
|
|
|
CASE(eCornerBottomLeftX, eCornerBottomLeft);
|
|
|
|
CASE(eCornerBottomLeftY, eCornerBottomLeft);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|
|
|
|
|
2017-01-05 09:59:17 +03:00
|
|
|
// Validation of FullToHalfCorner.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(corner, vert, result) \
|
2017-01-05 09:59:17 +03:00
|
|
|
static_assert(FullToHalfCorner(corner, vert) == result, \
|
|
|
|
"FullToHalfCorner is wrong")
|
2017-01-05 06:31:38 +03:00
|
|
|
CASE(eCornerTopLeft, false, eCornerTopLeftX);
|
|
|
|
CASE(eCornerTopLeft, true, eCornerTopLeftY);
|
|
|
|
CASE(eCornerTopRight, false, eCornerTopRightX);
|
|
|
|
CASE(eCornerTopRight, true, eCornerTopRightY);
|
|
|
|
CASE(eCornerBottomRight, false, eCornerBottomRightX);
|
|
|
|
CASE(eCornerBottomRight, true, eCornerBottomRightY);
|
|
|
|
CASE(eCornerBottomLeft, false, eCornerBottomLeftX);
|
|
|
|
CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|
|
|
|
|
2017-01-05 11:13:34 +03:00
|
|
|
// Validation of SideToFullCorner.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(side, second, result) \
|
2017-01-05 11:13:34 +03:00
|
|
|
static_assert(SideToFullCorner(side, second) == result, \
|
|
|
|
"SideToFullCorner is wrong")
|
2017-01-04 13:15:30 +03:00
|
|
|
CASE(eSideTop, false, eCornerTopLeft);
|
|
|
|
CASE(eSideTop, true, eCornerTopRight);
|
2008-10-01 09:50:52 +04:00
|
|
|
|
2017-01-04 13:15:30 +03:00
|
|
|
CASE(eSideRight, false, eCornerTopRight);
|
|
|
|
CASE(eSideRight, true, eCornerBottomRight);
|
2008-10-01 09:50:52 +04:00
|
|
|
|
2017-01-04 13:15:30 +03:00
|
|
|
CASE(eSideBottom, false, eCornerBottomRight);
|
|
|
|
CASE(eSideBottom, true, eCornerBottomLeft);
|
2008-10-01 09:50:52 +04:00
|
|
|
|
2017-01-04 13:15:30 +03:00
|
|
|
CASE(eSideLeft, false, eCornerBottomLeft);
|
|
|
|
CASE(eSideLeft, true, eCornerTopLeft);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|
|
|
|
|
2017-01-05 11:23:16 +03:00
|
|
|
// Validation of SideToHalfCorner.
|
2008-10-01 09:50:52 +04:00
|
|
|
#define CASE(side, second, parallel, result) \
|
2017-01-05 11:23:16 +03:00
|
|
|
static_assert(SideToHalfCorner(side, second, parallel) == result, \
|
|
|
|
"SideToHalfCorner is wrong")
|
2017-01-05 06:31:38 +03:00
|
|
|
CASE(eSideTop, false, true, eCornerTopLeftX);
|
|
|
|
CASE(eSideTop, false, false, eCornerTopLeftY);
|
|
|
|
CASE(eSideTop, true, true, eCornerTopRightX);
|
|
|
|
CASE(eSideTop, true, false, eCornerTopRightY);
|
|
|
|
|
|
|
|
CASE(eSideRight, false, false, eCornerTopRightX);
|
|
|
|
CASE(eSideRight, false, true, eCornerTopRightY);
|
|
|
|
CASE(eSideRight, true, false, eCornerBottomRightX);
|
|
|
|
CASE(eSideRight, true, true, eCornerBottomRightY);
|
|
|
|
|
|
|
|
CASE(eSideBottom, false, true, eCornerBottomRightX);
|
|
|
|
CASE(eSideBottom, false, false, eCornerBottomRightY);
|
|
|
|
CASE(eSideBottom, true, true, eCornerBottomLeftX);
|
|
|
|
CASE(eSideBottom, true, false, eCornerBottomLeftY);
|
|
|
|
|
|
|
|
CASE(eSideLeft, false, false, eCornerBottomLeftX);
|
|
|
|
CASE(eSideLeft, false, true, eCornerBottomLeftY);
|
|
|
|
CASE(eSideLeft, true, false, eCornerTopLeftX);
|
|
|
|
CASE(eSideLeft, true, true, eCornerTopLeftY);
|
2008-10-01 09:50:52 +04:00
|
|
|
#undef CASE
|