WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2008 02:23:22 +0000 (02:23 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2008 02:23:22 +0000 (02:23 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@30642 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/align-center-rtl-spill.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/bidi.cpp

index 893ade3d5294b117ee5a3effd4219e411c332c13..fb8574c14650730b16016a05308560b99bf876a9 100644 (file)
@@ -1,3 +1,14 @@
+2008-02-27  Dan Bernstein  <mitz@apple.com>
+
+        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.
+
 2008-02-27  Eric Seidel  <eric@webkit.org>
 
         Rubber-stamped by Adam.
diff --git a/LayoutTests/fast/text/align-center-rtl-spill.html b/LayoutTests/fast/text/align-center-rtl-spill.html
new file mode 100644 (file)
index 0000000..3d2e2cb
--- /dev/null
@@ -0,0 +1,3 @@
+<div style="display: inline-block; width: 50px; height: 100px; background-color: red;"></div><div style="display: inline-block; width: 50px; text-align: center; direction: rtl;">
+    <div style="display: inline-block; width: 100px; height: 100px; background-color: green;"></div>
+</div>
diff --git a/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.checksum b/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.checksum
new file mode 100644 (file)
index 0000000..ae7a7bd
--- /dev/null
@@ -0,0 +1 @@
+18f1f64eab31dfb69467a497de9442d7
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.png b/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.png
new file mode 100644 (file)
index 0000000..fc96c0b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.txt b/LayoutTests/platform/mac/fast/text/align-center-rtl-spill-expected.txt
new file mode 100644 (file)
index 0000000..b61323b
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 50x100 [bgcolor=#FF0000]
+      RenderBlock {DIV} at (50,0) size 50x100
+        RenderBlock {DIV} at (-50,0) size 100x100 [bgcolor=#008000]
+        RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
index ac93c9092edee951b079000cef1e210ed80d41de..1c3c4975b417f0267998a4c9ffeff8ea7a628317 100644 (file)
@@ -1,3 +1,14 @@
+2008-02-27  Dan Bernstein  <mitz@apple.com>
+
+        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):
+
 2008-02-27  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Darin Adler.
index 02785425c8bdd16104e89433429cf5fc287a202f..bd175ec926c6874b6e04ddfca7404ae5d3dff766 100644 (file)
@@ -644,8 +644,10 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, Bidi
             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;
     }