WebCore:

        Reviewed by Darin Adler.

        - make centered text in right-to-left blocks spill over to the left

        Test: fast/text/align-center-rtl-spill.html

        * rendering/bidi.cpp:
        (WebCore::RenderBlock::computeHorizontalPositionsForLine):

LayoutTests:

        Reviewed by Darin Adler.

        - test that centered text in right-to-left blocks spills over to the left

        * fast/text/align-center-rtl-spill.html: Added.
        * platform/mac/fast/text/align-center-rtl-spill-expected.checksum: Added.
        * platform/mac/fast/text/align-center-rtl-spill-expected.png: Added.
        * platform/mac/fast/text/align-center-rtl-spill-expected.txt: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30642 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 0278542..bd175ec 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -644,8 +644,10 @@
             break;
         case CENTER:
         case WEBKIT_CENTER:
-            // FIXME: It is inconsistent to pin to the left even in RTL blocks.
-            x += max((availableWidth - totWidth) / 2, 0);
+            if (style()->direction() == LTR)
+                x += max((availableWidth - totWidth) / 2, 0);
+            else
+                x += totWidth > availableWidth ? (availableWidth - totWidth) : (availableWidth - totWidth) / 2;
             break;
     }