Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1260)

Unified Diff: Source/platform/fonts/opentype/OpenTypeSanitizer.cpp

Issue 983973004: Provide user friendly messages for OTS parsing of fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Correcting Method call Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
diff --git a/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp b/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
index c5e71ae45976e36add0d0c78f017cdfcaa0c23f9..3ac7e9b6e81db2da6307f92f592d8e9154916550 100644
--- a/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
+++ b/Source/platform/fonts/opentype/OpenTypeSanitizer.cpp
@@ -58,6 +58,8 @@ static void recordDecodeSpeedHistogram(SharedBuffer* buffer, double decodeTime,
PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize()
{
+ // OTS parsing is not called yet, setting parsing error for OTS as false
+ setParsingError(false);
jungshik at Google 2015/06/01 23:22:19 You don't need to call an accessor. Why don't you
h.joshi 2015/06/04 15:19:16 Done.
if (!m_buffer)
jungshik at Google 2015/06/01 23:22:19 Set the error message to 'Empty Buffer' or somethi
h.joshi 2015/06/04 15:19:16 Done.
return nullptr;
@@ -77,8 +79,11 @@ PassRefPtr<SharedBuffer> OpenTypeSanitizer::sanitize()
double start = currentTime();
BlinkOTSContext otsContext;
- if (!otsContext.Process(&output, reinterpret_cast<const uint8_t*>(m_buffer->data()), m_buffer->size()))
+ if (!otsContext.Process(&output, reinterpret_cast<const uint8_t*>(m_buffer->data()), m_buffer->size())) {
+ setParsingError(true);
+ setErrorString(otsContext.getErrorString());
jungshik at Google 2015/06/01 23:22:19 again, you don't need accessors to set member vari
h.joshi 2015/06/04 15:19:16 Done.
return nullptr;
+ }
const size_t transcodeLen = output.Tell();
recordDecodeSpeedHistogram(m_buffer, currentTime() - start, transcodeLen);
@@ -90,4 +95,54 @@ bool OpenTypeSanitizer::supportsFormat(const String& format)
return equalIgnoringCase(format, "woff") || equalIgnoringCase(format, "woff2");
}
+void BlinkOTSContext::Message(int level, const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+#if COMPILER(MSVC)
+ int result = _vscprintf(format, args);
+#else
+ char ch;
+ int result = vsnprintf(&ch, 1, format, args);
+#endif
+ va_end(args);
+
+ if (result <= 0) {
+ m_errorString = String("OTS Error");
+ } else {
+ Vector<char, 256> buffer;
+ unsigned len = result;
+ buffer.grow(len + 1);
+
+ va_start(args, format);
+ vsnprintf(buffer.data(), buffer.size(), format, args);
+ va_end(args);
+ m_errorString = StringImpl::create(reinterpret_cast<const LChar*>(buffer.data()), len);
+ }
+}
+
+ots::TableAction BlinkOTSContext::GetTableAction(uint32_t tag)
+{
+#define TABLE_TAG(c1, c2, c3, c4) ((uint32_t)((((uint8_t)(c1)) << 24) | (((uint8_t)(c2)) << 16) | (((uint8_t)(c3)) << 8) | ((uint8_t)(c4))))
+
+ const uint32_t cbdtTag = TABLE_TAG('C', 'B', 'D', 'T');
+ const uint32_t cblcTag = TABLE_TAG('C', 'B', 'L', 'C');
+ const uint32_t colrTag = TABLE_TAG('C', 'O', 'L', 'R');
+ const uint32_t cpalTag = TABLE_TAG('C', 'P', 'A', 'L');
+
+ switch (tag) {
+ // Google Color Emoji Tables
+ case cbdtTag:
+ case cblcTag:
+ // Windows Color Emoji Tables
+ case colrTag:
+ case cpalTag:
+ return ots::TABLE_ACTION_PASSTHRU;
+ default:
+ return ots::TABLE_ACTION_DEFAULT;
+ }
+#undef TABLE_TAG
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698