Bug 1296050 - When checking whether bidi resolution is needed, ignore Unicode directional-control characters that do not actually introduce right-to-left-ness. r=xidorn
authorJonathan Kew <jkew@mozilla.com>
Mon, 05 Sep 2016 14:15:32 +0100
changeset 312706 68bcf4ac2aa2d448178442781dfba971f7ae68ea
parent 312705 5830a5488348c2eb891774f33968d12c2ac8d276
child 312707 438fa35a91c9ddb8ceec962a2be9aa8c7545b4bc
push id30653
push userphilringnalda@gmail.com
push dateMon, 05 Sep 2016 20:06:00 +0000
treeherdermozilla-central@3076fad24896 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1296050
milestone51.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 1296050 - When checking whether bidi resolution is needed, ignore Unicode directional-control characters that do not actually introduce right-to-left-ness. r=xidorn
dom/base/nsTextFragment.cpp
intl/unicharutil/util/nsBidiUtils.h
--- a/dom/base/nsTextFragment.cpp
+++ b/dom/base/nsTextFragment.cpp
@@ -456,15 +456,15 @@ nsTextFragment::UpdateBidiFlag(const cha
       char16_t ch1 = *cp++;
       uint32_t utf32Char = ch1;
       if (NS_IS_HIGH_SURROGATE(ch1) &&
           cp < end &&
           NS_IS_LOW_SURROGATE(*cp)) {
         char16_t ch2 = *cp++;
         utf32Char = SURROGATE_TO_UCS4(ch1, ch2);
       }
-      if (UTF32_CHAR_IS_BIDI(utf32Char) || IsBidiControl(utf32Char)) {
+      if (UTF32_CHAR_IS_BIDI(utf32Char) || IsBidiControlRTL(utf32Char)) {
         mState.mIsBidi = true;
         break;
       }
     }
   }
 }
--- a/intl/unicharutil/util/nsBidiUtils.h
+++ b/intl/unicharutil/util/nsBidiUtils.h
@@ -106,29 +106,52 @@ typedef enum nsCharType nsCharType;
 
   /**
    * Give a UTF-32 codepoint
    * return true if the codepoint is a Bidi control character (LRM, RLM, ALM;
    * LRE, RLE, PDF, LRO, RLO; LRI, RLI, FSI, PDI).
    * Return false, otherwise
    */
 #define LRM_CHAR 0x200e
+#define RLM_CHAR 0x200f
+
 #define LRE_CHAR 0x202a
+#define RLE_CHAR 0x202b
+#define PDF_CHAR 0x202c
+#define LRO_CHAR 0x202d
 #define RLO_CHAR 0x202e
+
 #define LRI_CHAR 0x2066
+#define RLI_CHAR 0x2067
+#define FSI_CHAR 0x2068
 #define PDI_CHAR 0x2069
+
 #define ALM_CHAR 0x061C
    inline bool IsBidiControl(uint32_t aChar) {
      return ((LRE_CHAR <= aChar && aChar <= RLO_CHAR) ||
              (LRI_CHAR <= aChar && aChar <= PDI_CHAR) ||
              (aChar == ALM_CHAR) ||
              (aChar & 0xfffffe) == LRM_CHAR);
    }
 
   /**
+   * Give a UTF-32 codepoint
+   * Return true if the codepoint is a Bidi control character that may result
+   * in RTL directionality and therefore needs to trigger bidi resolution;
+   * return false otherwise.
+   */
+   inline bool IsBidiControlRTL(uint32_t aChar) {
+     return aChar == RLM_CHAR ||
+            aChar == RLE_CHAR ||
+            aChar == RLO_CHAR ||
+            aChar == RLI_CHAR ||
+            aChar == ALM_CHAR;
+   }
+
+  /**
    * Give an nsString.
    * @return true if the string contains right-to-left characters
    */
    bool HasRTLChars(const nsAString& aString);
 
 // These values are shared with Preferences dialog
 //  ------------------
 //  If Pref values are to be changed