From c9747233d6434ac89d40ab3d3c12a6693424768e Mon Sep 17 00:00:00 2001
From: "agl@chromium.org"
 <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Mon, 4 Jan 2010 18:01:13 +0000
Subject: ...

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35458 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../renderer_host/render_sandbox_host_linux.cc     | 26 +++++++++++++++
 chrome/common/sandbox_methods_linux.h              |  1 +
 chrome/renderer/renderer_sandbox_support_linux.cc  | 38 ++++++++++++++++++++++
 chrome/renderer/renderer_sandbox_support_linux.h   |  7 ++++
 chrome/renderer/renderer_webkitclient_impl.cc      |  5 +++
 chrome/renderer/renderer_webkitclient_impl.h       |  2 ++
 6 files changed, 79 insertions(+)

diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc
index 2e89799..ac5e071 100644
--- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc
@@ -134,6 +134,8 @@ class SandboxIPCProcess  {
       HandleLocaltime(fd, pickle, iter, fds);
     } else if (kind == LinuxSandbox::METHOD_GET_CHILD_WITH_INODE) {
       HandleGetChildWithInode(fd, pickle, iter, fds);
+    } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) {
+      HandleGetStyleForStrike(fd, pickle, iter, fds);
     }
 
   error:
@@ -242,6 +244,30 @@ class SandboxIPCProcess  {
     SendRendererReply(fds, reply, -1);
   }
 
+  void HandleGetStyleForStrike(int fd, const Pickle& pickle, void* iter,
+                               std::vector<int>& fds) {
+    std::string family;
+    int sizeAndStyle;
+
+    if (!pickle.ReadString(&iter, &family) ||
+        !pickle.ReadInt(&iter, &sizeAndStyle)) {
+      return;
+    }
+
+    WebKit::WebFontRenderStyle style;
+    WebFontInfo::renderStyleForStrike(&style, family.c_str(), sizeAndStyle);
+
+    Pickle reply;
+    reply.WriteInt(style.useBitmaps);
+    reply.WriteInt(style.useAutoHint);
+    reply.WriteInt(style.useHinting);
+    reply.WriteInt(style.hintStyle);
+    reply.WriteInt(style.useAntiAlias);
+    reply.WriteInt(style.useSubpixel);
+
+    SendRendererReply(fds, reply, -1);
+  }
+
   void HandleLocaltime(int fd, const Pickle& pickle, void* iter,
                        std::vector<int>& fds) {
     // The other side of this call is in zygote_main_linux.cc
diff --git a/chrome/common/sandbox_methods_linux.h b/chrome/common/sandbox_methods_linux.h
index 22fbf29..71c6883 100644
--- a/chrome/common/sandbox_methods_linux.h
+++ b/chrome/common/sandbox_methods_linux.h
@@ -15,6 +15,7 @@ class LinuxSandbox {
     METHOD_GET_FONT_FAMILY_FOR_CHARS = 32,
     METHOD_LOCALTIME = 33,
     METHOD_GET_CHILD_WITH_INODE = 34,
+    METHOD_GET_STYLE_FOR_STRIKE = 35,
   };
 };
 
diff --git a/chrome/renderer/renderer_sandbox_support_linux.cc b/chrome/renderer/renderer_sandbox_support_linux.cc
index a08fff1..70f38c1 100644
--- a/chrome/renderer/renderer_sandbox_support_linux.cc
+++ b/chrome/renderer/renderer_sandbox_support_linux.cc
@@ -10,6 +10,8 @@
 #include "chrome/common/chrome_descriptors.h"
 #include "chrome/common/sandbox_methods_linux.h"
 
+#include "third_party/WebKit/WebKit/chromium/public/linux/WebFontRenderStyle.h"
+
 namespace renderer_sandbox_support {
 
 std::string getFontFamilyForCharacters(const uint16_t* utf16, size_t num_utf16) {
@@ -35,4 +37,40 @@ std::string getFontFamilyForCharacters(const uint16_t* utf16, size_t num_utf16)
   return family_name;
 }
 
+void getRenderStyleForStrike(WebKit::WebFontRenderStyle* out, const char* family,
+                             int sizeAndStyle) {
+  Pickle request;
+  request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
+  request.WriteString(family);
+  request.WriteInt(sizeAndStyle);
+
+  uint8_t buf[512];
+  const int sandbox_fd =
+    kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
+  const ssize_t n = base::SendRecvMsg(sandbox_fd, buf, sizeof(buf), NULL,
+                                      request);
+
+  out->setDefaults();
+  if (n == -1) {
+    return;
+  }
+
+  Pickle reply(reinterpret_cast<char*>(buf), n);
+  void* pickle_iter = NULL;
+  int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
+  if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
+      reply.ReadInt(&pickle_iter, &useAutoHint) &&
+      reply.ReadInt(&pickle_iter, &useHinting) &&
+      reply.ReadInt(&pickle_iter, &hintStyle) &&
+      reply.ReadInt(&pickle_iter, &useAntiAlias) &&
+      reply.ReadInt(&pickle_iter, &useSubpixel)) {
+    out->useBitmaps = useBitmaps;
+    out->useAutoHint = useAutoHint;
+    out->useHinting = useHinting;
+    out->hintStyle = hintStyle;
+    out->useAntiAlias = useAntiAlias;
+    out->useSubpixel = useSubpixel;
+  }
+}
+
 }  // namespace render_sandbox_support
diff --git a/chrome/renderer/renderer_sandbox_support_linux.h b/chrome/renderer/renderer_sandbox_support_linux.h
index f8f080e..fcca8ec 100644
--- a/chrome/renderer/renderer_sandbox_support_linux.h
+++ b/chrome/renderer/renderer_sandbox_support_linux.h
@@ -9,6 +9,10 @@
 
 #include <string>
 
+namespace WebKit {
+struct WebFontRenderStyle;
+}
+
 namespace renderer_sandbox_support {
 
 // Return a font family which provides glyphs for the Unicode code points
@@ -20,6 +24,9 @@ namespace renderer_sandbox_support {
 // satisfied.
 std::string getFontFamilyForCharacters(const uint16_t* utf16, size_t num_utf16);
 
+void getRenderStyleForStrike(WebKit::WebFontRenderStyle* out, const char* family,
+                             int sizeAndStyle);
+
 };  // namespace render_sandbox_support
 
 #endif  // CHROME_RENDERER_RENDERER_SANDBOX_SUPPORT_LINUX_H_
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 290c011..ba24558 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -295,6 +295,11 @@ WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
   return WebString::fromUTF8(family_name);
 }
 
+void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
+    WebKit::WebFontRenderStyle* out, const char* family, int sizeAndStyle) {
+  renderer_sandbox_support::getRenderStyleForStrike(out, family, sizeAndStyle);
+}
+
 #endif
 
 //------------------------------------------------------------------------------
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index eb77dce..0706d29 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -92,6 +92,8 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
    public:
     virtual WebKit::WebString getFontFamilyForCharacters(
         const WebKit::WebUChar* characters, size_t numCharacters);
+    virtual void getRenderStyleForStrike(
+        WebKit::WebFontRenderStyle* out, const char* family, int sizeAndStyle);
 
    private:
     // WebKit likes to ask us for the correct font family to use for a set of
-- 
cgit v1.1