[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:34:42 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 087ef480a382400daefcc136631137ca5c87cba8
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Sep 26 13:12:20 2009 +0000

    2009-09-26  Xiaomei Ji  <xji at chromium.org>
    
            Reviewed by Eric Seidel.
    
            This Patch fixes [chromium] the drop-down is always left-aligned even
            for RTL element.
            https://bugs.webkit.org/show_bug.cgi?id=29612
    
            For auto-complete, the items in drop-down should be right-aligned if
            the directionality of <input> field is RTL.
            For <select><option>, the items in drop-down should be right-aligned
            if the directionality of <select> is RTL.
    
            No automatic test is possible. Manual tests are added.
    
            * manual-tests/autofill_alignment.html: Added.
            * manual-tests/select_alignment.html: Added.
            * platform/chromium/PopupMenuChromium.cpp:
            (WebCore::PopupListBox::paintRow): Adjust the starting x-axis of text to
            be paint if it should be right-aligned.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48789 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4465c73..ddc675c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2009-09-26  Xiaomei Ji  <xji at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        This Patch fixes [chromium] the drop-down is always left-aligned even
+        for RTL element.
+        https://bugs.webkit.org/show_bug.cgi?id=29612
+
+        For auto-complete, the items in drop-down should be right-aligned if
+        the directionality of <input> field is RTL.
+        For <select><option>, the items in drop-down should be right-aligned
+        if the directionality of <select> is RTL.
+
+        No automatic test is possible. Manual tests are added.
+
+        * manual-tests/autofill_alignment.html: Added.
+        * manual-tests/select_alignment.html: Added.
+        * platform/chromium/PopupMenuChromium.cpp:
+        (WebCore::PopupListBox::paintRow): Adjust the starting x-axis of text to
+        be paint if it should be right-aligned.
+
 2009-09-25  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebCore/manual-tests/autofill_alignment.html b/WebCore/manual-tests/autofill_alignment.html
new file mode 100644
index 0000000..4863e41
--- /dev/null
+++ b/WebCore/manual-tests/autofill_alignment.html
@@ -0,0 +1,25 @@
+<html>
+<head>
+<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
+<title>
+Test auto-fill drop-down items' alignment
+</title>
+</head>
+<body>
+<p>
+Autofill drop-down item's alignment should be the same as the input field.
+It should align left if the input field's direction is ltr. It should 
+align right if the input field's direction is rtl.
+<p> Try type some text in the "First name" and "Last name" input box,
+then click "Submit". Open the file again, double click the "First name"
+field, the drop-down box should be opened with the items aligned right.
+Double click the "Last name" field, the drop-down box should be opened
+with the items aligned left.
+<br>
+<form action="form_action.asp" method="get">
+  First name: <input type="text" name="fname" dir="rtl"/><br />
+  Last name: <input type="text" name="lname" /><br />
+  <input type="submit" value="Submit" />
+</form>
+</body>
+</html>
diff --git a/WebCore/manual-tests/select_alignment.html b/WebCore/manual-tests/select_alignment.html
new file mode 100644
index 0000000..7c1bc0e
--- /dev/null
+++ b/WebCore/manual-tests/select_alignment.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+<title>Test drop-down item's alignment in <select>/<option></title>
+<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
+</head>
+<body>
+<p>
+select drop-down items' alignment should be determined by the directionality of
+&lt;select&gt; tag.
+<p>
+The drop-down items in the following &lt;select&gt; should be left-aligned.
+<br>
+<select>
+<option>abc def</option>
+<option>שנב גקכ</option>
+<option dir="rtl">abc שנב def</option>
+<option dir="ltr">שנב abc גקכ</option>
+<option dir="rtl">hi!</option>
+<option dir="ltr">hi!</option>
+</select>
+<br>
+The drop-down items in the second &lt;select&gt; should be right-aligned.
+<p>
+<select dir="rtl">
+<option>abc def</option>
+<option>שנב גקכ</option>
+<option dir="rtl">abc שנב def</option>
+<option dir="ltr">שנב abc גקכ</option>
+<option dir="rtl">hi!</option>
+<option dir="ltr">hi!</option>
+</select>
+</body>
+</html>
diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp
index 2f69eaf..d6f895d 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -826,12 +826,19 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
     Font itemFont = getRowFont(rowIndex);
     // FIXME: http://crbug.com/19872 We should get the padding of individual option
     // elements.  This probably implies changes to PopupMenuClient.
-    int textX = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
-    int textY = rowRect.y() + itemFont.ascent() + (rowRect.height() - itemFont.height()) / 2;
+    bool rightAligned = m_popupClient->menuStyle().textDirection() == RTL;
+    int textX = 0;
+    int maxWidth = 0;
+    if (rightAligned)
+        maxWidth = rowRect.width() - max(0, m_popupClient->clientPaddingRight() - m_popupClient->clientInsetRight());
+    else {
+        textX = max(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
+        maxWidth = rowRect.width() - textX;
+    }
     // Prepare text to be drawn.
     String itemText = m_popupClient->itemText(rowIndex);
     if (m_settings.restrictWidthOfListBox)  // truncate string to fit in.
-        itemText = StringTruncator::rightTruncate(itemText, rowRect.width() - textX, itemFont);
+        itemText = StringTruncator::rightTruncate(itemText, maxWidth, itemFont);
     unsigned length = itemText.length();
     const UChar* str = itemText.characters();
     // Prepare the directionality to draw text.
@@ -842,7 +849,12 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd
              PopupContainerSettings::FirstStrongDirectionalCharacterDirection)
         rtl = itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft;
     TextRun textRun(str, length, false, 0, 0, rtl);
+    // If the text is right-to-left, make it right-aligned by adjusting its
+    // beginning position.
+    if (rightAligned)
+        textX += maxWidth - itemFont.width(textRun);
     // Draw the item text.
+    int textY = rowRect.y() + itemFont.ascent() + (rowRect.height() - itemFont.height()) / 2;
     gc->drawBidiText(itemFont, textRun, IntPoint(textX, textY));
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list