WebCore:

        Reviewed by Sam Weinig with no hesitation.

        - fix the HTML/CSS case of https://bugs.webkit.org/show_bug.cgi?id=19839
          <rdar://problem/6304805> A PDF,RLE sequence that should be a no-op affects bidi reordering

        Test: fast/text/bidi-embedding-pop-and-push-same.html

        * platform/text/BidiResolver.h:
        (WebCore::BidiResolver::embed): Changed to only add the embedding
        operation to a vector of pending operations.

        (WebCore::BidiResolver::lowerExplicitEmbeddingLevel): Added. Moved the
        code that used to be in the PDF case of embed() here, except the part
        that sets the context.

        (WebCore::BidiResolver::raiseExplicitEmbeddingLevel): Added. Moved the
        code that used to be in the non-PDF case of embed() here, except the
        part the sets the context.

        (WebCore::BidiResolver::commitExplicitEmbedding): Added. Processes the
        explicit embedding operations in the vector by creating an updated
        context and determining the old and new embedding levels. If the levels
        are not the same, calls {lower,raise}ExplicitEmbeddingLevel(). Always
        sets the context to the new one.

        (WebCore::BidiResolver::createBidiRunsForLine): Added calls to
        commitExplicitEmbedding() after calling embed() and after calling
        increment().

        * rendering/bidi.cpp:
        (WebCore::bidiFirst): Added calls to commitExplicitEmbedding() because
        this function increments the resolver.

        (WebCore::RenderBlock::skipLeadingWhitespace): Ditto.

LayoutTests:

        Reviewed by Sam Weinig with no hesitation.

        - test for the HTML/CSS case of https://bugs.webkit.org/show_bug.cgi?id=19839
          <rdar://problem/6304805> A PDF,RLE sequence that should be a no-op affects bidi reordering

        * fast/text/bidi-embedding-pop-and-push-same.html: Added.
        * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.checksum: Added.
        * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.png: Added.
        * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.txt: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index a64d632..77b4b19 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -255,12 +255,19 @@
         }
         if (skipInlines && o->firstChild())
             o = bidiNext(block, o, resolver, skipInlines);
-        else
-            return o; // Never skip empty inlines.
+        else {
+            // Never skip empty inlines.
+            if (resolver)
+                resolver->commitExplicitEmbedding();
+            return o; 
+        }
     }
 
     if (o && !o->isText() && !o->isReplaced() && !o->isFloating() && !o->isPositioned())
         o = bidiNext(block, o, resolver, skipInlines);
+
+    if (resolver)
+        resolver->commitExplicitEmbedding();
     return o;
 }
 
@@ -1512,6 +1519,7 @@
         }
         resolver.increment();
     }
+    resolver.commitExplicitEmbedding();
     return availableWidth;
 }