Bug 1074809 - For OTS warning (rather than failure) messages, only log the first occurrence of any given message per font. r=jdaggett, a=lmandel
authorJonathan Kew <jkew@mozilla.com>
Fri, 17 Oct 2014 09:48:06 +0100
changeset 225723 1875f4aff106
parent 225722 0b7106ef79d2
child 225724 c00a4cfe83e9
push id3992
push userryanvm@gmail.com
push date2014-10-17 13:09 +0000
treeherdermozilla-beta@f752e25f4c42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett, lmandel
bugs1074809
milestone34.0
Bug 1074809 - For OTS warning (rather than failure) messages, only log the first occurrence of any given message per font. r=jdaggett, a=lmandel
gfx/thebes/gfxUserFontSet.cpp
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -192,29 +192,37 @@ 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);
 
-        mProxy->mFontSet->LogMessage(mFamily, mProxy, 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);
+        }
+
+        mProxy->mFontSet->LogMessage(mFamily, mProxy, msg.get());
     }
 
 private:
     gfxMixedFontFamily *mFamily;
     gfxProxyFontEntry  *mProxy;
+    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*
 gfxProxyFontEntry::SanitizeOpenTypeData(gfxMixedFontFamily *aFamily,
                                         const uint8_t* aData,
                                         uint32_t       aLength,