diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:55:13 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 21:55:13 +0000 |
commit | af9bff1457bc1dd342c48d0bd37747829c95f574 (patch) | |
tree | 89fb232cd39afdb7b11dd75cd90b657dae703ac6 | |
parent | f4ae6c69c4e14418a2dda5183fad7240e95c4908 (diff) | |
download | chromium_src-af9bff1457bc1dd342c48d0bd37747829c95f574.zip chromium_src-af9bff1457bc1dd342c48d0bd37747829c95f574.tar.gz chromium_src-af9bff1457bc1dd342c48d0bd37747829c95f574.tar.bz2 |
Fix minor issues in PPB_TrueTypeFont_Dev implementation.
1) PepperTrueTypeFontWin::GetTable needs to match behavior on Mac and Linux,
where we return success and copy 0 bytes if offset is off the end of a table.
2) Remove useless code from the message filter used by PepperTrueTypeFontListHost.
BUG=none
Review URL: https://codereview.chromium.org/27317003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228775 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc | 12 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_truetype_font_win.cc | 10 | ||||
-rw-r--r-- | ppapi/api/dev/ppb_truetype_font_dev.idl | 3 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_truetype_font_dev.h | 5 |
4 files changed, 12 insertions, 18 deletions
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc index 1b2aa66..ceeb73e 100644 --- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc +++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_host.cc @@ -82,13 +82,9 @@ int32_t FontMessageFilter::OnHostMsgGetFontFamilies( // Sort the names in case the host platform returns them out of order. std::sort(font_families.begin(), font_families.end()); - int32_t result = base::checked_numeric_cast<int32_t>(font_families.size()); - ppapi::host::ReplyMessageContext reply_context = - context->MakeReplyMessageContext(); - reply_context.params.set_result(result); context->reply_msg = PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply(font_families); - return result; + return base::checked_numeric_cast<int32_t>(font_families.size()); } int32_t FontMessageFilter::OnHostMsgGetFontsInFamily( @@ -98,14 +94,10 @@ int32_t FontMessageFilter::OnHostMsgGetFontsInFamily( std::vector<ppapi::proxy::SerializedTrueTypeFontDesc> fonts_in_family; GetFontsInFamily_SlowBlocking(family, &fonts_in_family); - int32_t result = base::checked_numeric_cast<int32_t>(fonts_in_family.size()); - ppapi::host::ReplyMessageContext reply_context = - context->MakeReplyMessageContext(); - reply_context.params.set_result(result); context->reply_msg = PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply( fonts_in_family); - return result; + return base::checked_numeric_cast<int32_t>(fonts_in_family.size()); } } // namespace diff --git a/content/renderer/pepper/pepper_truetype_font_win.cc b/content/renderer/pepper/pepper_truetype_font_win.cc index b8c5f96..6d04044 100644 --- a/content/renderer/pepper/pepper_truetype_font_win.cc +++ b/content/renderer/pepper/pepper_truetype_font_win.cc @@ -219,19 +219,19 @@ int32_t PepperTrueTypeFontWin::GetTable(uint32_t table_tag, if (table_size == GDI_ERROR) return PP_ERROR_FAILED; - // TODO(bbudge1) add check for when offset > file size DWORD safe_offset = std::min(static_cast<DWORD>(offset), table_size); DWORD safe_length = std::min(table_size - safe_offset, static_cast<DWORD>(max_data_length)); data->resize(safe_length); - if (max_data_length == 0) + if (safe_length == 0) { table_size = 0; - else + } else { table_size = GetFontData(hdc, table_tag, safe_offset, reinterpret_cast<uint8_t*>(&(*data)[0]), safe_length); - if (table_size == GDI_ERROR) - return PP_ERROR_FAILED; + if (table_size == GDI_ERROR) + return PP_ERROR_FAILED; + } return static_cast<int32_t>(table_size); } diff --git a/ppapi/api/dev/ppb_truetype_font_dev.idl b/ppapi/api/dev/ppb_truetype_font_dev.idl index b327eec..8a3ff2b 100644 --- a/ppapi/api/dev/ppb_truetype_font_dev.idl +++ b/ppapi/api/dev/ppb_truetype_font_dev.idl @@ -249,7 +249,8 @@ interface PPB_TrueTypeFont_Dev { * @param[in] table A 4 byte value indicating which table to copy. * For example, 'glyf' will cause the outline table to be copied into the * output array. A zero tag value will cause the entire font to be copied. - * @param[in] offset The offset into the font table. + * @param[in] offset The offset into the font table. Passing an offset + * greater than or equal to the table size will succeed with 0 bytes copied. * @param[in] max_data_length The maximum number of bytes to transfer from * <code>offset</code>. * @param[in] output A <code>PP_ArrayOutput</code> to hold the font data. diff --git a/ppapi/c/dev/ppb_truetype_font_dev.h b/ppapi/c/dev/ppb_truetype_font_dev.h index 5172cae..1511ca4 100644 --- a/ppapi/c/dev/ppb_truetype_font_dev.h +++ b/ppapi/c/dev/ppb_truetype_font_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/ppb_truetype_font_dev.idl modified Wed Apr 17 15:38:46 2013. */ +/* From dev/ppb_truetype_font_dev.idl modified Tue Oct 15 05:52:52 2013. */ #ifndef PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ #define PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ @@ -266,7 +266,8 @@ struct PPB_TrueTypeFont_Dev_0_1 { * @param[in] table A 4 byte value indicating which table to copy. * For example, 'glyf' will cause the outline table to be copied into the * output array. A zero tag value will cause the entire font to be copied. - * @param[in] offset The offset into the font table. + * @param[in] offset The offset into the font table. Passing an offset + * greater than or equal to the table size will succeed with 0 bytes copied. * @param[in] max_data_length The maximum number of bytes to transfer from * <code>offset</code>. * @param[in] output A <code>PP_ArrayOutput</code> to hold the font data. |