Bug 827521 - Work around spurious operator ambiguity errors in buggy versions of Clang. r=longsonr

This commit is contained in:
Graeme McCutcheon 2013-01-10 14:37:30 +00:00
parent 094d5d52f1
commit 63cadb2bf6
3 changed files with 24 additions and 17 deletions

View File

@ -54,7 +54,7 @@ GetAlignForString(const nsAString &aAlignString)
{
for (uint32_t i = 0 ; i < ArrayLength(sAlignStrings) ; i++) {
if (aAlignString.EqualsASCII(sAlignStrings[i])) {
return (i + SVG_PRESERVEASPECTRATIO_NONE);
return (i + SVG_ALIGN_MIN_VALID);
}
}
@ -65,12 +65,11 @@ static void
GetAlignString(nsAString& aAlignString, uint16_t aAlign)
{
NS_ASSERTION(
aAlign >= SVG_PRESERVEASPECTRATIO_NONE &&
aAlign <= SVG_PRESERVEASPECTRATIO_XMAXYMAX,
aAlign >= SVG_ALIGN_MIN_VALID && aAlign <= SVG_ALIGN_MAX_VALID,
"Unknown align");
aAlignString.AssignASCII(
sAlignStrings[aAlign - SVG_PRESERVEASPECTRATIO_NONE]);
sAlignStrings[aAlign - SVG_ALIGN_MIN_VALID]);
}
static uint16_t
@ -78,7 +77,7 @@ GetMeetOrSliceForString(const nsAString &aMeetOrSlice)
{
for (uint32_t i = 0 ; i < ArrayLength(sMeetOrSliceStrings) ; i++) {
if (aMeetOrSlice.EqualsASCII(sMeetOrSliceStrings[i])) {
return (i + SVG_MEETORSLICE_MEET);
return (i + SVG_MEETORSLICE_MIN_VALID);
}
}
@ -89,12 +88,12 @@ static void
GetMeetOrSliceString(nsAString& aMeetOrSliceString, uint16_t aMeetOrSlice)
{
NS_ASSERTION(
aMeetOrSlice >= SVG_MEETORSLICE_MEET &&
aMeetOrSlice <= SVG_MEETORSLICE_SLICE,
aMeetOrSlice >= SVG_MEETORSLICE_MIN_VALID &&
aMeetOrSlice <= SVG_MEETORSLICE_MAX_VALID,
"Unknown meetOrSlice");
aMeetOrSliceString.AssignASCII(
sMeetOrSliceStrings[aMeetOrSlice - SVG_MEETORSLICE_MEET]);
sMeetOrSliceStrings[aMeetOrSlice - SVG_MEETORSLICE_MIN_VALID]);
}
already_AddRefed<DOMSVGPreserveAspectRatio>
@ -226,7 +225,7 @@ SVGAnimatedPreserveAspectRatio::GetBaseValueString(
GetAlignString(tmpString, mBaseVal.mAlign);
aValueAsString.Append(tmpString);
if (mBaseVal.mAlign != SVG_PRESERVEASPECTRATIO_NONE) {
if (mBaseVal.mAlign != uint8_t(SVG_PRESERVEASPECTRATIO_NONE)) {
aValueAsString.AppendLiteral(" ");
GetMeetOrSliceString(tmpString, mBaseVal.mMeetOrSlice);

View File

@ -42,8 +42,7 @@ public:
void SetBaseValue(const SVGPreserveAspectRatio &aValue,
nsSVGElement *aSVGElement);
nsresult SetBaseAlign(uint16_t aAlign, nsSVGElement *aSVGElement) {
if (aAlign < SVG_PRESERVEASPECTRATIO_NONE ||
aAlign > SVG_PRESERVEASPECTRATIO_XMAXYMAX) {
if (aAlign < SVG_ALIGN_MIN_VALID || aAlign > SVG_ALIGN_MAX_VALID) {
return NS_ERROR_FAILURE;
}
SetBaseValue(SVGPreserveAspectRatio(
@ -53,8 +52,8 @@ public:
return NS_OK;
}
nsresult SetBaseMeetOrSlice(uint16_t aMeetOrSlice, nsSVGElement *aSVGElement) {
if (aMeetOrSlice < SVG_MEETORSLICE_MEET ||
aMeetOrSlice > SVG_MEETORSLICE_SLICE) {
if (aMeetOrSlice < SVG_MEETORSLICE_MIN_VALID ||
aMeetOrSlice > SVG_MEETORSLICE_MAX_VALID) {
return NS_ERROR_FAILURE;
}
SetBaseValue(SVGPreserveAspectRatio(

View File

@ -28,6 +28,11 @@ enum SVGAlign MOZ_ENUM_TYPE(uint8_t) {
SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
};
// These constants represent the range of valid enum values for the <align>
// parameter. They exclude the sentinel _UNKNOWN value.
const uint16_t SVG_ALIGN_MIN_VALID = SVG_PRESERVEASPECTRATIO_NONE;
const uint16_t SVG_ALIGN_MAX_VALID = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
// Meet-or-slice Types
enum SVGMeetOrSlice MOZ_ENUM_TYPE(uint8_t) {
SVG_MEETORSLICE_UNKNOWN = 0,
@ -35,6 +40,11 @@ enum SVGMeetOrSlice MOZ_ENUM_TYPE(uint8_t) {
SVG_MEETORSLICE_SLICE = 2
};
// These constants represent the range of valid enum values for the
// <meetOrSlice> parameter. They exclude the sentinel _UNKNOWN value.
const uint16_t SVG_MEETORSLICE_MIN_VALID = SVG_MEETORSLICE_MEET;
const uint16_t SVG_MEETORSLICE_MAX_VALID = SVG_MEETORSLICE_SLICE;
class SVGAnimatedPreserveAspectRatio;
class SVGPreserveAspectRatio MOZ_FINAL
@ -57,8 +67,7 @@ public:
{}
nsresult SetAlign(uint16_t aAlign) {
if (aAlign < SVG_PRESERVEASPECTRATIO_NONE ||
aAlign > SVG_PRESERVEASPECTRATIO_XMAXYMAX)
if (aAlign < SVG_ALIGN_MIN_VALID || aAlign > SVG_ALIGN_MAX_VALID)
return NS_ERROR_FAILURE;
mAlign = static_cast<uint8_t>(aAlign);
return NS_OK;
@ -69,8 +78,8 @@ public:
}
nsresult SetMeetOrSlice(uint16_t aMeetOrSlice) {
if (aMeetOrSlice < SVG_MEETORSLICE_MEET ||
aMeetOrSlice > SVG_MEETORSLICE_SLICE)
if (aMeetOrSlice < SVG_MEETORSLICE_MIN_VALID ||
aMeetOrSlice > SVG_MEETORSLICE_MAX_VALID)
return NS_ERROR_FAILURE;
mMeetOrSlice = static_cast<uint8_t>(aMeetOrSlice);
return NS_OK;