diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 00:11:31 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-10 00:11:31 +0000 |
commit | 0a35402454c1c2481d4c6dae6a272cd9f535abdb (patch) | |
tree | 7ad079cd5db536bc5dae553f42cf6ada8ac8d18b /webkit | |
parent | eb12b71f9b3a5ea44b1b44abb1f245b803a05443 (diff) | |
download | chromium_src-0a35402454c1c2481d4c6dae6a272cd9f535abdb.zip chromium_src-0a35402454c1c2481d4c6dae6a272cd9f535abdb.tar.gz chromium_src-0a35402454c1c2481d4c6dae6a272cd9f535abdb.tar.bz2 |
Move some files from platform/graphics to platform/graphics/chromium.
Files that ended with Win.cpp now end with ChromiumWin.cpp.
I also cleaned up FontUtils[Chromium]Win.cpp so that it no longer depends on
base/ or STL.
R=brettw,jungshik
Review URL: http://codereview.chromium.org/13304
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/SConscript.port | 26 | ||||
-rw-r--r-- | webkit/build/port/port.vcproj | 140 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp (renamed from webkit/port/platform/graphics/FontCacheWin.cpp) | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontChromiumWin.cpp (renamed from webkit/port/platform/graphics/FontWin.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp (renamed from webkit/port/platform/graphics/FontCustomPlatformData.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontCustomPlatformData.h (renamed from webkit/port/platform/graphics/FontCustomPlatformData.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontPlatformData.h (renamed from webkit/port/platform/graphics/FontPlatformData.h) | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp (renamed from webkit/port/platform/graphics/FontPlatformDataWin.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h (renamed from webkit/port/platform/graphics/FontPlatformDataWin.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp (renamed from webkit/port/platform/graphics/FontUtilsWin.cpp) | 269 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h (renamed from webkit/port/platform/graphics/FontUtilsWin.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp (renamed from webkit/port/platform/graphics/GlyphPageTreeNodeWin.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/IconChromiumWin.cpp (renamed from webkit/port/platform/graphics/IconWin.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/ImageBufferData.h | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp (renamed from webkit/port/platform/graphics/SimpleFontDataWin.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp (renamed from webkit/port/platform/graphics/ThemeHelperWin.cpp) | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h (renamed from webkit/port/platform/graphics/ThemeHelperWin.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/UniscribeHelper.cpp (renamed from webkit/port/platform/graphics/UniscribeHelper.cpp) | 4 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/UniscribeHelper.h (renamed from webkit/port/platform/graphics/UniscribeHelper.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp (renamed from webkit/port/platform/graphics/UniscribeHelperTextRun.cpp) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h (renamed from webkit/port/platform/graphics/UniscribeHelperTextRun.h) | 0 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/UniscribeHelper_unittest.cpp (renamed from webkit/port/platform/graphics/UniscribeHelper_unittest.cpp) | 0 | ||||
-rw-r--r-- | webkit/tools/test_shell/SConscript | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_tests.vcproj | 2 |
24 files changed, 214 insertions, 237 deletions
diff --git a/webkit/SConscript.port b/webkit/SConscript.port index 7ca98b9..bb2916d 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -74,7 +74,6 @@ input_files = [ '$PORT_DIR/platform/graphics/ColorSkia.cpp', '$PORT_DIR/platform/graphics/FloatPointSkia.cpp', '$PORT_DIR/platform/graphics/FloatRectSkia.cpp', - '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp', '$PORT_DIR/platform/graphics/GradientSkia.cpp', '$PORT_DIR/platform/graphics/GraphicsContextSkia.cpp', '$PORT_DIR/platform/graphics/ImageBufferSkia.cpp', @@ -87,6 +86,7 @@ input_files = [ '$PORT_DIR/platform/graphics/PatternSkia.cpp', '$PORT_DIR/platform/graphics/PlatformContextSkia.cpp', '$PORT_DIR/platform/graphics/SkiaUtils.cpp', + '$PORT_DIR/platform/graphics/chromium/FontCustomPlatformData.cpp', '$PORT_DIR/platform/graphics/svg/RenderPathSkia.cpp', '$PORT_DIR/platform/graphics/svg/SkiaSupport.cpp', @@ -121,16 +121,16 @@ if env['PLATFORM'] == 'win32': '$PORT_DIR/platform/win/BString.cpp', '$PORT_DIR/platform/win/SoundWin.cpp', - '$PORT_DIR/platform/graphics/FontCacheWin.cpp', - '$PORT_DIR/platform/graphics/FontPlatformDataWin.cpp', - '$PORT_DIR/platform/graphics/FontUtilsWin.cpp', - '$PORT_DIR/platform/graphics/FontWin.cpp', - '$PORT_DIR/platform/graphics/GlyphPageTreeNodeWin.cpp', - '$PORT_DIR/platform/graphics/IconWin.cpp', - '$PORT_DIR/platform/graphics/SimpleFontDataWin.cpp', - '$PORT_DIR/platform/graphics/ThemeHelperWin.cpp', - '$PORT_DIR/platform/graphics/UniscribeHelper.cpp', - '$PORT_DIR/platform/graphics/UniscribeHelperTextRun.cpp', + '$PORT_DIR/platform/graphics/chromium/FontCacheChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/FontUtilsChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/FontChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/IconChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/ThemeHelperChromiumWin.cpp', + '$PORT_DIR/platform/graphics/chromium/UniscribeHelper.cpp', + '$PORT_DIR/platform/graphics/chromium/UniscribeHelperTextRun.cpp', '$PORT_DIR/rendering/RenderThemeWin.cpp', ]) @@ -157,7 +157,7 @@ if env['PLATFORM'] == 'posix': # Remove from the list files that haven't yet been made portable to Linux. to_be_ported_files = [ - '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp', + '$PORT_DIR/platform/graphics/chromium/FontCustomPlatformData.cpp', ] input_files = list(set(input_files) - set(to_be_ported_files)) @@ -184,7 +184,7 @@ if env['PLATFORM'] == 'darwin': '$PORT_DIR/platform/chromium/PopupMenuChromium.cpp', '$PORT_DIR/platform/chromium/WidgetChromium.cpp', '$PORT_DIR/platform/chromium/ScrollbarThemeChromium.cpp', - '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp', + '$PORT_DIR/platform/graphics/chromium/FontCustomPlatformData.cpp', '$PORT_DIR/platform/graphics/ImageSkia.cpp', ] input_files = list(set(input_files) - set(to_be_ported_files)) diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj index 6ed828c..34c1f3f 100644 --- a/webkit/build/port/port.vcproj +++ b/webkit/build/port/port.vcproj @@ -1040,42 +1040,6 @@ >
</File>
<File
- RelativePath="..\..\port\platform\graphics\FontCacheWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontCustomPlatformData.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontCustomPlatformData.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontPlatformData.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontPlatformDataWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontUtilsWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontUtilsWin.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\FontWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\GlyphPageTreeNodeWin.cpp"
- >
- </File>
- <File
RelativePath="..\..\port\platform\graphics\GradientSkia.cpp"
>
</File>
@@ -1088,10 +1052,6 @@ >
</File>
<File
- RelativePath="..\..\port\platform\graphics\IconWin.cpp"
- >
- </File>
- <File
RelativePath="..\..\port\platform\graphics\ImageBufferSkia.cpp"
>
</File>
@@ -1140,10 +1100,6 @@ >
</File>
<File
- RelativePath="..\..\port\platform\graphics\SimpleFontDataWin.cpp"
- >
- </File>
- <File
RelativePath="..\..\port\platform\graphics\SkiaUtils.cpp"
>
</File>
@@ -1151,30 +1107,6 @@ RelativePath="..\..\port\platform\graphics\SkiaUtils.h"
>
</File>
- <File
- RelativePath="..\..\port\platform\graphics\ThemeHelperWin.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\ThemeHelperWin.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\UniscribeHelper.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\UniscribeHelper.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\UniscribeHelperTextRun.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\graphics\UniscribeHelperTextRun.h"
- >
- </File>
<Filter
Name="svg"
>
@@ -1215,6 +1147,50 @@ Name="chromium"
>
<File
+ RelativePath="..\..\port\platform\graphics\chromium\FontCacheChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontCustomPlatformData.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontCustomPlatformData.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontPlatformData.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontPlatformDataChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontPlatformDataChromiumWin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontUtilsChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\FontUtilsChromiumWin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\GlyphPageTreeNodeChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\IconChromiumWin.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\port\platform\graphics\chromium\ImageBufferData.h"
>
</File>
@@ -1230,6 +1206,34 @@ RelativePath="..\..\port\platform\graphics\chromium\PlatformIcon.h"
>
</File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\SimpleFontDataChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\ThemeHelperChromiumWin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\ThemeHelperChromiumWin.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\UniscribeHelper.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\UniscribeHelper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\UniscribeHelperTextRun.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\port\platform\graphics\chromium\UniscribeHelperTextRun.h"
+ >
+ </File>
</Filter>
</Filter>
<Filter
diff --git a/webkit/port/platform/graphics/FontCacheWin.cpp b/webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp index 2f09499..1f77343 100644 --- a/webkit/port/platform/graphics/FontCacheWin.cpp +++ b/webkit/port/platform/graphics/chromium/FontCacheChromiumWin.cpp @@ -30,7 +30,7 @@ #include "ChromiumBridge.h" #include "FontCache.h" #include "Font.h" -#include "FontUtilsWin.h" +#include "FontUtilsChromiumWin.h" #include "HashMap.h" #include "HashSet.h" #include "SimpleFontData.h" diff --git a/webkit/port/platform/graphics/FontWin.cpp b/webkit/port/platform/graphics/chromium/FontChromiumWin.cpp index 6726a83..6726a83 100644 --- a/webkit/port/platform/graphics/FontWin.cpp +++ b/webkit/port/platform/graphics/chromium/FontChromiumWin.cpp diff --git a/webkit/port/platform/graphics/FontCustomPlatformData.cpp b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp index 9105a8c..9105a8c 100644 --- a/webkit/port/platform/graphics/FontCustomPlatformData.cpp +++ b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.cpp diff --git a/webkit/port/platform/graphics/FontCustomPlatformData.h b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.h index 8aa0fea..8aa0fea 100644 --- a/webkit/port/platform/graphics/FontCustomPlatformData.h +++ b/webkit/port/platform/graphics/chromium/FontCustomPlatformData.h diff --git a/webkit/port/platform/graphics/FontPlatformData.h b/webkit/port/platform/graphics/chromium/FontPlatformData.h index 306960b..ea3dba5 100644 --- a/webkit/port/platform/graphics/FontPlatformData.h +++ b/webkit/port/platform/graphics/chromium/FontPlatformData.h @@ -9,7 +9,7 @@ #include "build/build_config.h" #if defined(OS_WIN) -#include "FontPlatformDataWin.h" +#include "FontPlatformDataChromiumWin.h" #elif defined(OS_LINUX) #include "FontPlatformDataLinux.h" #elif defined(OS_MACOSX) diff --git a/webkit/port/platform/graphics/FontPlatformDataWin.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp index e1afaa2..e1afaa2 100644 --- a/webkit/port/platform/graphics/FontPlatformDataWin.cpp +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp diff --git a/webkit/port/platform/graphics/FontPlatformDataWin.h b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h index 80f9df3..80f9df3 100644 --- a/webkit/port/platform/graphics/FontPlatformDataWin.h +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataChromiumWin.h diff --git a/webkit/port/platform/graphics/FontUtilsWin.cpp b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp index 80d8ce0b..ed40bf3 100644 --- a/webkit/port/platform/graphics/FontUtilsWin.cpp +++ b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.cpp @@ -3,115 +3,103 @@ // found in the LICENSE file. #include "config.h" -#include "FontUtilsWin.h" - -#include "UniscribeHelper.h" +#include "FontUtilsChromiumWin.h" #include <limits> -#include <map> - -#include "base/logging.h" -#include "base/singleton.h" -#include "base/string_util.h" -#include "unicode/locid.h" -#include "unicode/uchar.h" +#include "PlatformString.h" +#include "StringHash.h" +#include "UniscribeHelper.h" +#include <unicode/locid.h> +#include <unicode/uchar.h> +#include <wtf/HashMap.h> namespace WebCore { namespace { -// hash_map has extra cost with no sizable gain for a small number of integer -// key items. When the map size becomes much bigger (which will be later as -// more scripts are added) and this turns out to be prominent in the profile, we -// may consider switching to hash_map (or just an array if we support all the -// scripts) -typedef std::map<UScriptCode, const UChar*> ScriptToFontMap; - -struct ScriptToFontMapSingletonTraits - : public DefaultSingletonTraits<ScriptToFontMap> { - static ScriptToFontMap* New() { - struct FontMap { - UScriptCode script; - const UChar* family; - }; - - const static FontMap font_map[] = { - {USCRIPT_LATIN, L"times new roman"}, - {USCRIPT_GREEK, L"times new roman"}, - {USCRIPT_CYRILLIC, L"times new roman"}, - {USCRIPT_SIMPLIFIED_HAN, L"simsun"}, - //{USCRIPT_TRADITIONAL_HAN, L"pmingliu"}, - {USCRIPT_HIRAGANA, L"ms pgothic"}, - {USCRIPT_KATAKANA, L"ms pgothic"}, - {USCRIPT_KATAKANA_OR_HIRAGANA, L"ms pgothic"}, - {USCRIPT_HANGUL, L"gulim"}, - {USCRIPT_THAI, L"tahoma"}, - {USCRIPT_HEBREW, L"david"}, - {USCRIPT_ARABIC, L"tahoma"}, - {USCRIPT_DEVANAGARI, L"mangal"}, - {USCRIPT_BENGALI, L"vrinda"}, - {USCRIPT_GURMUKHI, L"raavi"}, - {USCRIPT_GUJARATI, L"shruti"}, - {USCRIPT_ORIYA, L"kalinga"}, - {USCRIPT_TAMIL, L"latha"}, - {USCRIPT_TELUGU, L"gautami"}, - {USCRIPT_KANNADA, L"tunga"}, - {USCRIPT_MALAYALAM, L"kartika"}, - {USCRIPT_LAO, L"dokchampa"}, - {USCRIPT_TIBETAN, L"microsoft himalaya"}, - {USCRIPT_GEORGIAN, L"sylfaen"}, - {USCRIPT_ARMENIAN, L"sylfaen"}, - {USCRIPT_ETHIOPIC, L"nyala"}, - {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"}, - {USCRIPT_CHEROKEE, L"plantagenet cherokee"}, - {USCRIPT_YI, L"microsoft yi balti"}, - {USCRIPT_SINHALA, L"iskoola pota"}, - {USCRIPT_SYRIAC, L"estrangelo edessa"}, - {USCRIPT_KHMER, L"daunpenh"}, - {USCRIPT_THAANA, L"mv boli"}, - {USCRIPT_MONGOLIAN, L"mongolian balti"}, - {USCRIPT_MYANMAR, L"padauk"}, - // For USCRIPT_COMMON, we map blocks to scripts when - // that makes sense. - }; - - ScriptToFontMap* new_instance = new ScriptToFontMap; - // Cannot recover from OOM so that there's no need to check. - for (int i = 0; i < arraysize(font_map); ++i) - (*new_instance)[font_map[i].script] = font_map[i].family; - - // Initialize the locale-dependent mapping. - // Since Chrome synchronizes the ICU default locale with its UI locale, - // this ICU locale tells the current UI locale of Chrome. - Locale locale = Locale::getDefault(); - ScriptToFontMap::const_iterator iter; - if (locale == Locale::getJapanese()) { - iter = new_instance->find(USCRIPT_HIRAGANA); - } else if (locale == Locale::getKorean()) { - iter = new_instance->find(USCRIPT_HANGUL); - } else { - // Use Simplified Chinese font for all other locales including - // Traditional Chinese because Simsun (SC font) has a wider - // coverage (covering both SC and TC) than PMingLiu (TC font). - // This also speeds up the TC version of Chrome when rendering SC - // pages. - iter = new_instance->find(USCRIPT_SIMPLIFIED_HAN); - } - if (iter != new_instance->end()) - (*new_instance)[USCRIPT_HAN] = iter->second; - - return new_instance; +// A simple mapping from UScriptCode to family name. This is a sparse array, +// which works well since the range of UScriptCode values is small. +typedef const UChar* ScriptToFontMap[USCRIPT_CODE_LIMIT]; + +void InitializeScriptFontMap(ScriptToFontMap& scriptFontMap) +{ + struct FontMap { + UScriptCode script; + const UChar* family; + }; + + const static FontMap fontMap[] = { + {USCRIPT_LATIN, L"times new roman"}, + {USCRIPT_GREEK, L"times new roman"}, + {USCRIPT_CYRILLIC, L"times new roman"}, + {USCRIPT_SIMPLIFIED_HAN, L"simsun"}, + //{USCRIPT_TRADITIONAL_HAN, L"pmingliu"}, + {USCRIPT_HIRAGANA, L"ms pgothic"}, + {USCRIPT_KATAKANA, L"ms pgothic"}, + {USCRIPT_KATAKANA_OR_HIRAGANA, L"ms pgothic"}, + {USCRIPT_HANGUL, L"gulim"}, + {USCRIPT_THAI, L"tahoma"}, + {USCRIPT_HEBREW, L"david"}, + {USCRIPT_ARABIC, L"tahoma"}, + {USCRIPT_DEVANAGARI, L"mangal"}, + {USCRIPT_BENGALI, L"vrinda"}, + {USCRIPT_GURMUKHI, L"raavi"}, + {USCRIPT_GUJARATI, L"shruti"}, + {USCRIPT_ORIYA, L"kalinga"}, + {USCRIPT_TAMIL, L"latha"}, + {USCRIPT_TELUGU, L"gautami"}, + {USCRIPT_KANNADA, L"tunga"}, + {USCRIPT_MALAYALAM, L"kartika"}, + {USCRIPT_LAO, L"dokchampa"}, + {USCRIPT_TIBETAN, L"microsoft himalaya"}, + {USCRIPT_GEORGIAN, L"sylfaen"}, + {USCRIPT_ARMENIAN, L"sylfaen"}, + {USCRIPT_ETHIOPIC, L"nyala"}, + {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"}, + {USCRIPT_CHEROKEE, L"plantagenet cherokee"}, + {USCRIPT_YI, L"microsoft yi balti"}, + {USCRIPT_SINHALA, L"iskoola pota"}, + {USCRIPT_SYRIAC, L"estrangelo edessa"}, + {USCRIPT_KHMER, L"daunpenh"}, + {USCRIPT_THAANA, L"mv boli"}, + {USCRIPT_MONGOLIAN, L"mongolian balti"}, + {USCRIPT_MYANMAR, L"padauk"}, + // For USCRIPT_COMMON, we map blocks to scripts when + // that makes sense. + }; + + // Cannot recover from OOM so that there's no need to check. + for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i) + scriptFontMap[fontMap[i].script] = fontMap[i].family; + + // Initialize the locale-dependent mapping. + // Since Chrome synchronizes the ICU default locale with its UI locale, + // this ICU locale tells the current UI locale of Chrome. + Locale locale = Locale::getDefault(); + const UChar* localeFamily = NULL; + if (locale == Locale::getJapanese()) { + localeFamily = scriptFontMap[USCRIPT_HIRAGANA]; + } else if (locale == Locale::getKorean()) { + localeFamily = scriptFontMap[USCRIPT_HANGUL]; + } else { + // Use Simplified Chinese font for all other locales including + // Traditional Chinese because Simsun (SC font) has a wider + // coverage (covering both SC and TC) than PMingLiu (TC font). + // This also speeds up the TC version of Chrome when rendering SC + // pages. + localeFamily = scriptFontMap[USCRIPT_SIMPLIFIED_HAN]; } -}; - -Singleton<ScriptToFontMap, ScriptToFontMapSingletonTraits> script_font_map; + if (localeFamily) + scriptFontMap[USCRIPT_HAN] = localeFamily; +} const int kUndefinedAscent = std::numeric_limits<int>::min(); // Given an HFONT, return the ascent. If GetTextMetrics fails, // kUndefinedAscent is returned, instead. -int GetAscent(HFONT hfont) { +int GetAscent(HFONT hfont) +{ HDC dc = GetDC(NULL); HGDIOBJ oldFont = SelectObject(dc, hfont); TEXTMETRIC tm; @@ -122,32 +110,18 @@ int GetAscent(HFONT hfont) { } struct FontData { - FontData() : hfont(NULL), ascent(kUndefinedAscent), script_cache(NULL) {} + FontData() : hfont(NULL), ascent(kUndefinedAscent), scriptCache(NULL) {} HFONT hfont; int ascent; - mutable SCRIPT_CACHE script_cache; + mutable SCRIPT_CACHE scriptCache; }; -// Again, using hash_map does not earn us much here. -// page_cycler_test intl2 gave us a 'better' result with map than with hash_map -// even though they're well-within 1-sigma of each other so that the difference -// is not significant. On the other hand, some pages in intl2 seem to -// take longer to load with map in the 1st pass. Need to experiment further. -typedef std::map<std::wstring, FontData*> FontDataCache; -struct FontDataCacheSingletonTraits - : public DefaultSingletonTraits<FontDataCache> { - static void Delete(FontDataCache* cache) { - FontDataCache::iterator iter = cache->begin(); - while (iter != cache->end()) { - SCRIPT_CACHE script_cache = iter->second->script_cache; - if (script_cache) - ScriptFreeCache(&script_cache); - delete iter->second; - ++iter; - } - delete cache; - } -}; +// Again, using hash_map does not earn us much here. page_cycler_test intl2 +// gave us a 'better' result with map than with hash_map even though they're +// well-within 1-sigma of each other so that the difference is not significant. +// On the other hand, some pages in intl2 seem to take longer to load with map +// in the 1st pass. Need to experiment further. +typedef HashMap<String, FontData*> FontDataCache; } // namespace @@ -168,11 +142,14 @@ struct FontDataCacheSingletonTraits const UChar* GetFontFamilyForScript(UScriptCode script, GenericFamilyType generic) { - ScriptToFontMap::const_iterator iter = script_font_map->find(script); - const UChar* family = NULL; - if (iter != script_font_map->end()) - family = iter->second; - return family; + static ScriptToFontMap scriptFontMap; + bool initialized = false; + if (!initialized) { + InitializeScriptFontMap(scriptFontMap); + initialized = true; + } + ASSERT(script < USCRIPT_CODE_LIMIT); + return scriptFontMap[script]; } // TODO(jungshik) @@ -186,9 +163,10 @@ const UChar* GetFontFamilyForScript(UScriptCode script, const UChar* GetFallbackFamily(const UChar *characters, int length, GenericFamilyType generic, - UChar32 *char_checked, - UScriptCode *script_checked) { - DCHECK(characters && characters[0] && length > 0); + UChar32 *charChecked, + UScriptCode *scriptChecked) +{ + ASSERT(characters && characters[0] && length > 0); UScriptCode script = USCRIPT_COMMON; // Sometimes characters common to script (e.g. space) is at @@ -266,38 +244,33 @@ const UChar* GetFallbackFamily(const UChar *characters, } } - if (char_checked) *char_checked = ucs4; - if (script_checked) *script_checked = script; + if (charChecked) + *charChecked = ucs4; + if (scriptChecked) + *scriptChecked = script; return family; } - - // Be aware that this is not thread-safe. bool GetDerivedFontData(const UChar *family, int style, LOGFONT *logfont, int *ascent, HFONT *hfont, - SCRIPT_CACHE **script_cache) { - DCHECK(logfont && family && *family); - // Using |Singleton| here is not free, but the intl2 page cycler test - // does not show any noticeable difference with and without it. Leaking - // the contents of FontDataCache (especially SCRIPT_CACHE) at the end - // of a renderer process may not be a good idea. We may use - // atexit(). However, with no noticeable performance difference, |Singleton| - // is cleaner, I believe. - FontDataCache* font_data_cache = - Singleton<FontDataCache, FontDataCacheSingletonTraits>::get(); + SCRIPT_CACHE **scriptCache) { + ASSERT(logfont && family && *family); + + // It does not matter that we leak font data when we exit. + static FontDataCache fontDataCache; + // TODO(jungshik) : This comes up pretty high in the profile so that // we need to measure whether using SHA256 (after coercing all the - // fields to char*) is faster than StringPrintf. - std::wstring font_key = StringPrintf(L"%1d:%d:%ls", style, - logfont->lfHeight, family); - FontDataCache::const_iterator iter = font_data_cache->find(font_key); + // fields to char*) is faster than String::format. + String fontKey = String::format("%1d:%d:%ls", style, logfont->lfHeight, family); + FontDataCache::iterator iter = fontDataCache.find(fontKey); FontData *derived; - if (iter == font_data_cache->end()) { - DCHECK(wcslen(family) < LF_FACESIZE); + if (iter == fontDataCache.end()) { + ASSERT(wcslen(family) < LF_FACESIZE); wcscpy_s(logfont->lfFaceName, LF_FACESIZE, family); // TODO(jungshik): CreateFontIndirect always comes up with // a font even if there's no font matching the name. Need to @@ -309,7 +282,7 @@ bool GetDerivedFontData(const UChar *family, // cache it so that we won't have to call CreateFontIndirect once // more for HFONT next time. derived->ascent = GetAscent(derived->hfont); - (*font_data_cache)[font_key] = derived; + fontDataCache.add(fontKey, derived); } else { derived = iter->second; // Last time, GetAscent failed so that only HFONT was @@ -320,7 +293,7 @@ bool GetDerivedFontData(const UChar *family, } *hfont = derived->hfont; *ascent = derived->ascent; - *script_cache = &(derived->script_cache); + *scriptCache = &(derived->scriptCache); return *ascent != kUndefinedAscent; } @@ -328,7 +301,7 @@ int GetStyleFromLogfont(const LOGFONT* logfont) { // TODO(jungshik) : consider defining UNDEFINED or INVALID for style and // returning it when logfont is NULL if (!logfont) { - NOTREACHED(); + ASSERT_NOT_REACHED(); return FONT_STYLE_NORMAL; } return (logfont->lfItalic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL) | diff --git a/webkit/port/platform/graphics/FontUtilsWin.h b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h index 1ec49eb..1ec49eb 100644 --- a/webkit/port/platform/graphics/FontUtilsWin.h +++ b/webkit/port/platform/graphics/chromium/FontUtilsChromiumWin.h diff --git a/webkit/port/platform/graphics/GlyphPageTreeNodeWin.cpp b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp index 709ee58..709ee58 100644 --- a/webkit/port/platform/graphics/GlyphPageTreeNodeWin.cpp +++ b/webkit/port/platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp diff --git a/webkit/port/platform/graphics/IconWin.cpp b/webkit/port/platform/graphics/chromium/IconChromiumWin.cpp index 4d640cc..4d640cc 100644 --- a/webkit/port/platform/graphics/IconWin.cpp +++ b/webkit/port/platform/graphics/chromium/IconChromiumWin.cpp diff --git a/webkit/port/platform/graphics/chromium/ImageBufferData.h b/webkit/port/platform/graphics/chromium/ImageBufferData.h index 227a258..9b46294 100644 --- a/webkit/port/platform/graphics/chromium/ImageBufferData.h +++ b/webkit/port/platform/graphics/chromium/ImageBufferData.h @@ -35,7 +35,7 @@ #include "PlatformContextSkia.h" -#include "base/gfx/platform_canvas.h" +#include "skia/ext/platform_canvas.h" namespace WebCore { diff --git a/webkit/port/platform/graphics/SimpleFontDataWin.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp index 6be0a1e..6be0a1e 100644 --- a/webkit/port/platform/graphics/SimpleFontDataWin.cpp +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp diff --git a/webkit/port/platform/graphics/ThemeHelperWin.cpp b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp index 10916e6..546f660 100644 --- a/webkit/port/platform/graphics/ThemeHelperWin.cpp +++ b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "FloatRect.h" #include "GraphicsContext.h" -#include "ThemeHelperWin.h" +#include "ThemeHelperChromiumWin.h" namespace WebCore { diff --git a/webkit/port/platform/graphics/ThemeHelperWin.h b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h index 3d7caf1..3d7caf1 100644 --- a/webkit/port/platform/graphics/ThemeHelperWin.h +++ b/webkit/port/platform/graphics/chromium/ThemeHelperChromiumWin.h diff --git a/webkit/port/platform/graphics/UniscribeHelper.cpp b/webkit/port/platform/graphics/chromium/UniscribeHelper.cpp index e0ff01a..6be3a10 100644 --- a/webkit/port/platform/graphics/UniscribeHelper.cpp +++ b/webkit/port/platform/graphics/chromium/UniscribeHelper.cpp @@ -7,8 +7,8 @@ #include <windows.h> -#include "FontUtilsWin.h" -#include "wtf/Assertions.h" +#include "FontUtilsChromiumWin.h" +#include <wtf/Assertions.h> namespace WebCore { diff --git a/webkit/port/platform/graphics/UniscribeHelper.h b/webkit/port/platform/graphics/chromium/UniscribeHelper.h index 27d7961..27d7961 100644 --- a/webkit/port/platform/graphics/UniscribeHelper.h +++ b/webkit/port/platform/graphics/chromium/UniscribeHelper.h diff --git a/webkit/port/platform/graphics/UniscribeHelperTextRun.cpp b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp index 93d23e9..93d23e9 100644 --- a/webkit/port/platform/graphics/UniscribeHelperTextRun.cpp +++ b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.cpp diff --git a/webkit/port/platform/graphics/UniscribeHelperTextRun.h b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h index 281e6d9..281e6d9 100644 --- a/webkit/port/platform/graphics/UniscribeHelperTextRun.h +++ b/webkit/port/platform/graphics/chromium/UniscribeHelperTextRun.h diff --git a/webkit/port/platform/graphics/UniscribeHelper_unittest.cpp b/webkit/port/platform/graphics/chromium/UniscribeHelper_unittest.cpp index d3e8206..d3e8206 100644 --- a/webkit/port/platform/graphics/UniscribeHelper_unittest.cpp +++ b/webkit/port/platform/graphics/chromium/UniscribeHelper_unittest.cpp diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript index 6408872..193a7b7 100644 --- a/webkit/tools/test_shell/SConscript +++ b/webkit/tools/test_shell/SConscript @@ -189,7 +189,7 @@ if env['PLATFORM'] == 'win32': # Commented out until a regression is fixed and this file is restored. #'$WEBKIT_DIR/glue/stringimpl_unittest.cc', '$WEBKIT_DIR/glue/webplugin_impl_unittest.cc', - '$WEBKIT_DIR/port/platform/graphics/UniscribeHelper_unittest.cpp', + '$WEBKIT_DIR/port/platform/graphics/chromium/UniscribeHelper_unittest.cpp', ]) test_shell_tests = env.ChromeTestProgram('test_shell_tests', diff --git a/webkit/tools/test_shell/test_shell_tests.vcproj b/webkit/tools/test_shell/test_shell_tests.vcproj index a9bd585..a2776ae 100644 --- a/webkit/tools/test_shell/test_shell_tests.vcproj +++ b/webkit/tools/test_shell/test_shell_tests.vcproj @@ -383,7 +383,7 @@ >
</File>
<File
- RelativePath="..\..\port\platform\graphics\UniscribeHelper_unittest.cpp"
+ RelativePath="..\..\port\platform\graphics\chromium\UniscribeHelper_unittest.cpp"
>
</File>
<File
|