Bug 1032671 - Part 1. Add emoji presentation API for UTR#51. r?jfkthame draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Sun, 12 Nov 2017 16:06:18 +0900
changeset 706546 23d082ec9c61487201442a3ce01184334f6b13de
parent 706205 781485c695e1f07b8782427d556f6570e4a8072f
child 706547 196e3c68dc3b810196c655cfd1e952f9ec2efa9a
push id91829
push userbmo:m_kato@ga2.so-net.ne.jp
push dateSat, 02 Dec 2017 09:30:34 +0000
reviewersjfkthame
bugs1032671
milestone59.0a1
Bug 1032671 - Part 1. Add emoji presentation API for UTR#51. r?jfkthame From ICU 57, ICU supports emoji presentation as draft API. MozReview-Commit-ID: 6JgQMv4Ky9m
intl/unicharutil/util/nsUnicodeProperties.h
--- a/intl/unicharutil/util/nsUnicodeProperties.h
+++ b/intl/unicharutil/util/nsUnicodeProperties.h
@@ -41,16 +41,22 @@ enum PairedBracketType {
 /* Flags for Unicode security IdentifierType.txt attributes. Only a subset
    of these are currently checked by Gecko, so we only define flags for the
    ones we need. */
 enum IdentifierType {
   IDTYPE_RESTRICTED = 0,
   IDTYPE_ALLOWED = 1,
 };
 
+enum EmojiPresentation {
+  TextOnly = 0,
+  TextDefault = 1,
+  EmojiDefault = 2
+};
+
 extern const hb_unicode_general_category_t sICUtoHBcategory[];
 
 inline uint32_t
 GetMirroredChar(uint32_t aCh)
 {
   return u_charMirror(aCh);
 }
 
@@ -167,16 +173,29 @@ IsEastAsianWidthFWH(uint32_t aCh)
 }
 
 inline bool
 IsDefaultIgnorable(uint32_t aCh)
 {
   return u_hasBinaryProperty(aCh, UCHAR_DEFAULT_IGNORABLE_CODE_POINT);
 }
 
+inline EmojiPresentation
+GetEmojiPresentation(uint32_t aCh)
+{
+  if (!u_hasBinaryProperty(aCh, UCHAR_EMOJI)) {
+    return TextOnly;
+  }
+
+  if (u_hasBinaryProperty(aCh, UCHAR_EMOJI_PRESENTATION)) {
+    return EmojiDefault;
+  }
+  return TextDefault;
+}
+
 // returns the simplified Gen Category as defined in nsUGenCategory
 inline nsUGenCategory GetGenCategory(uint32_t aCh) {
   return sDetailedToGeneralCategory[GetGeneralCategory(aCh)];
 }
 
 inline VerticalOrientation GetVerticalOrientation(uint32_t aCh) {
   return VerticalOrientation(GetCharProps2(aCh).mVertOrient);
 }