Bug 1256678 - Replace DrawTargetCairo::FillGlyphs crashes with other crashes - r=bobowen

This commit is contained in:
Edwin Flores 2016-04-06 11:07:27 +01:00
parent 686a6af75b
commit 7cb6393ecc
4 changed files with 15 additions and 6 deletions

View File

@ -389,6 +389,10 @@ DrawTargetRecording::FillGlyphs(ScaledFont *aFont,
{
EnsurePatternDependenciesStored(aPattern);
if (aFont->GetType() != FontType::DWRITE && aFont->GetType() != FontType::GDI) {
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Unexpected ScaledFont type " << (int)aFont->GetType();
}
if (!aFont->GetUserData(reinterpret_cast<UserDataKey*>(mRecorder.get()))) {
// TODO support font in b2g recordings
#ifndef MOZ_WIDGET_GONK

View File

@ -133,6 +133,7 @@ enum class LogReason : int {
IncompatibleBasicTexturedEffect,
InvalidFont,
PAllocTextureBackendMismatch,
GetFontFileDataFailed,
// End
MustBeLessThanThis = 101,
};

View File

@ -116,7 +116,7 @@ SFNTData::Create(const uint8_t *aFontData, uint32_t aDataLength)
// Check to see if this is a font collection.
if (aDataLength < sizeof(TTCHeader)) {
gfxWarning() << "Font data too short.";
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Font data too short: length = " << aDataLength;
return nullptr;
}
@ -124,7 +124,7 @@ SFNTData::Create(const uint8_t *aFontData, uint32_t aDataLength)
if (ttcHeader->ttcTag == TRUETYPE_TAG('t', 't', 'c', 'f')) {
uint32_t numFonts = ttcHeader->numFonts;
if (aDataLength < sizeof(TTCHeader) + (numFonts * sizeof(BigEndianUint32))) {
gfxWarning() << "Font data too short to contain full TTC Header.";
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Font data too short to contain full TTC Header: numFonts = " << numFonts << "; length = " << aDataLength;
return nullptr;
}
@ -134,6 +134,7 @@ SFNTData::Create(const uint8_t *aFontData, uint32_t aDataLength)
const BigEndianUint32* endOfOffsets = offset + numFonts;
while (offset != endOfOffsets) {
if (!sfntData->AddFont(aFontData, aDataLength, *offset)) {
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Failed to add font data from TTC";
return nullptr;
}
++offset;
@ -144,6 +145,7 @@ SFNTData::Create(const uint8_t *aFontData, uint32_t aDataLength)
UniquePtr<SFNTData> sfntData(new SFNTData);
if (!sfntData->AddFont(aFontData, aDataLength, 0)) {
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Failed to add single font data";
return nullptr;
}
@ -223,7 +225,7 @@ SFNTData::AddFont(const uint8_t *aFontData, uint32_t aDataLength,
{
uint32_t remainingLength = aDataLength - aOffset;
if (remainingLength < sizeof(OffsetTable)) {
gfxWarning() << "Font data too short to contain OffsetTable " << aOffset;
gfxCriticalError() << "Font data too short to contain OffsetTable: offset = " << aOffset << "; length = " << aDataLength;
return false;
}
@ -231,7 +233,7 @@ SFNTData::AddFont(const uint8_t *aFontData, uint32_t aDataLength,
reinterpret_cast<const OffsetTable*>(aFontData + aOffset);
if (remainingLength <
sizeof(OffsetTable) + (offsetTable->numTables * sizeof(TableDirEntry))) {
gfxWarning() << "Font data too short to contain tables.";
gfxCriticalError() << "Font data too short to contain tables. numTables = " << offsetTable->numTables << "; offset = " << aOffset << "; length = " << aDataLength;
return false;
}

View File

@ -40,6 +40,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
table = 0;
tableSize = ::GetFontData(dc.GetDC(), table, 0, nullptr, 0);
if (tableSize == GDI_ERROR) {
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Failed to get font data from GDI";
return false;
}
}
@ -49,6 +50,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
uint32_t sizeGot =
::GetFontData(dc.GetDC(), table, 0, fontData.get(), tableSize);
if (sizeGot != tableSize) {
gfxDevCrash(LogReason::GetFontFileDataFailed) << "GDI did not return enough data for font: wanted " << tableSize << ", got " << sizeGot;
return false;
}
@ -58,7 +60,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
UniquePtr<SFNTData> sfntData = SFNTData::Create(fontData.get(),
tableSize);
if (!sfntData) {
gfxWarning() << "Failed to create SFNTData for GetFontFileData.";
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Failed to create SFNTData for GetFontFileData.";
return false;
}
@ -66,7 +68,7 @@ ScaledFontWin::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
// both 16 bit.
if (!sfntData->GetIndexForU16Name(
reinterpret_cast<char16_t*>(mLogFont.lfFaceName), &index)) {
gfxWarning() << "Failed to get index for face name.";
gfxDevCrash(LogReason::GetFontFileDataFailed) << "Failed to get index for face name.";
return false;
}
}