Skip to content
  • mitz@apple.com's avatar
    Source/WebCore: <rdar://problem/4761512> <select> can't display right-to-left (rtl) languages · 07c9c84c
    mitz@apple.com authored
    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
    07c9c84c