Bug 380153 - SetupClusterBoundaries uses unset attrs from pango_break after NUL.

p=Karl Tomlinson <mozbugz@karlt.net>
r=roc
This commit is contained in:
asqueella%gmail.com 2007-05-13 12:31:24 +00:00
Родитель 95cd743e81
Коммит 337f2fc2d7
1 изменённых файлов: 24 добавлений и 15 удалений

Просмотреть файл

@ -1049,27 +1049,36 @@ SetupClusterBoundaries(gfxTextRun* aTextRun, const gchar *aUTF8, PRUint32 aUTF8L
if (!buffer.AppendElements(aUTF8Length + 1))
return;
pango_break(aUTF8, aUTF8Length, aAnalysis,
buffer.Elements(), buffer.Length());
const gchar *p = aUTF8;
const gchar *end = aUTF8 + aUTF8Length;
const PangoLogAttr *attr = buffer.Elements();
gfxTextRun::CompressedGlyph g;
while (p < end) {
if (!attr->is_cursor_position) {
aTextRun->SetCharacterGlyph(aUTF16Offset, g.SetClusterContinuation());
}
++aUTF16Offset;
gunichar ch = g_utf8_get_char(p);
NS_ASSERTION(!IS_SURROGATE(ch), "Shouldn't have surrogates in UTF8");
if (ch >= 0x10000) {
PangoLogAttr *attr = buffer.Elements();
pango_break(p, end - p, aAnalysis, attr, buffer.Length());
while (p < end) {
if (!attr->is_cursor_position) {
aTextRun->SetCharacterGlyph(aUTF16Offset, g.SetClusterContinuation());
}
++aUTF16Offset;
gunichar ch = g_utf8_get_char(p);
NS_ASSERTION(!IS_SURROGATE(ch), "Shouldn't have surrogates in UTF8");
if (ch >= 0x10000) {
++aUTF16Offset;
}
// We produced this utf8 so we don't need to worry about malformed stuff
p = g_utf8_next_char(p);
++attr;
if (ch == 0) {
// pango_break (pango 1.16.2) only analyses text before the
// first NUL (but sets one extra attr), so call pango_break
// again to analyse after the NUL.
break;
}
}
// We produced this utf8 so we don't need to worry about malformed stuff
p = g_utf8_next_char(p);
++attr;
}
}