[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mitz at apple.com mitz at apple.com
Mon Feb 21 00:13:04 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 07c9c84c29d12984004eb0af918781abd6d3ebe9
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 28 21:34:55 2011 +0000

    Source/WebCore: <rdar://problem/4761512> <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    Changed <select> pop-up menus on Mac OS X Snow Leopard and later to have their items aligned in the
    direction corresponding to the writing direction of the <select> element, with the checkmarks
    on the "start" side, and use the <option>'s writing direction rather than "natural". Made the
    pop-up button match the menu by adding a Chrome boolean function, selectItemAlignmentFollowsMenuWritingDirection(),
    which returns true for this pop-up behavior.
    
    * loader/EmptyClients.h:
    (WebCore::EmptyChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * manual-tests/pop-up-alignment-and-direction.html: Added.
    * page/Chrome.cpp:
    (WebCore::Chrome::selectItemAlignmentFollowsMenuWritingDirection): Added. Calls through to the
    client.
    * page/Chrome.h:
    * page/ChromeClient.h:
    * platform/PopupMenuStyle.h:
    (WebCore::PopupMenuStyle::PopupMenuStyle): Added hasTextDirectionOverride parameter and member
    variable initialization.
    (WebCore::PopupMenuStyle::hasTextDirectionOverride): Added this accessor.
    * platform/mac/PopupMenuMac.mm:
    (WebCore::PopupMenuMac::populate): Set the pop-up's layout direction and items' text alignment
    to match the menu's writing direction. Set items' writing direction and direction override
    according to their styles.
    * rendering/RenderMenuList.cpp:
    (WebCore::RenderMenuList::RenderMenuList): Removed unncesaary initialization of a smart pointer.
    (WebCore::RenderMenuList::adjustInnerStyle): If the alignment of items in the menu follows the
    menu's writing direction, use that alignment for the button as well. Also in this mode, use the
    item's writing direction and override setting.
    (WebCore::RenderMenuList::setTextFromOption): Store the option element's style.
    (WebCore::RenderMenuList::itemStyle): Pass the text direction override value.
    (WebCore::RenderMenuList::menuStyle): Ditto. Also use the button's direction, not the inner text's.
    * rendering/RenderMenuList.h:
    * rendering/RenderTextControlSingleLine.cpp:
    (WebCore::RenderTextControlSingleLine::menuStyle): Pass the text direction override value.
    
    Source/WebKit/chromium: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * src/AutoFillPopupMenuClient.cpp:
    (WebKit::AutoFillPopupMenuClient::initialize): Pass hasTextDirectionOverride to the PopupMenuStyle
    constructor.
    * src/ChromeClientImpl.cpp:
    (WebKit::ChromeClientImpl::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * src/ChromeClientImpl.h:
    * tests/PopupMenuTest.cpp:
    (WebKit::TestPopupMenuClient::itemStyle): Pass hasTextDirectionOverride to the PopupMenuStyle
    constructor.
    
    Source/WebKit/efl: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/ChromeClientEfl.cpp:
    (WebCore::ChromeClientEfl::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/ChromeClientEfl.h:
    
    Source/WebKit/gtk: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/ChromeClientGtk.cpp:
    (WebKit::ChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/ChromeClientGtk.h:
    
    Source/WebKit/haiku: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/ChromeClientHaiku.cpp:
    (WebCore::ChromeClientHaiku::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/ChromeClientHaiku.h:
    
    Source/WebKit/mac: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/WebChromeClient.h:
    * WebCoreSupport/WebChromeClient.mm:
    (WebChromeClient::selectItemWritingDirectionIsNatural): Changed to return false.
    (WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added. Returns true.
    
    Source/WebKit/qt: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/ChromeClientQt.cpp:
    (WebCore::ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/ChromeClientQt.h:
    
    Source/WebKit/win: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/WebChromeClient.cpp:
    (WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/WebChromeClient.h:
    
    Source/WebKit/wince: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebCoreSupport/ChromeClientWinCE.cpp:
    (WebKit::ChromeClientWinCE::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebCoreSupport/ChromeClientWinCE.h:
    
    Source/WebKit/wx: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * WebKitSupport/ChromeClientWx.cpp:
    (WebCore::ChromeClientWx::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebKitSupport/ChromeClientWx.h:
    
    Source/WebKit2: <select> can't display right-to-left (rtl) languages
    https://bugs.webkit.org/show_bug.cgi?id=19785
    
    Reviewed by Sam Weinig.
    
    * Shared/WebPopupItem.cpp:
    (WebKit::WebPopupItem::WebPopupItem): Added initializers for m_textDirection and m_hasTextDirectionOverride.
    (WebKit::WebPopupItem::encode): Encode the item's writing direction and direction override values.
    (WebKit::WebPopupItem::decode): Decode the item's writing direction and direction override values.
    * Shared/WebPopupItem.h:
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::showPopupMenu): Added a parameter for the menu's text direction.
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in: Ditto.
    * UIProcess/WebPopupMenuProxy.h:
    * UIProcess/mac/WebPopupMenuProxyMac.h:
    * UIProcess/mac/WebPopupMenuProxyMac.mm:
    (WebKit::WebPopupMenuProxyMac::populate): Added a parameter for the menu's text direction.
    Set items' text alignment to match the menu's writing direction. Set items' writing direction
    and direction override according to their styles.
    (WebKit::WebPopupMenuProxyMac::showPopupMenu): Set the pop-up's layout direction.
    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::selectItemWritingDirectionIsNatural): Changed to return false.
    (WebKit::WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
    * WebProcess/WebCoreSupport/WebChromeClient.h:
    * WebProcess/WebCoreSupport/WebPopupMenu.cpp:
    (WebKit::WebPopupMenu::populateItems): Initialize items' writing direction and direction override
    values.
    (WebKit::WebPopupMenu::show): Pass the menu's writing direction.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76983 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 748f4c6..3520097 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,44 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <rdar://problem/4761512> <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        Changed <select> pop-up menus on Mac OS X Snow Leopard and later to have their items aligned in the
+        direction corresponding to the writing direction of the <select> element, with the checkmarks
+        on the "start" side, and use the <option>'s writing direction rather than "natural". Made the
+        pop-up button match the menu by adding a Chrome boolean function, selectItemAlignmentFollowsMenuWritingDirection(),
+        which returns true for this pop-up behavior.
+
+        * loader/EmptyClients.h:
+        (WebCore::EmptyChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * manual-tests/pop-up-alignment-and-direction.html: Added.
+        * page/Chrome.cpp:
+        (WebCore::Chrome::selectItemAlignmentFollowsMenuWritingDirection): Added. Calls through to the
+        client.
+        * page/Chrome.h:
+        * page/ChromeClient.h:
+        * platform/PopupMenuStyle.h:
+        (WebCore::PopupMenuStyle::PopupMenuStyle): Added hasTextDirectionOverride parameter and member
+        variable initialization.
+        (WebCore::PopupMenuStyle::hasTextDirectionOverride): Added this accessor.
+        * platform/mac/PopupMenuMac.mm:
+        (WebCore::PopupMenuMac::populate): Set the pop-up's layout direction and items' text alignment
+        to match the menu's writing direction. Set items' writing direction and direction override
+        according to their styles.
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::RenderMenuList): Removed unncesaary initialization of a smart pointer.
+        (WebCore::RenderMenuList::adjustInnerStyle): If the alignment of items in the menu follows the
+        menu's writing direction, use that alignment for the button as well. Also in this mode, use the
+        item's writing direction and override setting.
+        (WebCore::RenderMenuList::setTextFromOption): Store the option element's style.
+        (WebCore::RenderMenuList::itemStyle): Pass the text direction override value.
+        (WebCore::RenderMenuList::menuStyle): Ditto. Also use the button's direction, not the inner text's.
+        * rendering/RenderMenuList.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::menuStyle): Pass the text direction override value.
+
 2011-01-28  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Daniel Bates.
diff --git a/Source/WebCore/loader/EmptyClients.h b/Source/WebCore/loader/EmptyClients.h
index 3e58c7a..83f42ad 100644
--- a/Source/WebCore/loader/EmptyClients.h
+++ b/Source/WebCore/loader/EmptyClients.h
@@ -137,6 +137,7 @@ public:
     virtual bool shouldInterruptJavaScript() { return false; }
 
     virtual bool selectItemWritingDirectionIsNatural() { return false; }
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection() { return false; }
     virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const { return adoptRef(new EmptyPopupMenu()); }
     virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const { return adoptRef(new EmptySearchPopupMenu()); }
 
diff --git a/Source/WebCore/manual-tests/pop-up-alignment-and-direction.html b/Source/WebCore/manual-tests/pop-up-alignment-and-direction.html
new file mode 100644
index 0000000..b51798e
Binary files /dev/null and b/Source/WebCore/manual-tests/pop-up-alignment-and-direction.html differ
diff --git a/Source/WebCore/page/Chrome.cpp b/Source/WebCore/page/Chrome.cpp
index d96b6c9..9595fa0 100644
--- a/Source/WebCore/page/Chrome.cpp
+++ b/Source/WebCore/page/Chrome.cpp
@@ -508,6 +508,11 @@ bool Chrome::selectItemWritingDirectionIsNatural()
     return m_client->selectItemWritingDirectionIsNatural();
 }
 
+bool Chrome::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return m_client->selectItemAlignmentFollowsMenuWritingDirection();
+}
+
 PassRefPtr<PopupMenu> Chrome::createPopupMenu(PopupMenuClient* client) const
 {
     return m_client->createPopupMenu(client);
diff --git a/Source/WebCore/page/Chrome.h b/Source/WebCore/page/Chrome.h
index 0afd807..bd43677 100644
--- a/Source/WebCore/page/Chrome.h
+++ b/Source/WebCore/page/Chrome.h
@@ -163,6 +163,7 @@ namespace WebCore {
 #endif
 
         bool selectItemWritingDirectionIsNatural();
+        bool selectItemAlignmentFollowsMenuWritingDirection();
         PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
         PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
 
diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h
index e348afb..c2f87e0 100644
--- a/Source/WebCore/page/ChromeClient.h
+++ b/Source/WebCore/page/ChromeClient.h
@@ -292,6 +292,7 @@ namespace WebCore {
 #endif
 
         virtual bool selectItemWritingDirectionIsNatural() = 0;
+        virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
         virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
         virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
 
diff --git a/Source/WebCore/platform/PopupMenuStyle.h b/Source/WebCore/platform/PopupMenuStyle.h
index b9a7abc..3cb33cc 100644
--- a/Source/WebCore/platform/PopupMenuStyle.h
+++ b/Source/WebCore/platform/PopupMenuStyle.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2008, 2011 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,7 +35,7 @@ namespace WebCore {
 
 class PopupMenuStyle {
 public:
-    PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, bool isDisplayNone, Length textIndent, TextDirection textDirection)
+    PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, bool isDisplayNone, Length textIndent, TextDirection textDirection, bool hasTextDirectionOverride)
         : m_foregroundColor(foreground)
         , m_backgroundColor(background)
         , m_font(font)
@@ -43,6 +43,7 @@ public:
         , m_isDisplayNone(isDisplayNone)
         , m_textIndent(textIndent)
         , m_textDirection(textDirection)
+        , m_hasTextDirectionOverride(hasTextDirectionOverride)
     {
     }
     
@@ -53,6 +54,7 @@ public:
     bool isDisplayNone() const { return m_isDisplayNone; }
     Length textIndent() const { return m_textIndent; }
     TextDirection textDirection() const { return m_textDirection; }
+    bool hasTextDirectionOverride() const { return m_hasTextDirectionOverride; }
 
 private:
     Color m_foregroundColor;
@@ -62,6 +64,7 @@ private:
     bool m_isDisplayNone;
     Length m_textIndent;
     TextDirection m_textDirection;
+    bool m_hasTextDirectionOverride;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/platform/mac/PopupMenuMac.mm b/Source/WebCore/platform/mac/PopupMenuMac.mm
index 1bf500b..e69bcb2 100644
--- a/Source/WebCore/platform/mac/PopupMenuMac.mm
+++ b/Source/WebCore/platform/mac/PopupMenuMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2010, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  *
  * This library is free software; you can redistribute it and/or
@@ -75,6 +75,11 @@ void PopupMenuMac::populate()
     if (!client()->shouldPopOver())
         [m_popup.get() addItemWithTitle:@""];
 
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+    TextDirection menuTextDirection = client()->menuStyle().textDirection();
+    [m_popup.get() setUserInterfaceLayoutDirection:menuTextDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
+#endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+
     ASSERT(client());
     int size = client()->listSize();
 
@@ -92,13 +97,27 @@ void PopupMenuMac::populate()
                 }
                 [attributes setObject:font forKey:NSFontAttributeName];
             }
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+            RetainPtr<NSMutableParagraphStyle> paragraphStyle(AdoptNS, [[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
+            [paragraphStyle.get() setAlignment:menuTextDirection == LTR ? NSLeftTextAlignment : NSRightTextAlignment];
+            NSWritingDirection writingDirection = style.textDirection() == LTR ? NSWritingDirectionLeftToRight : NSWritingDirectionRightToLeft;
+            [paragraphStyle.get() setBaseWritingDirection:writingDirection];
+            if (style.hasTextDirectionOverride()) {
+                RetainPtr<NSNumber> writingDirectionValue(AdoptNS, [[NSNumber alloc] initWithInteger:writingDirection + NSTextWritingDirectionOverride]);
+                RetainPtr<NSArray> writingDirectionArray(AdoptNS, [[NSArray alloc] initWithObjects:writingDirectionValue.get(), nil]);
+                [attributes setObject:writingDirectionArray.get() forKey:NSWritingDirectionAttributeName];
+            }
+            [attributes setObject:paragraphStyle.get() forKey:NSParagraphStyleAttributeName];
+#endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+
             // FIXME: Add support for styling the foreground and background colors.
             // FIXME: Find a way to customize text color when an item is highlighted.
-            NSAttributedString* string = [[NSAttributedString alloc] initWithString:client()->itemText(i) attributes:attributes];
+            NSAttributedString *string = [[NSAttributedString alloc] initWithString:client()->itemText(i) attributes:attributes];
             [attributes release];
 
             [m_popup.get() addItemWithTitle:@""];
-            NSMenuItem* menuItem = [m_popup.get() lastItem];
+            NSMenuItem *menuItem = [m_popup.get() lastItem];
             [menuItem setAttributedTitle:string];
             [menuItem setEnabled:client()->itemIsEnabled(i)];
             [menuItem setToolTip:client()->itemToolTip(i)];
diff --git a/Source/WebCore/rendering/RenderMenuList.cpp b/Source/WebCore/rendering/RenderMenuList.cpp
index e55b5ca..c45e60a 100644
--- a/Source/WebCore/rendering/RenderMenuList.cpp
+++ b/Source/WebCore/rendering/RenderMenuList.cpp
@@ -2,7 +2,7 @@
  * This file is part of the select element renderer in WebCore.
  *
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  *               2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  *
  * This library is free software; you can redistribute it and/or
@@ -55,7 +55,6 @@ RenderMenuList::RenderMenuList(Element* element)
     , m_optionsChanged(true)
     , m_optionsWidth(0)
     , m_lastSelectedIndex(-1)
-    , m_popup(0)
     , m_popupIsVisible(false)
 {
 }
@@ -84,19 +83,24 @@ void RenderMenuList::createInnerBlock()
 
 void RenderMenuList::adjustInnerStyle()
 {
-    m_innerBlock->style()->setBoxFlex(1.0f);
+    RenderStyle* innerStyle = m_innerBlock->style();
+    innerStyle->setBoxFlex(1);
     
-    m_innerBlock->style()->setPaddingLeft(Length(theme()->popupInternalPaddingLeft(style()), Fixed));
-    m_innerBlock->style()->setPaddingRight(Length(theme()->popupInternalPaddingRight(style()), Fixed));
-    m_innerBlock->style()->setPaddingTop(Length(theme()->popupInternalPaddingTop(style()), Fixed));
-    m_innerBlock->style()->setPaddingBottom(Length(theme()->popupInternalPaddingBottom(style()), Fixed));
+    innerStyle->setPaddingLeft(Length(theme()->popupInternalPaddingLeft(style()), Fixed));
+    innerStyle->setPaddingRight(Length(theme()->popupInternalPaddingRight(style()), Fixed));
+    innerStyle->setPaddingTop(Length(theme()->popupInternalPaddingTop(style()), Fixed));
+    innerStyle->setPaddingBottom(Length(theme()->popupInternalPaddingBottom(style()), Fixed));
 
     if (document()->page()->chrome()->selectItemWritingDirectionIsNatural()) {
         // Items in the popup will not respect the CSS text-align and direction properties,
         // so we must adjust our own style to match.
-        m_innerBlock->style()->setTextAlign(LEFT);
+        innerStyle->setTextAlign(LEFT);
         TextDirection direction = (m_buttonText && m_buttonText->text()->defaultWritingDirection() == WTF::Unicode::RightToLeft) ? RTL : LTR;
-        m_innerBlock->style()->setDirection(direction);
+        innerStyle->setDirection(direction);
+    } else if (m_optionStyle && document()->page()->chrome()->selectItemAlignmentFollowsMenuWritingDirection()) {
+        innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGHT);
+        innerStyle->setDirection(m_optionStyle->direction());
+        innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi());
     }
 }
 
@@ -184,8 +188,11 @@ void RenderMenuList::setTextFromOption(int optionIndex)
     int i = select->optionToListIndex(optionIndex);
     String text = "";
     if (i >= 0 && i < size) {
-        if (OptionElement* optionElement = toOptionElement(listItems[i]))
+        Element* element = listItems[i];
+        if (OptionElement* optionElement = toOptionElement(element)) {
             text = optionElement->textIndentedToRespectGroupLabel();
+            m_optionStyle = element->renderStyle();
+        }
     }
 
     setText(text.stripWhiteSpace());
@@ -418,7 +425,7 @@ PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const
     Element* element = listItems[listIndex];
     
     RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
-    return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE, style->display() == NONE, style->textIndent(), style->direction()) : menuStyle();
+    return style ? PopupMenuStyle(style->visitedDependentColor(CSSPropertyColor), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE, style->display() == NONE, style->textIndent(), style->direction(), style->unicodeBidi() == Override) : menuStyle();
 }
 
 Color RenderMenuList::itemBackgroundColor(unsigned listIndex) const
@@ -448,7 +455,7 @@ Color RenderMenuList::itemBackgroundColor(unsigned listIndex) const
 PopupMenuStyle RenderMenuList::menuStyle() const
 {
     RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style();
-    return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visitedDependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, s->display() == NONE, s->textIndent(), s->direction());
+    return PopupMenuStyle(s->visitedDependentColor(CSSPropertyColor), s->visitedDependentColor(CSSPropertyBackgroundColor), s->font(), s->visibility() == VISIBLE, s->display() == NONE, s->textIndent(), style()->direction(), style()->unicodeBidi() == Override);
 }
 
 HostWindow* RenderMenuList::hostWindow() const
diff --git a/Source/WebCore/rendering/RenderMenuList.h b/Source/WebCore/rendering/RenderMenuList.h
index b84b799..cd6e561 100644
--- a/Source/WebCore/rendering/RenderMenuList.h
+++ b/Source/WebCore/rendering/RenderMenuList.h
@@ -2,7 +2,7 @@
  * This file is part of the select element renderer in WebCore.
  *
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -132,6 +132,8 @@ private:
 
     int m_lastSelectedIndex;
 
+    RefPtr<RenderStyle> m_optionStyle;
+
     RefPtr<PopupMenu> m_popup;
     bool m_popupIsVisible;
 };
diff --git a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
index bd4d638..7372722 100644
--- a/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
+++ b/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
@@ -924,7 +924,7 @@ PopupMenuStyle RenderTextControlSingleLine::itemStyle(unsigned) const
 
 PopupMenuStyle RenderTextControlSingleLine::menuStyle() const
 {
-    return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE, style()->display() == NONE, style()->textIndent(), style()->direction());
+    return PopupMenuStyle(style()->visitedDependentColor(CSSPropertyColor), style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->font(), style()->visibility() == VISIBLE, style()->display() == NONE, style()->textIndent(), style()->direction(), style()->unicodeBidi() == Override);
 }
 
 int RenderTextControlSingleLine::clientInsetLeft() const
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog
index b789d0f..553ab78 100644
--- a/Source/WebKit/chromium/ChangeLog
+++ b/Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * src/AutoFillPopupMenuClient.cpp:
+        (WebKit::AutoFillPopupMenuClient::initialize): Pass hasTextDirectionOverride to the PopupMenuStyle
+        constructor.
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * src/ChromeClientImpl.h:
+        * tests/PopupMenuTest.cpp:
+        (WebKit::TestPopupMenuClient::itemStyle): Pass hasTextDirectionOverride to the PopupMenuStyle
+        constructor.
+
 2011-01-28  Adam Klein  <adamk at chromium.org>
 
         Reviewed by Kent Tamura.
diff --git a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
index 2ce31a9..d04c57c 100644
--- a/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
+++ b/Source/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
@@ -293,7 +293,7 @@ void AutoFillPopupMenuClient::initialize(
     // the input element: textField.
     m_regularStyle.set(new PopupMenuStyle(Color::black, Color::white, regularFont,
                                           true, false, Length(WebCore::Fixed),
-                                          textField->renderer()->style()->direction()));
+                                          textField->renderer()->style()->direction(), textField->renderer()->style()->unicodeBidi() == Override));
 
     FontDescription warningFontDescription = regularFont.fontDescription();
     warningFontDescription.setItalic(true);
@@ -305,7 +305,8 @@ void AutoFillPopupMenuClient::initialize(
                                           m_regularStyle->isVisible(),
                                           m_regularStyle->isDisplayNone(),
                                           m_regularStyle->textIndent(),
-                                          m_regularStyle->textDirection()));
+                                          m_regularStyle->textDirection(),
+                                          m_regularStyle->hasTextDirectionOverride()));
 }
 
 void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names,
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
index 0e40f1d..adea422 100644
--- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
@@ -853,6 +853,11 @@ bool ChromeClientImpl::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientImpl::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(PopupMenuClient* client) const
 {
     if (WebViewImpl::useExternalPopupMenus())
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h
index 07f7d1f..64335e8 100644
--- a/Source/WebKit/chromium/src/ChromeClientImpl.h
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.h
@@ -173,6 +173,7 @@ public:
     void setCursorForPlugin(const WebCursorInfo&);
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 
diff --git a/Source/WebKit/chromium/tests/PopupMenuTest.cpp b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
index 4c9a149..acfcda5 100644
--- a/Source/WebKit/chromium/tests/PopupMenuTest.cpp
+++ b/Source/WebKit/chromium/tests/PopupMenuTest.cpp
@@ -76,7 +76,7 @@ public:
     virtual PopupMenuStyle itemStyle(unsigned listIndex) const
     {
         Font font(FontPlatformData(12.0, false, false), false);
-        return PopupMenuStyle(Color::black, Color::white, font, true, false, Length(), TextDirection());
+        return PopupMenuStyle(Color::black, Color::white, font, true, false, Length(), TextDirection(), false /* has text direction override */);
     }
     virtual PopupMenuStyle menuStyle() const { return itemStyle(0); }
     virtual int clientInsetLeft() const { return 0; }
diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog
index 17072bc..e83d1ce 100644
--- a/Source/WebKit/efl/ChangeLog
+++ b/Source/WebKit/efl/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/ChromeClientEfl.cpp:
+        (WebCore::ChromeClientEfl::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/ChromeClientEfl.h:
+
 2011-01-27  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
index e9904c6..6425c39 100644
--- a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
+++ b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
@@ -532,6 +532,11 @@ bool ChromeClientEfl::selectItemWritingDirectionIsNatural()
     return true;
 }
 
+bool ChromeClientEfl::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientEfl::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuEfl(client));
diff --git a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
index a714dd4..7e4bf0b 100644
--- a/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
+++ b/Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
@@ -149,6 +149,7 @@ public:
     virtual void dispatchViewportDataDidChange(const ViewportArguments&) const;
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
     virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
 
diff --git a/Source/WebKit/gtk/ChangeLog b/Source/WebKit/gtk/ChangeLog
index 327cb48..ca5840e 100644
--- a/Source/WebKit/gtk/ChangeLog
+++ b/Source/WebKit/gtk/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/ChromeClientGtk.cpp:
+        (WebKit::ChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/ChromeClientGtk.h:
+
 2011-01-28  Alejandro G. Castro  <alex at igalia.com>
 
         Reviewed by Xan Lopez.
diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
index 04ee8ba..bbfdd72 100644
--- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
+++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
@@ -674,6 +674,11 @@ bool ChromeClient::selectItemWritingDirectionIsNatural()
     return true;
 }
 
+bool ChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<WebCore::PopupMenu> ChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuGtk(client));
diff --git a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
index d607c54..d525e82 100644
--- a/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
+++ b/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
@@ -137,6 +137,7 @@ namespace WebKit {
         virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
 
         virtual bool selectItemWritingDirectionIsNatural();
+        virtual bool selectItemAlignmentFollowsMenuWritingDirection();
         virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
         virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 #if ENABLE(VIDEO)
diff --git a/Source/WebKit/haiku/ChangeLog b/Source/WebKit/haiku/ChangeLog
index fdaafef..e63e23f 100644
--- a/Source/WebKit/haiku/ChangeLog
+++ b/Source/WebKit/haiku/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/ChromeClientHaiku.cpp:
+        (WebCore::ChromeClientHaiku::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/ChromeClientHaiku.h:
+
 2011-01-27  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp b/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp
index 01b9c1d..f1f42ea 100644
--- a/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp
+++ b/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.cpp
@@ -399,6 +399,11 @@ bool ChromeClientHaiku::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientHaiku::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientHaiku::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuHaiku(client));
diff --git a/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h b/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h
index deb3678..59d4b28 100644
--- a/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h
+++ b/Source/WebKit/haiku/WebCoreSupport/ChromeClientHaiku.h
@@ -133,6 +133,7 @@ namespace WebCore {
 #endif
 
         virtual bool selectItemWritingDirectionIsNatural();
+        virtual bool selectItemAlignmentFollowsMenuWritingDirection();
         virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
         virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
 
diff --git a/Source/WebKit/mac/ChangeLog b/Source/WebKit/mac/ChangeLog
index 0e5329b..375959e 100644
--- a/Source/WebKit/mac/ChangeLog
+++ b/Source/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/WebChromeClient.h:
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::selectItemWritingDirectionIsNatural): Changed to return false.
+        (WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added. Returns true.
+
 2011-01-27  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r76891.
diff --git a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
index 05db524..ea306b2 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
+++ b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
@@ -179,6 +179,7 @@ public:
     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { }
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 
diff --git a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
index a5fd71a..0e7e2f2 100644
--- a/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
+++ b/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
@@ -749,7 +749,20 @@ void WebChromeClient::formDidBlur(const WebCore::Node* node)
 
 bool WebChromeClient::selectItemWritingDirectionIsNatural()
 {
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+    return false;
+#else
     return true;
+#endif
+}
+
+bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
+{
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+    return true;
+#else
+    return false;
+#endif
 }
 
 PassRefPtr<WebCore::PopupMenu> WebChromeClient::createPopupMenu(WebCore::PopupMenuClient* client) const
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index e2e22a5..08cb035 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/ChromeClientQt.h:
+
 2011-01-27  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index acb136a..5a51b63 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -736,6 +736,11 @@ bool ChromeClientQt::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientQt::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuQt(client, this));
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index d8c2f57..e59f6ae 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -189,6 +189,7 @@ namespace WebCore {
         virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
 
         virtual bool selectItemWritingDirectionIsNatural();
+        virtual bool selectItemAlignmentFollowsMenuWritingDirection();
         virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
         virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
         virtual void populateVisitedLinks();
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog
index b92bbb3..26cf0c5 100644
--- a/Source/WebKit/win/ChangeLog
+++ b/Source/WebKit/win/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/WebChromeClient.cpp:
+        (WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/WebChromeClient.h:
+
 2011-01-27  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
index f5cce4e..47ca713 100644
--- a/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
+++ b/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
@@ -862,6 +862,11 @@ bool WebChromeClient::selectItemWritingDirectionIsNatural()
     return true;
 }
 
+bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> WebChromeClient::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuWin(client));
diff --git a/Source/WebKit/win/WebCoreSupport/WebChromeClient.h b/Source/WebKit/win/WebCoreSupport/WebChromeClient.h
index b6c2525..15118b5 100644
--- a/Source/WebKit/win/WebCoreSupport/WebChromeClient.h
+++ b/Source/WebKit/win/WebCoreSupport/WebChromeClient.h
@@ -175,6 +175,7 @@ public:
 #endif
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 
diff --git a/Source/WebKit/wince/ChangeLog b/Source/WebKit/wince/ChangeLog
index 87ca29e..4541a90 100644
--- a/Source/WebKit/wince/ChangeLog
+++ b/Source/WebKit/wince/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebCoreSupport/ChromeClientWinCE.cpp:
+        (WebKit::ChromeClientWinCE::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebCoreSupport/ChromeClientWinCE.h:
+
 2011-01-25  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Adam Roben.
diff --git a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp
index 659d246..a8604c1 100644
--- a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp
+++ b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.cpp
@@ -390,6 +390,11 @@ bool ChromeClientWinCE::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientWinCE::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientWinCE::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuWin(client));
diff --git a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
index 4e7fb28..11588af 100644
--- a/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
+++ b/Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
@@ -174,6 +174,7 @@ public:
 #endif
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 
diff --git a/Source/WebKit/wx/ChangeLog b/Source/WebKit/wx/ChangeLog
index 5face2c..e39a686 100644
--- a/Source/WebKit/wx/ChangeLog
+++ b/Source/WebKit/wx/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * WebKitSupport/ChromeClientWx.cpp:
+        (WebCore::ChromeClientWx::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebKitSupport/ChromeClientWx.h:
+
 2011-01-27  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Adam Barth.
diff --git a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
index c89bb17..026d8a6 100644
--- a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
+++ b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
@@ -476,6 +476,11 @@ bool ChromeClientWx::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientWx::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientWx::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuWx(client));
diff --git a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h
index 2ccad43..c1aeab0 100644
--- a/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h
+++ b/Source/WebKit/wx/WebKitSupport/ChromeClientWx.h
@@ -149,6 +149,7 @@ public:
     virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) { }
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
     virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
 
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 0b63c73..bbab997 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2011-01-28  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <select> can't display right-to-left (rtl) languages
+        https://bugs.webkit.org/show_bug.cgi?id=19785
+
+        * Shared/WebPopupItem.cpp:
+        (WebKit::WebPopupItem::WebPopupItem): Added initializers for m_textDirection and m_hasTextDirectionOverride.
+        (WebKit::WebPopupItem::encode): Encode the item's writing direction and direction override values.
+        (WebKit::WebPopupItem::decode): Decode the item's writing direction and direction override values.
+        * Shared/WebPopupItem.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::showPopupMenu): Added a parameter for the menu's text direction.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in: Ditto.
+        * UIProcess/WebPopupMenuProxy.h:
+        * UIProcess/mac/WebPopupMenuProxyMac.h:
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::populate): Added a parameter for the menu's text direction.
+        Set items' text alignment to match the menu's writing direction. Set items' writing direction
+        and direction override according to their styles.
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu): Set the pop-up's layout direction.
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::selectItemWritingDirectionIsNatural): Changed to return false.
+        (WebKit::WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection): Added.
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/WebPopupMenu.cpp:
+        (WebKit::WebPopupMenu::populateItems): Initialize items' writing direction and direction override
+        values.
+        (WebKit::WebPopupMenu::show): Pass the menu's writing direction.
+
 2011-01-28  Anders Carlsson  <andersca at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/Source/WebKit2/Shared/WebPopupItem.cpp b/Source/WebKit2/Shared/WebPopupItem.cpp
index d9a7cb1..a9ac032 100644
--- a/Source/WebKit2/Shared/WebPopupItem.cpp
+++ b/Source/WebKit2/Shared/WebPopupItem.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,24 +30,32 @@
 #include "ArgumentCoders.h"
 #include "Arguments.h"
 
+using namespace WebCore;
+
 namespace WebKit {
 
 WebPopupItem::WebPopupItem()
     : m_type(Item)
+    , m_textDirection(LTR)
+    , m_hasTextDirectionOverride(false)
     , m_isEnabled(true)
 {
 }
 
 WebPopupItem::WebPopupItem(Type type)
     : m_type(type)
+    , m_textDirection(LTR)
+    , m_hasTextDirectionOverride(false)
     , m_isEnabled(true)
     , m_isLabel(false)
 {
 }
 
-WebPopupItem::WebPopupItem(Type type, const String& text, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel)
+WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel)
     : m_type(type)
     , m_text(text)
+    , m_textDirection(textDirection)
+    , m_hasTextDirectionOverride(hasTextDirectionOverride)
     , m_toolTip(toolTip)
     , m_accessibilityText(accessibilityText)
     , m_isEnabled(isEnabled)
@@ -57,21 +65,23 @@ WebPopupItem::WebPopupItem(Type type, const String& text, const String& toolTip,
 
 void WebPopupItem::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), m_text, m_toolTip, m_accessibilityText, m_isEnabled, m_isLabel));
+    encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), m_text, static_cast<uint64_t>(m_textDirection), m_hasTextDirectionOverride, m_toolTip, m_accessibilityText, m_isEnabled, m_isLabel));
 }
 
 bool WebPopupItem::decode(CoreIPC::ArgumentDecoder* decoder, WebPopupItem& item)
 {
     uint32_t type;
     String text;
+    uint64_t textDirection;
+    bool hasTextDirectionOverride;
     String toolTip;
     String accessibilityText;
     bool isEnabled;
     bool isLabel;
-    if (!decoder->decode(CoreIPC::Out(type, text, toolTip, accessibilityText, isEnabled, isLabel)))
+    if (!decoder->decode(CoreIPC::Out(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel)))
         return false;
 
-    item = WebPopupItem(static_cast<Type>(type), text, toolTip, accessibilityText, isEnabled, isLabel);
+    item = WebPopupItem(static_cast<Type>(type), text, static_cast<TextDirection>(textDirection), hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel);
     return true;
 }
 
diff --git a/Source/WebKit2/Shared/WebPopupItem.h b/Source/WebKit2/Shared/WebPopupItem.h
index c6874f8..85495a3 100644
--- a/Source/WebKit2/Shared/WebPopupItem.h
+++ b/Source/WebKit2/Shared/WebPopupItem.h
@@ -26,6 +26,7 @@
 #ifndef WebPopupItem_h
 #define WebPopupItem_h
 
+#include <WebCore/TextDirection.h>
 #include <wtf/text/WTFString.h>
 
 namespace CoreIPC {
@@ -43,13 +44,15 @@ struct WebPopupItem {
 
     WebPopupItem();
     WebPopupItem(Type);
-    WebPopupItem(Type, const String& text, const String& toolTip, const String& accessibilityText, bool isEnabled, bool m_isLabel);
+    WebPopupItem(Type, const String& text, WebCore::TextDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool m_isLabel);
 
     void encode(CoreIPC::ArgumentEncoder*) const;
     static bool decode(CoreIPC::ArgumentDecoder*, WebPopupItem&);
 
     Type m_type;
     String m_text;
+    WebCore::TextDirection m_textDirection;
+    bool m_hasTextDirectionOverride;
     String m_toolTip;
     String m_accessibilityText;
     bool m_isEnabled;
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
index c756d2a..7e31882 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -1860,7 +1860,7 @@ void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index
     process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
 }
 
-void WebPageProxy::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
+void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
 {
     if (m_activePopupMenu)
         m_activePopupMenu->hidePopupMenu();
@@ -1872,7 +1872,7 @@ void WebPageProxy::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>
     process()->responsivenessTimer()->stop();
 #endif
 
-    m_activePopupMenu->showPopupMenu(rect, items, data, selectedIndex);
+    m_activePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), items, data, selectedIndex);
     m_activePopupMenu = 0;
 }
 
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h
index d0613ac..197f31c 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.h
+++ b/Source/WebKit2/UIProcess/WebPageProxy.h
@@ -493,7 +493,7 @@ private:
     void didFailToFindString(const String&);
 
     // Popup Menu.
-    void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData&);
+    void showPopupMenu(const WebCore::IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData&);
     void hidePopupMenu();
 
     // Context Menu.
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in
index a48ca8f..ef87728 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -153,7 +153,7 @@ messages -> WebPageProxy {
     DidFailToFindString(WTF::String string)
 
     # PopupMenu messages
-    ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
+    ShowPopupMenu(WebCore::IntRect rect, uint64_t textDirection, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
     HidePopupMenu()
     
     # ContextMenu messages
diff --git a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
index fd84928..fd86b15 100644
--- a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
+++ b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
 #ifndef WebPopupMenuProxy_h
 #define WebPopupMenuProxy_h
 
+#include <WebCore/TextDirection.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
@@ -56,7 +57,7 @@ public:
     {
     }
 
-    virtual void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex) = 0;
+    virtual void showPopupMenu(const WebCore::IntRect& rect, WebCore::TextDirection, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex) = 0;
     virtual void hidePopupMenu() = 0;
 
 protected:
diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
index 85339d6..3c4902c 100644
--- a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
@@ -49,13 +49,13 @@ public:
     }
     ~WebPopupMenuProxyMac();
 
-    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
     virtual void hidePopupMenu();
 
 private:
     WebPopupMenuProxyMac(WKView*, WebPopupMenuProxy::Client* client);
 
-    void populate(const Vector<WebPopupItem>&);
+    void populate(const Vector<WebPopupItem>&, WebCore::TextDirection);
 
     RetainPtr<NSPopUpButtonCell> m_popup;
     WKView* m_webView;
diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
index 355c115..095542c 100644
--- a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,7 +47,7 @@ WebPopupMenuProxyMac::~WebPopupMenuProxyMac()
         [m_popup.get() setControlView:nil];
 }
 
-void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items)
+void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items, TextDirection menuTextDirection)
 {
     if (m_popup)
         [m_popup.get() removeAllItems];
@@ -64,20 +64,37 @@ void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items)
             [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]];
         else {
             [m_popup.get() addItemWithTitle:@""];
-            NSMenuItem* menuItem = [m_popup.get() lastItem];
-            [menuItem setTitle:nsStringFromWebCoreString(items[i].m_text)];
+            NSMenuItem *menuItem = [m_popup.get() lastItem];
+
+            RetainPtr<NSMutableParagraphStyle> paragraphStyle(AdoptNS, [[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
+            NSWritingDirection writingDirection = items[i].m_textDirection == LTR ? NSWritingDirectionLeftToRight : NSWritingDirectionRightToLeft;
+            [paragraphStyle.get() setBaseWritingDirection:writingDirection];
+            [paragraphStyle.get() setAlignment:menuTextDirection == LTR ? NSLeftTextAlignment : NSRightTextAlignment];
+            RetainPtr<NSMutableDictionary> attributes(AdoptNS, [[NSMutableDictionary alloc] initWithObjectsAndKeys:
+                paragraphStyle.get(), NSParagraphStyleAttributeName,
+                [m_popup.get() font], NSFontAttributeName,
+            nil]);
+            if (items[i].m_hasTextDirectionOverride) {
+                RetainPtr<NSNumber> writingDirectionValue(AdoptNS, [[NSNumber alloc] initWithInteger:writingDirection + NSTextWritingDirectionOverride]);
+                RetainPtr<NSArray> writingDirectionArray(AdoptNS, [[NSArray alloc] initWithObjects:writingDirectionValue.get(), nil]);
+                [attributes.get() setObject:writingDirectionArray.get() forKey:NSWritingDirectionAttributeName];
+            }
+            RetainPtr<NSAttributedString> string(AdoptNS, [[NSAttributedString alloc] initWithString:nsStringFromWebCoreString(items[i].m_text) attributes:attributes.get()]);
+
+            [menuItem setAttributedTitle:string.get()];
             [menuItem setEnabled:items[i].m_isEnabled];
             [menuItem setToolTip:nsStringFromWebCoreString(items[i].m_toolTip)];
         }
     }
 }
 
-void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
+void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection textDirection, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
 {
-    populate(items);
+    populate(items, textDirection);
 
     [m_popup.get() attachPopUpWithFrame:rect inView:m_webView];
     [m_popup.get() selectItemAtIndex:selectedIndex];
+    [m_popup.get() setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
 
     NSMenu* menu = [m_popup.get() menu];
 
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
index 1b44265..a79cc3c 100644
--- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -42,7 +42,7 @@ WebPopupMenuProxyQt::~WebPopupMenuProxyQt()
 {
 }
 
-void WebPopupMenuProxyQt::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
+void WebPopupMenuProxyQt::showPopupMenu(const IntRect& rect, WebCore::TextDirection, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
 {
 }
 
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
index e6c7a1e..f41432c 100644
--- a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
@@ -38,7 +38,7 @@ public:
     }
     ~WebPopupMenuProxyQt();
 
-    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
     virtual void hidePopupMenu();
 
 private:
diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
index 989a04f..18f8ade 100644
--- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
@@ -188,7 +188,7 @@ WebPopupMenuProxyWin::~WebPopupMenuProxyWin()
         m_scrollbar->setParent(0);
 }
 
-void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
+void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, TextDirection, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
 {
     m_items = items;
     m_data = data;
diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
index d1dc466..2d09bb9 100644
--- a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
@@ -48,7 +48,7 @@ public:
     }
     ~WebPopupMenuProxyWin();
 
-    virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+    virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
     virtual void hidePopupMenu();
 
     void hide() { hidePopupMenu(); }
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
index d48e8c8..30b3287 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
@@ -612,6 +612,11 @@ void WebChromeClient::formDidBlur(const Node*)
 
 bool WebChromeClient::selectItemWritingDirectionIsNatural()
 {
+    return false;
+}
+
+bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
+{
     return true;
 }
 
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
index d749833..40d6c6a 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
@@ -175,6 +175,7 @@ private:
     virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks();
 
     virtual bool selectItemWritingDirectionIsNatural();
+    virtual bool selectItemAlignmentFollowsMenuWritingDirection();
     virtual PassRefPtr<WebCore::PopupMenu> createPopupMenu(WebCore::PopupMenuClient*) const;
     virtual PassRefPtr<WebCore::SearchPopupMenu> createSearchPopupMenu(WebCore::PopupMenuClient*) const;
 
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
index 709063c..7242d4f 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebPopupMenu.cpp
@@ -86,7 +86,8 @@ Vector<WebPopupItem> WebPopupMenu::populateItems()
             // FIXME: Add support for styling the font.
             // FIXME: Add support for styling the foreground and background colors.
             // FIXME: Find a way to customize text color when an item is highlighted.
-            items.append(WebPopupItem(WebPopupItem::Item, m_popupClient->itemText(i), m_popupClient->itemToolTip(i), m_popupClient->itemAccessibilityText(i), m_popupClient->itemIsEnabled(i), m_popupClient->itemIsLabel(i)));
+            PopupMenuStyle itemStyle = m_popupClient->itemStyle(i);
+            items.append(WebPopupItem(WebPopupItem::Item, m_popupClient->itemText(i), itemStyle.textDirection(), itemStyle.hasTextDirectionOverride(), m_popupClient->itemToolTip(i), m_popupClient->itemAccessibilityText(i), m_popupClient->itemIsEnabled(i), m_popupClient->itemIsLabel(i)));
         }
     }
 
@@ -111,7 +112,7 @@ void WebPopupMenu::show(const IntRect& rect, FrameView* view, int index)
     PlatformPopupMenuData platformData;
     setUpPlatformData(pageCoordinates, platformData);
 
-    WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowPopupMenu(pageCoordinates, items, index, platformData), m_page->pageID());
+    WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowPopupMenu(pageCoordinates, m_popupClient->menuStyle().textDirection(), items, index, platformData), m_page->pageID());
 }
 
 void WebPopupMenu::hide()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list