Changeset 75982 in webkit


Ignore:
Timestamp:
Jan 17, 2011 4:44:20 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-01-17 Naoki Takano <takano.naoki@gmail.com>

Reviewed by Kent Tamura.

[Chromium] Fix popup menu re-positioning when the menu is opened upward, above the corresponding form field.
https://bugs.webkit.org/show_bug.cgi?id=51382
http://crbug.com/60427

Calculate correct location of popup window whenever the items in the window change.

No new tests, because this fix is for Chromium project and hard to test only in WebKit project

  • platform/chromium/PopupMenuChromium.cpp: (WebCore::PopupContainer::layoutAndCalculateWidgetRect): New Function to layout and calculate popup widget rect. (WebCore::PopupContainer::showPopup): Move widgetRect calculation logic to calculateWidgetRect(). (WebCore::PopupContainer::refresh): Add parameter focusRect to take the location and the size of focus text input field to calculate correct popup window location.
  • platform/chromium/PopupMenuChromium.h: Append new input parameter for refresh().

2011-01-17 Naoki Takano <takano.naoki@gmail.com>

Reviewed by Kent Tamura.

[Chromium] Fix popup menu re-positioning when the menu is opened upward, above the corresponding form field.
https://bugs.webkit.org/show_bug.cgi?id=51382
http://crbug.com/60427

Calculate correct location of popup window whenever the items in the window change.

No new tests, because this fix is for Chromium project and hard to test only in WebKit project

  • WebKit/chromium/src/WebViewImpl.cpp: (WebKit::WebViewImpl::refreshAutoFillPopup): Change the logic in refreshAutoFilPopup() to check both the location and the size of popup window.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r75976 r75982  
     12011-01-17  Naoki Takano  <takano.naoki@gmail.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        [Chromium] Fix popup menu re-positioning when the menu is opened upward, above the corresponding form field.
     6        https://bugs.webkit.org/show_bug.cgi?id=51382
     7        http://crbug.com/60427
     8
     9        Calculate correct location of popup window whenever the items in the window change.
     10
     11        No new tests, because this fix is for Chromium project and hard to test only in WebKit project
     12
     13        * platform/chromium/PopupMenuChromium.cpp:
     14        (WebCore::PopupContainer::layoutAndCalculateWidgetRect): New Function to layout and calculate popup widget rect.
     15        (WebCore::PopupContainer::showPopup): Move widgetRect calculation logic to calculateWidgetRect().
     16        (WebCore::PopupContainer::refresh): Add parameter focusRect to take the location and the size of focus text input field to calculate correct popup window location.
     17        * platform/chromium/PopupMenuChromium.h: Append new input parameter for refresh().
     18
    1192011-01-17  Mark Rowe  <mrowe@apple.com>
    220
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp

    r72403 r75982  
    330330}
    331331
    332 void PopupContainer::showPopup(FrameView* view)
    333 {
    334     // Pre-layout, our size matches the <select> dropdown control.
    335     int selectHeight = frameRect().height();
    336 
     332IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate)
     333{
    337334    // Reset the max height to its default value, it will be recomputed below
    338335    // if necessary.
     
    342339    // WidgetClient about it.  It should assign us a client.
    343340    layout();
    344 
    345     m_frameView = view;
     341 
     342    // Assume m_listBox size is already calculated.
     343    IntSize targetSize(m_listBox->width() + kBorderSize * 2,
     344                       m_listBox->height() + kBorderSize * 2);
     345
     346    IntRect widgetRect;
    346347    ChromeClientChromium* chromeClient = chromeClientChromium();
    347348    if (chromeClient) {
    348349        // If the popup would extend past the bottom of the screen, open upwards
    349350        // instead.
    350         FloatRect screen = screenAvailableRect(view);
    351         IntRect widgetRect = chromeClient->windowToScreen(frameRect());
    352 
     351        FloatRect screen = screenAvailableRect(m_frameView.get());
     352        widgetRect = chromeClient->windowToScreen(IntRect(popupInitialCoordinate, targetSize));
    353353        if (widgetRect.bottom() > static_cast<int>(screen.bottom())) {
    354             if (widgetRect.y() - widgetRect.height() - selectHeight > 0) {
     354            if (widgetRect.y() - widgetRect.height() - targetControlHeight > 0) {
    355355                // There is enough room to open upwards.
    356                 widgetRect.move(0, -(widgetRect.height() + selectHeight));
     356                widgetRect.move(0, -(widgetRect.height() + targetControlHeight));
    357357            } else {
    358358                // Figure whether upwards or downwards has more room and set the
    359359                // maximum number of items.
    360                 int spaceAbove = widgetRect.y() - selectHeight;
     360                int spaceAbove = widgetRect.y() - targetControlHeight;
    361361                int spaceBelow = screen.bottom() - widgetRect.y();
    362362                if (spaceAbove > spaceBelow)
     
    369369                // And move upwards if necessary.
    370370                if (spaceAbove > spaceBelow)
    371                     widgetRect.move(0, -(widgetRect.height() + selectHeight));
     371                    widgetRect.move(0, -(widgetRect.height() + targetControlHeight));
    372372            }
    373373        }
    374         chromeClient->popupOpened(this, widgetRect, false);
     374    }
     375    return widgetRect;
     376}
     377
     378void PopupContainer::showPopup(FrameView* view)
     379{
     380    m_frameView = view;
     381
     382    ChromeClientChromium* chromeClient = chromeClientChromium();
     383    if (chromeClient) {
     384        IntRect popupRect = frameRect();
     385        chromeClient->popupOpened(this, layoutAndCalculateWidgetRect(popupRect.height(), popupRect.location()), false);
    375386        m_popupOpen = true;
    376387    }
     
    557568    location.move(0, r.height());
    558569
    559     IntRect popupRect(location, r.size());
    560     setFrameRect(popupRect);
     570    setFrameRect(IntRect(location, r.size()));
    561571    showPopup(v);
    562572}
    563573
    564 void PopupContainer::refresh()
    565 {
     574void PopupContainer::refresh(const IntRect& targetControlRect)
     575{
     576    IntPoint location = m_frameView->contentsToWindow(targetControlRect.location());
     577    // Move it below the select widget.
     578    location.move(0, targetControlRect.height());
     579
    566580    listBox()->updateFromElement();
    567     layout();
     581    // Store the original height to check if we need to request the location.
     582    int originalHeight = height();
     583    IntRect widgetRect = layoutAndCalculateWidgetRect(targetControlRect.height(), location);
     584    if (originalHeight != widgetRect.height())
     585        setFrameRect(widgetRect);
     586
     587    invalidate();
    568588}
    569589
  • trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h

    r72403 r75982  
    169169
    170170    // Refresh the popup values from the PopupMenuClient.
    171     void refresh();
     171    void refresh(const IntRect& targetControlRect);
    172172
    173173    // The menu per-item data.
     
    193193    // Paint the border.
    194194    void paintBorder(GraphicsContext*, const IntRect&);
     195
     196    // Layout and calculate popup widget size and location and returns it as IntRect.
     197    IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate);
    195198
    196199    // Returns the ChromeClient of the page this popup is associated with.
  • trunk/Source/WebKit/chromium/ChangeLog

    r75938 r75982  
     12011-01-17  Naoki Takano  <takano.naoki@gmail.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        [Chromium] Fix popup menu re-positioning when the menu is opened upward, above the corresponding form field.
     6        https://bugs.webkit.org/show_bug.cgi?id=51382
     7        http://crbug.com/60427
     8
     9        Calculate correct location of popup window whenever the items in the window change.
     10
     11        No new tests, because this fix is for Chromium project and hard to test only in WebKit project
     12
     13       * WebKit/chromium/src/WebViewImpl.cpp:
     14       (WebKit::WebViewImpl::refreshAutoFillPopup): Change the logic in refreshAutoFilPopup() to check both the location and the size of popup window.
     15
    1162011-01-17  Pavel Feldman  <pfeldman@chromium.org>
    217
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r75815 r75982  
    21982198    }
    21992199
    2200     IntRect oldBounds = m_autoFillPopup->boundsRect();
    2201     m_autoFillPopup->refresh();
    2202     IntRect newBounds = m_autoFillPopup->boundsRect();
     2200    IntRect oldBounds = m_autoFillPopup->frameRect();
     2201    m_autoFillPopup->refresh(focusedWebCoreNode()->getRect());
     2202    IntRect newBounds = m_autoFillPopup->frameRect();
    22032203    // Let's resize the backing window if necessary.
    22042204    if (oldBounds != newBounds) {
Note: See TracChangeset for help on using the changeset viewer.