summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbashi@chromium.org <bashi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 00:58:38 +0000
committerbashi@chromium.org <bashi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-21 00:58:38 +0000
commit0f9067badc4ebce72372d06f1e75550cfb8af945 (patch)
tree64d15dd3ef485dcdb3c688482016ad698521bc0b
parentd36352ca0fa7e3ab41651b1bdb49401b537e9a5e (diff)
downloadchromium_src-0f9067badc4ebce72372d06f1e75550cfb8af945.zip
chromium_src-0f9067badc4ebce72372d06f1e75550cfb8af945.tar.gz
chromium_src-0f9067badc4ebce72372d06f1e75550cfb8af945.tar.bz2
Use new getFontFamilyForCharacters() API.
Uses new getFontFamilyForCharacters() WebKit Chromium API so that Chromium can pass bold and italic property. This will fix issue 32109. No behavior change at this time. The CL will work after the fix of WebKit side is completed. The WebKit bug entry is https://bugs.webkit.org/show_bug.cgi?id=38701. BUG=32109 TEST=compiled. Review URL: http://codereview.chromium.org/8590028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110871 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/renderer_host/render_sandbox_host_linux.cc14
-rw-r--r--content/common/child_process_sandbox_support_impl_linux.cc20
-rw-r--r--content/common/child_process_sandbox_support_impl_linux.h12
-rw-r--r--content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc33
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc31
5 files changed, 69 insertions, 41 deletions
diff --git a/content/browser/renderer_host/render_sandbox_host_linux.cc b/content/browser/renderer_host/render_sandbox_host_linux.cc
index 0ce5d88..50706e9 100644
--- a/content/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/content/browser/renderer_host/render_sandbox_host_linux.cc
@@ -267,16 +267,20 @@ class SandboxIPCProcess {
if (!pickle.ReadString(&iter, &preferred_locale))
return;
- WebCString family = WebFontInfo::familyForChars(chars.get(),
- num_chars,
- preferred_locale.c_str());
+ WebKit::WebFontFamily family;
+ WebFontInfo::familyForChars(chars.get(),
+ num_chars,
+ preferred_locale.c_str(),
+ &family);
Pickle reply;
- if (family.data()) {
- reply.WriteString(family.data());
+ if (family.name.data()) {
+ reply.WriteString(family.name.data());
} else {
reply.WriteString("");
}
+ reply.WriteBool(family.isBold);
+ reply.WriteBool(family.isItalic);
SendRendererReply(fds, reply, -1);
}
diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/common/child_process_sandbox_support_impl_linux.cc
index 692d4ed..46d08917 100644
--- a/content/common/child_process_sandbox_support_impl_linux.cc
+++ b/content/common/child_process_sandbox_support_impl_linux.cc
@@ -13,6 +13,7 @@
#include "content/common/chrome_descriptors.h"
#include "content/common/sandbox_methods_linux.h"
#include "content/common/unix_domain_socket_posix.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontFamily.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderStyle.h"
static int GetSandboxFD() {
@@ -21,9 +22,10 @@ static int GetSandboxFD() {
namespace content {
-std::string GetFontFamilyForCharacters(const uint16_t* utf16,
- size_t num_utf16,
- const char* preferred_locale) {
+void GetFontFamilyForCharacters(const uint16_t* utf16,
+ size_t num_utf16,
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family) {
Pickle request;
request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
request.WriteInt(num_utf16);
@@ -36,13 +38,19 @@ std::string GetFontFamilyForCharacters(const uint16_t* utf16,
sizeof(buf), NULL, request);
std::string family_name;
+ bool isBold = false;
+ bool isItalic = false;
if (n != -1) {
Pickle reply(reinterpret_cast<char*>(buf), n);
void* pickle_iter = NULL;
- reply.ReadString(&pickle_iter, &family_name);
+ if (reply.ReadString(&pickle_iter, &family_name) &&
+ reply.ReadBool(&pickle_iter, &isBold) &&
+ reply.ReadBool(&pickle_iter, &isItalic)) {
+ family->name = family_name;
+ family->isBold = isBold;
+ family->isItalic = isItalic;
+ }
}
-
- return family_name;
}
void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
diff --git a/content/common/child_process_sandbox_support_impl_linux.h b/content/common/child_process_sandbox_support_impl_linux.h
index b26634a..29b103b 100644
--- a/content/common/child_process_sandbox_support_impl_linux.h
+++ b/content/common/child_process_sandbox_support_impl_linux.h
@@ -9,6 +9,7 @@
#include "content/public/common/child_process_sandbox_support_linux.h"
namespace WebKit {
+struct WebFontFamily;
struct WebFontRenderStyle;
}
@@ -20,11 +21,12 @@ namespace content {
// num_utf16: the number of 16-bit words in |utf16|
// preferred_locale: preferred locale identifier for the |utf16|
//
-// Returns: the font family or an empty string if the request could not be
-// satisfied.
-std::string GetFontFamilyForCharacters(const uint16_t* utf16,
- size_t num_utf16,
- const char* preferred_locale);
+// Returns: a font family instance.
+// The instance has an empty font name if the request could not be satisfied.
+void GetFontFamilyForCharacters(const uint16_t* utf16,
+ size_t num_utf16,
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family);
void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
WebKit::WebFontRenderStyle* out);
diff --git a/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc b/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc
index a2acb57..366f7e7 100644
--- a/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc
+++ b/content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc
@@ -22,6 +22,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h"
#elif defined(OS_POSIX)
#include "content/common/child_process_sandbox_support_impl_linux.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontFamily.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif
@@ -41,10 +42,11 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport : public WebSandboxSupport
virtual bool loadFont(
NSFont* srcFont, CGFontRef* out, uint32_t* fontID);
#elif defined(OS_POSIX)
- virtual WebString getFontFamilyForCharacters(
+ virtual void getFontFamilyForCharacters(
const WebUChar* characters,
size_t numCharacters,
- const char* preferred_locale);
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family);
virtual void getRenderStyleForStrike(
const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
@@ -54,7 +56,7 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport : public WebSandboxSupport
// here. The key in this map is an array of 16-bit UTF16 values from WebKit.
// The value is a string containing the correct font family.
base::Lock unicode_font_families_mutex_;
- std::map<string16, std::string> unicode_font_families_;
+ std::map<string16, WebKit::WebFontFamily> unicode_font_families_;
#endif
};
@@ -83,24 +85,29 @@ bool PpapiWebKitPlatformSupportImpl::SandboxSupport::loadFont(
#elif defined(OS_POSIX)
-WebString
+void
PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters(
const WebUChar* characters,
size_t num_characters,
- const char* preferred_locale) {
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family) {
base::AutoLock lock(unicode_font_families_mutex_);
const string16 key(characters, num_characters);
- const std::map<string16, std::string>::const_iterator iter =
+ const std::map<string16, WebKit::WebFontFamily>::const_iterator iter =
unicode_font_families_.find(key);
- if (iter != unicode_font_families_.end())
- return WebString::fromUTF8(iter->second);
-
- const std::string family_name = content::GetFontFamilyForCharacters(
+ if (iter != unicode_font_families_.end()) {
+ family->name = iter->second.name;
+ family->isBold = iter->second.isBold;
+ family->isItalic = iter->second.isItalic;
+ return;
+ }
+
+ content::GetFontFamilyForCharacters(
characters,
num_characters,
- preferred_locale);
- unicode_font_families_.insert(make_pair(key, family_name));
- return WebString::fromUTF8(family_name);
+ preferred_locale,
+ family);
+ unicode_font_families_.insert(make_pair(key, *family));
}
void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike(
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 975c1e28..dd427d0 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -63,6 +63,7 @@
#include "base/synchronization/lock.h"
#include "content/common/child_process_sandbox_support_impl_linux.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontFamily.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif
@@ -121,10 +122,11 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport
CGFontRef* container,
uint32* font_id);
#elif defined(OS_POSIX)
- virtual WebKit::WebString getFontFamilyForCharacters(
+ virtual void getFontFamilyForCharacters(
const WebKit::WebUChar* characters,
size_t numCharacters,
- const char* preferred_locale);
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family);
virtual void getRenderStyleForStrike(
const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
@@ -134,7 +136,7 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport
// here. The key in this map is an array of 16-bit UTF16 values from WebKit.
// The value is a string containing the correct font family.
base::Lock unicode_font_families_mutex_;
- std::map<string16, std::string> unicode_font_families_;
+ std::map<string16, WebKit::WebFontFamily> unicode_font_families_;
#endif
};
@@ -481,24 +483,29 @@ bool RendererWebKitPlatformSupportImpl::SandboxSupport::loadFont(
#elif defined(OS_POSIX)
-WebString
+void
RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters(
const WebKit::WebUChar* characters,
size_t num_characters,
- const char* preferred_locale) {
+ const char* preferred_locale,
+ WebKit::WebFontFamily* family) {
base::AutoLock lock(unicode_font_families_mutex_);
const string16 key(characters, num_characters);
- const std::map<string16, std::string>::const_iterator iter =
+ const std::map<string16, WebKit::WebFontFamily>::const_iterator iter =
unicode_font_families_.find(key);
- if (iter != unicode_font_families_.end())
- return WebString::fromUTF8(iter->second);
+ if (iter != unicode_font_families_.end()) {
+ family->name = iter->second.name;
+ family->isBold = iter->second.isBold;
+ family->isItalic = iter->second.isItalic;
+ return;
+ }
- const std::string family_name = content::GetFontFamilyForCharacters(
+ content::GetFontFamilyForCharacters(
characters,
num_characters,
- preferred_locale);
- unicode_font_families_.insert(make_pair(key, family_name));
- return WebString::fromUTF8(family_name);
+ preferred_locale,
+ family);
+ unicode_font_families_.insert(make_pair(key, *family));
}
void