WebCore:
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2006 17:42:48 +0000 (17:42 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Sep 2006 17:42:48 +0000 (17:42 +0000)
        Reviewed by Adele.

        Fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=10935
        REGRESSION: file upload control with direction:rtl or text-align:right
        draws button on top of filename/icon

        * rendering/RenderFileUploadControl.cpp:
        (WebCore::RenderFileUploadControl::setStyle): Force text-align to
        match direction
        (WebCore::RenderFileUploadControl::paintObject): Fix positioning of
        the filename and icon in RTL

LayoutTests:
        Reviewed by Adele.

        Adding test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10935
        REGRESSION: file upload control with direction:rtl or text-align:right
        draws button on top of filename/icon

        * fast/forms/file-input-direction-expected.checksum: Added.
        * fast/forms/file-input-direction-expected.png: Added.
        * fast/forms/file-input-direction-expected.txt: Added.
        * fast/forms/file-input-direction.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16472 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/file-input-direction-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/file-input-direction-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/file-input-direction-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/file-input-direction.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderFileUploadControl.cpp

index b98770b43e4ee53fb63720c7751218ac8fe71f2a..6440ee3bc28524ac55114541a91c0ece74eb2542 100644 (file)
@@ -1,3 +1,16 @@
+2006-09-20  Adam Roben  <aroben@apple.com>
+
+        Reviewed by Adele.
+
+        Adding test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10935
+        REGRESSION: file upload control with direction:rtl or text-align:right
+        draws button on top of filename/icon
+
+        * fast/forms/file-input-direction-expected.checksum: Added.
+        * fast/forms/file-input-direction-expected.png: Added.
+        * fast/forms/file-input-direction-expected.txt: Added.
+        * fast/forms/file-input-direction.html: Added.
+
 2006-09-20  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by hyatt.
diff --git a/LayoutTests/fast/forms/file-input-direction-expected.checksum b/LayoutTests/fast/forms/file-input-direction-expected.checksum
new file mode 100644 (file)
index 0000000..4b2d4eb
--- /dev/null
@@ -0,0 +1 @@
+04a2da1e07f3955baf774bb0af4db14b
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/file-input-direction-expected.png b/LayoutTests/fast/forms/file-input-direction-expected.png
new file mode 100644 (file)
index 0000000..0d9421f
Binary files /dev/null and b/LayoutTests/fast/forms/file-input-direction-expected.png differ
diff --git a/LayoutTests/fast/forms/file-input-direction-expected.txt b/LayoutTests/fast/forms/file-input-direction-expected.txt
new file mode 100644 (file)
index 0000000..d23eb6a
--- /dev/null
@@ -0,0 +1,101 @@
+layer at (0,0) size 1083x585
+  RenderView at (0,0) size 800x585
+layer at (0,0) size 1083x585
+  RenderBlock {HTML} at (0,0) size 800x585
+    RenderBody {BODY} at (8,8) size 784x569
+      RenderTable {TABLE} at (0,0) size 1075x108
+        RenderTableSection {TBODY} at (0,0) size 1075x108
+          RenderTableRow {TR} at (0,2) size 1075x20
+            RenderTableCell {TH} at (2,11) size 83x2 [r=0 c=0 rs=1 cs=1]
+            RenderTableCell {TH} at (87,11) size 245x2 [r=0 c=1 rs=1 cs=1]
+            RenderTableCell {TH} at (334,2) size 245x20 [r=0 c=2 rs=1 cs=1]
+              RenderText {#text} at (78,1) size 89x18
+                text run at (78,1) width 89: "text-align:left"
+            RenderTableCell {TH} at (581,2) size 245x20 [r=0 c=3 rs=1 cs=1]
+              RenderText {#text} at (67,1) size 110x18
+                text run at (67,1) width 110: "text-align:center"
+            RenderTableCell {TH} at (828,2) size 245x20 [r=0 c=4 rs=1 cs=1]
+              RenderText {#text} at (72,1) size 101x18
+                text run at (72,1) width 101: "text-align:right"
+          RenderTableRow {TR} at (0,24) size 1075x26
+            RenderTableCell {TH} at (2,36) size 83x2 [r=1 c=0 rs=1 cs=1]
+            RenderTableCell {TD} at (87,24) size 245x26 [border: (1px solid #000000)] [r=1 c=1 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (334,24) size 245x26 [border: (1px solid #000000)] [r=1 c=2 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (581,24) size 245x26 [border: (1px solid #000000)] [r=1 c=3 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (828,24) size 245x26 [border: (1px solid #000000)] [r=1 c=4 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+          RenderTableRow {TR} at (0,52) size 1075x26
+            RenderTableCell {TH} at (2,55) size 83x20 [r=2 c=0 rs=1 cs=1]
+              RenderText {#text} at (1,1) size 81x18
+                text run at (1,1) width 81: "direction:ltr"
+            RenderTableCell {TD} at (87,52) size 245x26 [border: (1px solid #000000)] [r=2 c=1 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (334,52) size 245x26 [border: (1px solid #000000)] [r=2 c=2 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (581,52) size 245x26 [border: (1px solid #000000)] [r=2 c=3 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (828,52) size 245x26 [border: (1px solid #000000)] [r=2 c=4 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (0,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+          RenderTableRow {TR} at (0,80) size 1075x26
+            RenderTableCell {TH} at (2,83) size 83x20 [r=3 c=0 rs=1 cs=1]
+              RenderText {#text} at (1,1) size 81x18
+                text run at (1,1) width 81: "direction:rtl"
+            RenderTableCell {TD} at (87,80) size 245x26 [border: (1px solid #000000)] [r=3 c=1 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (159,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (334,80) size 245x26 [border: (1px solid #000000)] [r=3 c=2 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (159,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (581,80) size 245x26 [border: (1px solid #000000)] [r=3 c=3 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (159,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
+            RenderTableCell {TD} at (828,80) size 245x26 [border: (1px solid #000000)] [r=3 c=4 rs=1 cs=1]
+              RenderFileUploadControl {INPUT} at (4,4) size 237x18
+                RenderButton {INPUT} at (159,0) size 78x18 [bgcolor=#C0C0C0]
+                  RenderBlock (anonymous) at (8,2) size 62x13
+                    RenderText at (0,0) size 62x13
+                      text run at (0,0) width 62: "Choose File"
diff --git a/LayoutTests/fast/forms/file-input-direction.html b/LayoutTests/fast/forms/file-input-direction.html
new file mode 100644 (file)
index 0000000..5b6df85
--- /dev/null
@@ -0,0 +1,35 @@
+<style>
+td {
+  border: 1px solid black;
+}
+</style>
+<table>
+  <tr>
+    <th></th>
+    <th></th>
+    <th>text-align:left</th>
+    <th>text-align:center</th>
+    <th>text-align:right</th>
+  </tr>
+  <tr>
+    <th></th>
+    <td><input type="file"></td>
+    <td><input type="file" style="text-align:left"></td>
+    <td><input type="file" style="text-align:center"></td>
+    <td><input type="file" style="text-align:right"></td>
+  </tr>
+  <tr>
+    <th>direction:ltr</th>
+    <td><input type="file" style="direction:ltr"></td>
+    <td><input type="file" style="direction:ltr; text-align:left"></td>
+    <td><input type="file" style="direction:ltr; text-align:center"></td>
+    <td><input type="file" style="direction:ltr; text-align:right"></td>
+  </tr>
+  <tr>
+    <th>direction:rtl</th>
+    <td><input type="file" style="direction:rtl"></td>
+    <td><input type="file" style="direction:rtl; text-align:left"></td>
+    <td><input type="file" style="direction:rtl; text-align:center"></td>
+    <td><input type="file" style="direction:rtl; text-align:right"></td>
+  </tr>
+</table>
index 984216a4c547be54da84e8d45d3216220fd9c86d..ac736b76cd5bd34844007f9e97fc8260b1b340bf 100644 (file)
@@ -1,3 +1,17 @@
+2006-09-20  Adam Roben  <aroben@apple.com>
+
+        Reviewed by Adele.
+
+        Fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=10935
+        REGRESSION: file upload control with direction:rtl or text-align:right
+        draws button on top of filename/icon
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::setStyle): Force text-align to
+        match direction
+        (WebCore::RenderFileUploadControl::paintObject): Fix positioning of
+        the filename and icon in RTL
+
 2006-09-20  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Adam Roben.
index cd2ef584be2e14118ed607c75e02f2977743b982..1e835e6b2ba407be6098d6d5d899a11a47be9bd8 100644 (file)
@@ -80,6 +80,12 @@ RenderFileUploadControl::~RenderFileUploadControl()
 
 void RenderFileUploadControl::setStyle(RenderStyle* s)
 {
+    // Force text-align to match the direction
+    if (s->direction() == LTR)
+        s->setTextAlign(LEFT);
+    else
+        s->setTextAlign(RIGHT);
+    
     RenderBlock::setStyle(s);
     if (m_button)
         m_button->renderer()->setStyle(createButtonStyle(s));
@@ -158,7 +164,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& i, int tx, int ty)
         if (style()->direction() == LTR)
             textX = contentLeft + buttonAndIconWidth;
         else
-            textX = contentLeft + contentWidth() - buttonAndIconWidth;
+            textX = contentLeft + contentWidth() - buttonAndIconWidth - style()->font().width(textRun);
         // We want to match the button's baseline
         RenderButton* buttonRenderer = static_cast<RenderButton*>(m_button->renderer());
         int textY = buttonRenderer->absoluteBoundingBoxRect().y() + buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop() + buttonRenderer->baselinePosition(true, false);
@@ -176,7 +182,7 @@ void RenderFileUploadControl::paintObject(PaintInfo& i, int tx, int ty)
             if (style()->direction() == LTR)
                 iconX = contentLeft + m_button->renderer()->width() + afterButtonSpacing;
             else
-                iconX = contentLeft + contentWidth() - m_button->renderer()->width() - afterButtonSpacing;
+                iconX = contentLeft + contentWidth() - m_button->renderer()->width() - afterButtonSpacing - iconWidth;
             
             // Draw the file icon
             m_fileChooser->icon()->paint(i.p, IntRect(iconX, iconY, iconWidth, iconHeight));