mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 670901 pt 3 - add OTS message callback and enable error reporting in our build. r=jdaggett
This commit is contained in:
parent
5d3c693bcf
commit
589ff39ea3
@ -88,6 +88,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
DEFINES += -DPACKAGE_VERSION="\"moz\""
|
||||
DEFINES += -DPACKAGE_BUGREPORT="\"http://bugzilla.mozilla.org/\""
|
||||
DEFINES += -DNOMINMAX
|
||||
DEFINES += -DMOZ_OTS_REPORT_ERRORS
|
||||
|
||||
ifeq (WINNT,$(OS_TARGET))
|
||||
DEFINES += -DOTS_DLL -DOTS_DLL_EXPORTS
|
||||
|
@ -337,6 +337,7 @@ endif
|
||||
CSRCS += woff.c
|
||||
|
||||
DEFINES += -DIMPL_THEBES -DWOFF_MOZILLA_CLIENT -DHB_DONT_DEFINE_STDINT
|
||||
DEFINES += -DMOZ_OTS_REPORT_ERRORS
|
||||
|
||||
ifeq (WINNT,$(OS_TARGET))
|
||||
DEFINES += -DOTS_DLL
|
||||
|
@ -322,11 +322,38 @@ private:
|
||||
off_t mOff;
|
||||
};
|
||||
|
||||
#ifdef MOZ_OTS_REPORT_ERRORS
|
||||
struct OTSCallbackUserData {
|
||||
gfxUserFontSet *mFontSet;
|
||||
gfxProxyFontEntry *mProxy;
|
||||
};
|
||||
|
||||
/* static */ bool
|
||||
gfxUserFontSet::OTSMessage(void *aUserData, const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
|
||||
// buf should be more than adequate for any message OTS generates,
|
||||
// so we don't worry about checking the result of vsnprintf()
|
||||
char buf[512];
|
||||
(void)vsnprintf(buf, sizeof(buf), format, va);
|
||||
|
||||
va_end(va);
|
||||
|
||||
OTSCallbackUserData *d = static_cast<OTSCallbackUserData*>(aUserData);
|
||||
d->mFontSet->LogMessage(d->mProxy, buf);
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Call the OTS library to sanitize an sfnt before attempting to use it.
|
||||
// Returns a newly-allocated block, or NULL in case of fatal errors.
|
||||
static const PRUint8*
|
||||
SanitizeOpenTypeData(const PRUint8* aData, PRUint32 aLength,
|
||||
PRUint32& aSaneLength, bool aIsCompressed)
|
||||
const PRUint8*
|
||||
gfxUserFontSet::SanitizeOpenTypeData(gfxProxyFontEntry *aProxy,
|
||||
const PRUint8* aData, PRUint32 aLength,
|
||||
PRUint32& aSaneLength, bool aIsCompressed)
|
||||
{
|
||||
// limit output/expansion to 256MB
|
||||
ExpandingMemoryStream output(aIsCompressed ? aLength * 2 : aLength,
|
||||
@ -336,7 +363,19 @@ SanitizeOpenTypeData(const PRUint8* aData, PRUint32 aLength,
|
||||
#else
|
||||
#define PRESERVE_GRAPHITE false
|
||||
#endif
|
||||
if (ots::Process(&output, aData, aLength, PRESERVE_GRAPHITE)) {
|
||||
|
||||
#ifdef MOZ_OTS_REPORT_ERRORS
|
||||
OTSCallbackUserData userData;
|
||||
userData.mFontSet = this;
|
||||
userData.mProxy = aProxy;
|
||||
#define ERROR_REPORTING_ARGS &gfxUserFontSet::OTSMessage, &userData,
|
||||
#else
|
||||
#define ERROR_REPORTING_ARGS
|
||||
#endif
|
||||
|
||||
if (ots::Process(&output, aData, aLength,
|
||||
ERROR_REPORTING_ARGS
|
||||
PRESERVE_GRAPHITE)) {
|
||||
aSaneLength = output.Tell();
|
||||
return static_cast<PRUint8*>(output.forget());
|
||||
} else {
|
||||
@ -632,7 +671,7 @@ gfxUserFontSet::LoadFont(gfxProxyFontEntry *aProxy,
|
||||
// if necessary. The original data in aFontData is left unchanged.
|
||||
PRUint32 saneLen;
|
||||
const PRUint8* saneData =
|
||||
SanitizeOpenTypeData(aFontData, aLength, saneLen,
|
||||
SanitizeOpenTypeData(aProxy, aFontData, aLength, saneLen,
|
||||
fontType == GFX_USERFONT_WOFF);
|
||||
if (!saneData) {
|
||||
LogMessage(aProxy, "rejected by sanitizer");
|
||||
|
@ -261,6 +261,16 @@ protected:
|
||||
PRUint32 aFlags = nsIScriptError::errorFlag,
|
||||
nsresult aStatus = 0) = 0;
|
||||
|
||||
const PRUint8* SanitizeOpenTypeData(gfxProxyFontEntry *aProxy,
|
||||
const PRUint8* aData,
|
||||
PRUint32 aLength,
|
||||
PRUint32& aSaneLength,
|
||||
bool aIsCompressed);
|
||||
|
||||
#ifdef MOZ_OTS_REPORT_ERRORS
|
||||
static bool OTSMessage(void *aUserData, const char *format, ...);
|
||||
#endif
|
||||
|
||||
// font families defined by @font-face rules
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxMixedFontFamily> mFontFamilies;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user