Fix nested unicode-bidi: isolate
When we have a nested isolate renderer if the outer isolate has a text and this text is not the first child, the isolated chain is not rendered correctly. This happens because constructBidiRunsForSegment uses always the first inner isolated renderer as isolated inline container. This patch fixes the behavior described changing containingIsolate to find the right isolated container.

BUG=274717

Review URL: https://chromiumcodereview.appspot.com/23298002

git-svn-id: svn://svn.chromium.org/blink/trunk@156261 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text-expected.html b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text-expected.html
new file mode 100644
index 0000000..bd3af84
--- /dev/null
+++ b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text-expected.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+  </head>
+  <body>
+      <span>First Text
+          <span>&#x05D0;-></span>Second Text
+          <span>&#x05D0;-<</span>
+      </span>
+  </body>
+</html>
diff --git a/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text.html b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text.html
new file mode 100644
index 0000000..22c103a
--- /dev/null
+++ b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-first-child-text.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <style>
+      .isolate {
+        unicode-bidi: -webkit-isolate;
+      }
+    </style>
+  </head>
+  <body>
+      <span class="isolate">First Text
+          <span class="isolate">&#x05D0;-></span>Second Text
+          <span class="isolate">&#x05D0;-<</span>
+      </span>
+  </body>
+</html>
diff --git a/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple-expected.html b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple-expected.html
new file mode 100644
index 0000000..3a12144
--- /dev/null
+++ b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple-expected.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    </style>
+  </head>
+  <body>
+      <span><span>&#x05D0;-></span>Text</span>
+  </body>
+</html>
diff --git a/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple.html b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple.html
new file mode 100644
index 0000000..ca0d47e
--- /dev/null
+++ b/LayoutTests/fast/text/international/unicode-bidi-isolate-nested-simple.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <style>
+      .isolate {
+        unicode-bidi: -webkit-isolate;
+      }
+    </style>
+  </head>
+  <body>
+      <span class="isolate"><span class="isolate">&#x05D0;-></span>Text</span>
+  </body>
+</html>
diff --git a/Source/core/rendering/InlineIterator.h b/Source/core/rendering/InlineIterator.h
index eae2dca..d88205a 100644
--- a/Source/core/rendering/InlineIterator.h
+++ b/Source/core/rendering/InlineIterator.h
@@ -417,12 +417,17 @@
 static inline RenderObject* containingIsolate(RenderObject* object, RenderObject* root)
 {
     ASSERT(object);
+    RenderObject* containingIsolateObj = 0;
     while (object && object != root) {
+        if (containingIsolateObj && !isIsolatedInline(object))
+            break;
+
         if (isIsolatedInline(object))
-            return object;
+            containingIsolateObj = object;
+
         object = object->parent();
     }
-    return 0;
+    return containingIsolateObj;
 }
 
 static inline unsigned numberOfIsolateAncestors(const InlineIterator& iter)
diff --git a/Source/core/rendering/RenderBlockLineLayout.cpp b/Source/core/rendering/RenderBlockLineLayout.cpp
index 0317ecf..b7484d6 100644
--- a/Source/core/rendering/RenderBlockLineLayout.cpp
+++ b/Source/core/rendering/RenderBlockLineLayout.cpp
@@ -1309,6 +1309,7 @@
         if (!isolatedResolver.isolatedRuns().isEmpty()) {
             topResolver.isolatedRuns().append(isolatedResolver.isolatedRuns());
             isolatedResolver.isolatedRuns().clear();
+            currentRoot = isolatedInline;
         }
     }
 }