Commit 0f9067ba authored by bashi@chromium.org's avatar bashi@chromium.org

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
parent d36352ca
...@@ -267,16 +267,20 @@ class SandboxIPCProcess { ...@@ -267,16 +267,20 @@ class SandboxIPCProcess {
if (!pickle.ReadString(&iter, &preferred_locale)) if (!pickle.ReadString(&iter, &preferred_locale))
return; return;
WebCString family = WebFontInfo::familyForChars(chars.get(), WebKit::WebFontFamily family;
num_chars, WebFontInfo::familyForChars(chars.get(),
preferred_locale.c_str()); num_chars,
preferred_locale.c_str(),
&family);
Pickle reply; Pickle reply;
if (family.data()) { if (family.name.data()) {
reply.WriteString(family.data()); reply.WriteString(family.name.data());
} else { } else {
reply.WriteString(""); reply.WriteString("");
} }
reply.WriteBool(family.isBold);
reply.WriteBool(family.isItalic);
SendRendererReply(fds, reply, -1); SendRendererReply(fds, reply, -1);
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "content/common/chrome_descriptors.h" #include "content/common/chrome_descriptors.h"
#include "content/common/sandbox_methods_linux.h" #include "content/common/sandbox_methods_linux.h"
#include "content/common/unix_domain_socket_posix.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" #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderStyle.h"
static int GetSandboxFD() { static int GetSandboxFD() {
...@@ -21,9 +22,10 @@ static int GetSandboxFD() { ...@@ -21,9 +22,10 @@ static int GetSandboxFD() {
namespace content { namespace content {
std::string GetFontFamilyForCharacters(const uint16_t* utf16, void GetFontFamilyForCharacters(const uint16_t* utf16,
size_t num_utf16, size_t num_utf16,
const char* preferred_locale) { const char* preferred_locale,
WebKit::WebFontFamily* family) {
Pickle request; Pickle request;
request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
request.WriteInt(num_utf16); request.WriteInt(num_utf16);
...@@ -36,13 +38,19 @@ std::string GetFontFamilyForCharacters(const uint16_t* utf16, ...@@ -36,13 +38,19 @@ std::string GetFontFamilyForCharacters(const uint16_t* utf16,
sizeof(buf), NULL, request); sizeof(buf), NULL, request);
std::string family_name; std::string family_name;
bool isBold = false;
bool isItalic = false;
if (n != -1) { if (n != -1) {
Pickle reply(reinterpret_cast<char*>(buf), n); Pickle reply(reinterpret_cast<char*>(buf), n);
void* pickle_iter = NULL; 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, void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "content/public/common/child_process_sandbox_support_linux.h" #include "content/public/common/child_process_sandbox_support_linux.h"
namespace WebKit { namespace WebKit {
struct WebFontFamily;
struct WebFontRenderStyle; struct WebFontRenderStyle;
} }
...@@ -20,11 +21,12 @@ namespace content { ...@@ -20,11 +21,12 @@ namespace content {
// num_utf16: the number of 16-bit words in |utf16| // num_utf16: the number of 16-bit words in |utf16|
// preferred_locale: preferred locale identifier for the |utf16| // preferred_locale: preferred locale identifier for the |utf16|
// //
// Returns: the font family or an empty string if the request could not be // Returns: a font family instance.
// satisfied. // The instance has an empty font name if the request could not be satisfied.
std::string GetFontFamilyForCharacters(const uint16_t* utf16, void GetFontFamilyForCharacters(const uint16_t* utf16,
size_t num_utf16, size_t num_utf16,
const char* preferred_locale); const char* preferred_locale,
WebKit::WebFontFamily* family);
void GetRenderStyleForStrike(const char* family, int sizeAndStyle, void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
WebKit::WebFontRenderStyle* out); WebKit::WebFontRenderStyle* out);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h" #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebSandboxSupport.h"
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
#include "content/common/child_process_sandbox_support_impl_linux.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" #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif #endif
...@@ -41,10 +42,11 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport : public WebSandboxSupport ...@@ -41,10 +42,11 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport : public WebSandboxSupport
virtual bool loadFont( virtual bool loadFont(
NSFont* srcFont, CGFontRef* out, uint32_t* fontID); NSFont* srcFont, CGFontRef* out, uint32_t* fontID);
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
virtual WebString getFontFamilyForCharacters( virtual void getFontFamilyForCharacters(
const WebUChar* characters, const WebUChar* characters,
size_t numCharacters, size_t numCharacters,
const char* preferred_locale); const char* preferred_locale,
WebKit::WebFontFamily* family);
virtual void getRenderStyleForStrike( virtual void getRenderStyleForStrike(
const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
...@@ -54,7 +56,7 @@ class PpapiWebKitPlatformSupportImpl::SandboxSupport : public WebSandboxSupport ...@@ -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. // 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. // The value is a string containing the correct font family.
base::Lock unicode_font_families_mutex_; base::Lock unicode_font_families_mutex_;
std::map<string16, std::string> unicode_font_families_; std::map<string16, WebKit::WebFontFamily> unicode_font_families_;
#endif #endif
}; };
...@@ -83,24 +85,29 @@ bool PpapiWebKitPlatformSupportImpl::SandboxSupport::loadFont( ...@@ -83,24 +85,29 @@ bool PpapiWebKitPlatformSupportImpl::SandboxSupport::loadFont(
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
WebString void
PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( PpapiWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters(
const WebUChar* characters, const WebUChar* characters,
size_t num_characters, size_t num_characters,
const char* preferred_locale) { const char* preferred_locale,
WebKit::WebFontFamily* family) {
base::AutoLock lock(unicode_font_families_mutex_); base::AutoLock lock(unicode_font_families_mutex_);
const string16 key(characters, num_characters); 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); unicode_font_families_.find(key);
if (iter != unicode_font_families_.end()) if (iter != unicode_font_families_.end()) {
return WebString::fromUTF8(iter->second); family->name = iter->second.name;
family->isBold = iter->second.isBold;
const std::string family_name = content::GetFontFamilyForCharacters( family->isItalic = iter->second.isItalic;
return;
}
content::GetFontFamilyForCharacters(
characters, characters,
num_characters, num_characters,
preferred_locale); preferred_locale,
unicode_font_families_.insert(make_pair(key, family_name)); family);
return WebString::fromUTF8(family_name); unicode_font_families_.insert(make_pair(key, *family));
} }
void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( void PpapiWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike(
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "content/common/child_process_sandbox_support_impl_linux.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" #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebSandboxSupport.h"
#endif #endif
...@@ -121,10 +122,11 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport ...@@ -121,10 +122,11 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport
CGFontRef* container, CGFontRef* container,
uint32* font_id); uint32* font_id);
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
virtual WebKit::WebString getFontFamilyForCharacters( virtual void getFontFamilyForCharacters(
const WebKit::WebUChar* characters, const WebKit::WebUChar* characters,
size_t numCharacters, size_t numCharacters,
const char* preferred_locale); const char* preferred_locale,
WebKit::WebFontFamily* family);
virtual void getRenderStyleForStrike( virtual void getRenderStyleForStrike(
const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
...@@ -134,7 +136,7 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport ...@@ -134,7 +136,7 @@ class RendererWebKitPlatformSupportImpl::SandboxSupport
// here. The key in this map is an array of 16-bit UTF16 values from WebKit. // 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. // The value is a string containing the correct font family.
base::Lock unicode_font_families_mutex_; base::Lock unicode_font_families_mutex_;
std::map<string16, std::string> unicode_font_families_; std::map<string16, WebKit::WebFontFamily> unicode_font_families_;
#endif #endif
}; };
...@@ -481,24 +483,29 @@ bool RendererWebKitPlatformSupportImpl::SandboxSupport::loadFont( ...@@ -481,24 +483,29 @@ bool RendererWebKitPlatformSupportImpl::SandboxSupport::loadFont(
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
WebString void
RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters( RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacters(
const WebKit::WebUChar* characters, const WebKit::WebUChar* characters,
size_t num_characters, size_t num_characters,
const char* preferred_locale) { const char* preferred_locale,
WebKit::WebFontFamily* family) {
base::AutoLock lock(unicode_font_families_mutex_); base::AutoLock lock(unicode_font_families_mutex_);
const string16 key(characters, num_characters); 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); unicode_font_families_.find(key);
if (iter != unicode_font_families_.end()) if (iter != unicode_font_families_.end()) {
return WebString::fromUTF8(iter->second); 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, characters,
num_characters, num_characters,
preferred_locale); preferred_locale,
unicode_font_families_.insert(make_pair(key, family_name)); family);
return WebString::fromUTF8(family_name); unicode_font_families_.insert(make_pair(key, *family));
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment