summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--chrome/renderer/renderer_glue.cc16
-rw-r--r--chrome/renderer/renderer_sandbox_support_linux.cc2
-rw-r--r--chrome/renderer/renderer_sandbox_support_linux.h4
-rw-r--r--webkit/glue/plugins/pepper_font.cc100
-rw-r--r--webkit/glue/plugins/pepper_font.h39
-rw-r--r--webkit/glue/plugins/pepper_plugin_module.cc4
-rw-r--r--webkit/glue/plugins/pepper_resource.h3
-rw-r--r--webkit/glue/webkit_glue.gypi2
-rw-r--r--webkit/glue/webkit_glue.h20
-rw-r--r--webkit/support/webkit_support_glue.cc12
-rw-r--r--webkit/tools/test_shell/test_shell.cc12
12 files changed, 211 insertions, 5 deletions
diff --git a/DEPS b/DEPS
index c4592e2..7ff5d11 100644
--- a/DEPS
+++ b/DEPS
@@ -158,7 +158,7 @@ deps = {
Var("libvpx_revision"),
"src/third_party/ppapi":
- "http://ppapi.googlecode.com/svn/trunk@142",
+ "http://ppapi.googlecode.com/svn/trunk@147",
"src/third_party/libjingle/source":
"http://libjingle.googlecode.com/svn/branches/nextsnap@" +
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index d740c6e..849565a 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -39,6 +39,8 @@
#if defined(OS_WIN)
#include <strsafe.h> // note: per msdn docs, this must *follow* other includes
+#elif defined(OS_LINUX)
+#include "chrome/renderer/renderer_sandbox_support_linux.h"
#endif
template <typename T, size_t stack_capacity>
@@ -311,4 +313,18 @@ bool IsSingleProcess() {
return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
}
+#if defined(OS_LINUX)
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset) {
+ return renderer_sandbox_support::MatchFontWithFallback(
+ face, bold, italic, charset);
+}
+
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length) {
+ return renderer_sandbox_support::GetFontTable(
+ fd, table, output, output_length);
+}
+#endif
+
} // namespace webkit_glue
diff --git a/chrome/renderer/renderer_sandbox_support_linux.cc b/chrome/renderer/renderer_sandbox_support_linux.cc
index 4b02bbce..6733f75 100644
--- a/chrome/renderer/renderer_sandbox_support_linux.cc
+++ b/chrome/renderer/renderer_sandbox_support_linux.cc
@@ -93,7 +93,7 @@ int MakeSharedMemorySegmentViaIPC(size_t length) {
}
int MatchFontWithFallback(const std::string& face, bool bold,
- bool italic, NPCharset charset) {
+ bool italic, int charset) {
Pickle request;
request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
request.WriteString(face);
diff --git a/chrome/renderer/renderer_sandbox_support_linux.h b/chrome/renderer/renderer_sandbox_support_linux.h
index 098c46e..5f216f1 100644
--- a/chrome/renderer/renderer_sandbox_support_linux.h
+++ b/chrome/renderer/renderer_sandbox_support_linux.h
@@ -9,8 +9,6 @@
#include <string>
-#include "third_party/npapi/bindings/npapi_extensions.h"
-
namespace WebKit {
struct WebFontRenderStyle;
}
@@ -37,7 +35,7 @@ int MakeSharedMemorySegmentViaIPC(size_t length);
// charset: specifies the language(s) that the font must cover. See
// render_sandbox_host_linux.cc for more information.
int MatchFontWithFallback(const std::string& face, bool bold,
- bool italic, NPCharset charset);
+ bool italic, int charset);
// GetFontTable loads a specified font table from an open SFNT file.
// fd: a file descriptor to the SFNT file. The position doesn't matter.
diff --git a/webkit/glue/plugins/pepper_font.cc b/webkit/glue/plugins/pepper_font.cc
new file mode 100644
index 0000000..8bc48a3
--- /dev/null
+++ b/webkit/glue/plugins/pepper_font.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "build/build_config.h"
+
+#include "webkit/glue/plugins/pepper_font.h"
+
+#if defined(OS_LINUX)
+#include <unistd.h>
+#endif
+
+#include "base/logging.h"
+#include "third_party/ppapi/c/ppb_font.h"
+#include "webkit/glue/plugins/pepper_plugin_module.h"
+#include "webkit/glue/webkit_glue.h"
+
+namespace pepper {
+
+namespace {
+
+PP_Resource MatchFontWithFallback(PP_Module module_id,
+ const PP_FontDescription* description) {
+#if defined(OS_LINUX)
+ PluginModule* module = PluginModule::FromPPModule(module_id);
+ if (!module)
+ return NULL;
+
+ int fd = webkit_glue::MatchFontWithFallback(description->face,
+ description->weight >= 700,
+ description->italic,
+ description->charset);
+ if (fd == -1)
+ return NULL;
+
+ scoped_refptr<Font> font(new Font(module, fd));
+ font->AddRef(); // AddRef for the caller.
+
+ return font->GetResource();
+#else
+ // For trusted pepper plugins, this is only needed in Linux since font loading
+ // on Windows and Mac works through the renderer sandbox.
+ return false;
+#endif
+}
+
+bool IsFont(PP_Resource resource) {
+ return !!Resource::GetAs<Font>(resource).get();
+}
+
+bool GetFontTable(PP_Resource font_id,
+ uint32_t table,
+ void* output,
+ uint32_t* output_length) {
+ scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
+ if (!font.get())
+ return false;
+
+ return font->GetFontTable(table, output, output_length);
+}
+
+const PPB_Font ppb_font = {
+ &MatchFontWithFallback,
+ &IsFont,
+ &GetFontTable,
+};
+
+} // namespace
+
+Font::Font(PluginModule* module, int fd)
+ : Resource(module),
+ fd_(fd) {
+}
+
+Font::~Font() {
+#if defined (OS_LINUX)
+ close(fd_);
+#endif
+}
+
+// static
+const PPB_Font* Font::GetInterface() {
+ return &ppb_font;
+}
+
+bool Font::GetFontTable(uint32_t table,
+ void* output,
+ uint32_t* output_length) {
+#if defined(OS_LINUX)
+ size_t temp_size = static_cast<size_t>(*output_length);
+ bool rv = webkit_glue::GetFontTable(
+ fd_, table, static_cast<uint8_t*>(output), &temp_size);
+ *output_length = static_cast<uint32_t>(temp_size);
+ return rv;
+#else
+ return false;
+#endif
+}
+
+} // namespace pepper
diff --git a/webkit/glue/plugins/pepper_font.h b/webkit/glue/plugins/pepper_font.h
new file mode 100644
index 0000000..ad1abba
--- /dev/null
+++ b/webkit/glue/plugins/pepper_font.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
+#define WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
+
+#include "webkit/glue/plugins/pepper_resource.h"
+
+typedef struct _ppb_Font PPB_Font;
+
+namespace pepper {
+
+class PluginInstance;
+
+class Font : public Resource {
+ public:
+ Font(PluginModule* module, int fd);
+ virtual ~Font();
+
+ // Returns a pointer to the interface implementing PPB_Font that is exposed to
+ // the plugin.
+ static const PPB_Font* GetInterface();
+
+ // Resource overrides.
+ Font* AsFont() { return this; }
+
+ // PPB_Font implementation.
+ bool GetFontTable(uint32_t table,
+ void* output,
+ uint32_t* output_length);
+
+ private:
+ int fd_;
+};
+
+} // namespace pepper
+
+#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc
index 7eecfb6..3dc3e04 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/glue/plugins/pepper_plugin_module.cc
@@ -19,6 +19,7 @@
#include "third_party/ppapi/c/ppb_file_io_trusted.h"
#include "third_party/ppapi/c/ppb_file_system.h"
#include "third_party/ppapi/c/ppb_image_data.h"
+#include "third_party/ppapi/c/ppb_font.h"
#include "third_party/ppapi/c/ppb_instance.h"
#include "third_party/ppapi/c/ppb_scrollbar.h"
#include "third_party/ppapi/c/ppb_testing.h"
@@ -38,6 +39,7 @@
#include "webkit/glue/plugins/pepper_file_io.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_file_system.h"
+#include "webkit/glue/plugins/pepper_font.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
@@ -181,6 +183,8 @@ const void* GetInterface(const char* name) {
return Widget::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_INTERFACE) == 0)
return Scrollbar::GetInterface();
+ if (strcmp(name, PPB_FONT_INTERFACE) == 0)
+ return Font::GetInterface();
// Only support the testing interface when the command line switch is
// specified. This allows us to prevent people from (ab)using this interface
diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/glue/plugins/pepper_resource.h
index d8cf837..4e347cb 100644
--- a/webkit/glue/plugins/pepper_resource.h
+++ b/webkit/glue/plugins/pepper_resource.h
@@ -18,6 +18,7 @@ class DirectoryReader;
class FileChooser;
class FileIO;
class FileRef;
+class Font;
class ImageData;
class PluginModule;
class Scrollbar;
@@ -57,6 +58,7 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
virtual FileChooser* AsFileChooser() { return NULL; }
virtual FileIO* AsFileIO() { return NULL; }
virtual FileRef* AsFileRef() { return NULL; }
+ virtual Font* AsFont() { return NULL; }
virtual ImageData* AsImageData() { return NULL; }
virtual Scrollbar* AsScrollbar() { return NULL; }
virtual URLLoader* AsURLLoader() { return NULL; }
@@ -81,6 +83,7 @@ DEFINE_RESOURCE_CAST(DirectoryReader)
DEFINE_RESOURCE_CAST(FileChooser)
DEFINE_RESOURCE_CAST(FileIO)
DEFINE_RESOURCE_CAST(FileRef)
+DEFINE_RESOURCE_CAST(Font)
DEFINE_RESOURCE_CAST(ImageData)
DEFINE_RESOURCE_CAST(Scrollbar)
DEFINE_RESOURCE_CAST(URLLoader)
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 9bdebd7..75631bf 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -179,6 +179,8 @@
'plugins/pepper_file_ref.h',
'plugins/pepper_file_system.cc',
'plugins/pepper_file_system.h',
+ 'plugins/pepper_font.cc',
+ 'plugins/pepper_font.h',
'plugins/pepper_image_data.cc',
'plugins/pepper_image_data.h',
'plugins/pepper_plugin_delegate.h',
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index d24e1512..541836b 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -265,6 +265,26 @@ std::string GetProductVersion();
// Returns true if the embedder is running in single process mode.
bool IsSingleProcess();
+#if defined(OS_LINUX)
+// Return a read-only file descriptor to the font which best matches the given
+// properties or -1 on failure.
+// charset: specifies the language(s) that the font must cover. See
+// render_sandbox_host_linux.cc for more information.
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset);
+
+// GetFontTable loads a specified font table from an open SFNT file.
+// fd: a file descriptor to the SFNT file. The position doesn't matter.
+// table: the table in *big-endian* format, or 0 for the whole font file.
+// output: a buffer of size output_length that gets the data. can be 0, in
+// which case output_length will be set to the required size in bytes.
+// output_length: size of output, if it's not 0.
+//
+// returns: true on success.
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length);
+#endif
+
// ---- END FUNCTIONS IMPLEMENTED BY EMBEDDER ---------------------------------
diff --git a/webkit/support/webkit_support_glue.cc b/webkit/support/webkit_support_glue.cc
index a82b941..bae6374 100644
--- a/webkit/support/webkit_support_glue.cc
+++ b/webkit/support/webkit_support_glue.cc
@@ -72,4 +72,16 @@ bool IsSingleProcess() {
return true;
}
+#if defined(OS_LINUX)
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset) {
+ return -1;
+}
+
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length) {
+ return false;
+}
+#endif
+
} // namespace webkit_glue
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index a73dc95..a2b4507 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -813,4 +813,16 @@ bool IsSingleProcess() {
return true;
}
+#if defined(OS_LINUX)
+int MatchFontWithFallback(const std::string& face, bool bold,
+ bool italic, int charset) {
+ return -1;
+}
+
+bool GetFontTable(int fd, uint32_t table, uint8_t* output,
+ size_t* output_length) {
+ return false;
+}
+#endif
+
} // namespace webkit_glue