summaryrefslogtreecommitdiff
path: root/www/firefox3/patches/patch-el
blob: 6f0c631aedeebf746642d05042dba6e793369f86 (plain)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
$NetBSD: patch-el,v 1.2 2009/02/02 09:28:56 martin Exp $

# Ensure correct alignment for nsCSSValue objects inside nsCSSValue::Array.
#  (Bug 476345)

--- layout/style/nsCSSValue.h.orig	2008-07-02 00:51:43.000000000 +0200
+++ layout/style/nsCSSValue.h	2009-02-01 21:43:29.000000000 +0100
@@ -286,104 +286,7 @@
   // failure.
   static nsStringBuffer* BufferFromString(const nsString& aValue);
   
-  struct Array {
-
-    // return |Array| with reference count of zero
-    static Array* Create(PRUint16 aItemCount) {
-      return new (aItemCount) Array(aItemCount);
-    }
-
-    nsCSSValue& operator[](PRUint16 aIndex) {
-      NS_ASSERTION(aIndex < mCount, "out of range");
-      return *(First() + aIndex);
-    }
-
-    const nsCSSValue& operator[](PRUint16 aIndex) const {
-      NS_ASSERTION(aIndex < mCount, "out of range");
-      return *(First() + aIndex);
-    }
-
-    nsCSSValue& Item(PRUint16 aIndex) { return (*this)[aIndex]; }
-    const nsCSSValue& Item(PRUint16 aIndex) const { return (*this)[aIndex]; }
-
-    PRUint16 Count() const { return mCount; }
-
-    PRBool operator==(const Array& aOther) const
-    {
-      if (mCount != aOther.mCount)
-        return PR_FALSE;
-      for (PRUint16 i = 0; i < mCount; ++i)
-        if ((*this)[i] != aOther[i])
-          return PR_FALSE;
-      return PR_TRUE;
-    }
-
-    void AddRef() {
-      if (mRefCnt == PR_UINT16_MAX) {
-        NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
-        return;
-      }
-      ++mRefCnt;
-      NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
-    }
-    void Release() {
-      if (mRefCnt == PR_UINT16_MAX) {
-        NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
-        return;
-      }
-      --mRefCnt;
-      NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
-      if (mRefCnt == 0)
-        delete this;
-    }
-
-  private:
-
-    PRUint16 mRefCnt;
-    PRUint16 mCount;
-
-    void* operator new(size_t aSelfSize, PRUint16 aItemCount) CPP_THROW_NEW {
-      return ::operator new(aSelfSize + sizeof(nsCSSValue)*aItemCount);
-    }
-
-    void operator delete(void* aPtr) { ::operator delete(aPtr); }
-
-    nsCSSValue* First() {
-      return (nsCSSValue*) (((char*)this) + sizeof(*this));
-    }
-
-    const nsCSSValue* First() const {
-      return (const nsCSSValue*) (((const char*)this) + sizeof(*this));
-    }
-
-#define CSSVALUE_LIST_FOR_VALUES(var)                                         \
-  for (nsCSSValue *var = First(), *var##_end = var + mCount;                  \
-       var != var##_end; ++var)
-
-    Array(PRUint16 aItemCount)
-      : mRefCnt(0)
-      , mCount(aItemCount)
-    {
-      MOZ_COUNT_CTOR(nsCSSValue::Array);
-      CSSVALUE_LIST_FOR_VALUES(val) {
-        new (val) nsCSSValue();
-      }
-    }
-
-    ~Array()
-    {
-      MOZ_COUNT_DTOR(nsCSSValue::Array);
-      CSSVALUE_LIST_FOR_VALUES(val) {
-        val->~nsCSSValue();
-      }
-    }
-
-#undef CSSVALUE_LIST_FOR_VALUES
-
-  private:
-    Array(const Array& aOther); // not to be implemented
-  };
-
+  struct Array;
   struct URL {
     // Methods are not inline because using an nsIPrincipal means requiring
     // caps, which leads to REQUIRES hell, since this header is included all
@@ -454,5 +357,102 @@
   }         mValue;
 };
 
-#endif /* nsCSSValue_h___ */
+struct nsCSSValue::Array {
+
+  // return |Array| with reference count of zero
+  static Array* Create(PRUint16 aItemCount) {
+    return new (aItemCount) Array(aItemCount);
+  }
+
+  nsCSSValue& operator[](PRUint16 aIndex) {
+    NS_ASSERTION(aIndex < mCount, "out of range");
+    return mArray[aIndex];
+  }
+
+  const nsCSSValue& operator[](PRUint16 aIndex) const {
+    NS_ASSERTION(aIndex < mCount, "out of range");
+    return mArray[aIndex];
+  }
+
+  nsCSSValue& Item(PRUint16 aIndex) { return (*this)[aIndex]; }
+  const nsCSSValue& Item(PRUint16 aIndex) const { return (*this)[aIndex]; }
+
+  PRUint16 Count() const { return mCount; }
+
+  PRBool operator==(const Array& aOther) const
+  {
+    if (mCount != aOther.mCount)
+      return PR_FALSE;
+    for (PRUint16 i = 0; i < mCount; ++i)
+      if ((*this)[i] != aOther[i])
+        return PR_FALSE;
+    return PR_TRUE;
+  }
+
+  void AddRef() {
+    if (mRefCnt == PR_UINT16_MAX) {
+      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
+      return;
+    }
+    ++mRefCnt;
+    NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
+  }
+  void Release() {
+    if (mRefCnt == PR_UINT16_MAX) {
+      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
+      return;
+    }
+    --mRefCnt;
+    NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
+    if (mRefCnt == 0)
+      delete this;
+  }
+
+private:
+
+  PRUint16 mRefCnt;
+  const PRUint16 mCount;
+  // This must be the last sub-object, since we extend this array to
+  // be of size mCount; it needs to be a sub-object so it gets proper
+  // alignment.
+  nsCSSValue mArray[1];
 
+  void* operator new(size_t aSelfSize, PRUint16 aItemCount) CPP_THROW_NEW {
+    return ::operator new(aSelfSize + sizeof(nsCSSValue) * (aItemCount - 1));
+  }
+
+  void operator delete(void* aPtr) { ::operator delete(aPtr); }
+
+  nsCSSValue* First() { return mArray; }
+
+  const nsCSSValue* First() const { return mArray; }
+
+#define CSSVALUE_LIST_FOR_EXTRA_VALUES(var)                                   \
+for (nsCSSValue *var = First() + 1, *var##_end = First() + mCount;          \
+     var != var##_end; ++var)
+
+  Array(PRUint16 aItemCount)
+    : mRefCnt(0)
+    , mCount(aItemCount)
+  {
+    MOZ_COUNT_CTOR(nsCSSValue::Array);
+    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
+      new (val) nsCSSValue();
+    }
+  }
+
+  ~Array()
+  {
+    MOZ_COUNT_DTOR(nsCSSValue::Array);
+    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
+      val->~nsCSSValue();
+    }
+  }
+
+#undef CSSVALUE_LIST_FOR_VALUES
+
+private:
+  Array(const Array& aOther); // not to be implemented
+};
+
+#endif /* nsCSSValue_h___ */