| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 118 const WebKit::WebUChar* characters, |
| 119 size_t numCharacters, | 119 size_t numCharacters, |
| 120 const char* preferred_locale); | 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); | |
| 126 virtual void getRenderStyleForStrike( | 121 virtual void getRenderStyleForStrike( |
| 127 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); | 122 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out); |
| 128 | 123 |
| 129 private: | 124 private: |
| 130 // WebKit likes to ask us for the correct font family to use for a set of | 125 // WebKit likes to ask us for the correct font family to use for a set of |
| 131 // unicode code points. It needs this information frequently so we cache it | 126 // unicode code points. It needs this information frequently so we cache it |
| 132 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. | 127 // here. The key in this map is an array of 16-bit UTF16 values from WebKit. |
| 133 // The value is a string containing the correct font family. | 128 // The value is a string containing the correct font family. |
| 134 base::Lock unicode_font_families_mutex_; | 129 base::Lock unicode_font_families_mutex_; |
| 135 std::map<std::string, std::string> unicode_font_families_; | 130 std::map<std::string, std::string> unicode_font_families_; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return WebString::fromUTF8(iter->second); | 445 return WebString::fromUTF8(iter->second); |
| 451 | 446 |
| 452 const std::string family_name = | 447 const std::string family_name = |
| 453 renderer_sandbox_support::getFontFamilyForCharacters(characters, | 448 renderer_sandbox_support::getFontFamilyForCharacters(characters, |
| 454 num_characters, | 449 num_characters, |
| 455 preferred_locale); | 450 preferred_locale); |
| 456 unicode_font_families_.insert(make_pair(key, family_name)); | 451 unicode_font_families_.insert(make_pair(key, family_name)); |
| 457 return WebString::fromUTF8(family_name); | 452 return WebString::fromUTF8(family_name); |
| 458 } | 453 } |
| 459 | 454 |
| 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 | |
| 468 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( | 455 void RendererWebKitClientImpl::SandboxSupport::getRenderStyleForStrike( |
| 469 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { | 456 const char* family, int sizeAndStyle, WebKit::WebFontRenderStyle* out) { |
| 470 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out); | 457 renderer_sandbox_support::getRenderStyleForStrike(family, sizeAndStyle, out); |
| 471 } | 458 } |
| 472 | 459 |
| 473 #elif defined(OS_MACOSX) | 460 #elif defined(OS_MACOSX) |
| 474 | 461 |
| 475 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, | 462 bool RendererWebKitClientImpl::SandboxSupport::loadFont(NSFont* srcFont, |
| 476 ATSFontContainerRef* out) { | 463 ATSFontContainerRef* out) { |
| 477 DCHECK(srcFont); | 464 DCHECK(srcFont); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return WebString::fromUTF8(signed_public_key); | 562 return WebString::fromUTF8(signed_public_key); |
| 576 } | 563 } |
| 577 | 564 |
| 578 //------------------------------------------------------------------------------ | 565 //------------------------------------------------------------------------------ |
| 579 | 566 |
| 580 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { | 567 WebBlobRegistry* RendererWebKitClientImpl::blobRegistry() { |
| 581 if (!blob_registry_.get()) | 568 if (!blob_registry_.get()) |
| 582 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); | 569 blob_registry_.reset(new WebBlobRegistryImpl(RenderThread::current())); |
| 583 return blob_registry_.get(); | 570 return blob_registry_.get(); |
| 584 } | 571 } |
| OLD | NEW |