Bug 1081858 - Part 3. Implement IsEastAsianWidthFWH using ICU or nsUnicodeProperties data. r=jfkthame
authorKan-Ru Chen <kanru@kanru.info>
Wed, 26 Oct 2016 17:11:36 +0800
changeset 362545 3573997144c60cdc896a19a96d2f4bac4d73b9bd
parent 362544 766b5a6cec7c6724611453258e13a040dcdcaf4a
child 362546 be7d9851343b6612a322dfa15b11ec099cd94c18
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1081858
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1081858 - Part 3. Implement IsEastAsianWidthFWH using ICU or nsUnicodeProperties data. r=jfkthame MozReview-Commit-ID: DvBgSm5SJwD
intl/unicharutil/util/nsUnicodeProperties.cpp
intl/unicharutil/util/nsUnicodeProperties.h
--- a/intl/unicharutil/util/nsUnicodeProperties.cpp
+++ b/intl/unicharutil/util/nsUnicodeProperties.cpp
@@ -290,16 +290,21 @@ GetTitlecaseForAll(uint32_t aCh)
     if (mapValue & (kLowerToTitle | kLowerToUpper)) {
         return aCh ^ (mapValue & kCaseMapCharMask);
     }
     if (mapValue & kUpperToLower) {
         return GetTitlecaseForLower(aCh ^ (mapValue & kCaseMapCharMask));
     }
     return aCh;
 }
+
+bool IsEastAsianWidthFWH(uint32_t aCh)
+{
+    return GetCharProps2(aCh).mEastAsianWidthFWH;
+}
 #endif
 
 #define DEFINE_BMP_1PLANE_MAPPING_GET_FUNC(prefix_) \
   uint32_t Get##prefix_(uint32_t aCh) \
   { \
     if (aCh >= UNICODE_BMP_LIMIT) { \
       return aCh; \
     } \
--- a/intl/unicharutil/util/nsUnicodeProperties.h
+++ b/intl/unicharutil/util/nsUnicodeProperties.h
@@ -151,16 +151,32 @@ GetTitlecaseForLower(uint32_t aCh) // ma
 }
 
 inline uint32_t
 GetTitlecaseForAll(uint32_t aCh) // maps both UC and LC to titlecase
 {
   return u_totitle(aCh);
 }
 
+inline bool
+IsEastAsianWidthFWH(uint32_t aCh)
+{
+  switch (u_getIntPropertyValue(aCh, UCHAR_EAST_ASIAN_WIDTH)) {
+    case U_EA_FULLWIDTH:
+    case U_EA_WIDE:
+    case U_EA_HALFWIDTH:
+      return true;
+    case U_EA_AMBIGUOUS:
+    case U_EA_NARROW:
+    case U_EA_NEUTRAL:
+      return false;
+  }
+  return false;
+}
+
 #else // not ENABLE_INTL_API
 
 // Return whether the char has a mirrored-pair counterpart.
 uint32_t GetMirroredChar(uint32_t aCh);
 
 bool HasMirroredChar(uint32_t aChr);
 
 uint8_t GetCombiningClass(uint32_t aCh);
@@ -187,16 +203,19 @@ uint32_t GetPairedBracket(uint32_t aCh);
  */
 int8_t GetNumericValue(uint32_t aCh);
 
 uint32_t GetUppercase(uint32_t aCh);
 uint32_t GetLowercase(uint32_t aCh);
 uint32_t GetTitlecaseForLower(uint32_t aCh); // maps LC to titlecase, UC unchanged
 uint32_t GetTitlecaseForAll(uint32_t aCh); // maps both UC and LC to titlecase
 
+// Return whether the char has EastAsianWidth class F or W or H.
+bool IsEastAsianWidthFWH(uint32_t aCh);
+
 #endif // !ENABLE_INTL_API
 
 // returns the simplified Gen Category as defined in nsIUGenCategory
 inline nsIUGenCategory::nsUGenCategory GetGenCategory(uint32_t aCh) {
   return sDetailedToGeneralCategory[GetGeneralCategory(aCh)];
 }
 
 inline VerticalOrientation GetVerticalOrientation(uint32_t aCh) {