Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: chrome/renderer/renderer_webkitclient_impl.cc

Issue 6592065: Pass around preferred language to font fallback selection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the reference bug number of webkit bugzilla in comments. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/renderer_webkitclient_impl.h" 5 #include "chrome/renderer/renderer_webkitclient_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/platform_file.h" 9 #include "base/platform_file.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 class RendererWebKitClientImpl::SandboxSupport 109 class RendererWebKitClientImpl::SandboxSupport
110 : public WebKit::WebSandboxSupport { 110 : public WebKit::WebSandboxSupport {
111 public: 111 public:
112 #if defined(OS_WIN) 112 #if defined(OS_WIN)
113 virtual bool ensureFontLoaded(HFONT); 113 virtual bool ensureFontLoaded(HFONT);
114 #elif defined(OS_MACOSX) 114 #elif defined(OS_MACOSX)
115 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out); 115 virtual bool loadFont(NSFont* srcFont, ATSFontContainerRef* out);
116 #elif defined(OS_LINUX) 116 #elif defined(OS_LINUX)
117 virtual WebKit::WebString getFontFamilyForCharacters( 117 virtual WebKit::WebString getFontFamilyForCharacters(
118 const WebKit::WebUChar* characters, size_t numCharacters); 118 const WebKit::WebUChar* characters,
119 size_t numCharacters,
120 const char* preferred_locale);
121 // TODO(kochi): Remove this old interface once WebKit side of the change
122 // https://bugs.webkit.org/show_bug.cgi?id=55453 is landed.
123 virtual WebKit::WebString getFontFamilyForCharacters(
124 const WebKit::WebUChar* characters,
125 size_t numCharacters);
119 virtual void getRenderStyleForStrike( 126 virtual void getRenderStyleForStrike(
120 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); 127 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out);
121 128
122 private: 129 private:
123 // WebKit likes to ask us for the correct font family to use for a set of 130 // WebKit likes to ask us for the correct font family to use for a set of
124 // unicode code points. It needs this information frequently so we cache it 131 // unicode code points. It needs this information frequently so we cache it
125 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. 132 // here. The key in this map is an array of 16-bit UTF16 values from WebKit.
126 // The value is a string containing the correct font family. 133 // The value is a string containing the correct font family.
127 base::Lock unicode_font_families_mutex_; 134 base::Lock unicode_font_families_mutex_;
128 std::map<std::string, std::string> unicode_font_families_; 135 std::map<std::string, std::string> unicode_font_families_;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 431
425 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) { 432 bool RendererWebKitClientImpl::SandboxSupport::ensureFontLoaded(HFONT font) {
426 LOGFONT logfont; 433 LOGFONT logfont;
427 GetObject(font, sizeof(LOGFONT), &logfont); 434 GetObject(font, sizeof(LOGFONT), &logfont);
428 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont)); 435 return RenderThread::current()->Send(new ViewHostMsg_PreCacheFont(logfont));
429 } 436 }
430 437
431 #elif defined(OS_LINUX) 438 #elif defined(OS_LINUX)
432 439
433 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters( 440 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
434 const WebKit::WebUChar* characters, size_t num_characters) { 441 const WebKit::WebUChar* characters,
442 size_t num_characters,
443 const char* preferred_locale) {
435 base::AutoLock lock(unicode_font_families_mutex_); 444 base::AutoLock lock(unicode_font_families_mutex_);
436 const std::string key(reinterpret_cast<const char*>(characters), 445 const std::string key(reinterpret_cast<const char*>(characters),
437 num_characters * sizeof(characters[0])); 446 num_characters * sizeof(characters[0]));
438 const std::map<std::string, std::string>::const_iterator iter = 447 const std::map<std::string, std::string>::const_iterator iter =
439 unicode_font_families_.find(key); 448 unicode_font_families_.find(key);
440 if (iter != unicode_font_families_.end()) 449 if (iter != unicode_font_families_.end())
441 return WebString::fromUTF8(iter->second); 450 return WebString::fromUTF8(iter->second);
442 451
443 const std::string family_name = 452 const std::string family_name =
444 renderer_sandbox_support::getFontFamilyForCharacters(characters, 453 renderer_sandbox_support::getFontFamilyForCharacters(characters,
445 num_characters); 454 num_characters,
455 preferred_locale);
446 unicode_font_families_.insert(make_pair(key, family_name)); 456 unicode_font_families_.insert(make_pair(key, family_name));
447 return WebString::fromUTF8(family_name); 457 return WebString::fromUTF8(family_name);
448 } 458 }
449 459
460 // TODO(kochi): Remove this once the WebKit side of this change in
461 // https://bugs.webkit.org/show_bug.cgi?id=55453 is landed.
462 WebString RendererWebKitClientImpl::SandboxSupport::getFontFamilyForCharacters(
463 const WebKit::WebUChar* characters,
464 size_t num_characters) {
465 return getFontFamilyForCharacters(characters, num_characters, "");
466 }
467
450 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( 468 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike(
451 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { 469 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) {
452 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out); 470 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out);
453 } 471 }
454 472
455 #elif defined(OS_MACOSX) 473 #elif defined(OS_MACOSX)
456 474
457 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, 475 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont,
458 ATSFontContainerRef* out) { 476 ATSFontContainerRef* out) {
459 DCHECK(srcFont); 477 DCHECK(srcFont);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return WebString::fromUTF8(signed_public_key); 575 return WebString::fromUTF8(signed_public_key);
558 } 576 }
559 577
560 //------------------------------------------------------------------------------ 578 //------------------------------------------------------------------------------
561 579
562 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { 580 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() {
563 if (!blob_registry_.get()) 581 if (!blob_registry_.get())
564 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); 582 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current()));
565 return blob_registry_.get(); 583 return blob_registry_.get();
566 } 584 }
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_sandbox_support_linux.cc ('k') | content/browser/renderer_host/render_sandbox_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698