Merge a bidi fix to ICU's M42 branch

The following two changes are cherry-picked along with the corresponding
patch file (bidi.patch) and update for README.chromium.

http://crrev.com/7c81740601355556e630da515b74d889ba2f8d08/source/common/ubidi.c
http://crrev.com/7c81740601355556e630da515b74d889ba2f8d08/source/common/ubidiimp.h

DEPS in M42 will be updated to include this change.

BUG=451799
TEST=none
TBR=inferno@chromium.org

Review URL: https://codereview.chromium.org/1004743003
diff --git a/README.chromium b/README.chromium
index 1f336d5..3deb52a 100644
--- a/README.chromium
+++ b/README.chromium
@@ -248,4 +248,7 @@
 
 12. Fix a bug in BiDi
    - patches/bidi.patch
-   - upstream bug: http://bugs.icu-project.org/trac/ticket/11177
+   - upstream bugs
+     http://bugs.icu-project.org/trac/ticket/11177
+     http://bugs.icu-project.org/trac/ticket/11451
+
diff --git a/patches/bidi.patch b/patches/bidi.patch
index 41764f0..a66c2da 100644
--- a/patches/bidi.patch
+++ b/patches/bidi.patch
@@ -1,5 +1,5 @@
 diff --git a/source/common/ubidi.c b/source/common/ubidi.c
-index 8c0d64b..e773de7 100644
+index 8c0d64b..c43c41c 100644
 --- a/source/common/ubidi.c
 +++ b/source/common/ubidi.c
 @@ -1,7 +1,7 @@
@@ -11,6 +11,15 @@
  *   Corporation and others.  All Rights Reserved.
  *
  ******************************************************************************
+@@ -2138,7 +2138,7 @@ resolveImplicitLevels(UBiDi *pBiDi,
+     /* The isolates[] entries contain enough information to
+        resume the bidi algorithm in the same state as it was
+        when it was interrupted by an isolate sequence. */
+-    if(dirProps[start]==PDI) {
++    if(dirProps[start]==PDI  && pBiDi->isolateCount >= 0) {
+         levState.startON=pBiDi->isolates[pBiDi->isolateCount].startON;
+         start1=pBiDi->isolates[pBiDi->isolateCount].start1;
+         stateImp=pBiDi->isolates[pBiDi->isolateCount].stateImp;
 @@ -2340,7 +2340,7 @@ setParaSuccess(UBiDi *pBiDi) {
  static void
  setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length,
@@ -36,3 +45,26 @@
      pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
  }
  
+diff --git a/source/common/ubidiimp.h b/source/common/ubidiimp.h
+index 20ab9b9..14d7b99 100644
+--- a/source/common/ubidiimp.h
++++ b/source/common/ubidiimp.h
+@@ -1,7 +1,7 @@
+ /*
+ ******************************************************************************
+ *
+-*   Copyright (C) 1999-2014, International Business Machines
++*   Copyright (C) 1999-2015, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ ******************************************************************************
+@@ -184,8 +184,8 @@ typedef struct BracketData {
+ typedef struct Isolate {
+     int32_t startON;
+     int32_t start1;
++    int32_t state;
+     int16_t stateImp;
+-    int16_t state;
+ } Isolate;
+ 
+ typedef struct Run {
diff --git a/source/common/ubidi.c b/source/common/ubidi.c
index e773de7..c43c41c 100644
--- a/source/common/ubidi.c
+++ b/source/common/ubidi.c
@@ -2138,7 +2138,7 @@
     /* The isolates[] entries contain enough information to
        resume the bidi algorithm in the same state as it was
        when it was interrupted by an isolate sequence. */
-    if(dirProps[start]==PDI) {
+    if(dirProps[start]==PDI  && pBiDi->isolateCount >= 0) {
         levState.startON=pBiDi->isolates[pBiDi->isolateCount].startON;
         start1=pBiDi->isolates[pBiDi->isolateCount].start1;
         stateImp=pBiDi->isolates[pBiDi->isolateCount].stateImp;
diff --git a/source/common/ubidiimp.h b/source/common/ubidiimp.h
index 20ab9b9..14d7b99 100644
--- a/source/common/ubidiimp.h
+++ b/source/common/ubidiimp.h
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1999-2014, International Business Machines
+*   Copyright (C) 1999-2015, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -184,8 +184,8 @@
 typedef struct Isolate {
     int32_t startON;
     int32_t start1;
+    int32_t state;
     int16_t stateImp;
-    int16_t state;
 } Isolate;
 
 typedef struct Run {