updated on Wed Jan 25 20:08:56 UTC 2012
[aur-mirror.git] / firefox2 / iceweasel_2.0.0.12-1_part.patch
blob69160ecadac20193af25e4299785a89acf123123
1 --- iceweasel-2.0.0.12.orig/gfx/src/gtk/nsFontMetricsPango.cpp
2 +++ iceweasel-2.0.0.12/gfx/src/gtk/nsFontMetricsPango.cpp
3 @@ -537,11 +537,23 @@
4 nsRenderingContextGTK *aContext)
6 nsresult rv = NS_OK;
8 + gchar *text = NULL;
9 PangoLayout *layout = pango_layout_new(mPangoContext);
11 - gchar *text = g_utf16_to_utf8(aString, aLength,
12 - NULL, NULL, NULL);
13 + // Just copy the aString to ensure the alignment,
14 + // it is not used anywhere else.
15 + PRUnichar* dummy = (PRUnichar *) PR_Malloc(aLength*sizeof(PRUnichar));
16 + if(!dummy) {
17 +#ifdef DEBUG
18 + NS_WARNING("nsFontMetricsPango::GetTextDimensions malloc() failed");
19 +#endif
20 + rv = NS_ERROR_FAILURE;
21 + goto out;
22 + }
23 + memcpy(dummy, aString, aLength*sizeof(PRUnichar));
24 + text = g_utf16_to_utf8(dummy, aLength,
25 + NULL, NULL, NULL);
26 + PR_Free(dummy);
28 if (!text) {
29 #ifdef DEBUG
30 @@ -582,6 +594,7 @@
32 loser:
33 g_free(text);
34 + out:
35 g_object_unref(layout);
37 return rv;
38 @@ -952,7 +965,6 @@
40 int trailing = 0;
41 int inx = 0;
42 - gboolean found = FALSE;
43 const gchar *curChar;
44 PRInt32 retval = 0;
46 @@ -978,22 +990,12 @@
47 pango_layout_set_text(layout, text, strlen(text));
48 FixupSpaceWidths(layout, text);
50 - found = pango_layout_xy_to_index(layout, localX, localY,
51 - &inx, &trailing);
52 + pango_layout_xy_to_index(layout, localX, localY,
53 + &inx, &trailing);
55 // Convert the index back to the utf-16 index
56 curChar = text;
58 - // Jump to the end if it's not found.
59 - if (!found) {
60 - if (inx == 0)
61 - retval = 0;
62 - else if (trailing)
63 - retval = aLength;
65 - goto loser;
66 - }
68 for (PRUint32 curOffset=0; curOffset < aLength;
69 curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
71 --- iceweasel-2.0.0.12.orig/gfx/src/gtk/nsFontMetricsXft.cpp
72 +++ iceweasel-2.0.0.12/gfx/src/gtk/nsFontMetricsXft.cpp
73 @@ -2200,19 +2200,27 @@
74 nsAutoDrawSpecBuffer::Flush()
76 if (mSpecPos) {
77 - // Some Xft libraries will crash if none of the glyphs have any
78 - // area. So before we draw, we scan through the glyphs. If we
79 - // find any that have area, we can draw.
80 - for (PRUint32 i = 0; i < mSpecPos; i++) {
81 - XftGlyphFontSpec *sp = &mSpecBuffer[i];
82 - XGlyphInfo info;
83 - XftGlyphExtents(GDK_DISPLAY(), sp->font, &sp->glyph, 1, &info);
84 - if (info.width && info.height) {
85 - // If we get here it means we found a drawable glyph. We will
86 - // Draw all the remaining glyphs and then break out of the loop
87 - XftDrawGlyphFontSpec(mDraw, mColor, mSpecBuffer+i, mSpecPos-i);
88 - break;
89 + // There are two Xft problems to work around here:
90 + // 1. Some Xft libraries reportedly crash if none of the
91 + // glyphs have any area.
92 + // 2. Because of an apparent X server bug (see bug 252033),
93 + // a glyph with no area may cause all following glyphs to be
94 + // dropped under some circumstances.
95 + // For this reason, we manually ship out blocks of glyphs with
96 + // area and skip blocks of glyphs with no area.
97 + PRUint32 start = 0;
98 + while (start < mSpecPos) {
99 + PRUint32 i;
100 + for (i = start; i < mSpecPos; i++) {
101 + XftGlyphFontSpec *sp = &mSpecBuffer[i];
102 + XGlyphInfo info;
103 + XftGlyphExtents(GDK_DISPLAY(), sp->font, &sp->glyph, 1, &info);
104 + if (!info.width || !info.height)
105 + break;
107 + if (i > start)
108 + XftDrawGlyphFontSpec(mDraw, mColor, mSpecBuffer+start, i-start);
109 + start = i + 1;
111 mSpecPos = 0;