2011-06-23 Jungshik Shin <jshin@chromium.org>
authorjshin@chromium.org <jshin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Jun 2011 18:23:32 +0000 (18:23 +0000)
committerjshin@chromium.org <jshin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Jun 2011 18:23:32 +0000 (18:23 +0000)
        Reviewed by Alexey Proskuryakov.

        Add ScriptCodesFromICU.h to wtf/unicode and make necessary changes in
        build files for ports not using ICU.
        Add icu/unicode/uscript.h for ports using ICU. It's taken from
        ICU 3.6 (the version used on Mac OS 10.5)

        http://bugs.webkit.org/show_bug.cgi?id=20797

        * GNUmakefile.list.am:
        * JavaScriptCore.gypi:
        * icu/unicode/uscript.h: Added for UScriptCode enum.
        * wtf/unicode/ScriptCodesFromICU.h: UScriptCode enum added.
        * wtf/unicode/icu/UnicodeIcu.h:
        * wtf/unicode/brew/UnicodeBrew.h:
        * wtf/unicode/glib/UnicodeGLib.h:
        * wtf/unicode/qt4/UnicodeQt4.h:
        * wtf/unicode/wince/UnicodeWinCE.h:
2011-06-23  Jungshik Shin  <jshin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Add uscript.h to icu/unicode to get JavaScriptGlue get built. The same
        file was added to JavaScriptCore/icu/unicode.

        http://bugs.webkit.org/show_bug.cgi?id=20797

        * icu/unicode/uscript.h: Added.
2011-06-23  Jungshik Shin  <jshin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Allow generic font family settings per script code.
        https://bugs.webkit.org/show_bug.cgi?id=20797

        Make generic font family getters/setters accept an additional
        argument (script code). It has a default value so that if an embedder
        does not have/want a per-script font family setting, call-sites
        don't have to be changed.
        This is to prepare for fixing bug 10874 (font selection is not
        language-dependent) and bug 18085.

        uscript.h has been updated to that of ICU 3.6 (the version of ICU on
        Mac OS 10.5)

        There should be no change in layout and no new layout test
        is added.

        * WebCore.exp.in:
        * icu/unicode/uscript.h: updated to ICU 4.6
        * page/Settings.cpp:
        (WebCore::setGenericFontFamilyMap): helper to set generic family per script
        (WebCore::getGenericFontFamilyForScript): helper function used by getters for fooFontFamily.
        (WebCore::Settings::standardFontFamily):
        (WebCore::Settings::setStandardFontFamily):
        (WebCore::Settings::fixedFontFamily):
        (WebCore::Settings::setFixedFontFamily):
        (WebCore::Settings::serifFontFamily):
        (WebCore::Settings::setSerifFontFamily):
        (WebCore::Settings::sansSerifFontFamily):
        (WebCore::Settings::setSansSerifFontFamily):
        (WebCore::Settings::cursiveFontFamily):
        (WebCore::Settings::setCursiveFontFamily):
        (WebCore::Settings::fantasyFontFamily):
        (WebCore::Settings::setFantasyFontFamily):
        * page/Settings.h: setter and getter for FooFontFamily have a new optional argument, scriptCode.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@89594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/icu/unicode/uscript.h [new file with mode: 0644]
Source/JavaScriptCore/wtf/unicode/ScriptCodesFromICU.h [new file with mode: 0644]
Source/JavaScriptCore/wtf/unicode/brew/UnicodeBrew.h
Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h
Source/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h
Source/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h
Source/JavaScriptCore/wtf/unicode/wince/UnicodeWinCE.h
Source/JavaScriptGlue/ChangeLog
Source/JavaScriptGlue/icu/unicode/uscript.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/icu/unicode/uscript.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h

index cd0014b..2edd1d2 100644 (file)
@@ -1,3 +1,24 @@
+2011-06-23  Jungshik Shin  <jshin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add ScriptCodesFromICU.h to wtf/unicode and make necessary changes in
+        build files for ports not using ICU.
+        Add icu/unicode/uscript.h for ports using ICU. It's taken from 
+        ICU 3.6 (the version used on Mac OS 10.5)
+
+        http://bugs.webkit.org/show_bug.cgi?id=20797
+
+        * GNUmakefile.list.am:
+        * JavaScriptCore.gypi:
+        * icu/unicode/uscript.h: Added for UScriptCode enum.
+        * wtf/unicode/ScriptCodesFromICU.h: UScriptCode enum added.
+        * wtf/unicode/icu/UnicodeIcu.h:
+        * wtf/unicode/brew/UnicodeBrew.h:
+        * wtf/unicode/glib/UnicodeGLib.h:
+        * wtf/unicode/qt4/UnicodeQt4.h:
+        * wtf/unicode/wince/UnicodeWinCE.h:
+
 2011-06-23  Ryuan Choi  <ryuan.choi@samsung.com>
 
         Reviewed by Andreas Kling.
index 99c990e..7ebca52 100644 (file)
@@ -630,6 +630,7 @@ endif # USE_ICU_UNICODE
 if USE_GLIB_UNICODE
 javascriptcore_sources += \
        Source/JavaScriptCore/wtf/unicode/UnicodeMacrosFromICU.h \
+       Source/JavaScriptCore/wtf/unicode/ScriptCodesFromICU.h \
        Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h \
        Source/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.cpp
 endif # USE_GLIB_UNICODE
index 9b47519..a8ec889 100644 (file)
             'icu/unicode/umachine.h',
             'icu/unicode/unorm.h',
             'icu/unicode/urename.h',
+            'icu/unicode/uscript.h',
             'icu/unicode/uset.h',
             'icu/unicode/ustring.h',
             'icu/unicode/utf.h',
             'wtf/text/StringStatics.cpp',
             'wtf/text/WTFString.cpp',
             'wtf/unicode/CollatorDefault.cpp',
+            'wtf/unicode/ScriptCodesFromICU.h',
             'wtf/unicode/UTF8.cpp',
             'wtf/unicode/UnicodeMacrosFromICU.h',
             'wtf/unicode/brew/UnicodeBrew.cpp',
diff --git a/Source/JavaScriptCore/icu/unicode/uscript.h b/Source/JavaScriptCore/icu/unicode/uscript.h
new file mode 100644 (file)
index 0000000..d7cbc38
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File USCRIPT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   07/06/2001    Ram         Creation.
+******************************************************************************
+*/
+#ifndef USCRIPT_H
+#define USCRIPT_H
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API: Unicode Script Information
+ */
+/**
+ * Constants for ISO 15924 script codes.
+ *
+ * Many of these script codes - those from Unicode's ScriptNames.txt -
+ * are character property values for Unicode's Script property.
+ * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).
+ *
+ * Starting with ICU 3.6, constants for most ISO 15924 script codes
+ * are included (currently excluding private-use codes Qaaa..Qabx).
+ * For scripts for which there are codes in ISO 15924 but which are not
+ * used in the Unicode Character Database (UCD), there are no Unicode characters
+ * associated with those scripts.
+ *
+ * For example, there are no characters that have a UCD script code of
+ * Hans or Hant. All Han ideographs have the Hani script code.
+ * The Hans and Hant script codes are used with CLDR data.
+ *
+ * ISO 15924 script codes are included for use with CLDR and similar.
+ *
+ * @stable ICU 2.2
+ */
+typedef enum UScriptCode {
+      USCRIPT_INVALID_CODE = -1,
+      USCRIPT_COMMON       =  0 , /* Zyyy */
+      USCRIPT_INHERITED    =  1,  /* Qaai */
+      USCRIPT_ARABIC       =  2,  /* Arab */
+      USCRIPT_ARMENIAN     =  3,  /* Armn */
+      USCRIPT_BENGALI      =  4,  /* Beng */
+      USCRIPT_BOPOMOFO     =  5,  /* Bopo */
+      USCRIPT_CHEROKEE     =  6,  /* Cher */
+      USCRIPT_COPTIC       =  7,  /* Copt */
+      USCRIPT_CYRILLIC     =  8,  /* Cyrl */
+      USCRIPT_DESERET      =  9,  /* Dsrt */
+      USCRIPT_DEVANAGARI   = 10,  /* Deva */
+      USCRIPT_ETHIOPIC     = 11,  /* Ethi */
+      USCRIPT_GEORGIAN     = 12,  /* Geor */
+      USCRIPT_GOTHIC       = 13,  /* Goth */
+      USCRIPT_GREEK        = 14,  /* Grek */
+      USCRIPT_GUJARATI     = 15,  /* Gujr */
+      USCRIPT_GURMUKHI     = 16,  /* Guru */
+      USCRIPT_HAN          = 17,  /* Hani */
+      USCRIPT_HANGUL       = 18,  /* Hang */
+      USCRIPT_HEBREW       = 19,  /* Hebr */
+      USCRIPT_HIRAGANA     = 20,  /* Hira */
+      USCRIPT_KANNADA      = 21,  /* Knda */
+      USCRIPT_KATAKANA     = 22,  /* Kana */
+      USCRIPT_KHMER        = 23,  /* Khmr */
+      USCRIPT_LAO          = 24,  /* Laoo */
+      USCRIPT_LATIN        = 25,  /* Latn */
+      USCRIPT_MALAYALAM    = 26,  /* Mlym */
+      USCRIPT_MONGOLIAN    = 27,  /* Mong */
+      USCRIPT_MYANMAR      = 28,  /* Mymr */
+      USCRIPT_OGHAM        = 29,  /* Ogam */
+      USCRIPT_OLD_ITALIC   = 30,  /* Ital */
+      USCRIPT_ORIYA        = 31,  /* Orya */
+      USCRIPT_RUNIC        = 32,  /* Runr */
+      USCRIPT_SINHALA      = 33,  /* Sinh */
+      USCRIPT_SYRIAC       = 34,  /* Syrc */
+      USCRIPT_TAMIL        = 35,  /* Taml */
+      USCRIPT_TELUGU       = 36,  /* Telu */
+      USCRIPT_THAANA       = 37,  /* Thaa */
+      USCRIPT_THAI         = 38,  /* Thai */
+      USCRIPT_TIBETAN      = 39,  /* Tibt */
+      /** Canadian_Aboriginal script. @stable ICU 2.6 */
+      USCRIPT_CANADIAN_ABORIGINAL = 40,  /* Cans */
+      /** Canadian_Aboriginal script (alias). @stable ICU 2.2 */
+      USCRIPT_UCAS         = USCRIPT_CANADIAN_ABORIGINAL,
+      USCRIPT_YI           = 41,  /* Yiii */
+      USCRIPT_TAGALOG      = 42,  /* Tglg */
+      USCRIPT_HANUNOO      = 43,  /* Hano */
+      USCRIPT_BUHID        = 44,  /* Buhd */
+      USCRIPT_TAGBANWA     = 45,  /* Tagb */
+
+      /* New scripts in Unicode 4 @stable ICU 2.6 */
+      USCRIPT_BRAILLE      = 46,  /* Brai */
+      USCRIPT_CYPRIOT      = 47,  /* Cprt */
+      USCRIPT_LIMBU        = 48,  /* Limb */
+      USCRIPT_LINEAR_B     = 49,  /* Linb */
+      USCRIPT_OSMANYA      = 50,  /* Osma */
+      USCRIPT_SHAVIAN      = 51,  /* Shaw */
+      USCRIPT_TAI_LE       = 52,  /* Tale */
+      USCRIPT_UGARITIC     = 53,  /* Ugar */
+
+      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */
+      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */
+      
+#ifndef U_HIDE_DRAFT_API
+      /* New scripts in Unicode 4.1 @draft ICU 3.4 */
+      USCRIPT_BUGINESE      = 55, /* Bugi */
+      USCRIPT_GLAGOLITIC    = 56, /* Glag */
+      USCRIPT_KHAROSHTHI    = 57, /* Khar */
+      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */
+      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */
+      USCRIPT_TIFINAGH      = 60, /* Tfng */
+      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */
+
+      /* New script codes from ISO 15924 @draft ICU 3.6 */
+      USCRIPT_BALINESE                      = 62, /* Bali */
+      USCRIPT_BATAK                         = 63, /* Batk */
+      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */
+      USCRIPT_BRAHMI                        = 65, /* Brah */
+      USCRIPT_CHAM                          = 66, /* Cham */
+      USCRIPT_CIRTH                         = 67, /* Cirt */
+      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */
+      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */
+      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */
+      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */
+      USCRIPT_KHUTSURI                      = 72, /* Geok */
+      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */
+      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */
+      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */
+      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */
+      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */
+      USCRIPT_JAVANESE                      = 78, /* Java */
+      USCRIPT_KAYAH_LI                      = 79, /* Kali */
+      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */
+      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */
+      USCRIPT_LEPCHA                        = 82, /* Lepc */
+      USCRIPT_LINEAR_A                      = 83, /* Lina */
+      USCRIPT_MANDAEAN                      = 84, /* Mand */
+      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */
+      USCRIPT_MEROITIC                      = 86, /* Mero */
+      USCRIPT_NKO                           = 87, /* Nkoo */
+      USCRIPT_ORKHON                        = 88, /* Orkh */
+      USCRIPT_OLD_PERMIC                    = 89, /* Perm */
+      USCRIPT_PHAGS_PA                      = 90, /* Phag */
+      USCRIPT_PHOENICIAN                    = 91, /* Phnx */
+      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */
+      USCRIPT_RONGORONGO                    = 93, /* Roro */
+      USCRIPT_SARATI                        = 94, /* Sara */
+      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */
+      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */
+      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */
+      USCRIPT_TENGWAR                       = 98, /* Teng */
+      USCRIPT_VAI                           = 99, /* Vaii */
+      USCRIPT_VISIBLE_SPEECH                = 100, /* Visp */
+      USCRIPT_CUNEIFORM                     = 101,/* Xsux */
+      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */
+      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
+      /* Private use codes from Qaaa - Qabx are not supported*/
+#endif /* U_HIDE_DRAFT_API */
+      USCRIPT_CODE_LIMIT    = 104
+} UScriptCode;
+
+/**
+ * Gets script codes associated with the given locale or ISO 15924 abbreviation or name. 
+ * Fills in USCRIPT_MALAYALAM given "Malayam" OR "Mlym".
+ * Fills in USCRIPT_LATIN given "en" OR "en_US" 
+ * If required capacity is greater than capacity of the destination buffer then the error code
+ * is set to U_BUFFER_OVERFLOW_ERROR and the required capacity is returned
+ *
+ * <p>Note: To search by short or long script alias only, use
+ * u_getPropertyValueEnum(UCHAR_SCRIPT, alias) instead.  This does
+ * a fast lookup with no access of the locale data.
+ * @param nameOrAbbrOrLocale name of the script, as given in
+ * PropertyValueAliases.txt, or ISO 15924 code or locale
+ * @param fillIn the UScriptCode buffer to fill in the script code
+ * @param capacity the capacity (size) fo UScriptCode buffer passed in.
+ * @param err the error status code.
+ * @return The number of script codes filled in the buffer passed in 
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t  U_EXPORT2 
+uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Malayam" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script long name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getName(UScriptCode scriptCode);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Mlym" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script abbreviated name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getShortName(UScriptCode scriptCode);
+
+/** 
+ * Gets the script code associated with the given codepoint.
+ * Returns USCRIPT_MALAYALAM given 0x0D02 
+ * @param codepoint UChar32 codepoint
+ * @param err the error status code.
+ * @return The UScriptCode, or 0 if codepoint is invalid 
+ * @stable ICU 2.4
+ */
+U_STABLE UScriptCode  U_EXPORT2 
+uscript_getScript(UChar32 codepoint, UErrorCode *err);
+
+#endif
+
+
diff --git a/Source/JavaScriptCore/wtf/unicode/ScriptCodesFromICU.h b/Source/JavaScriptCore/wtf/unicode/ScriptCodesFromICU.h
new file mode 100644 (file)
index 0000000..7e1dcc1
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ *   Copyright (C) 1997-2010, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ */
+
+#ifndef WTF_ScriptCodesFromICU_h
+#define WTF_ScriptCodesFromICU_h
+
+/**
+ * Constants for ISO 15924 script codes.
+ *
+ * Many of these script codes - those from Unicode's ScriptNames.txt -
+ * are character property values for Unicode's Script property.
+ * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).
+ *
+ * Starting with ICU 3.6, constants for most ISO 15924 script codes
+ * are included (currently excluding private-use codes Qaaa..Qabx).
+ * For scripts for which there are codes in ISO 15924 but which are not
+ * used in the Unicode Character Database (UCD), there are no Unicode characters
+ * associated with those scripts.
+ *
+ * For example, there are no characters that have a UCD script code of
+ * Hans or Hant. All Han ideographs have the Hani script code.
+ * The Hans and Hant script codes are used with CLDR data.
+ *
+ * ISO 15924 script codes are included for use with CLDR and similar.
+ *
+ * @stable ICU 2.2
+ */
+typedef enum UScriptCode {
+      USCRIPT_INVALID_CODE = -1,
+      USCRIPT_COMMON       =  0 , /* Zyyy */
+      USCRIPT_INHERITED    =  1,  /* Qaai */
+      USCRIPT_ARABIC       =  2,  /* Arab */
+      USCRIPT_ARMENIAN     =  3,  /* Armn */
+      USCRIPT_BENGALI      =  4,  /* Beng */
+      USCRIPT_BOPOMOFO     =  5,  /* Bopo */
+      USCRIPT_CHEROKEE     =  6,  /* Cher */
+      USCRIPT_COPTIC       =  7,  /* Copt */
+      USCRIPT_CYRILLIC     =  8,  /* Cyrl */
+      USCRIPT_DESERET      =  9,  /* Dsrt */
+      USCRIPT_DEVANAGARI   = 10,  /* Deva */
+      USCRIPT_ETHIOPIC     = 11,  /* Ethi */
+      USCRIPT_GEORGIAN     = 12,  /* Geor */
+      USCRIPT_GOTHIC       = 13,  /* Goth */
+      USCRIPT_GREEK        = 14,  /* Grek */
+      USCRIPT_GUJARATI     = 15,  /* Gujr */
+      USCRIPT_GURMUKHI     = 16,  /* Guru */
+      USCRIPT_HAN          = 17,  /* Hani */
+      USCRIPT_HANGUL       = 18,  /* Hang */
+      USCRIPT_HEBREW       = 19,  /* Hebr */
+      USCRIPT_HIRAGANA     = 20,  /* Hira */
+      USCRIPT_KANNADA      = 21,  /* Knda */
+      USCRIPT_KATAKANA     = 22,  /* Kana */
+      USCRIPT_KHMER        = 23,  /* Khmr */
+      USCRIPT_LAO          = 24,  /* Laoo */
+      USCRIPT_LATIN        = 25,  /* Latn */
+      USCRIPT_MALAYALAM    = 26,  /* Mlym */
+      USCRIPT_MONGOLIAN    = 27,  /* Mong */
+      USCRIPT_MYANMAR      = 28,  /* Mymr */
+      USCRIPT_OGHAM        = 29,  /* Ogam */
+      USCRIPT_OLD_ITALIC   = 30,  /* Ital */
+      USCRIPT_ORIYA        = 31,  /* Orya */
+      USCRIPT_RUNIC        = 32,  /* Runr */
+      USCRIPT_SINHALA      = 33,  /* Sinh */
+      USCRIPT_SYRIAC       = 34,  /* Syrc */
+      USCRIPT_TAMIL        = 35,  /* Taml */
+      USCRIPT_TELUGU       = 36,  /* Telu */
+      USCRIPT_THAANA       = 37,  /* Thaa */
+      USCRIPT_THAI         = 38,  /* Thai */
+      USCRIPT_TIBETAN      = 39,  /* Tibt */
+      /** Canadian_Aboriginal script. @stable ICU 2.6 */
+      USCRIPT_CANADIAN_ABORIGINAL = 40,  /* Cans */
+      /** Canadian_Aboriginal script (alias). @stable ICU 2.2 */
+      USCRIPT_UCAS         = USCRIPT_CANADIAN_ABORIGINAL,
+      USCRIPT_YI           = 41,  /* Yiii */
+      USCRIPT_TAGALOG      = 42,  /* Tglg */
+      USCRIPT_HANUNOO      = 43,  /* Hano */
+      USCRIPT_BUHID        = 44,  /* Buhd */
+      USCRIPT_TAGBANWA     = 45,  /* Tagb */
+
+      /* New scripts in Unicode 4 @stable ICU 2.6 */
+      USCRIPT_BRAILLE      = 46,  /* Brai */
+      USCRIPT_CYPRIOT      = 47,  /* Cprt */
+      USCRIPT_LIMBU        = 48,  /* Limb */
+      USCRIPT_LINEAR_B     = 49,  /* Linb */
+      USCRIPT_OSMANYA      = 50,  /* Osma */
+      USCRIPT_SHAVIAN      = 51,  /* Shaw */
+      USCRIPT_TAI_LE       = 52,  /* Tale */
+      USCRIPT_UGARITIC     = 53,  /* Ugar */
+
+      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */
+      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */
+      
+#ifndef U_HIDE_DRAFT_API
+      /* New scripts in Unicode 4.1 @draft ICU 3.4 */
+      USCRIPT_BUGINESE      = 55, /* Bugi */
+      USCRIPT_GLAGOLITIC    = 56, /* Glag */
+      USCRIPT_KHAROSHTHI    = 57, /* Khar */
+      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */
+      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */
+      USCRIPT_TIFINAGH      = 60, /* Tfng */
+      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */
+
+      /* New script codes from ISO 15924 @draft ICU 3.6 */
+      USCRIPT_BALINESE                      = 62, /* Bali */
+      USCRIPT_BATAK                         = 63, /* Batk */
+      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */
+      USCRIPT_BRAHMI                        = 65, /* Brah */
+      USCRIPT_CHAM                          = 66, /* Cham */
+      USCRIPT_CIRTH                         = 67, /* Cirt */
+      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */
+      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */
+      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */
+      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */
+      USCRIPT_KHUTSURI                      = 72, /* Geok */
+      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */
+      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */
+      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */
+      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */
+      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */
+      USCRIPT_JAVANESE                      = 78, /* Java */
+      USCRIPT_KAYAH_LI                      = 79, /* Kali */
+      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */
+      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */
+      USCRIPT_LEPCHA                        = 82, /* Lepc */
+      USCRIPT_LINEAR_A                      = 83, /* Lina */
+      USCRIPT_MANDAEAN                      = 84, /* Mand */
+      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */
+      USCRIPT_MEROITIC                      = 86, /* Mero */
+      USCRIPT_NKO                           = 87, /* Nkoo */
+      USCRIPT_ORKHON                        = 88, /* Orkh */
+      USCRIPT_OLD_PERMIC                    = 89, /* Perm */
+      USCRIPT_PHAGS_PA                      = 90, /* Phag */
+      USCRIPT_PHOENICIAN                    = 91, /* Phnx */
+      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */
+      USCRIPT_RONGORONGO                    = 93, /* Roro */
+      USCRIPT_SARATI                        = 94, /* Sara */
+      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */
+      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */
+      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */
+      USCRIPT_TENGWAR                       = 98, /* Teng */
+      USCRIPT_VAI                           = 99, /* Vaii */
+      USCRIPT_VISIBLE_SPEECH                = 100, /* Visp */
+      USCRIPT_CUNEIFORM                     = 101,/* Xsux */
+      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */
+      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
+      /* Private use codes from Qaaa - Qabx are not supported*/
+#endif /* U_HIDE_DRAFT_API */
+      USCRIPT_CODE_LIMIT    = 104
+} UScriptCode;
+
+#endif
index 1d7576f..e246f4b 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef UnicodeBrew_h
 #define UnicodeBrew_h
 
+#include "ScriptCodesFromICU.h"
 #include "UnicodeFromICU.h"
 #include "UnicodeMacrosFromICU.h"
 
index 46b00ea..7bff934 100644 (file)
@@ -25,8 +25,9 @@
 #ifndef UnicodeGLib_h
 #define UnicodeGLib_h
 
-#include "UnicodeMacrosFromICU.h"
 #include "GOwnPtr.h"
+#include "ScriptCodesFromICU.h"
+#include "UnicodeMacrosFromICU.h"
 
 #include <glib.h>
 #include <pango/pango.h>
index a2a5c0a..fe524b2 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdlib.h>
 #include <unicode/uchar.h>
+#include <unicode/uscript.h>
 #include <unicode/ustring.h>
 #include <unicode/utf16.h>
 
index 7eb2160..76eb562 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef WTF_UNICODE_QT4_H
 #define WTF_UNICODE_QT4_H
 
+#include "ScriptCodesFromICU.h"
 #include "UnicodeMacrosFromICU.h"
 
 #include <QChar>
index 2688aa9..af6ff07 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef WTF_UnicodeWinCE_h
 #define WTF_UnicodeWinCE_h
 
+#include "ScriptCodesFromICU.h"
 #include "UnicodeMacrosFromICU.h"
 
 #include "ce_unicode.h"
index 764f414..ac8280b 100644 (file)
@@ -1,3 +1,14 @@
+2011-06-23  Jungshik Shin  <jshin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add uscript.h to icu/unicode to get JavaScriptGlue get built. The same
+        file was added to JavaScriptCore/icu/unicode.
+
+        http://bugs.webkit.org/show_bug.cgi?id=20797
+
+        * icu/unicode/uscript.h: Added.
+
 2011-05-16  David Kilzer  <ddkilzer@apple.com>
 
         <http://webkit.org/b/60913> C++ exceptions should not be enabled when building with llvm-gcc-4.2
diff --git a/Source/JavaScriptGlue/icu/unicode/uscript.h b/Source/JavaScriptGlue/icu/unicode/uscript.h
new file mode 100644 (file)
index 0000000..d7cbc38
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+**********************************************************************
+*   Copyright (C) 1997-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*
+* File USCRIPT.H
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   07/06/2001    Ram         Creation.
+******************************************************************************
+*/
+#ifndef USCRIPT_H
+#define USCRIPT_H
+#include "unicode/utypes.h"
+
+/**
+ * \file
+ * \brief C API: Unicode Script Information
+ */
+/**
+ * Constants for ISO 15924 script codes.
+ *
+ * Many of these script codes - those from Unicode's ScriptNames.txt -
+ * are character property values for Unicode's Script property.
+ * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).
+ *
+ * Starting with ICU 3.6, constants for most ISO 15924 script codes
+ * are included (currently excluding private-use codes Qaaa..Qabx).
+ * For scripts for which there are codes in ISO 15924 but which are not
+ * used in the Unicode Character Database (UCD), there are no Unicode characters
+ * associated with those scripts.
+ *
+ * For example, there are no characters that have a UCD script code of
+ * Hans or Hant. All Han ideographs have the Hani script code.
+ * The Hans and Hant script codes are used with CLDR data.
+ *
+ * ISO 15924 script codes are included for use with CLDR and similar.
+ *
+ * @stable ICU 2.2
+ */
+typedef enum UScriptCode {
+      USCRIPT_INVALID_CODE = -1,
+      USCRIPT_COMMON       =  0 , /* Zyyy */
+      USCRIPT_INHERITED    =  1,  /* Qaai */
+      USCRIPT_ARABIC       =  2,  /* Arab */
+      USCRIPT_ARMENIAN     =  3,  /* Armn */
+      USCRIPT_BENGALI      =  4,  /* Beng */
+      USCRIPT_BOPOMOFO     =  5,  /* Bopo */
+      USCRIPT_CHEROKEE     =  6,  /* Cher */
+      USCRIPT_COPTIC       =  7,  /* Copt */
+      USCRIPT_CYRILLIC     =  8,  /* Cyrl */
+      USCRIPT_DESERET      =  9,  /* Dsrt */
+      USCRIPT_DEVANAGARI   = 10,  /* Deva */
+      USCRIPT_ETHIOPIC     = 11,  /* Ethi */
+      USCRIPT_GEORGIAN     = 12,  /* Geor */
+      USCRIPT_GOTHIC       = 13,  /* Goth */
+      USCRIPT_GREEK        = 14,  /* Grek */
+      USCRIPT_GUJARATI     = 15,  /* Gujr */
+      USCRIPT_GURMUKHI     = 16,  /* Guru */
+      USCRIPT_HAN          = 17,  /* Hani */
+      USCRIPT_HANGUL       = 18,  /* Hang */
+      USCRIPT_HEBREW       = 19,  /* Hebr */
+      USCRIPT_HIRAGANA     = 20,  /* Hira */
+      USCRIPT_KANNADA      = 21,  /* Knda */
+      USCRIPT_KATAKANA     = 22,  /* Kana */
+      USCRIPT_KHMER        = 23,  /* Khmr */
+      USCRIPT_LAO          = 24,  /* Laoo */
+      USCRIPT_LATIN        = 25,  /* Latn */
+      USCRIPT_MALAYALAM    = 26,  /* Mlym */
+      USCRIPT_MONGOLIAN    = 27,  /* Mong */
+      USCRIPT_MYANMAR      = 28,  /* Mymr */
+      USCRIPT_OGHAM        = 29,  /* Ogam */
+      USCRIPT_OLD_ITALIC   = 30,  /* Ital */
+      USCRIPT_ORIYA        = 31,  /* Orya */
+      USCRIPT_RUNIC        = 32,  /* Runr */
+      USCRIPT_SINHALA      = 33,  /* Sinh */
+      USCRIPT_SYRIAC       = 34,  /* Syrc */
+      USCRIPT_TAMIL        = 35,  /* Taml */
+      USCRIPT_TELUGU       = 36,  /* Telu */
+      USCRIPT_THAANA       = 37,  /* Thaa */
+      USCRIPT_THAI         = 38,  /* Thai */
+      USCRIPT_TIBETAN      = 39,  /* Tibt */
+      /** Canadian_Aboriginal script. @stable ICU 2.6 */
+      USCRIPT_CANADIAN_ABORIGINAL = 40,  /* Cans */
+      /** Canadian_Aboriginal script (alias). @stable ICU 2.2 */
+      USCRIPT_UCAS         = USCRIPT_CANADIAN_ABORIGINAL,
+      USCRIPT_YI           = 41,  /* Yiii */
+      USCRIPT_TAGALOG      = 42,  /* Tglg */
+      USCRIPT_HANUNOO      = 43,  /* Hano */
+      USCRIPT_BUHID        = 44,  /* Buhd */
+      USCRIPT_TAGBANWA     = 45,  /* Tagb */
+
+      /* New scripts in Unicode 4 @stable ICU 2.6 */
+      USCRIPT_BRAILLE      = 46,  /* Brai */
+      USCRIPT_CYPRIOT      = 47,  /* Cprt */
+      USCRIPT_LIMBU        = 48,  /* Limb */
+      USCRIPT_LINEAR_B     = 49,  /* Linb */
+      USCRIPT_OSMANYA      = 50,  /* Osma */
+      USCRIPT_SHAVIAN      = 51,  /* Shaw */
+      USCRIPT_TAI_LE       = 52,  /* Tale */
+      USCRIPT_UGARITIC     = 53,  /* Ugar */
+
+      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */
+      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */
+      
+#ifndef U_HIDE_DRAFT_API
+      /* New scripts in Unicode 4.1 @draft ICU 3.4 */
+      USCRIPT_BUGINESE      = 55, /* Bugi */
+      USCRIPT_GLAGOLITIC    = 56, /* Glag */
+      USCRIPT_KHAROSHTHI    = 57, /* Khar */
+      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */
+      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */
+      USCRIPT_TIFINAGH      = 60, /* Tfng */
+      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */
+
+      /* New script codes from ISO 15924 @draft ICU 3.6 */
+      USCRIPT_BALINESE                      = 62, /* Bali */
+      USCRIPT_BATAK                         = 63, /* Batk */
+      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */
+      USCRIPT_BRAHMI                        = 65, /* Brah */
+      USCRIPT_CHAM                          = 66, /* Cham */
+      USCRIPT_CIRTH                         = 67, /* Cirt */
+      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */
+      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */
+      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */
+      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */
+      USCRIPT_KHUTSURI                      = 72, /* Geok */
+      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */
+      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */
+      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */
+      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */
+      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */
+      USCRIPT_JAVANESE                      = 78, /* Java */
+      USCRIPT_KAYAH_LI                      = 79, /* Kali */
+      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */
+      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */
+      USCRIPT_LEPCHA                        = 82, /* Lepc */
+      USCRIPT_LINEAR_A                      = 83, /* Lina */
+      USCRIPT_MANDAEAN                      = 84, /* Mand */
+      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */
+      USCRIPT_MEROITIC                      = 86, /* Mero */
+      USCRIPT_NKO                           = 87, /* Nkoo */
+      USCRIPT_ORKHON                        = 88, /* Orkh */
+      USCRIPT_OLD_PERMIC                    = 89, /* Perm */
+      USCRIPT_PHAGS_PA                      = 90, /* Phag */
+      USCRIPT_PHOENICIAN                    = 91, /* Phnx */
+      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */
+      USCRIPT_RONGORONGO                    = 93, /* Roro */
+      USCRIPT_SARATI                        = 94, /* Sara */
+      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */
+      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */
+      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */
+      USCRIPT_TENGWAR                       = 98, /* Teng */
+      USCRIPT_VAI                           = 99, /* Vaii */
+      USCRIPT_VISIBLE_SPEECH                = 100, /* Visp */
+      USCRIPT_CUNEIFORM                     = 101,/* Xsux */
+      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */
+      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
+      /* Private use codes from Qaaa - Qabx are not supported*/
+#endif /* U_HIDE_DRAFT_API */
+      USCRIPT_CODE_LIMIT    = 104
+} UScriptCode;
+
+/**
+ * Gets script codes associated with the given locale or ISO 15924 abbreviation or name. 
+ * Fills in USCRIPT_MALAYALAM given "Malayam" OR "Mlym".
+ * Fills in USCRIPT_LATIN given "en" OR "en_US" 
+ * If required capacity is greater than capacity of the destination buffer then the error code
+ * is set to U_BUFFER_OVERFLOW_ERROR and the required capacity is returned
+ *
+ * <p>Note: To search by short or long script alias only, use
+ * u_getPropertyValueEnum(UCHAR_SCRIPT, alias) instead.  This does
+ * a fast lookup with no access of the locale data.
+ * @param nameOrAbbrOrLocale name of the script, as given in
+ * PropertyValueAliases.txt, or ISO 15924 code or locale
+ * @param fillIn the UScriptCode buffer to fill in the script code
+ * @param capacity the capacity (size) fo UScriptCode buffer passed in.
+ * @param err the error status code.
+ * @return The number of script codes filled in the buffer passed in 
+ * @stable ICU 2.4
+ */
+U_STABLE int32_t  U_EXPORT2 
+uscript_getCode(const char* nameOrAbbrOrLocale,UScriptCode* fillIn,int32_t capacity,UErrorCode *err);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Malayam" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script long name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getName(UScriptCode scriptCode);
+
+/**
+ * Gets a script name associated with the given script code. 
+ * Returns  "Mlym" given USCRIPT_MALAYALAM
+ * @param scriptCode UScriptCode enum
+ * @return script abbreviated name as given in
+ * PropertyValueAliases.txt, or NULL if scriptCode is invalid
+ * @stable ICU 2.4
+ */
+U_STABLE const char*  U_EXPORT2 
+uscript_getShortName(UScriptCode scriptCode);
+
+/** 
+ * Gets the script code associated with the given codepoint.
+ * Returns USCRIPT_MALAYALAM given 0x0D02 
+ * @param codepoint UChar32 codepoint
+ * @param err the error status code.
+ * @return The UScriptCode, or 0 if codepoint is invalid 
+ * @stable ICU 2.4
+ */
+U_STABLE UScriptCode  U_EXPORT2 
+uscript_getScript(UChar32 codepoint, UErrorCode *err);
+
+#endif
+
+
index 89c7ba1..74ece1f 100644 (file)
@@ -1,3 +1,42 @@
+2011-06-23  Jungshik Shin  <jshin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Allow generic font family settings per script code.
+        https://bugs.webkit.org/show_bug.cgi?id=20797
+
+        Make generic font family getters/setters accept an additional
+        argument (script code). It has a default value so that if an embedder
+        does not have/want a per-script font family setting, call-sites
+        don't have to be changed.
+        This is to prepare for fixing bug 10874 (font selection is not
+        language-dependent) and bug 18085.
+
+        uscript.h has been updated to that of ICU 3.6 (the version of ICU on
+        Mac OS 10.5)
+
+        There should be no change in layout and no new layout test
+        is added.
+
+        * WebCore.exp.in:
+        * icu/unicode/uscript.h: updated to ICU 4.6
+        * page/Settings.cpp:
+        (WebCore::setGenericFontFamilyMap): helper to set generic family per script
+        (WebCore::getGenericFontFamilyForScript): helper function used by getters for fooFontFamily.
+        (WebCore::Settings::standardFontFamily):
+        (WebCore::Settings::setStandardFontFamily):
+        (WebCore::Settings::fixedFontFamily):
+        (WebCore::Settings::setFixedFontFamily):
+        (WebCore::Settings::serifFontFamily):
+        (WebCore::Settings::setSerifFontFamily):
+        (WebCore::Settings::sansSerifFontFamily):
+        (WebCore::Settings::setSansSerifFontFamily):
+        (WebCore::Settings::cursiveFontFamily):
+        (WebCore::Settings::setCursiveFontFamily):
+        (WebCore::Settings::fantasyFontFamily):
+        (WebCore::Settings::setFantasyFontFamily):
+        * page/Settings.h: setter and getter for FooFontFamily have a new optional argument, scriptCode.
+
 2011-06-23  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Alexey Proskuryakov.
index 8597ee7..cd2b8d1 100644 (file)
@@ -856,22 +856,22 @@ __ZN7WebCore8Settings16setUsesPageCacheEb
 __ZN7WebCore8Settings17setPluginsEnabledEb
 __ZN7WebCore8Settings18setDOMPasteAllowedEb
 __ZN7WebCore8Settings18setDefaultFontSizeEi
-__ZN7WebCore8Settings18setFixedFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings18setFixedFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings18setMinimumFontSizeEi
-__ZN7WebCore8Settings18setSerifFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings18setSerifFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings18setWebAudioEnabledEb
 __ZN7WebCore8Settings19minDOMTimerIntervalEv
 __ZN7WebCore8Settings19setShowDebugBordersEb
-__ZN7WebCore8Settings20setCursiveFontFamilyERKN3WTF12AtomicStringE
-__ZN7WebCore8Settings20setFantasyFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings20setCursiveFontFamilyERKN3WTF12AtomicStringE11UScriptCode
+__ZN7WebCore8Settings20setFantasyFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings20setJavaScriptEnabledEb
 __ZN7WebCore8Settings20setXSSAuditorEnabledEb
 __ZN7WebCore8Settings21setShowRepaintCounterEb
-__ZN7WebCore8Settings21setStandardFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings21setStandardFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings21setWebSecurityEnabledEb
 __ZN7WebCore8Settings22setLocalStorageEnabledEb
 __ZN7WebCore8Settings22setMinDOMTimerIntervalEd
-__ZN7WebCore8Settings22setSansSerifFontFamilyERKN3WTF12AtomicStringE
+__ZN7WebCore8Settings22setSansSerifFontFamilyERKN3WTF12AtomicStringE11UScriptCode
 __ZN7WebCore8Settings22setSessionStorageQuotaEj
 __ZN7WebCore8Settings22setShowsURLsInToolTipsEb
 __ZN7WebCore8Settings23setDefaultFixedFontSizeEi
index f31d748..d7cbc38 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 1997-2004, International Business Machines
+*   Copyright (C) 1997-2006, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
 #include "unicode/utypes.h"
 
 /**
- * Constants for Unicode script values from ScriptNames.txt .
+ * \file
+ * \brief C API: Unicode Script Information
+ */
+/**
+ * Constants for ISO 15924 script codes.
+ *
+ * Many of these script codes - those from Unicode's ScriptNames.txt -
+ * are character property values for Unicode's Script property.
+ * See UAX #24 Script Names (http://www.unicode.org/reports/tr24/).
+ *
+ * Starting with ICU 3.6, constants for most ISO 15924 script codes
+ * are included (currently excluding private-use codes Qaaa..Qabx).
+ * For scripts for which there are codes in ISO 15924 but which are not
+ * used in the Unicode Character Database (UCD), there are no Unicode characters
+ * associated with those scripts.
+ *
+ * For example, there are no characters that have a UCD script code of
+ * Hans or Hant. All Han ideographs have the Hani script code.
+ * The Hans and Hant script codes are used with CLDR data.
+ *
+ * ISO 15924 script codes are included for use with CLDR and similar.
  *
  * @stable ICU 2.2
  */
@@ -31,11 +52,11 @@ typedef enum UScriptCode {
       USCRIPT_BOPOMOFO     =  5,  /* Bopo */
       USCRIPT_CHEROKEE     =  6,  /* Cher */
       USCRIPT_COPTIC       =  7,  /* Copt */
-      USCRIPT_CYRILLIC     =  8,  /* Cyrl (Cyrs) */
+      USCRIPT_CYRILLIC     =  8,  /* Cyrl */
       USCRIPT_DESERET      =  9,  /* Dsrt */
       USCRIPT_DEVANAGARI   = 10,  /* Deva */
       USCRIPT_ETHIOPIC     = 11,  /* Ethi */
-      USCRIPT_GEORGIAN     = 12,  /* Geor (Geon, Geoa) */
+      USCRIPT_GEORGIAN     = 12,  /* Geor */
       USCRIPT_GOTHIC       = 13,  /* Goth */
       USCRIPT_GREEK        = 14,  /* Grek */
       USCRIPT_GUJARATI     = 15,  /* Gujr */
@@ -48,7 +69,7 @@ typedef enum UScriptCode {
       USCRIPT_KATAKANA     = 22,  /* Kana */
       USCRIPT_KHMER        = 23,  /* Khmr */
       USCRIPT_LAO          = 24,  /* Laoo */
-      USCRIPT_LATIN        = 25,  /* Latn (Latf, Latg) */
+      USCRIPT_LATIN        = 25,  /* Latn */
       USCRIPT_MALAYALAM    = 26,  /* Mlym */
       USCRIPT_MONGOLIAN    = 27,  /* Mong */
       USCRIPT_MYANMAR      = 28,  /* Mymr */
@@ -57,7 +78,7 @@ typedef enum UScriptCode {
       USCRIPT_ORIYA        = 31,  /* Orya */
       USCRIPT_RUNIC        = 32,  /* Runr */
       USCRIPT_SINHALA      = 33,  /* Sinh */
-      USCRIPT_SYRIAC       = 34,  /* Syrc (Syrj, Syrn, Syre) */
+      USCRIPT_SYRIAC       = 34,  /* Syrc */
       USCRIPT_TAMIL        = 35,  /* Taml */
       USCRIPT_TELUGU       = 36,  /* Telu */
       USCRIPT_THAANA       = 37,  /* Thaa */
@@ -74,19 +95,74 @@ typedef enum UScriptCode {
       USCRIPT_TAGBANWA     = 45,  /* Tagb */
 
       /* New scripts in Unicode 4 @stable ICU 2.6 */
-      USCRIPT_BRAILLE,            /* Brai */
-      USCRIPT_CYPRIOT,            /* Cprt */
-      USCRIPT_LIMBU,              /* Limb */
-      USCRIPT_LINEAR_B,           /* Linb */
-      USCRIPT_OSMANYA,            /* Osma */
-      USCRIPT_SHAVIAN,            /* Shaw */
-      USCRIPT_TAI_LE,             /* Tale */
-      USCRIPT_UGARITIC,           /* Ugar */
+      USCRIPT_BRAILLE      = 46,  /* Brai */
+      USCRIPT_CYPRIOT      = 47,  /* Cprt */
+      USCRIPT_LIMBU        = 48,  /* Limb */
+      USCRIPT_LINEAR_B     = 49,  /* Linb */
+      USCRIPT_OSMANYA      = 50,  /* Osma */
+      USCRIPT_SHAVIAN      = 51,  /* Shaw */
+      USCRIPT_TAI_LE       = 52,  /* Tale */
+      USCRIPT_UGARITIC     = 53,  /* Ugar */
 
-      /** New script code in Unicode 4.0.1 @draft ICU 3.0 */
-      USCRIPT_KATAKANA_OR_HIRAGANA,/*Hrkt */
+      /** New script code in Unicode 4.0.1 @stable ICU 3.0 */
+      USCRIPT_KATAKANA_OR_HIRAGANA = 54,/*Hrkt */
+      
+#ifndef U_HIDE_DRAFT_API
+      /* New scripts in Unicode 4.1 @draft ICU 3.4 */
+      USCRIPT_BUGINESE      = 55, /* Bugi */
+      USCRIPT_GLAGOLITIC    = 56, /* Glag */
+      USCRIPT_KHAROSHTHI    = 57, /* Khar */
+      USCRIPT_SYLOTI_NAGRI  = 58, /* Sylo */
+      USCRIPT_NEW_TAI_LUE   = 59, /* Talu */
+      USCRIPT_TIFINAGH      = 60, /* Tfng */
+      USCRIPT_OLD_PERSIAN   = 61, /* Xpeo */
 
-      USCRIPT_CODE_LIMIT
+      /* New script codes from ISO 15924 @draft ICU 3.6 */
+      USCRIPT_BALINESE                      = 62, /* Bali */
+      USCRIPT_BATAK                         = 63, /* Batk */
+      USCRIPT_BLISSYMBOLS                   = 64, /* Blis */
+      USCRIPT_BRAHMI                        = 65, /* Brah */
+      USCRIPT_CHAM                          = 66, /* Cham */
+      USCRIPT_CIRTH                         = 67, /* Cirt */
+      USCRIPT_OLD_CHURCH_SLAVONIC_CYRILLIC  = 68, /* Cyrs */
+      USCRIPT_DEMOTIC_EGYPTIAN              = 69, /* Egyd */
+      USCRIPT_HIERATIC_EGYPTIAN             = 70, /* Egyh */
+      USCRIPT_EGYPTIAN_HIEROGLYPHS          = 71, /* Egyp */
+      USCRIPT_KHUTSURI                      = 72, /* Geok */
+      USCRIPT_SIMPLIFIED_HAN                = 73, /* Hans */
+      USCRIPT_TRADITIONAL_HAN               = 74, /* Hant */
+      USCRIPT_PAHAWH_HMONG                  = 75, /* Hmng */
+      USCRIPT_OLD_HUNGARIAN                 = 76, /* Hung */
+      USCRIPT_HARAPPAN_INDUS                = 77, /* Inds */
+      USCRIPT_JAVANESE                      = 78, /* Java */
+      USCRIPT_KAYAH_LI                      = 79, /* Kali */
+      USCRIPT_LATIN_FRAKTUR                 = 80, /* Latf */
+      USCRIPT_LATIN_GAELIC                  = 81, /* Latg */
+      USCRIPT_LEPCHA                        = 82, /* Lepc */
+      USCRIPT_LINEAR_A                      = 83, /* Lina */
+      USCRIPT_MANDAEAN                      = 84, /* Mand */
+      USCRIPT_MAYAN_HIEROGLYPHS             = 85, /* Maya */
+      USCRIPT_MEROITIC                      = 86, /* Mero */
+      USCRIPT_NKO                           = 87, /* Nkoo */
+      USCRIPT_ORKHON                        = 88, /* Orkh */
+      USCRIPT_OLD_PERMIC                    = 89, /* Perm */
+      USCRIPT_PHAGS_PA                      = 90, /* Phag */
+      USCRIPT_PHOENICIAN                    = 91, /* Phnx */
+      USCRIPT_PHONETIC_POLLARD              = 92, /* Plrd */
+      USCRIPT_RONGORONGO                    = 93, /* Roro */
+      USCRIPT_SARATI                        = 94, /* Sara */
+      USCRIPT_ESTRANGELO_SYRIAC             = 95, /* Syre */
+      USCRIPT_WESTERN_SYRIAC                = 96, /* Syrj */
+      USCRIPT_EASTERN_SYRIAC                = 97, /* Syrn */
+      USCRIPT_TENGWAR                       = 98, /* Teng */
+      USCRIPT_VAI                           = 99, /* Vaii */
+      USCRIPT_VISIBLE_SPEECH                = 100, /* Visp */
+      USCRIPT_CUNEIFORM                     = 101,/* Xsux */
+      USCRIPT_UNWRITTEN_LANGUAGES           = 102,/* Zxxx */
+      USCRIPT_UNKNOWN                       = 103,/* Zzzz */ /* Unknown="Code for uncoded script", for unassigned code points */
+      /* Private use codes from Qaaa - Qabx are not supported*/
+#endif /* U_HIDE_DRAFT_API */
+      USCRIPT_CODE_LIMIT    = 104
 } UScriptCode;
 
 /**
index 3926de5..4d65e6c 100644 (file)
@@ -52,6 +52,20 @@ static void setLoadsImagesAutomaticallyInAllFrames(Page* page)
         frame->document()->cachedResourceLoader()->setAutoLoadImages(page->settings()->loadsImagesAutomatically());
 }
 
+static inline void setGenericFontFamilyMap(ScriptFontFamilyMap& fontMap, const AtomicString& family, UScriptCode script, Page* page)
+{
+    fontMap.set(static_cast<int>(script), family);
+    page->setNeedsRecalcStyleInAllFrames();
+}
+
+static inline const AtomicString& getGenericFontFamilyForScript(const ScriptFontFamilyMap& fontMap, UScriptCode script)
+{
+    ScriptFontFamilyMap::const_iterator it = fontMap.find(static_cast<int>(script));
+    if (it != fontMap.end())
+        return it->second;
+    return emptyAtom;
+}
+
 #if USE(SAFARI_THEME)
 bool Settings::gShouldPaintNativeControls = true;
 #endif
@@ -192,58 +206,64 @@ Settings::Settings(Page* page)
     AtomicString::init();
 }
 
-void Settings::setStandardFontFamily(const AtomicString& standardFontFamily)
+const AtomicString& Settings::standardFontFamily(UScriptCode script) const
 {
-    if (standardFontFamily == m_standardFontFamily)
-        return;
+    return getGenericFontFamilyForScript(m_standardFontFamilyMap, script);
+}
 
-    m_standardFontFamily = standardFontFamily;
-    m_page->setNeedsRecalcStyleInAllFrames();
+void Settings::setStandardFontFamily(const AtomicString& family, UScriptCode script)
+{
+    setGenericFontFamilyMap(m_standardFontFamilyMap, family, script, m_page);
 }
 
-void Settings::setFixedFontFamily(const AtomicString& fixedFontFamily)
+const AtomicString& Settings::fixedFontFamily(UScriptCode script) const
 {
-    if (m_fixedFontFamily == fixedFontFamily)
-        return;
-        
-    m_fixedFontFamily = fixedFontFamily;
-    m_page->setNeedsRecalcStyleInAllFrames();
+    return getGenericFontFamilyForScript(m_fixedFontFamilyMap, script);
 }
 
-void Settings::setSerifFontFamily(const AtomicString& serifFontFamily)
+void Settings::setFixedFontFamily(const AtomicString& family, UScriptCode script)
 {
-    if (m_serifFontFamily == serifFontFamily)
-        return;
-        
-    m_serifFontFamily = serifFontFamily;
-    m_page->setNeedsRecalcStyleInAllFrames();
+    setGenericFontFamilyMap(m_fixedFontFamilyMap, family, script, m_page);
 }
 
-void Settings::setSansSerifFontFamily(const AtomicString& sansSerifFontFamily)
+const AtomicString& Settings::serifFontFamily(UScriptCode script) const
 {
-    if (m_sansSerifFontFamily == sansSerifFontFamily)
-        return;
-        
-    m_sansSerifFontFamily = sansSerifFontFamily; 
-    m_page->setNeedsRecalcStyleInAllFrames();
+    return getGenericFontFamilyForScript(m_serifFontFamilyMap, script);
 }
 
-void Settings::setCursiveFontFamily(const AtomicString& cursiveFontFamily)
+void Settings::setSerifFontFamily(const AtomicString& family, UScriptCode script)
 {
-    if (m_cursiveFontFamily == cursiveFontFamily)
-        return;
-        
-    m_cursiveFontFamily = cursiveFontFamily;
-    m_page->setNeedsRecalcStyleInAllFrames();
+     setGenericFontFamilyMap(m_serifFontFamilyMap, family, script, m_page);
 }
 
-void Settings::setFantasyFontFamily(const AtomicString& fantasyFontFamily)
+const AtomicString& Settings::sansSerifFontFamily(UScriptCode script) const
 {
-    if (m_fantasyFontFamily == fantasyFontFamily)
-        return;
-        
-    m_fantasyFontFamily = fantasyFontFamily;
-    m_page->setNeedsRecalcStyleInAllFrames();
+    return getGenericFontFamilyForScript(m_sansSerifFontFamilyMap, script);
+}
+
+void Settings::setSansSerifFontFamily(const AtomicString& family, UScriptCode script)
+{
+    setGenericFontFamilyMap(m_sansSerifFontFamilyMap, family, script, m_page);
+}
+
+const AtomicString& Settings::cursiveFontFamily(UScriptCode script) const
+{
+    return getGenericFontFamilyForScript(m_cursiveFontFamilyMap, script);
+}
+
+void Settings::setCursiveFontFamily(const AtomicString& family, UScriptCode script)
+{
+    setGenericFontFamilyMap(m_cursiveFontFamilyMap, family, script, m_page);
+}
+
+const AtomicString& Settings::fantasyFontFamily(UScriptCode script) const
+{
+    return getGenericFontFamilyForScript(m_fantasyFontFamilyMap, script);
+}
+
+void Settings::setFantasyFontFamily(const AtomicString& family, UScriptCode script)
+{
+    setGenericFontFamilyMap(m_fantasyFontFamilyMap, family, script, m_page);
 }
 
 void Settings::setMinimumFontSize(int minimumFontSize)
index 9f9d16f..547ed1a 100644 (file)
 #include "FontRenderingMode.h"
 #include "KURL.h"
 #include "Timer.h"
+#include <wtf/HashMap.h>
 #include <wtf/text/AtomicString.h>
+#include <wtf/text/AtomicStringHash.h>
+#include <wtf/unicode/Unicode.h>
 
 namespace WebCore {
 
@@ -51,28 +54,39 @@ namespace WebCore {
         TextDirectionSubmenuAlwaysIncluded
     };
 
+    // UScriptCode uses -1 and 0 for UScriptInvalidCode and UScriptCommon.
+    // We need to use -2 and -3 for empty value and deleted value.
+    struct UScriptCodeHashTraits : WTF::GenericHashTraits<int> {
+        static const bool emptyValueIsZero = false;
+        static int emptyValue() { return -2; }
+        static void constructDeletedValue(int& slot) { slot = -3; }
+        static bool isDeletedValue(int value) { return value == -3; }
+    };
+
+    typedef HashMap<int, AtomicString, DefaultHash<int>::Hash, UScriptCodeHashTraits> ScriptFontFamilyMap;
+
     class Settings {
         WTF_MAKE_NONCOPYABLE(Settings); WTF_MAKE_FAST_ALLOCATED;
     public:
         Settings(Page*);
 
-        void setStandardFontFamily(const AtomicString&);
-        const AtomicString& standardFontFamily() const { return m_standardFontFamily; }
+        void setStandardFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& standardFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-        void setFixedFontFamily(const AtomicString&);
-        const AtomicString& fixedFontFamily() const { return m_fixedFontFamily; }
+        void setFixedFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& fixedFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-        void setSerifFontFamily(const AtomicString&);
-        const AtomicString& serifFontFamily() const { return m_serifFontFamily; }
+        void setSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& serifFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-        void setSansSerifFontFamily(const AtomicString&);
-        const AtomicString& sansSerifFontFamily() const { return m_sansSerifFontFamily; }
+        void setSansSerifFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& sansSerifFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-        void setCursiveFontFamily(const AtomicString&);
-        const AtomicString& cursiveFontFamily() const { return m_cursiveFontFamily; }
+        void setCursiveFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& cursiveFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
-        void setFantasyFontFamily(const AtomicString&);
-        const AtomicString& fantasyFontFamily() const { return m_fantasyFontFamily; }
+        void setFantasyFontFamily(const AtomicString&, UScriptCode = USCRIPT_COMMON);
+        const AtomicString& fantasyFontFamily(UScriptCode = USCRIPT_COMMON) const;
 
         void setMinimumFontSize(int);
         int minimumFontSize() const { return m_minimumFontSize; }
@@ -421,12 +435,12 @@ namespace WebCore {
         String m_ftpDirectoryTemplatePath;
         String m_localStorageDatabasePath;
         KURL m_userStyleSheetLocation;
-        AtomicString m_standardFontFamily;
-        AtomicString m_fixedFontFamily;
-        AtomicString m_serifFontFamily;
-        AtomicString m_sansSerifFontFamily;
-        AtomicString m_cursiveFontFamily;
-        AtomicString m_fantasyFontFamily;
+        ScriptFontFamilyMap m_standardFontFamilyMap;
+        ScriptFontFamilyMap m_serifFontFamilyMap;
+        ScriptFontFamilyMap m_fixedFontFamilyMap;
+        ScriptFontFamilyMap m_sansSerifFontFamilyMap;
+        ScriptFontFamilyMap m_cursiveFontFamilyMap;
+        ScriptFontFamilyMap m_fantasyFontFamilyMap;
         EditableLinkBehavior m_editableLinkBehavior;
         TextDirectionSubmenuInclusionBehavior m_textDirectionSubmenuInclusionBehavior;
         int m_minimumFontSize;