| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "webkit/glue/plugins/pepper_font.h" | 7 #include "webkit/glue/plugins/pepper_font.h" |
| 8 | 8 |
| 9 #if defined(OS_LINUX) | 9 #if defined(OS_LINUX) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "third_party/ppapi/c/ppb_font.h" | 14 #include "third_party/ppapi/c/ppb_font.h" |
| 15 #include "webkit/glue/plugins/pepper_plugin_module.h" | 15 #include "webkit/glue/plugins/pepper_plugin_module.h" |
| 16 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 17 | 17 |
| 18 namespace pepper { | 18 namespace pepper { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 PP_Resource MatchFontWithFallback(PP_Module module_id, | 22 PP_Resource MatchFontWithFallback(PP_Module module_id, |
| 23 const PP_FontDescription* description) { | 23 const PP_FontDescription* description) { |
| 24 #if defined(OS_LINUX) | 24 #if defined(OS_LINUX) |
| 25 PluginModule* module = PluginModule::FromPPModule(module_id); | 25 PluginModule* module = PluginModule::FromPPModule(module_id); |
| 26 if (!module) | 26 if (!module) |
| 27 return NULL; | 27 return 0; |
| 28 | 28 |
| 29 int fd = webkit_glue::MatchFontWithFallback(description->face, | 29 int fd = webkit_glue::MatchFontWithFallback(description->face, |
| 30 description->weight >= 700, | 30 description->weight >= 700, |
| 31 description->italic, | 31 description->italic, |
| 32 description->charset); | 32 description->charset); |
| 33 if (fd == -1) | 33 if (fd == -1) |
| 34 return NULL; | 34 return 0; |
| 35 | 35 |
| 36 scoped_refptr<Font> font(new Font(module, fd)); | 36 scoped_refptr<Font> font(new Font(module, fd)); |
| 37 | 37 |
| 38 return font->GetReference(); | 38 return font->GetReference(); |
| 39 #else | 39 #else |
| 40 // For trusted pepper plugins, this is only needed in Linux since font loading | 40 // For trusted pepper plugins, this is only needed in Linux since font loading |
| 41 // on Windows and Mac works through the renderer sandbox. | 41 // on Windows and Mac works through the renderer sandbox. |
| 42 return false; | 42 return false; |
| 43 #endif | 43 #endif |
| 44 } | 44 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool rv = webkit_glue::GetFontTable( | 90 bool rv = webkit_glue::GetFontTable( |
| 91 fd_, table, static_cast<uint8_t*>(output), &temp_size); | 91 fd_, table, static_cast<uint8_t*>(output), &temp_size); |
| 92 *output_length = static_cast<uint32_t>(temp_size); | 92 *output_length = static_cast<uint32_t>(temp_size); |
| 93 return rv; | 93 return rv; |
| 94 #else | 94 #else |
| 95 return false; | 95 return false; |
| 96 #endif | 96 #endif |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace pepper | 99 } // namespace pepper |
| OLD | NEW |