bug 724826 pt 1 - move various Unicode property tables from gfx to intl. r=smontagu

--HG--
rename : gfx/thebes/gfxUnicodeProperties.h => intl/unicharutil/public/nsUnicodeProperties.h
rename : gfx/thebes/gfxUnicodeScriptCodes.h => intl/unicharutil/public/nsUnicodeScriptCodes.h
rename : gfx/thebes/gfxUnicodeProperties.cpp => intl/unicharutil/src/nsUnicodeProperties.cpp
rename : gfx/thebes/gfxUnicodePropertyData.cpp => intl/unicharutil/src/nsUnicodePropertyData.cpp
rename : gfx/thebes/genUnicodeScriptData.pl => intl/unicharutil/tools/genUnicodePropertyData.pl
This commit is contained in:
Jonathan Kew 2012-02-24 10:15:46 +00:00
parent 7c4000a995
commit c7fa86d451
20 changed files with 146 additions and 112 deletions

View File

@ -75,8 +75,6 @@ EXPORTS = \
gfxSkipChars.h \ gfxSkipChars.h \
gfxTeeSurface.h \ gfxTeeSurface.h \
gfxTypes.h \ gfxTypes.h \
gfxUnicodeProperties.h \
gfxUnicodeScriptCodes.h \
gfxUtils.h \ gfxUtils.h \
gfxUserFontSet.h \ gfxUserFontSet.h \
nsCoreAnimationSupport.h \ nsCoreAnimationSupport.h \
@ -204,7 +202,6 @@ CPPSRCS = \
gfxTeeSurface.cpp \ gfxTeeSurface.cpp \
gfxUserFontSet.cpp \ gfxUserFontSet.cpp \
gfxUtils.cpp \ gfxUtils.cpp \
gfxUnicodeProperties.cpp \
gfxScriptItemizer.cpp \ gfxScriptItemizer.cpp \
gfxHarfBuzzShaper.cpp \ gfxHarfBuzzShaper.cpp \
gfxSharedImageSurface.cpp \ gfxSharedImageSurface.cpp \

View File

@ -59,7 +59,6 @@
#ifdef MOZ_GRAPHITE #ifdef MOZ_GRAPHITE
#include "gfxGraphiteShaper.h" #include "gfxGraphiteShaper.h"
#endif #endif
#include "gfxUnicodeProperties.h"
#include "gfxAtoms.h" #include "gfxAtoms.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsUnicodeRange.h" #include "nsUnicodeRange.h"

View File

@ -62,7 +62,7 @@
#include "gfxUserFontSet.h" #include "gfxUserFontSet.h"
#include "gfxPlatformFontList.h" #include "gfxPlatformFontList.h"
#include "gfxScriptItemizer.h" #include "gfxScriptItemizer.h"
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "nsMathUtils.h" #include "nsMathUtils.h"
#include "nsBidiUtils.h" #include "nsBidiUtils.h"
#include "nsUnicodeRange.h" #include "nsUnicodeRange.h"
@ -83,6 +83,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::gfx; using namespace mozilla::gfx;
using namespace mozilla::unicode;
using mozilla::services::GetObserverService; using mozilla::services::GetObserverService;
gfxFontCache *gfxFontCache::gGlobalCache = nsnull; gfxFontCache *gfxFontCache::gGlobalCache = nsnull;
@ -723,7 +724,7 @@ gfxFontFamily::FindFontForChar(FontSearch *aMatchData)
if (NS_UNLIKELY(log)) { if (NS_UNLIKELY(log)) {
PRUint32 charRange = gfxFontUtils::CharRangeBit(aMatchData->mCh); PRUint32 charRange = gfxFontUtils::CharRangeBit(aMatchData->mCh);
PRUint32 unicodeRange = FindCharUnicodeRange(aMatchData->mCh); PRUint32 unicodeRange = FindCharUnicodeRange(aMatchData->mCh);
PRUint32 script = gfxUnicodeProperties::GetScriptCode(aMatchData->mCh); PRUint32 script = GetScriptCode(aMatchData->mCh);
PR_LOG(log, PR_LOG_DEBUG,\ PR_LOG(log, PR_LOG_DEBUG,\
("(textrun-systemfallback-fonts) char: u+%6.6x " ("(textrun-systemfallback-fonts) char: u+%6.6x "
"char-range: %d unicode-range: %d script: %d match: [%s]\n", "char-range: %d unicode-range: %d script: %d match: [%s]\n",
@ -1878,7 +1879,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
static bool static bool
IsClusterExtender(PRUint32 aUSV) IsClusterExtender(PRUint32 aUSV)
{ {
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aUSV); PRUint8 category = GetGeneralCategory(aUSV);
return ((category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK && return ((category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) || category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) ||
(aUSV >= 0x200c && aUSV <= 0x200d) || // ZWJ, ZWNJ (aUSV >= 0x200c && aUSV <= 0x200d) || // ZWJ, ZWNJ
@ -3332,7 +3333,7 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
// Don't switch fonts for control characters, regardless of // Don't switch fonts for control characters, regardless of
// whether they are present in the current font, as they won't // whether they are present in the current font, as they won't
// actually be rendered (see bug 716229) // actually be rendered (see bug 716229)
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh); PRUint8 category = GetGeneralCategory(aCh);
if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) { if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) {
selectedFont = aPrevMatchedFont; selectedFont = aPrevMatchedFont;
return selectedFont.forget(); return selectedFont.forget();
@ -3406,7 +3407,7 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
// for known "space" characters, don't do a full system-fallback search; // for known "space" characters, don't do a full system-fallback search;
// we'll synthesize appropriate-width spaces instead of missing-glyph boxes // we'll synthesize appropriate-width spaces instead of missing-glyph boxes
if (gfxUnicodeProperties::GetGeneralCategory(aCh) == if (GetGeneralCategory(aCh) ==
HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR && HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR &&
GetFontAt(0)->SynthesizeSpaceWidth(aCh) >= 0.0) GetFontAt(0)->SynthesizeSpaceWidth(aCh) >= 0.0)
{ {
@ -3796,7 +3797,7 @@ gfxShapedWord::SetupClusterBoundaries(CompressedGlyph *aGlyphs,
gfxTextRun::CompressedGlyph extendCluster; gfxTextRun::CompressedGlyph extendCluster;
extendCluster.SetComplex(false, true, 0); extendCluster.SetComplex(false, true, 0);
gfxUnicodeProperties::HSType hangulState = gfxUnicodeProperties::HST_NONE; HSType hangulState = HST_NONE;
for (PRUint32 i = 0; i < aLength; ++i) { for (PRUint32 i = 0; i < aLength; ++i) {
bool surrogatePair = false; bool surrogatePair = false;
@ -3808,8 +3809,8 @@ gfxShapedWord::SetupClusterBoundaries(CompressedGlyph *aGlyphs,
surrogatePair = true; surrogatePair = true;
} }
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(ch); PRUint8 category = GetGeneralCategory(ch);
gfxUnicodeProperties::HSType hangulType = gfxUnicodeProperties::HST_NONE; HSType hangulType = HST_NONE;
// combining marks extend the cluster // combining marks extend the cluster
if (IsClusterExtender(ch)) { if (IsClusterExtender(ch)) {
@ -3850,25 +3851,25 @@ gfxShapedWord::SetupClusterBoundaries(CompressedGlyph *aGlyphs,
(ch >= 0xac00 && ch <= 0xd7ff)) (ch >= 0xac00 && ch <= 0xd7ff))
{ {
// no break within Hangul syllables // no break within Hangul syllables
hangulType = gfxUnicodeProperties::GetHangulSyllableType(ch); hangulType = GetHangulSyllableType(ch);
switch (hangulType) { switch (hangulType) {
case gfxUnicodeProperties::HST_L: case HST_L:
case gfxUnicodeProperties::HST_LV: case HST_LV:
case gfxUnicodeProperties::HST_LVT: case HST_LVT:
if (hangulState == gfxUnicodeProperties::HST_L) { if (hangulState == HST_L) {
aGlyphs[i] = extendCluster; aGlyphs[i] = extendCluster;
} }
break; break;
case gfxUnicodeProperties::HST_V: case HST_V:
if ( (hangulState != gfxUnicodeProperties::HST_NONE) && if ( (hangulState != HST_NONE) &&
!(hangulState & gfxUnicodeProperties::HST_T)) !(hangulState & HST_T))
{ {
aGlyphs[i] = extendCluster; aGlyphs[i] = extendCluster;
} }
break; break;
case gfxUnicodeProperties::HST_T: case HST_T:
if (hangulState & (gfxUnicodeProperties::HST_V | if (hangulState & (HST_V |
gfxUnicodeProperties::HST_T)) HST_T))
{ {
aGlyphs[i] = extendCluster; aGlyphs[i] = extendCluster;
} }
@ -5021,7 +5022,7 @@ gfxTextRun::SetGlyphs(PRUint32 aIndex, CompressedGlyph aGlyph,
void void
gfxTextRun::SetMissingGlyph(PRUint32 aIndex, PRUint32 aChar) gfxTextRun::SetMissingGlyph(PRUint32 aIndex, PRUint32 aChar)
{ {
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aChar); PRUint8 category = GetGeneralCategory(aChar);
if (category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK && if (category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
{ {

View File

@ -48,7 +48,6 @@
#endif #endif
#include "gfxWindowsPlatform.h" #include "gfxWindowsPlatform.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxUnicodeProperties.h"
#include "cairo-win32.h" #include "cairo-win32.h"

View File

@ -48,7 +48,6 @@
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "gfxGraphiteShaper.h" #include "gfxGraphiteShaper.h"
#include "gfxFontUtils.h" #include "gfxFontUtils.h"
#include "gfxUnicodeProperties.h"
#include "graphite2/Font.h" #include "graphite2/Font.h"
#include "graphite2/Segment.h" #include "graphite2/Segment.h"

View File

@ -49,7 +49,8 @@
#include "gfxPlatform.h" #include "gfxPlatform.h"
#include "gfxHarfBuzzShaper.h" #include "gfxHarfBuzzShaper.h"
#include "gfxFontUtils.h" #include "gfxFontUtils.h"
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "nsUnicodeScriptCodes.h"
#include "nsUnicodeNormalizer.h" #include "nsUnicodeNormalizer.h"
#include "harfbuzz/hb-unicode.h" #include "harfbuzz/hb-unicode.h"
@ -72,6 +73,7 @@
: -((32767 - (f)) >> 16)) : -((32767 - (f)) >> 16))
using namespace mozilla; // for AutoSwap_* types using namespace mozilla; // for AutoSwap_* types
using namespace mozilla::unicode; // for Unicode property lookup
/* /*
* Creation and destruction; on deletion, release any font tables we're holding * Creation and destruction; on deletion, release any font tables we're holding
@ -672,32 +674,32 @@ HBGetHKerning(hb_font_t *font, void *font_data,
static hb_codepoint_t static hb_codepoint_t
HBGetMirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data) HBGetMirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
{ {
return gfxUnicodeProperties::GetMirroredChar(aCh); return GetMirroredChar(aCh);
} }
static hb_unicode_general_category_t static hb_unicode_general_category_t
HBGetGeneralCategory(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data) HBGetGeneralCategory(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
{ {
return hb_unicode_general_category_t(gfxUnicodeProperties::GetGeneralCategory(aCh)); return hb_unicode_general_category_t(GetGeneralCategory(aCh));
} }
static hb_script_t static hb_script_t
HBGetScript(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data) HBGetScript(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
{ {
return hb_script_t(gfxUnicodeProperties::GetScriptTagForCode return hb_script_t(GetScriptTagForCode
(gfxUnicodeProperties::GetScriptCode(aCh))); (GetScriptCode(aCh)));
} }
static unsigned int static unsigned int
HBGetCombiningClass(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data) HBGetCombiningClass(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
{ {
return gfxUnicodeProperties::GetCombiningClass(aCh); return GetCombiningClass(aCh);
} }
static unsigned int static unsigned int
HBGetEastAsianWidth(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data) HBGetEastAsianWidth(hb_unicode_funcs_t *ufuncs, hb_codepoint_t aCh, void *user_data)
{ {
return gfxUnicodeProperties::GetEastAsianWidth(aCh); return GetEastAsianWidth(aCh);
} }
// Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA; // Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA;
@ -1005,7 +1007,7 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext *aContext,
PRInt32 scriptCode = aShapedWord->Script(); PRInt32 scriptCode = aShapedWord->Script();
hb_script_t scriptTag = (scriptCode <= MOZ_SCRIPT_INHERITED) ? hb_script_t scriptTag = (scriptCode <= MOZ_SCRIPT_INHERITED) ?
HB_SCRIPT_LATIN : HB_SCRIPT_LATIN :
hb_script_t(gfxUnicodeProperties::GetScriptTagForCode(scriptCode)); hb_script_t(GetScriptTagForCode(scriptCode));
hb_buffer_set_script(buffer, scriptTag); hb_buffer_set_script(buffer, scriptTag);
hb_language_t language; hb_language_t language;

View File

@ -46,7 +46,6 @@
#endif #endif
#include "gfxPlatformMac.h" #include "gfxPlatformMac.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxUnicodeProperties.h"
#include "gfxFontUtils.h" #include "gfxFontUtils.h"
#include "cairo-quartz.h" #include "cairo-quartz.h"

View File

@ -69,7 +69,8 @@
#ifdef MOZ_GRAPHITE #ifdef MOZ_GRAPHITE
#include "gfxGraphiteShaper.h" #include "gfxGraphiteShaper.h"
#endif #endif
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "nsUnicodeScriptCodes.h"
#include "gfxFontconfigUtils.h" #include "gfxFontconfigUtils.h"
#include "gfxUserFontSet.h" #include "gfxUserFontSet.h"
#include "gfxAtoms.h" #include "gfxAtoms.h"
@ -90,6 +91,7 @@
#include <math.h> #include <math.h>
using namespace mozilla; using namespace mozilla;
using namespace mozilla::unicode;
#define FLOAT_PANGO_SCALE ((gfxFloat)PANGO_SCALE) #define FLOAT_PANGO_SCALE ((gfxFloat)PANGO_SCALE)
@ -329,7 +331,7 @@ gfxFcFontEntry::ShouldUseHarfBuzz(PRInt32 aRunScript) {
// Mimicing gfxHarfBuzzShaper::ShapeWord // Mimicing gfxHarfBuzzShaper::ShapeWord
hb_script_t script = (aRunScript <= MOZ_SCRIPT_INHERITED) ? hb_script_t script = (aRunScript <= MOZ_SCRIPT_INHERITED) ?
HB_SCRIPT_LATIN : HB_SCRIPT_LATIN :
hb_script_t(gfxUnicodeProperties::GetScriptTagForCode(aRunScript)); hb_script_t(GetScriptTagForCode(aRunScript));
// Prefer HarfBuzz if the font also has support for OpenType shaping of // Prefer HarfBuzz if the font also has support for OpenType shaping of
// this script. // this script.
@ -2053,7 +2055,7 @@ gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
// Don't switch fonts for control characters, regardless of // Don't switch fonts for control characters, regardless of
// whether they are present in the current font, as they won't // whether they are present in the current font, as they won't
// actually be rendered (see bug 716229) // actually be rendered (see bug 716229)
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh); PRUint8 category = GetGeneralCategory(aCh);
if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) { if (category == HB_UNICODE_GENERAL_CATEGORY_CONTROL) {
return nsRefPtr<gfxFont>(aPrevMatchedFont).forget(); return nsRefPtr<gfxFont>(aPrevMatchedFont).forget();
} }

View File

@ -62,7 +62,7 @@
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "gfxUserFontSet.h" #include "gfxUserFontSet.h"
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "harfbuzz/hb-unicode.h" #include "harfbuzz/hb-unicode.h"
#ifdef MOZ_GRAPHITE #ifdef MOZ_GRAPHITE
#include "gfxGraphiteShaper.h" #include "gfxGraphiteShaper.h"
@ -149,7 +149,7 @@ SRGBOverrideObserver::Observe(nsISupports *aSubject,
#define GFX_DOWNLOADABLE_FONTS_SANITIZE "gfx.downloadable_fonts.sanitize" #define GFX_DOWNLOADABLE_FONTS_SANITIZE "gfx.downloadable_fonts.sanitize"
#define GFX_PREF_HARFBUZZ_SCRIPTS "gfx.font_rendering.harfbuzz.scripts" #define GFX_PREF_HARFBUZZ_SCRIPTS "gfx.font_rendering.harfbuzz.scripts"
#define HARFBUZZ_SCRIPTS_DEFAULT gfxUnicodeProperties::SHAPING_DEFAULT #define HARFBUZZ_SCRIPTS_DEFAULT mozilla::unicode::SHAPING_DEFAULT
#ifdef MOZ_GRAPHITE #ifdef MOZ_GRAPHITE
#define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled" #define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled"
@ -697,7 +697,7 @@ gfxPlatform::UseHarfBuzzForScript(PRInt32 aScriptCode)
mUseHarfBuzzScripts = Preferences::GetInt(GFX_PREF_HARFBUZZ_SCRIPTS, HARFBUZZ_SCRIPTS_DEFAULT); mUseHarfBuzzScripts = Preferences::GetInt(GFX_PREF_HARFBUZZ_SCRIPTS, HARFBUZZ_SCRIPTS_DEFAULT);
} }
PRInt32 shapingType = gfxUnicodeProperties::ScriptShapingType(aScriptCode); PRInt32 shapingType = mozilla::unicode::ScriptShapingType(aScriptCode);
return (mUseHarfBuzzScripts & shapingType) != 0; return (mUseHarfBuzzScripts & shapingType) != 0;
} }

View File

@ -73,7 +73,7 @@
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsUnicodeRange.h" #include "nsUnicodeRange.h"
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
@ -422,7 +422,7 @@ gfxPlatformFontList::FindFontForChar(const PRUint32 aCh, gfxFont *aPrevFont)
if (NS_UNLIKELY(log)) { if (NS_UNLIKELY(log)) {
PRUint32 charRange = gfxFontUtils::CharRangeBit(aCh); PRUint32 charRange = gfxFontUtils::CharRangeBit(aCh);
PRUint32 unicodeRange = FindCharUnicodeRange(aCh); PRUint32 unicodeRange = FindCharUnicodeRange(aCh);
PRInt32 script = gfxUnicodeProperties::GetScriptCode(aCh); PRInt32 script = mozilla::unicode::GetScriptCode(aCh);
PR_LOG(log, PR_LOG_DEBUG,\ PR_LOG(log, PR_LOG_DEBUG,\
("(textrun-systemfallback) char: u+%6.6x " ("(textrun-systemfallback) char: u+%6.6x "
"char-range: %d unicode-range: %d script: %d match: [%s]" "char-range: %d unicode-range: %d script: %d match: [%s]"

View File

@ -78,8 +78,8 @@
*/ */
#include "gfxScriptItemizer.h" #include "gfxScriptItemizer.h"
#include "gfxUnicodeProperties.h"
#include "gfxFontUtils.h" // for the FindHighestBit function #include "gfxFontUtils.h" // for the FindHighestBit function
#include "nsUnicodeProperties.h"
#include "nsCharTraits.h" #include "nsCharTraits.h"
@ -281,7 +281,7 @@ gfxScriptItemizer::Next(PRUint32& aRunStart, PRUint32& aRunLimit,
} }
} }
sc = gfxUnicodeProperties::GetScriptCode(ch); sc = mozilla::unicode::GetScriptCode(ch);
pairIndex = getPairIndex(ch); pairIndex = getPairIndex(ch);

View File

@ -83,7 +83,7 @@
#include "mozilla/StdInt.h" #include "mozilla/StdInt.h"
#include "prtypes.h" #include "prtypes.h"
#include "harfbuzz/hb.h" #include "harfbuzz/hb.h"
#include "gfxUnicodeScriptCodes.h" #include "nsUnicodeScriptCodes.h"
#define PAREN_STACK_DEPTH 32 #define PAREN_STACK_DEPTH 32

View File

@ -49,6 +49,8 @@ EXPORTS = \
nsIUGenCategory.h \ nsIUGenCategory.h \
nsUnicharUtilCIID.h \ nsUnicharUtilCIID.h \
nsUnicodeNormalizer.h \ nsUnicodeNormalizer.h \
nsUnicodeProperties.h \
nsUnicodeScriptCodes.h \
$(NULL) $(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -35,50 +35,52 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef GFX_UNICODEPROPERTIES_H #ifndef NS_UNICODEPROPERTIES_H
#define GFX_UNICODEPROPERTIES_H #define NS_UNICODEPROPERTIES_H
#include "prtypes.h" #include "prtypes.h"
#include "gfxTypes.h"
#include "gfxUnicodeScriptCodes.h"
class THEBES_API gfxUnicodeProperties namespace mozilla {
{
public:
static PRUint32 GetMirroredChar(PRUint32 aCh);
static PRUint8 GetCombiningClass(PRUint32 aCh); namespace unicode {
static PRUint8 GetGeneralCategory(PRUint32 aCh); PRUint32 GetMirroredChar(PRUint32 aCh);
static PRUint8 GetEastAsianWidth(PRUint32 aCh); PRUint8 GetCombiningClass(PRUint32 aCh);
static PRInt32 GetScriptCode(PRUint32 aCh); PRUint8 GetGeneralCategory(PRUint32 aCh);
static PRUint32 GetScriptTagForCode(PRInt32 aScriptCode); PRUint8 GetEastAsianWidth(PRUint32 aCh);
enum HSType { PRInt32 GetScriptCode(PRUint32 aCh);
HST_NONE = 0x00,
HST_L = 0x01,
HST_V = 0x02,
HST_T = 0x04,
HST_LV = 0x03,
HST_LVT = 0x07
};
static HSType GetHangulSyllableType(PRUint32 aCh); PRUint32 GetScriptTagForCode(PRInt32 aScriptCode);
enum ShapingType { enum HSType {
SHAPING_DEFAULT = 0x0001, HST_NONE = 0x00,
SHAPING_ARABIC = 0x0002, HST_L = 0x01,
SHAPING_HEBREW = 0x0004, HST_V = 0x02,
SHAPING_HANGUL = 0x0008, HST_T = 0x04,
SHAPING_MONGOLIAN = 0x0010, HST_LV = 0x03,
SHAPING_INDIC = 0x0020, HST_LVT = 0x07
SHAPING_THAI = 0x0040
};
static PRInt32 ScriptShapingType(PRInt32 aScriptCode);
}; };
#endif /* GFX_UNICODEPROPERTIES_H */ HSType GetHangulSyllableType(PRUint32 aCh);
enum ShapingType {
SHAPING_DEFAULT = 0x0001,
SHAPING_ARABIC = 0x0002,
SHAPING_HEBREW = 0x0004,
SHAPING_HANGUL = 0x0008,
SHAPING_MONGOLIAN = 0x0010,
SHAPING_INDIC = 0x0020,
SHAPING_THAI = 0x0040
};
PRInt32 ScriptShapingType(PRInt32 aScriptCode);
} // end namespace unicode
} // end namespace mozilla
#endif /* NS_UNICODEPROPERTIES_H */

View File

@ -34,14 +34,14 @@
* the provisions above, a recipient may use your version of this file under * the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* Derived from the Unicode Character Database by genUnicodeScriptData.pl * Derived from the Unicode Character Database by genUnicodePropertyData.pl
* *
* For Unicode terms of use, see http://www.unicode.org/terms_of_use.html * For Unicode terms of use, see http://www.unicode.org/terms_of_use.html
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/* /*
* Created on Mon Feb 13 09:25:50 2012 from UCD data files with version info: * Created on Thu Feb 23 13:15:51 2012 from UCD data files with version info:
* *
# Date: 2012-01-26, 22:03:00 GMT [KW] # Date: 2012-01-26, 22:03:00 GMT [KW]
@ -74,8 +74,8 @@ for the Unicode Character Database (UCD) for Unicode 6.1.0.
* * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * * * * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * *
*/ */
#ifndef GFX_UNICODE_SCRIPT_CODES #ifndef NS_UNICODE_SCRIPT_CODES
#define GFX_UNICODE_SCRIPT_CODES #define NS_UNICODE_SCRIPT_CODES
enum { enum {
MOZ_SCRIPT_COMMON = 0, MOZ_SCRIPT_COMMON = 0,
MOZ_SCRIPT_INHERITED = 1, MOZ_SCRIPT_INHERITED = 1,

View File

@ -47,6 +47,7 @@ LIBRARY_NAME = ucharucomp_s
FORCE_STATIC_LIB = 1 FORCE_STATIC_LIB = 1
LIBXUL_LIBRARY = 1 LIBXUL_LIBRARY = 1
DEFINES += -DHB_DONT_DEFINE_STDINT
CPPSRCS = \ CPPSRCS = \
nsCaseConversionImp2.cpp \ nsCaseConversionImp2.cpp \
@ -54,6 +55,7 @@ CPPSRCS = \
nsEntityConverter.cpp \ nsEntityConverter.cpp \
nsSaveAsCharset.cpp \ nsSaveAsCharset.cpp \
nsUnicodeNormalizer.cpp \ nsUnicodeNormalizer.cpp \
nsUnicodeProperties.cpp \
$(NULL) $(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

View File

@ -35,19 +35,22 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "gfxUnicodePropertyData.cpp" #include "nsUnicodeScriptCodes.h"
#include "nsUnicodePropertyData.cpp"
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include "nsMemory.h" #include "nsMemory.h"
#include "harfbuzz/hb-unicode.h" #include "harfbuzz/hb-unicode.h"
using namespace mozilla;
#define UNICODE_BMP_LIMIT 0x10000 #define UNICODE_BMP_LIMIT 0x10000
#define UNICODE_LIMIT 0x110000 #define UNICODE_LIMIT 0x110000
namespace mozilla {
namespace unicode {
/* /*
To store properties for a million Unicode codepoints compactly, we use To store properties for a million Unicode codepoints compactly, we use
a three-level array structure, with the Unicode values considered as a three-level array structure, with the Unicode values considered as
@ -70,7 +73,7 @@ of values.
*/ */
PRUint32 PRUint32
gfxUnicodeProperties::GetMirroredChar(PRUint32 aCh) GetMirroredChar(PRUint32 aCh)
{ {
// all mirrored chars are in plane 0 // all mirrored chars are in plane 0
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
@ -90,7 +93,7 @@ gfxUnicodeProperties::GetMirroredChar(PRUint32 aCh)
} }
PRUint8 PRUint8
gfxUnicodeProperties::GetCombiningClass(PRUint32 aCh) GetCombiningClass(PRUint32 aCh)
{ {
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
return sCClassValues[sCClassPages[0][aCh >> kCClassCharBits]] return sCClassValues[sCClassPages[0][aCh >> kCClassCharBits]]
@ -106,7 +109,7 @@ gfxUnicodeProperties::GetCombiningClass(PRUint32 aCh)
} }
PRUint8 PRUint8
gfxUnicodeProperties::GetGeneralCategory(PRUint32 aCh) GetGeneralCategory(PRUint32 aCh)
{ {
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
return sCatEAWValues[sCatEAWPages[0][aCh >> kCatEAWCharBits]] return sCatEAWValues[sCatEAWPages[0][aCh >> kCatEAWCharBits]]
@ -122,7 +125,7 @@ gfxUnicodeProperties::GetGeneralCategory(PRUint32 aCh)
} }
PRUint8 PRUint8
gfxUnicodeProperties::GetEastAsianWidth(PRUint32 aCh) GetEastAsianWidth(PRUint32 aCh)
{ {
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
return sCatEAWValues[sCatEAWPages[0][aCh >> kCatEAWCharBits]] return sCatEAWValues[sCatEAWPages[0][aCh >> kCatEAWCharBits]]
@ -138,7 +141,7 @@ gfxUnicodeProperties::GetEastAsianWidth(PRUint32 aCh)
} }
PRInt32 PRInt32
gfxUnicodeProperties::GetScriptCode(PRUint32 aCh) GetScriptCode(PRUint32 aCh)
{ {
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
return sScriptValues[sScriptPages[0][aCh >> kScriptCharBits]] return sScriptValues[sScriptPages[0][aCh >> kScriptCharBits]]
@ -154,7 +157,7 @@ gfxUnicodeProperties::GetScriptCode(PRUint32 aCh)
} }
PRUint32 PRUint32
gfxUnicodeProperties::GetScriptTagForCode(PRInt32 aScriptCode) GetScriptTagForCode(PRInt32 aScriptCode)
{ {
// this will safely return 0 for negative script codes, too :) // this will safely return 0 for negative script codes, too :)
if (PRUint32(aScriptCode) > ArrayLength(sScriptCodeToTag)) { if (PRUint32(aScriptCode) > ArrayLength(sScriptCodeToTag)) {
@ -163,8 +166,8 @@ gfxUnicodeProperties::GetScriptTagForCode(PRInt32 aScriptCode)
return sScriptCodeToTag[aScriptCode]; return sScriptCodeToTag[aScriptCode];
} }
gfxUnicodeProperties::HSType HSType
gfxUnicodeProperties::GetHangulSyllableType(PRUint32 aCh) GetHangulSyllableType(PRUint32 aCh)
{ {
// all Hangul chars are in plane 0 // all Hangul chars are in plane 0
if (aCh < UNICODE_BMP_LIMIT) { if (aCh < UNICODE_BMP_LIMIT) {
@ -183,7 +186,7 @@ gfxUnicodeProperties::GetHangulSyllableType(PRUint32 aCh)
// preference to decide whether to use the harfbuzz shaper. // preference to decide whether to use the harfbuzz shaper.
// //
PRInt32 PRInt32
gfxUnicodeProperties::ScriptShapingType(PRInt32 aScriptCode) ScriptShapingType(PRInt32 aScriptCode)
{ {
switch (aScriptCode) { switch (aScriptCode) {
default: default:
@ -231,3 +234,7 @@ gfxUnicodeProperties::ScriptShapingType(PRInt32 aScriptCode)
return SHAPING_INDIC; // scripts that require Indic or other "special" shaping return SHAPING_INDIC; // scripts that require Indic or other "special" shaping
} }
} }
} // end namespace unicode
} // end namespace mozilla

View File

@ -34,14 +34,14 @@
* the provisions above, a recipient may use your version of this file under * the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* Derived from the Unicode Character Database by genUnicodeScriptData.pl * Derived from the Unicode Character Database by genUnicodePropertyData.pl
* *
* For Unicode terms of use, see http://www.unicode.org/terms_of_use.html * For Unicode terms of use, see http://www.unicode.org/terms_of_use.html
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/* /*
* Created on Mon Feb 13 09:25:50 2012 from UCD data files with version info: * Created on Thu Feb 23 13:15:51 2012 from UCD data files with version info:
* *
# Date: 2012-01-26, 22:03:00 GMT [KW] # Date: 2012-01-26, 22:03:00 GMT [KW]

View File

@ -41,7 +41,7 @@
# read from the Unicode Character Database and compiled into multi-level arrays # read from the Unicode Character Database and compiled into multi-level arrays
# for efficient lookup. # for efficient lookup.
# #
# To regenerate the tables in gfxUnicodePropertyData.cpp: # To regenerate the tables in nsUnicodePropertyData.cpp:
# #
# (1) Download the current Unicode data files from # (1) Download the current Unicode data files from
# #
@ -60,21 +60,44 @@
# #
# (2) Run this tool using a command line of the form # (2) Run this tool using a command line of the form
# #
# perl genUnicodeScriptData.pl \ # perl genUnicodePropertyData.pl \
# /path/to/hb-common.h \ # /path/to/hb-common.h \
# /path/to/UCD-directory # /path/to/UCD-directory
# #
# (where hb-common.h is found in the gfx/harfbuzz/src directory). # (where hb-common.h is found in the gfx/harfbuzz/src directory).
# #
# This will generate (or overwrite!) the files # This will generate (or overwrite!) the files
# #
# gfxUnicodePropertyData.cpp # nsUnicodePropertyData.cpp
# gfxUnicodeScriptCodes.h # nsUnicodeScriptCodes.h
# #
# in the current directory. # in the current directory.
use strict; use strict;
if ($#ARGV != 1) {
print <<__EOT;
# Run this tool using a command line of the form
#
# perl genUnicodePropertyData.pl \
# /path/to/hb-common.h \
# /path/to/UCD-directory
#
# where hb-common.h is currently found in the gfx/harfbuzz/src directory,
# and UCD-directory is a directory containing the current Unicode Character
# Database files (UnicodeData.txt, etc), available from
# http://www.unicode.org/Public/UNIDATA/
#
# This will generate (or overwrite!) the files
#
# nsUnicodePropertyData.cpp
# nsUnicodeScriptCodes.h
#
# in the current directory.
__EOT
exit 0;
}
# load HB_Script and HB_Category constants # load HB_Script and HB_Category constants
# NOTE that HB_SCRIPT_* constants are now "tag" values, NOT sequentially-allocated # NOTE that HB_SCRIPT_* constants are now "tag" values, NOT sequentially-allocated
@ -89,7 +112,7 @@ my %catCode;
my @scriptCodeToTag; my @scriptCodeToTag;
my @scriptCodeToName; my @scriptCodeToName;
open FH, "< $ARGV[0]" or die "can't open $ARGV[0] (header file hb-unicode.h)\n"; open FH, "< $ARGV[0]" or die "can't open $ARGV[0] (should be header file hb-common.h)\n";
while (<FH>) { while (<FH>) {
if (m/HB_SCRIPT_([A-Z_]+)\s*=\s*HB_TAG\s*\(('.','.','.','.')\)\s*,/) { if (m/HB_SCRIPT_([A-Z_]+)\s*=\s*HB_TAG\s*\(('.','.','.','.')\)\s*,/) {
$scriptCodeToTag[++$sc] = $2; $scriptCodeToTag[++$sc] = $2;
@ -294,7 +317,7 @@ close FH;
my $timestamp = gmtime(); my $timestamp = gmtime();
open DATA_TABLES, "> gfxUnicodePropertyData.cpp" or die "unable to open gfxUnicodePropertyData.cpp for output"; open DATA_TABLES, "> nsUnicodePropertyData.cpp" or die "unable to open nsUnicodePropertyData.cpp for output";
my $licenseBlock = q[ my $licenseBlock = q[
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
@ -332,7 +355,7 @@ my $licenseBlock = q[
* the provisions above, a recipient may use your version of this file under * the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL. * the terms of any one of the MPL, the GPL or the LGPL.
* *
* Derived from the Unicode Character Database by genUnicodeScriptData.pl * Derived from the Unicode Character Database by genUnicodePropertyData.pl
* *
* For Unicode terms of use, see http://www.unicode.org/terms_of_use.html * For Unicode terms of use, see http://www.unicode.org/terms_of_use.html
* *
@ -486,7 +509,7 @@ __END
close DATA_TABLES; close DATA_TABLES;
open HEADER, "> gfxUnicodeScriptCodes.h" or die "unable to open gfxUnicodeScriptCodes.h for output"; open HEADER, "> nsUnicodeScriptCodes.h" or die "unable to open nsUnicodeScriptCodes.h for output";
print HEADER <<__END; print HEADER <<__END;
$licenseBlock $licenseBlock
@ -500,8 +523,8 @@ $versionInfo
* * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * * * * * * * This file contains MACHINE-GENERATED DATA, do not edit! * * * * *
*/ */
#ifndef GFX_UNICODE_SCRIPT_CODES #ifndef NS_UNICODE_SCRIPT_CODES
#define GFX_UNICODE_SCRIPT_CODES #define NS_UNICODE_SCRIPT_CODES
__END __END
print HEADER "enum {\n"; print HEADER "enum {\n";

View File

@ -54,7 +54,7 @@
#include "nsPlaceholderFrame.h" #include "nsPlaceholderFrame.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsFirstLetterFrame.h" #include "nsFirstLetterFrame.h"
#include "gfxUnicodeProperties.h" #include "nsUnicodeProperties.h"
#include "nsTextFrame.h" #include "nsTextFrame.h"
#undef NOISY_BIDI #undef NOISY_BIDI
@ -2020,7 +2020,7 @@ void nsBidiPresUtils::WriteReverse(const PRUnichar* aSrc,
UTF32Char = *src; UTF32Char = *src;
} }
UTF32Char = gfxUnicodeProperties::GetMirroredChar(UTF32Char); UTF32Char = mozilla::unicode::GetMirroredChar(UTF32Char);
if (IS_IN_BMP(UTF32Char)) { if (IS_IN_BMP(UTF32Char)) {
*(dest++) = UTF32Char; *(dest++) = UTF32Char;