Bug 1281988 - Skip BN characters when resolving implicit levels in bidi engine. r=jfkthame
authorXidorn Quan <me@upsuper.org>
Tue, 28 Jun 2016 10:26:33 +1000
changeset 302812 23a3e2678c02f1b0b44983ad948729eec0f2bb88
parent 302811 a8b01fe40d2ff74a6ca57fb2723f67de0e736cec
child 302813 f99734930e6899a3bc0b69e752c3b773615488ec
push id30376
push usercbook@mozilla.com
push dateTue, 28 Jun 2016 14:09:36 +0000
treeherdermozilla-central@e45890951ce7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1281988
milestone50.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 1281988 - Skip BN characters when resolving implicit levels in bidi engine. r=jfkthame MozReview-Commit-ID: 87rUOMJSduf
layout/base/nsBidi.cpp
--- a/layout/base/nsBidi.cpp
+++ b/layout/base/nsBidi.cpp
@@ -384,17 +384,19 @@ nsresult nsBidi::SetPara(const char16_t 
           /* determine start and limit of the run (end points just behind the run) */
 
           /* the values for this run's start are the same as for the previous run's end */
           sor=eor;
           start=limit;
           level=nextLevel;
 
           /* search for the limit of this run */
-          while(++limit<aLength && levels[limit]==level) {}
+          while(++limit<aLength &&
+                (levels[limit]==level ||
+                 (DIRPROP_FLAG(mDirProps[limit])&MASK_BN_EXPLICIT))) {}
 
           /* get the correct level of the next run */
           if(limit<aLength) {
             nextLevel=levels[limit];
           } else {
             nextLevel=mParaLevel;
           }
 
@@ -1511,21 +1513,24 @@ void nsBidi::ResolveImplicitLevels(int32
     }
     levState.state = 0;
     ProcessPropertySeq(&levState, aSOR, aStart, aStart);
   }
   start2 = aStart;
 
   for (i = aStart; i <= aLimit; i++) {
     if (i >= aLimit) {
-      if (aLimit > aStart) {
-        dirProp = mDirProps[aLimit - 1];
-        if (dirProp == LRI || dirProp == RLI) {
-          break;  /* no forced closing for sequence ending with LRI/RLI */
-        }
+      int32_t k;
+      for (k = aLimit - 1;
+           k > aStart && (DIRPROP_FLAG(dirProps[k]) & MASK_BN_EXPLICIT); k--) {
+        // empty loop body
+      }
+      dirProp = mDirProps[k];
+      if (dirProp == LRI || dirProp == RLI) {
+        break;  /* no forced closing for sequence ending with LRI/RLI */
       }
       gprop = aEOR;
     } else {
       DirProp prop;
       prop = dirProps[i];
       gprop = groupProp[prop];
     }
     oldStateImp = stateImp;
@@ -1558,17 +1563,21 @@ void nsBidi::ResolveImplicitLevels(int32
         break;
       default:            /* we should never get here */
         MOZ_ASSERT(false);
         break;
       }
     }
   }
 
-  dirProp = dirProps[aLimit - 1];
+  for (i = aLimit - 1;
+       i > aStart && (DIRPROP_FLAG(dirProps[i]) & MASK_BN_EXPLICIT); i--) {
+    // empty loop body
+  }
+  dirProp = dirProps[i];
   if ((dirProp == LRI || dirProp == RLI) && aLimit < mLength) {
     mIsolateCount++;
     mIsolates[mIsolateCount].stateImp = stateImp;
     mIsolates[mIsolateCount].state = levState.state;
     mIsolates[mIsolateCount].start1 = start1;
   } else {
     ProcessPropertySeq(&levState, aEOR, aLimit, aLimit);
   }