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

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 327633002: Introduce WebFallbackFont on the Chromium side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing rename in DEPS file Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/renderer_webkitplatformsupport_impl.h" 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #endif 93 #endif
94 94
95 #if defined(OS_POSIX) 95 #if defined(OS_POSIX)
96 #include "base/file_descriptor_posix.h" 96 #include "base/file_descriptor_posix.h"
97 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 97 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
98 #include <map> 98 #include <map>
99 #include <string> 99 #include <string>
100 100
101 #include "base/synchronization/lock.h" 101 #include "base/synchronization/lock.h"
102 #include "content/common/child_process_sandbox_support_impl_linux.h" 102 #include "content/common/child_process_sandbox_support_impl_linux.h"
103 #include "third_party/WebKit/public/platform/linux/WebFontFamily.h" 103 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
104 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h" 104 #include "third_party/WebKit/public/platform/linux/WebSandboxSupport.h"
105 #include "third_party/icu/source/common/unicode/utf16.h" 105 #include "third_party/icu/source/common/unicode/utf16.h"
106 #endif 106 #endif
107 #endif 107 #endif
108 108
109 #if defined(OS_WIN) 109 #if defined(OS_WIN)
110 #include "content/common/child_process_messages.h" 110 #include "content/common/child_process_messages.h"
111 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h" 111 #include "third_party/WebKit/public/platform/win/WebSandboxSupport.h"
112 #endif 112 #endif
113 113
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 virtual ~SandboxSupport() {} 200 virtual ~SandboxSupport() {}
201 201
202 #if defined(OS_WIN) 202 #if defined(OS_WIN)
203 virtual bool ensureFontLoaded(HFONT); 203 virtual bool ensureFontLoaded(HFONT);
204 #elif defined(OS_MACOSX) 204 #elif defined(OS_MACOSX)
205 virtual bool loadFont( 205 virtual bool loadFont(
206 NSFont* src_font, 206 NSFont* src_font,
207 CGFontRef* container, 207 CGFontRef* container,
208 uint32* font_id); 208 uint32* font_id);
209 #elif defined(OS_POSIX) 209 #elif defined(OS_POSIX)
210 // TODO(dro): crbug.com/382411 Remove this function, once the blink side
211 // does not need it anymore.
210 virtual void getFontFamilyForCharacter( 212 virtual void getFontFamilyForCharacter(
213 blink::WebUChar32 character,
214 const char* preferred_locale,
215 blink::WebFontFamily* family);
216 virtual void getFallbackFontForCharacter(
211 blink::WebUChar32 character, 217 blink::WebUChar32 character,
212 const char* preferred_locale, 218 const char* preferred_locale,
213 blink::WebFontFamily* family); 219 blink::WebFallbackFont* fallbackFont);
214 virtual void getRenderStyleForStrike( 220 virtual void getRenderStyleForStrike(
215 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out); 221 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out);
216 222
217 private: 223 private:
218 // WebKit likes to ask us for the correct font family to use for a set of 224 // WebKit likes to ask us for the correct font family to use for a set of
219 // unicode code points. It needs this information frequently so we cache it 225 // unicode code points. It needs this information frequently so we cache it
220 // here. 226 // here.
221 base::Lock unicode_font_families_mutex_; 227 base::Lock unicode_font_families_mutex_;
222 std::map<int32_t, blink::WebFontFamily> unicode_font_families_; 228 std::map<int32_t, blink::WebFallbackFont> unicode_font_families_;
223 #endif 229 #endif
224 }; 230 };
225 #endif // defined(OS_ANDROID) 231 #endif // defined(OS_ANDROID)
226 232
227 //------------------------------------------------------------------------------ 233 //------------------------------------------------------------------------------
228 234
229 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() 235 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl()
230 : clipboard_client_(new RendererClipboardClient), 236 : clipboard_client_(new RendererClipboardClient),
231 clipboard_(new WebClipboardImpl(clipboard_client_.get())), 237 clipboard_(new WebClipboardImpl(clipboard_client_.get())),
232 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), 238 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry),
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // whole class for android. 612 // whole class for android.
607 613
608 #elif defined(OS_POSIX) 614 #elif defined(OS_POSIX)
609 615
610 void 616 void
611 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter( 617 RendererWebKitPlatformSupportImpl::SandboxSupport::getFontFamilyForCharacter(
612 blink::WebUChar32 character, 618 blink::WebUChar32 character,
613 const char* preferred_locale, 619 const char* preferred_locale,
614 blink::WebFontFamily* family) { 620 blink::WebFontFamily* family) {
615 base::AutoLock lock(unicode_font_families_mutex_); 621 base::AutoLock lock(unicode_font_families_mutex_);
616 const std::map<int32_t, blink::WebFontFamily>::const_iterator iter = 622 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
617 unicode_font_families_.find(character); 623 unicode_font_families_.find(character);
618 if (iter != unicode_font_families_.end()) { 624 if (iter != unicode_font_families_.end()) {
619 family->name = iter->second.name; 625 family->name = iter->second.name;
620 family->isBold = iter->second.isBold; 626 family->isBold = iter->second.isBold;
621 family->isItalic = iter->second.isItalic; 627 family->isItalic = iter->second.isItalic;
622 return; 628 return;
623 } 629 }
624 630
625 GetFontFamilyForCharacter(character, preferred_locale, family); 631 blink::WebFallbackFont fallbackFont;
626 unicode_font_families_.insert(std::make_pair(character, *family)); 632 GetFallbackFontForCharacter(character, preferred_locale, &fallbackFont);
633 unicode_font_families_.insert(std::make_pair(character, fallbackFont));
634 family->name = fallbackFont.name;
635 family->isBold = fallbackFont.isBold;
636 family->isItalic = fallbackFont.isItalic;
637 }
638
639
640 void
641 RendererWebKitPlatformSupportImpl::SandboxSupport::getFallbackFontForCharacter(
642 blink::WebUChar32 character,
643 const char* preferred_locale,
644 blink::WebFallbackFont* fallbackFont) {
645 base::AutoLock lock(unicode_font_families_mutex_);
646 const std::map<int32_t, blink::WebFallbackFont>::const_iterator iter =
647 unicode_font_families_.find(character);
648 if (iter != unicode_font_families_.end()) {
649 fallbackFont->name = iter->second.name;
650 fallbackFont->filename = iter->second.filename;
651 fallbackFont->ttcIndex = iter->second.ttcIndex;
652 fallbackFont->isBold = iter->second.isBold;
653 fallbackFont->isItalic = iter->second.isItalic;
654 return;
655 }
656
657 GetFallbackFontForCharacter(character, preferred_locale, fallbackFont);
658 unicode_font_families_.insert(std::make_pair(character, *fallbackFont));
627 } 659 }
628 660
629 void 661 void
630 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike( 662 RendererWebKitPlatformSupportImpl::SandboxSupport::getRenderStyleForStrike(
631 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) { 663 const char* family, int sizeAndStyle, blink::WebFontRenderStyle* out) {
632 GetRenderStyleForStrike(family, sizeAndStyle, out); 664 GetRenderStyleForStrike(family, sizeAndStyle, out);
633 } 665 }
634 666
635 #endif 667 #endif
636 668
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 battery_status_dispatcher_->SetListener(listener); 1250 battery_status_dispatcher_->SetListener(listener);
1219 } 1251 }
1220 1252
1221 // static 1253 // static
1222 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( 1254 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting(
1223 const blink::WebBatteryStatus& status) { 1255 const blink::WebBatteryStatus& status) {
1224 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); 1256 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status);
1225 } 1257 }
1226 1258
1227 } // namespace content 1259 } // namespace content
OLDNEW
« content/common/DEPS ('K') | « content/ppapi_plugin/ppapi_webkitplatformsupport_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698