updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / firefox2 / firefox-1.5-xft-rangewidth.patch
blob1ecc5f23acfa1fc6d6136886ae3e4a87d083c0f1
1 diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp mozilla/gfx/src/gtk/nsFontMetricsXft.cpp
2 --- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp 2006-04-25 08:58:36.000000000 +0900
3 +++ mozilla/gfx/src/gtk/nsFontMetricsXft.cpp 2007-02-08 01:50:05.000000000 +0900
4 @@ -227,10 +227,14 @@ static nsresult EnumFontsXft (nsIAto
6 static void ConvertCharToUCS4 (const char *aString,
7 PRUint32 aLength,
8 + PRUint32 aStart,
9 + PRUint32 aEnd,
10 nsAutoFcChar32Buffer &aOutBuffer,
11 PRUint32 *aOutLen);
12 static void ConvertUnicharToUCS4 (const PRUnichar *aString,
13 PRUint32 aLength,
14 + PRUint32 aStart,
15 + PRUint32 aEnd,
16 nsAutoFcChar32Buffer &aOutBuffer,
17 PRUint32 *aOutLen);
18 static nsresult ConvertUCS4ToCustom (FcChar32 *aSrc, PRUint32 aSrcLen,
19 @@ -507,7 +511,7 @@ nsFontMetricsXft::GetWidth(const PRUnich
20 return NS_OK;
23 - gint rawWidth = RawGetWidth(aString, aLength);
24 + gint rawWidth = RawGetWidth(aString, aLength, 0, aLength);
26 float f;
27 f = mDeviceContext->DevUnitsToAppUnits();
28 @@ -533,7 +537,7 @@ nsFontMetricsXft::GetTextDimensions(cons
29 return NS_OK;
31 nsresult rv;
32 - rv = EnumerateGlyphs(aString, aLength,
33 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
34 &nsFontMetricsXft::TextDimensionsCallback,
35 &aDimensions);
37 @@ -608,7 +612,7 @@ nsFontMetricsXft::DrawString(const char
38 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
39 data.drawBuffer = &drawBuffer;
41 - return EnumerateGlyphs(aString, aLength,
42 + return EnumerateGlyphs(aString, aLength, 0, aLength,
43 &nsFontMetricsXft::DrawStringCallback, &data);
46 @@ -638,7 +642,7 @@ nsFontMetricsXft::DrawString(const PRUni
47 nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
48 data.drawBuffer = &drawBuffer;
50 - return EnumerateGlyphs(aString, aLength,
51 + return EnumerateGlyphs(aString, aLength, 0, aLength,
52 &nsFontMetricsXft::DrawStringCallback, &data);
55 @@ -662,7 +666,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
56 data.firstTime = PR_TRUE;
58 nsresult rv;
59 - rv = EnumerateGlyphs(aString, aLength,
60 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
61 &nsFontMetricsXft::BoundingMetricsCallback, &data);
62 NS_ENSURE_SUCCESS(rv, rv);
64 @@ -700,7 +704,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
65 data.firstTime = PR_TRUE;
67 nsresult rv;
68 - rv = EnumerateGlyphs(aString, aLength,
69 + rv = EnumerateGlyphs(aString, aLength, 0, aLength,
70 &nsFontMetricsXft::BoundingMetricsCallback, &data);
71 NS_ENSURE_SUCCESS(rv, rv);
73 @@ -758,7 +762,17 @@ nsFontMetricsXft::GetRangeWidth(const PR
74 PRUint32 aEnd,
75 PRUint32 &aWidth)
77 - return NS_ERROR_NOT_IMPLEMENTED;
78 + if (!aLength) {
79 + aWidth = 0;
80 + return NS_OK;
81 + }
83 + gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
84 + float f = mDeviceContext->DevUnitsToAppUnits();
86 + aWidth = NSToCoordRound(rawWidth * f);
88 + return NS_OK;
91 nsresult
92 @@ -768,7 +782,17 @@ nsFontMetricsXft::GetRangeWidth(const ch
93 PRUint32 aEnd,
94 PRUint32 &aWidth)
96 - return NS_ERROR_NOT_IMPLEMENTED;
97 + if (!aLength) {
98 + aWidth = 0;
99 + return NS_OK;
102 + gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
103 + float f = mDeviceContext->DevUnitsToAppUnits();
105 + aWidth = NSToCoordRound(rawWidth * f);
107 + return NS_OK;
110 PRUint32
111 @@ -850,12 +874,12 @@ nsFontMetricsXft::CacheFontMetrics(void)
112 // mSpaceWidth (width of a space)
113 gint rawWidth;
114 PRUnichar unispace(' ');
115 - rawWidth = RawGetWidth(&unispace, 1);
116 + rawWidth = RawGetWidth(&unispace, 1, 0, 1);
117 mSpaceWidth = NSToCoordRound(rawWidth * f);
119 // mAveCharWidth (width of an 'average' char)
120 PRUnichar xUnichar('x');
121 - rawWidth = RawGetWidth(&xUnichar, 1);
122 + rawWidth = RawGetWidth(&xUnichar, 1, 0, 1);
123 mAveCharWidth = NSToCoordRound(rawWidth * f);
125 // mXHeight (height of an 'x' character)
126 @@ -1226,12 +1250,27 @@ nsFontMetricsXft::DoMatch(PRBool aMatchA
129 gint
130 -nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength)
131 +nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
133 + nscoord width = 0;
134 + nsresult rv;
136 + rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
137 + &nsFontMetricsXft::GetWidthCallback, &width);
139 + if (NS_FAILED(rv))
140 + width = 0;
142 + return width;
145 +gint
146 +nsFontMetricsXft::RawGetWidth(const char* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
148 nscoord width = 0;
149 nsresult rv;
151 - rv = EnumerateGlyphs(aString, aLength,
152 + rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
153 &nsFontMetricsXft::GetWidthCallback, &width);
155 if (NS_FAILED(rv))
156 @@ -1457,6 +1496,8 @@ nsFontMetricsXft::EnumerateXftGlyphs(con
157 nsresult
158 nsFontMetricsXft::EnumerateGlyphs(const PRUnichar *aString,
159 PRUint32 aLen,
160 + PRUint32 aStart,
161 + PRUint32 aEnd,
162 GlyphEnumeratorCallback aCallback,
163 void *aCallbackData)
165 @@ -1465,7 +1506,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
167 NS_ENSURE_TRUE(aLen, NS_OK);
169 - ConvertUnicharToUCS4(aString, aLen, charBuffer, &len);
170 + ConvertUnicharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
171 if (!len)
172 return NS_ERROR_OUT_OF_MEMORY;
174 @@ -1475,6 +1516,8 @@ nsFontMetricsXft::EnumerateGlyphs(const
175 nsresult
176 nsFontMetricsXft::EnumerateGlyphs(const char *aString,
177 PRUint32 aLen,
178 + PRUint32 aStart,
179 + PRUint32 aEnd,
180 GlyphEnumeratorCallback aCallback,
181 void *aCallbackData)
183 @@ -1484,7 +1527,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
184 NS_ENSURE_TRUE(aLen, NS_OK);
186 // Convert the incoming string into an array of UCS4 chars
187 - ConvertCharToUCS4(aString, aLen, charBuffer, &len);
188 + ConvertCharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
189 if (!len)
190 return NS_ERROR_OUT_OF_MEMORY;
192 @@ -2343,7 +2386,7 @@ EnumFontsXft(nsIAtom* aLangGroup, const
194 /* static */
195 void
196 -ConvertCharToUCS4(const char *aString, PRUint32 aLength,
197 +ConvertCharToUCS4(const char *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
198 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
200 *aOutLen = 0;
201 @@ -2352,19 +2395,21 @@ ConvertCharToUCS4(const char *aString, P
202 if (!aOutBuffer.EnsureElemCapacity(aLength))
203 return;
204 outBuffer = aOutBuffer.get();
205 + if (aEnd > aLength)
206 + aEnd = aLength;
208 - for (PRUint32 i = 0; i < aLength; ++i) {
209 - outBuffer[i] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
210 + for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
211 + outBuffer[i - aStart] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
214 - *aOutLen = aLength;
215 + *aOutLen = aEnd - aStart;
218 // Convert the incoming string into an array of UCS4 chars
220 /* static */
221 void
222 -ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
223 +ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
224 nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
226 *aOutLen = 0;
227 @@ -2378,7 +2423,7 @@ ConvertUnicharToUCS4(const PRUnichar *aS
229 // Walk the passed in string looking for surrogates to convert to
230 // their full ucs4 representation.
231 - for (PRUint32 i = 0; i < aLength; ++i) {
232 + for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
233 PRUnichar c = aString[i];
235 // Optimized for the non-surrogate case
236 @@ -2693,12 +2738,12 @@ ConvertUCS4ToCustom(FcChar32 *aSrc, PRU
237 #endif
238 // Convert 16bit custom font codes to UCS4
239 ConvertUnicharToUCS4(NS_REINTERPRET_CAST(PRUnichar *, med),
240 - medLen >> 1, aResult, &aDestLen);
241 + medLen >> 1, 0, medLen >> 1, aResult, &aDestLen);
242 rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
244 else {
245 // Convert 8bit custom font codes to UCS4
246 - ConvertCharToUCS4(med, medLen, aResult, &aDestLen);
247 + ConvertCharToUCS4(med, medLen, 0, medLen, aResult, &aDestLen);
248 rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
251 diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h mozilla/gfx/src/gtk/nsFontMetricsXft.h
252 --- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h 2005-05-03 05:48:30.000000000 +0900
253 +++ mozilla/gfx/src/gtk/nsFontMetricsXft.h 2007-02-08 01:38:27.000000000 +0900
254 @@ -259,7 +259,13 @@ private:
255 void DoMatch (PRBool aMatchAll);
257 gint RawGetWidth (const PRUnichar* aString,
258 - PRUint32 aLength);
259 + PRUint32 aLength,
260 + PRUint32 aStart,
261 + PRUint32 aEnd);
262 + gint RawGetWidth (const char* aString,
263 + PRUint32 aLength,
264 + PRUint32 aStart,
265 + PRUint32 aEnd);
266 nsresult SetupMiniFont (void);
267 nsresult DrawUnknownGlyph (FcChar32 aChar,
268 nscoord aX,
269 @@ -272,10 +278,14 @@ private:
270 void *aCallbackData);
271 nsresult EnumerateGlyphs (const char *aString,
272 PRUint32 aLen,
273 + PRUint32 aStart,
274 + PRUint32 aEnd,
275 GlyphEnumeratorCallback aCallback,
276 void *aCallbackData);
277 nsresult EnumerateGlyphs (const PRUnichar *aString,
278 PRUint32 aLen,
279 + PRUint32 aStart,
280 + PRUint32 aEnd,
281 GlyphEnumeratorCallback aCallback,
282 void *aCallbackData);
283 void PrepareToDraw (nsRenderingContextGTK *aContext,