]> gitweb @ CieloNegro.org - pkgsrc-firefox3.git/blob - patches/patch-el
Initial revision of the upstream www/firefox3
[pkgsrc-firefox3.git] / patches / patch-el
1 $NetBSD: patch-el,v 1.2 2009/02/02 09:28:56 martin Exp $
2
3 # Ensure correct alignment for nsCSSValue objects inside nsCSSValue::Array.
4 #  (Bug 476345)
5
6 --- layout/style/nsCSSValue.h.orig      2008-07-02 00:51:43.000000000 +0200
7 +++ layout/style/nsCSSValue.h   2009-02-01 21:43:29.000000000 +0100
8 @@ -286,104 +286,7 @@
9    // failure.
10    static nsStringBuffer* BufferFromString(const nsString& aValue);
11    
12 -  struct Array {
13 -
14 -    // return |Array| with reference count of zero
15 -    static Array* Create(PRUint16 aItemCount) {
16 -      return new (aItemCount) Array(aItemCount);
17 -    }
18 -
19 -    nsCSSValue& operator[](PRUint16 aIndex) {
20 -      NS_ASSERTION(aIndex < mCount, "out of range");
21 -      return *(First() + aIndex);
22 -    }
23 -
24 -    const nsCSSValue& operator[](PRUint16 aIndex) const {
25 -      NS_ASSERTION(aIndex < mCount, "out of range");
26 -      return *(First() + aIndex);
27 -    }
28 -
29 -    nsCSSValue& Item(PRUint16 aIndex) { return (*this)[aIndex]; }
30 -    const nsCSSValue& Item(PRUint16 aIndex) const { return (*this)[aIndex]; }
31 -
32 -    PRUint16 Count() const { return mCount; }
33 -
34 -    PRBool operator==(const Array& aOther) const
35 -    {
36 -      if (mCount != aOther.mCount)
37 -        return PR_FALSE;
38 -      for (PRUint16 i = 0; i < mCount; ++i)
39 -        if ((*this)[i] != aOther[i])
40 -          return PR_FALSE;
41 -      return PR_TRUE;
42 -    }
43 -
44 -    void AddRef() {
45 -      if (mRefCnt == PR_UINT16_MAX) {
46 -        NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
47 -        return;
48 -      }
49 -      ++mRefCnt;
50 -      NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
51 -    }
52 -    void Release() {
53 -      if (mRefCnt == PR_UINT16_MAX) {
54 -        NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
55 -        return;
56 -      }
57 -      --mRefCnt;
58 -      NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
59 -      if (mRefCnt == 0)
60 -        delete this;
61 -    }
62 -
63 -  private:
64 -
65 -    PRUint16 mRefCnt;
66 -    PRUint16 mCount;
67 -
68 -    void* operator new(size_t aSelfSize, PRUint16 aItemCount) CPP_THROW_NEW {
69 -      return ::operator new(aSelfSize + sizeof(nsCSSValue)*aItemCount);
70 -    }
71 -
72 -    void operator delete(void* aPtr) { ::operator delete(aPtr); }
73 -
74 -    nsCSSValue* First() {
75 -      return (nsCSSValue*) (((char*)this) + sizeof(*this));
76 -    }
77 -
78 -    const nsCSSValue* First() const {
79 -      return (const nsCSSValue*) (((const char*)this) + sizeof(*this));
80 -    }
81 -
82 -#define CSSVALUE_LIST_FOR_VALUES(var)                                         \
83 -  for (nsCSSValue *var = First(), *var##_end = var + mCount;                  \
84 -       var != var##_end; ++var)
85 -
86 -    Array(PRUint16 aItemCount)
87 -      : mRefCnt(0)
88 -      , mCount(aItemCount)
89 -    {
90 -      MOZ_COUNT_CTOR(nsCSSValue::Array);
91 -      CSSVALUE_LIST_FOR_VALUES(val) {
92 -        new (val) nsCSSValue();
93 -      }
94 -    }
95 -
96 -    ~Array()
97 -    {
98 -      MOZ_COUNT_DTOR(nsCSSValue::Array);
99 -      CSSVALUE_LIST_FOR_VALUES(val) {
100 -        val->~nsCSSValue();
101 -      }
102 -    }
103 -
104 -#undef CSSVALUE_LIST_FOR_VALUES
105 -
106 -  private:
107 -    Array(const Array& aOther); // not to be implemented
108 -  };
109 -
110 +  struct Array;
111    struct URL {
112      // Methods are not inline because using an nsIPrincipal means requiring
113      // caps, which leads to REQUIRES hell, since this header is included all
114 @@ -454,5 +357,102 @@
115    }         mValue;
116  };
117  
118 -#endif /* nsCSSValue_h___ */
119 +struct nsCSSValue::Array {
120 +
121 +  // return |Array| with reference count of zero
122 +  static Array* Create(PRUint16 aItemCount) {
123 +    return new (aItemCount) Array(aItemCount);
124 +  }
125 +
126 +  nsCSSValue& operator[](PRUint16 aIndex) {
127 +    NS_ASSERTION(aIndex < mCount, "out of range");
128 +    return mArray[aIndex];
129 +  }
130 +
131 +  const nsCSSValue& operator[](PRUint16 aIndex) const {
132 +    NS_ASSERTION(aIndex < mCount, "out of range");
133 +    return mArray[aIndex];
134 +  }
135 +
136 +  nsCSSValue& Item(PRUint16 aIndex) { return (*this)[aIndex]; }
137 +  const nsCSSValue& Item(PRUint16 aIndex) const { return (*this)[aIndex]; }
138 +
139 +  PRUint16 Count() const { return mCount; }
140 +
141 +  PRBool operator==(const Array& aOther) const
142 +  {
143 +    if (mCount != aOther.mCount)
144 +      return PR_FALSE;
145 +    for (PRUint16 i = 0; i < mCount; ++i)
146 +      if ((*this)[i] != aOther[i])
147 +        return PR_FALSE;
148 +    return PR_TRUE;
149 +  }
150 +
151 +  void AddRef() {
152 +    if (mRefCnt == PR_UINT16_MAX) {
153 +      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
154 +      return;
155 +    }
156 +    ++mRefCnt;
157 +    NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Array", sizeof(*this));
158 +  }
159 +  void Release() {
160 +    if (mRefCnt == PR_UINT16_MAX) {
161 +      NS_WARNING("refcount overflow, leaking nsCSSValue::Array");
162 +      return;
163 +    }
164 +    --mRefCnt;
165 +    NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Array");
166 +    if (mRefCnt == 0)
167 +      delete this;
168 +  }
169 +
170 +private:
171 +
172 +  PRUint16 mRefCnt;
173 +  const PRUint16 mCount;
174 +  // This must be the last sub-object, since we extend this array to
175 +  // be of size mCount; it needs to be a sub-object so it gets proper
176 +  // alignment.
177 +  nsCSSValue mArray[1];
178  
179 +  void* operator new(size_t aSelfSize, PRUint16 aItemCount) CPP_THROW_NEW {
180 +    return ::operator new(aSelfSize + sizeof(nsCSSValue) * (aItemCount - 1));
181 +  }
182 +
183 +  void operator delete(void* aPtr) { ::operator delete(aPtr); }
184 +
185 +  nsCSSValue* First() { return mArray; }
186 +
187 +  const nsCSSValue* First() const { return mArray; }
188 +
189 +#define CSSVALUE_LIST_FOR_EXTRA_VALUES(var)                                   \
190 +for (nsCSSValue *var = First() + 1, *var##_end = First() + mCount;          \
191 +     var != var##_end; ++var)
192 +
193 +  Array(PRUint16 aItemCount)
194 +    : mRefCnt(0)
195 +    , mCount(aItemCount)
196 +  {
197 +    MOZ_COUNT_CTOR(nsCSSValue::Array);
198 +    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
199 +      new (val) nsCSSValue();
200 +    }
201 +  }
202 +
203 +  ~Array()
204 +  {
205 +    MOZ_COUNT_DTOR(nsCSSValue::Array);
206 +    CSSVALUE_LIST_FOR_EXTRA_VALUES(val) {
207 +      val->~nsCSSValue();
208 +    }
209 +  }
210 +
211 +#undef CSSVALUE_LIST_FOR_VALUES
212 +
213 +private:
214 +  Array(const Array& aOther); // not to be implemented
215 +};
216 +
217 +#endif /* nsCSSValue_h___ */