diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 22:25:54 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 22:25:54 +0000 |
commit | adb072f92d93e5adf28a77fb4f6c15effca7b001 (patch) | |
tree | 11043d294f773825ecd59aa8f8ede9df549f1e30 /chrome/renderer/webplugin_delegate_pepper.cc | |
parent | d4d1b878fde9f01c21a8e247288d56df1e5382c6 (diff) | |
download | chromium_src-adb072f92d93e5adf28a77fb4f6c15effca7b001.zip chromium_src-adb072f92d93e5adf28a77fb4f6c15effca7b001.tar.gz chromium_src-adb072f92d93e5adf28a77fb4f6c15effca7b001.tar.bz2 |
Add a font API to Pepper and implement on Linux based on agl's code from http://codereview.chromium.org/2673003.
Review URL: http://codereview.chromium.org/2794004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/webplugin_delegate_pepper.cc')
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc index 1fd996e..69b1b0e 100644 --- a/chrome/renderer/webplugin_delegate_pepper.cc +++ b/chrome/renderer/webplugin_delegate_pepper.cc @@ -9,6 +9,10 @@ #include <string> #include <vector> +#if defined(OS_LINUX) +#include <unistd.h> +#endif + #include "base/file_util.h" #include "base/keyboard_codes.h" #if defined(OS_MACOSX) @@ -27,6 +31,9 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/pepper_widget.h" #include "chrome/renderer/render_thread.h" +#if defined(OS_LINUX) +#include "chrome/renderer/renderer_sandbox_support_linux.h" +#endif #include "chrome/renderer/webplugin_delegate_proxy.h" #include "gfx/blit.h" #if defined(OS_WIN) @@ -426,6 +433,58 @@ bool WebPluginDelegatePepper::SetCursor(NPCursorType type) { return true; } +NPError NPMatchFontWithFallback(NPP instance, + const NPFontDescription* description, + NPFontID* id) { +#if defined(OS_LINUX) + int fd = renderer_sandbox_support::MatchFontWithFallback( + description->face, description->weight >= 700, description->italic, + description->charset); + if (fd == -1) + return NPERR_GENERIC_ERROR; + *id = fd; + return NPERR_NO_ERROR; +#else + NOTIMPLEMENTED(); + return NPERR_GENERIC_ERROR; +#endif +} + +NPError GetFontTable(NPP instance, + NPFontID id, + uint32_t table, + void* output, + size_t* output_length) { +#if defined(OS_LINUX) + bool rv = renderer_sandbox_support::GetFontTable( + id, table, static_cast<uint8_t*>(output), output_length); + return rv ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR; +#else + NOTIMPLEMENTED(); + return NPERR_GENERIC_ERROR; +#endif +} + +NPError NPDestroyFont(NPP instance, NPFontID id) { +#if defined(OS_LINUX) + close(id); + return NPERR_NO_ERROR; +#else + NOTIMPLEMENTED(); + return NPERR_GENERIC_ERROR; +#endif +} + +NPFontExtensions g_font_extensions = { + NPMatchFontWithFallback, + GetFontTable, + NPDestroyFont +}; + +NPFontExtensions* WebPluginDelegatePepper::GetFontExtensions() { + return &g_font_extensions; +} + void WebPluginDelegatePepper::Zoom(int factor) { NPPExtensions* extensions = NULL; instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); |