Changeset 87137 in webkit


Ignore:
Timestamp:
May 24, 2011 2:02:49 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-05-24 Naoki Takano <takano.naoki@gmail.com>

Reviewed by Kent Tamura.

[Chromium]Add clipping for listBox in popup window to fix wrong location display when the autofill item is really long.
https://bugs.webkit.org/show_bug.cgi?id=61252
http://code.google.com/p/chromium/issues/detail?id=83539

Manual test: manual-tests/autofill-popup-location.html.

  • manual-tests/autofill-popup-location.html: With long long text, test the shown location is correct.
  • platform/chromium/PopupMenuChromium.cpp: (WebCore::PopupListBox::setBaseWidth): Clip width with m_maxWindowWidth. (WebCore::PopupListBox::PopupListBox): Add m_maxWindowWidth initialization. (WebCore::PopupContainer::layoutAndCalculateWidgetRect): Call setMaxWidthAndLayout() when the width is clipped with screen size. (WebCore::PopupListBox::setMaxWidthAndLayout): Set m_maxWindowWidth and call layout(). (WebCore::PopupListBox::layout): Compare renewed windowWidth and m_maxWindowWidth, and clip the it.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87136 r87137  
     12011-05-24  Naoki Takano  <takano.naoki@gmail.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        [Chromium]Add clipping for listBox in popup window to fix wrong location display when the autofill item is really long.
     6        https://bugs.webkit.org/show_bug.cgi?id=61252
     7        http://code.google.com/p/chromium/issues/detail?id=83539
     8
     9        Manual test: manual-tests/autofill-popup-location.html.
     10
     11        * manual-tests/autofill-popup-location.html: With long long text, test the shown location is correct.
     12        * platform/chromium/PopupMenuChromium.cpp:
     13        (WebCore::PopupListBox::setBaseWidth): Clip width with m_maxWindowWidth.
     14        (WebCore::PopupListBox::PopupListBox): Add m_maxWindowWidth initialization.
     15        (WebCore::PopupContainer::layoutAndCalculateWidgetRect): Call setMaxWidthAndLayout() when the width is clipped with screen size.
     16        (WebCore::PopupListBox::setMaxWidthAndLayout): Set m_maxWindowWidth and call layout().
     17        (WebCore::PopupListBox::layout): Compare renewed windowWidth and m_maxWindowWidth, and clip the it.
     18
    1192011-05-24  James Robinson  <jamesr@chromium.org>
    220
  • trunk/Source/WebCore/manual-tests/autofill-popup-location.html

    r83237 r87137  
    1717    <br>
    1818    <form><input name=q autofocus></form>
     19
     20    <ol>
     21      <li> Type the text 'This is really long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text.' in the following text input area. And press ENTER to submit.</li>
     22      <li>Return to this page</li>
     23      <li> Press 'T' and make sure the input text is shown in autofill popup window and it exceeds the width of screen. If your display resolution is very high, and the while text fits in the window, please fill more characters and try again till the text exceeds the width.
     24      <li> Type the text 'This is short text.' in the following text input area. And press ENTER to submit.</li>
     25      <li> Press 't' and make sure the input text which you typed in is displayed in autofill popup window.</li>
     26      <li> Press 'h' and make sure the popup window location is correct.</li>
     27      <li> Press arrow key down and make sure the popup window text is not broken.</li>
     28    </ol>
     29    <br>
     30    <form><input name=p></form>
    1931  </body>
    2032</html>
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp

    r85143 r87137  
    134134    int numItems() const { return static_cast<int>(m_items.size()); }
    135135
    136     void setBaseWidth(int width) { m_baseWidth = width; }
     136    void setBaseWidth(int width) { m_baseWidth = min(m_maxWindowWidth, width); }
    137137
    138138    // Computes the size of widget and children.
     
    146146
    147147    void setMaxHeight(int maxHeight) { m_maxHeight = maxHeight; }
     148
     149    void setMaxWidthAndLayout(int);
    148150
    149151    void disconnectClient() { m_popupClient = 0; }
     
    166168        , m_repeatingChar(0)
    167169        , m_lastCharTime(0)
     170        , m_maxWindowWidth(std::numeric_limits<int>::max())
    168171    {
    169172        setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
     
    272275    // The last time the user hit a key.  Used for typeAheadFind.
    273276    TimeStamp m_lastCharTime;
     277
     278    // If width exeeds screen width, we have to clip it.
     279    int m_maxWindowWidth;
    274280};
    275281
     
    356362        // If we have multiple screens and the browser rect is in one screen, we have
    357363        // to clip the window width to the screen width.
     364        // When clipping, we also need to set a maximum width for the list box.
    358365        FloatRect windowRect = chromeClient->windowRect();
    359366        if (windowRect.x() >= screen.x() && windowRect.maxX() <= screen.maxX()) {
     
    361368                widgetRect.setWidth(widgetRect.maxX() - screen.x());
    362369                widgetRect.setX(screen.x());
    363             } else if (widgetRect.maxX() > screen.maxX())
     370                listBox()->setMaxWidthAndLayout(max(widgetRect.width() - kBorderSize * 2, 0));
     371            } else if (widgetRect.maxX() > screen.maxX()) {
    364372                widgetRect.setWidth(screen.maxX() - widgetRect.x());
     373                listBox()->setMaxWidthAndLayout(max(widgetRect.width() - kBorderSize * 2, 0));
     374            }
    365375        }
    366376
     
    12841294}
    12851295
     1296void PopupListBox::setMaxWidthAndLayout(int maxWidth)
     1297{
     1298    m_maxWindowWidth = maxWidth;
     1299    layout();
     1300}
     1301
    12861302void PopupListBox::layout()
    12871303{
     
    13631379    } else {
    13641380        windowWidth = baseWidth + scrollbarWidth + paddingWidth;
    1365         contentWidth = baseWidth + paddingWidth;
     1381        if (windowWidth > m_maxWindowWidth) {
     1382            // windowWidth exceeds m_maxWindowWidth, so we have to clip.
     1383            windowWidth = m_maxWindowWidth;
     1384            baseWidth = windowWidth - scrollbarWidth - paddingWidth;
     1385            m_baseWidth = baseWidth;
     1386        }
     1387        contentWidth = windowWidth - scrollbarWidth;
    13661388
    13671389        if (windowWidth < m_baseWidth) {
Note: See TracChangeset for help on using the changeset viewer.