Bug 1074809 - For OTS warning (rather than failure) messages, only log the first occurrence of any given message per font. r=jdaggett
authorJonathan Kew <jkew@mozilla.com>
Fri, 10 Oct 2014 14:50:52 +0100
changeset 233071 0402daa909e416b596ddac2980e916907ed27205
parent 233070 e0662f559c632a79ce1021e0eada0953590d14ce
child 233072 0fbe7cd05a11269bcdd7e43da91ff16994fd97ff
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs1074809
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1074809 - For OTS warning (rather than failure) messages, only log the first occurrence of any given message per font. r=jdaggett
gfx/thebes/gfxUserFontSet.cpp
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -194,28 +194,36 @@ public:
         return ots::TABLE_ACTION_DEFAULT;
     }
 
     virtual void Message(int level, const char* format,
                          ...) MSGFUNC_FMT_ATTR MOZ_OVERRIDE {
         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);
+        nsCString msg;
+        msg.AppendPrintf(format, va);
 
         va_end(va);
 
-        mUserFontEntry->mFontSet->LogMessage(mUserFontEntry, buf);
+        if (level > 0) {
+            // For warnings (rather than errors that cause the font to fail),
+            // we only report the first instance of any given message.
+            if (mWarningsIssued.Contains(msg)) {
+                return;
+            }
+            mWarningsIssued.PutEntry(msg);
+        }
+
+        mUserFontEntry->mFontSet->LogMessage(mUserFontEntry, msg.get());
     }
 
 private:
     gfxUserFontEntry* mUserFontEntry;
+    nsTHashtable<nsCStringHashKey> mWarningsIssued;
 };
 
 // Call the OTS library to sanitize an sfnt before attempting to use it.
 // Returns a newly-allocated block, or nullptr in case of fatal errors.
 const uint8_t*
 gfxUserFontEntry::SanitizeOpenTypeData(const uint8_t* aData,
                                        uint32_t       aLength,
                                        uint32_t&      aSaneLength,