bug 941940 - don't render stray <CR> characters (&#13; entities) in the DOM as hexboxes, just leave them invisible. r=roc

This commit is contained in:
Jonathan Kew 2013-11-22 21:43:36 +00:00
parent e5b0dcb0bd
commit 464d663376

View File

@ -3311,6 +3311,17 @@ gfxFont::ShapeFragmentWithoutWordCache(gfxContext *aContext,
return ok;
}
// Check if aCh is an unhandled control character that should be displayed
// as a hexbox rather than rendered by some random font on the system.
// We exclude \r as stray &#13;s are rather common (bug 941940).
// Note that \n and \t don't come through here, as they have specific
// meanings that have already been handled.
static bool
IsInvalidControlChar(uint32_t aCh)
{
return aCh != '\r' && ((aCh & 0x7f) < 0x20 || aCh == 0x7f);
}
template<typename T>
bool
gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
@ -3350,7 +3361,7 @@ gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
aTextRun->SetIsTab(aOffset + i);
} else if (ch == '\n') {
aTextRun->SetIsNewline(aOffset + i);
} else if ((ch & 0x7f) < 0x20 || ch == 0x7f) {
} else if (IsInvalidControlChar(ch)) {
aTextRun->SetMissingGlyph(aOffset + i, ch, this);
}
fragStart = i + 1;
@ -3494,7 +3505,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
aTextRun->SetIsTab(aRunStart + i);
} else if (ch == '\n') {
aTextRun->SetIsNewline(aRunStart + i);
} else if ((ch & 0x7f) < 0x20 || ch == 0x7f) {
} else if (IsInvalidControlChar(ch)) {
aTextRun->SetMissingGlyph(aRunStart + i, ch, this);
}