Changeset 21900 in webkit


Ignore:
Timestamp:
May 30, 2007 12:16:19 PM (17 years ago)
Author:
bdash
Message:

2007-05-30 Mitz Pettel <mitz@webkit.org>

Reviewed by Darin.

Test: fast/forms/select-writing-direction-natural.html

  • platform/PopupMenu.h: Added the static method itemWritingDirectionIsNatural which says whether items in the popup ignore the CSS text-align and direction properties and instead are left-aligned and use natural writing direction.
  • platform/gdk/PopupMenuGdk.cpp: (WebCore::PopupMenu::itemWritingDirectionIsNatural):
  • platform/mac/PopupMenuMac.mm: (WebCore::PopupMenu::itemWritingDirectionIsNatural):
  • platform/qt/PopupMenuQt.cpp: (WebCore::PopupMenu::itemWritingDirectionIsNatural):
  • platform/win/TemporaryLinkStubs.cpp: (WebCore::PopupMenu::itemWritingDirectionIsNatural):
  • platform/wx/TemporaryLinkStubs.cpp: (PopupMenu::itemWritingDirectionIsNatural):
  • rendering/RenderMenuList.cpp: (WebCore::textDirectionForParagraph): Added this helper function that uses the Unicode Bidi Algorithm rules P2 and P3 to determine the writing direction of text. (WebCore::RenderMenuList::adjustInnerStyle): Made the alignment and direction adjustment conditional on the popup implementation. (WebCore::RenderMenuList::setText): Added call to adjustInnerStyle() since the style depends on the text when natural writing direction is used.

2007-05-30 Mitz Pettel <mitz@webkit.org>

Reviewed by Darin.

  • fast/forms/select-writing-direction-natural-expected.checksum: Added.
  • fast/forms/select-writing-direction-natural-expected.png: Added.
  • fast/forms/select-writing-direction-natural-expected.txt: Added.
  • fast/forms/select-writing-direction-natural.html: Added.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r21899 r21900  
     12007-05-30  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=13775
     6          REGRESSION: Popup button text should use "natural" directionality to match the items in the popup menu
     7
     8        * fast/forms/select-writing-direction-natural-expected.checksum: Added.
     9        * fast/forms/select-writing-direction-natural-expected.png: Added.
     10        * fast/forms/select-writing-direction-natural-expected.txt: Added.
     11        * fast/forms/select-writing-direction-natural.html: Added.
     12
    1132007-05-30  Mitz Pettel  <mitz@webkit.org>
    214
  • trunk/WebCore/ChangeLog

    r21897 r21900  
     12007-05-30  Mitz Pettel  <mitz@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=13775
     6          REGRESSION: Popup button text should use "natural" directionality to match the items in the popup menu
     7
     8        Test: fast/forms/select-writing-direction-natural.html
     9
     10        * platform/PopupMenu.h: Added the static method itemWritingDirectionIsNatural
     11        which says whether items in the popup ignore the CSS text-align and direction
     12        properties and instead are left-aligned and use natural writing direction.
     13        * platform/gdk/PopupMenuGdk.cpp:
     14        (WebCore::PopupMenu::itemWritingDirectionIsNatural):
     15        * platform/mac/PopupMenuMac.mm:
     16        (WebCore::PopupMenu::itemWritingDirectionIsNatural):
     17        * platform/qt/PopupMenuQt.cpp:
     18        (WebCore::PopupMenu::itemWritingDirectionIsNatural):
     19        * platform/win/TemporaryLinkStubs.cpp:
     20        (WebCore::PopupMenu::itemWritingDirectionIsNatural):
     21        * platform/wx/TemporaryLinkStubs.cpp:
     22        (PopupMenu::itemWritingDirectionIsNatural):
     23        * rendering/RenderMenuList.cpp:
     24        (WebCore::textDirectionForParagraph): Added this helper function that uses
     25        the Unicode Bidi Algorithm rules P2 and P3 to determine the writing direction
     26        of text.
     27        (WebCore::RenderMenuList::adjustInnerStyle): Made the alignment and direction
     28        adjustment conditional on the popup implementation.
     29        (WebCore::RenderMenuList::setText): Added call to adjustInnerStyle() since
     30        the style depends on the text when natural writing direction is used.
     31
    1322007-05-30  Timothy Hatcher  <timothy@apple.com>
    233
  • trunk/WebCore/platform/PopupMenu.h

    r20761 r21900  
    6969   
    7070    PopupMenuClient* client() const { return m_popupClient; }
     71
     72    static bool itemWritingDirectionIsNatural();
    7173
    7274#if PLATFORM(WIN)
  • trunk/WebCore/platform/gdk/PopupMenuGdk.cpp

    r21827 r21900  
    5656}
    5757
     58bool PopupMenu::itemWritingDirectionIsNatural()
     59{
     60    return false;
    5861}
    5962
     63}
     64
  • trunk/WebCore/platform/mac/PopupMenuMac.mm

    r21463 r21900  
    185185}
    186186
     187bool PopupMenu::itemWritingDirectionIsNatural()
     188{
     189    return true;
    187190}
     191
     192}
  • trunk/WebCore/platform/qt/PopupMenuQt.cpp

    r21827 r21900  
    106106}
    107107
     108bool PopupMenu::itemWritingDirectionIsNatural()
     109{
     110    return false;
     111}
     112
    108113}
    109114
  • trunk/WebCore/platform/win/TemporaryLinkStubs.cpp

    r21827 r21900  
    330330void PopupMenu::hide() { notImplemented(); }
    331331void PopupMenu::updateFromElement() { notImplemented(); }
     332bool PopupMenu::itemWritingDirectionIsNatural() { notImplemented(); return false; }
    332333
    333334void RenderThemeWin::systemFont(int propId, FontDescription& fontDescription) const { notImplemented(); }
  • trunk/WebCore/platform/wx/TemporaryLinkStubs.cpp

    r21827 r21900  
    191191void PopupMenu::hide() { notImplemented(); }
    192192void PopupMenu::updateFromElement() { notImplemented(); }
     193bool PopupMenu::itemWritingDirectionIsNatural() { notImplemented(); return false; }
    193194
    194195Icon::Icon() { notImplemented(); }
  • trunk/WebCore/rendering/RenderMenuList.cpp

    r21544 r21900  
    7777}
    7878
     79// Determines the writing direction using the Unicode Bidi Algorithm rules P2 and P3.
     80static TextDirection textDirectionForParagraph(StringImpl* paragraph)
     81{
     82    int length = paragraph->length();
     83    for (int i = 0; i < length; ++i) {
     84        WTF::Unicode::Direction charDirection = WTF::Unicode::direction((*paragraph)[i]);
     85        if (charDirection == WTF::Unicode::LeftToRight)
     86            return LTR;
     87        if (charDirection == WTF::Unicode::RightToLeft || charDirection == WTF::Unicode::RightToLeftArabic)
     88            return RTL;
     89    }
     90    return LTR;
     91}
     92
    7993void RenderMenuList::adjustInnerStyle()
    8094{
    8195    m_innerBlock->style()->setBoxFlex(1.0f);
    82     m_innerBlock->style()->setDirection(LTR);
    83     m_innerBlock->style()->setTextAlign(LEFT);
     96
     97    if (PopupMenu::itemWritingDirectionIsNatural()) {
     98        // Items in the popup will not respect the CSS text-align and direction properties,
     99        // so we must adjust our own style to match.
     100        m_innerBlock->style()->setTextAlign(LEFT);
     101        TextDirection direction = m_buttonText ? textDirectionForParagraph(m_buttonText->text()) : LTR;
     102        m_innerBlock->style()->setDirection(direction);
     103    }
    84104}
    85105
     
    190210            addChild(m_buttonText);
    191211        }
     212        adjustInnerStyle();
    192213    }
    193214}
Note: See TracChangeset for help on using the changeset viewer.