summaryrefslogtreecommitdiff
path: root/www/firefox/files/patch-bug827521
blob: a9f76176c801c3bdd568fa4a027b288fb7071ade (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
commit ab46441
Author: Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
Date:   Thu Jan 10 14:37:30 2013 +0000

    Bug 827521 - Work around spurious operator ambiguity errors in buggy versions of Clang. r=longsonr
---
 .../svg/content/src/SVGAnimatedPreserveAspectRatio.cpp  | 17 ++++++++---------
 .../svg/content/src/SVGAnimatedPreserveAspectRatio.h    |  7 +++----
 content/svg/content/src/SVGPreserveAspectRatio.h        | 17 +++++++++++++----
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
index 6593461..56956b2 100644
--- content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
+++ content/svg/content/src/SVGAnimatedPreserveAspectRatio.cpp
@@ -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);
diff --git content/svg/content/src/SVGAnimatedPreserveAspectRatio.h content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
index 61cfba7..b08fb60 100644
--- content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
+++ content/svg/content/src/SVGAnimatedPreserveAspectRatio.h
@@ -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(
diff --git content/svg/content/src/SVGPreserveAspectRatio.h content/svg/content/src/SVGPreserveAspectRatio.h
index 066ad52..ebe724e 100644
--- content/svg/content/src/SVGPreserveAspectRatio.h
+++ content/svg/content/src/SVGPreserveAspectRatio.h
@@ -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;