From 544d70a000067f15a55149512368b335b338b714 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Mon, 7 Sep 2015 11:54:46 +0900 Subject: [PATCH] Bug 1170072 - Part 1. Make GetCharProps1 as static function. r=jfkthame --- gfx/thebes/gfxScriptItemizer.cpp | 9 ------ intl/unicharutil/util/nsUnicodeProperties.cpp | 29 ++++++++++++++++++- intl/unicharutil/util/nsUnicodeProperties.h | 21 +++----------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/gfx/thebes/gfxScriptItemizer.cpp b/gfx/thebes/gfxScriptItemizer.cpp index 3ca2581b1758..1aa8dbe94cea 100644 --- a/gfx/thebes/gfxScriptItemizer.cpp +++ b/gfx/thebes/gfxScriptItemizer.cpp @@ -115,15 +115,6 @@ SameScript(int32_t runScript, int32_t currCharScript) currCharScript == runScript; } -// Return whether the char has a mirrored-pair counterpart. -// NOTE that this depends on the implementation of nsCharProps records in -// nsUnicodeProperties, and may need to be updated if those structures change -static inline bool -HasMirroredChar(uint32_t aCh) -{ - return GetCharProps1(aCh).mMirrorOffsetIndex != 0; -} - gfxScriptItemizer::gfxScriptItemizer(const char16_t *src, uint32_t length) : textPtr(src), textLength(length) { diff --git a/intl/unicharutil/util/nsUnicodeProperties.cpp b/intl/unicharutil/util/nsUnicodeProperties.cpp index 39c12221410b..1d22e588c40e 100644 --- a/intl/unicharutil/util/nsUnicodeProperties.cpp +++ b/intl/unicharutil/util/nsUnicodeProperties.cpp @@ -13,7 +13,7 @@ #define UNICODE_LIMIT 0x110000 -const nsCharProps1& +static const nsCharProps1& GetCharProps1(uint32_t aCh) { if (aCh < UNICODE_BMP_LIMIT) { @@ -130,6 +130,18 @@ GetMirroredChar(uint32_t aCh) return aCh + sMirrorOffsets[GetCharProps1(aCh).mMirrorOffsetIndex]; } +bool +HasMirroredChar(uint32_t aCh) +{ + return GetCharProps1(aCh).mMirrorOffsetIndex != 0; +} + +uint8_t +GetCombiningClass(uint32_t aCh) +{ + return GetCharProps1(aCh).mCombiningClass; +} + uint32_t GetScriptTagForCode(int32_t aScriptCode) { @@ -249,6 +261,21 @@ IsClusterExtender(uint32_t aCh, uint8_t aCategory) (aCh >= 0xff9e && aCh <= 0xff9f)); // katakana sound marks } +enum HSType { + HST_NONE = 0x00, + HST_L = 0x01, + HST_V = 0x02, + HST_T = 0x04, + HST_LV = 0x03, + HST_LVT = 0x07 +}; + +static HSType +GetHangulSyllableType(uint32_t aCh) +{ + return HSType(GetCharProps1(aCh).mHangulType); +} + void ClusterIterator::Next() { diff --git a/intl/unicharutil/util/nsUnicodeProperties.h b/intl/unicharutil/util/nsUnicodeProperties.h index b06837ac3e93..71a23cf598e2 100644 --- a/intl/unicharutil/util/nsUnicodeProperties.h +++ b/intl/unicharutil/util/nsUnicodeProperties.h @@ -10,7 +10,6 @@ #include "nsIUGenCategory.h" #include "nsUnicodeScriptCodes.h" -const nsCharProps1& GetCharProps1(uint32_t aCh); const nsCharProps2& GetCharProps2(uint32_t aCh); namespace mozilla { @@ -19,11 +18,12 @@ namespace unicode { extern nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[]; +// Return whether the char has a mirrored-pair counterpart. uint32_t GetMirroredChar(uint32_t aCh); -inline uint8_t GetCombiningClass(uint32_t aCh) { - return GetCharProps1(aCh).mCombiningClass; -} +bool HasMirroredChar(uint32_t aChr); + +uint8_t GetCombiningClass(uint32_t aCh); // returns the detailed General Category in terms of HB_UNICODE_* values inline uint8_t GetGeneralCategory(uint32_t aCh) { @@ -104,19 +104,6 @@ inline bool IsClusterExtender(uint32_t aCh) { return IsClusterExtender(aCh, GetGeneralCategory(aCh)); } -enum HSType { - HST_NONE = 0x00, - HST_L = 0x01, - HST_V = 0x02, - HST_T = 0x04, - HST_LV = 0x03, - HST_LVT = 0x07 -}; - -inline HSType GetHangulSyllableType(uint32_t aCh) { - return HSType(GetCharProps1(aCh).mHangulType); -} - // Case mappings for the full Unicode range; // note that it may be worth testing for ASCII chars and taking // a separate fast-path before calling these, in perf-critical places