Changeset 75982 in webkit
- Timestamp:
- Jan 17, 2011 4:44:20 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r75976 r75982 1 2011-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 1 19 2011-01-17 Mark Rowe <mrowe@apple.com> 2 20 -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
r72403 r75982 330 330 } 331 331 332 void PopupContainer::showPopup(FrameView* view) 333 { 334 // Pre-layout, our size matches the <select> dropdown control. 335 int selectHeight = frameRect().height(); 336 332 IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate) 333 { 337 334 // Reset the max height to its default value, it will be recomputed below 338 335 // if necessary. … … 342 339 // WidgetClient about it. It should assign us a client. 343 340 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; 346 347 ChromeClientChromium* chromeClient = chromeClientChromium(); 347 348 if (chromeClient) { 348 349 // If the popup would extend past the bottom of the screen, open upwards 349 350 // 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)); 353 353 if (widgetRect.bottom() > static_cast<int>(screen.bottom())) { 354 if (widgetRect.y() - widgetRect.height() - selectHeight > 0) {354 if (widgetRect.y() - widgetRect.height() - targetControlHeight > 0) { 355 355 // There is enough room to open upwards. 356 widgetRect.move(0, -(widgetRect.height() + selectHeight));356 widgetRect.move(0, -(widgetRect.height() + targetControlHeight)); 357 357 } else { 358 358 // Figure whether upwards or downwards has more room and set the 359 359 // maximum number of items. 360 int spaceAbove = widgetRect.y() - selectHeight;360 int spaceAbove = widgetRect.y() - targetControlHeight; 361 361 int spaceBelow = screen.bottom() - widgetRect.y(); 362 362 if (spaceAbove > spaceBelow) … … 369 369 // And move upwards if necessary. 370 370 if (spaceAbove > spaceBelow) 371 widgetRect.move(0, -(widgetRect.height() + selectHeight));371 widgetRect.move(0, -(widgetRect.height() + targetControlHeight)); 372 372 } 373 373 } 374 chromeClient->popupOpened(this, widgetRect, false); 374 } 375 return widgetRect; 376 } 377 378 void 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); 375 386 m_popupOpen = true; 376 387 } … … 557 568 location.move(0, r.height()); 558 569 559 IntRect popupRect(location, r.size()); 560 setFrameRect(popupRect); 570 setFrameRect(IntRect(location, r.size())); 561 571 showPopup(v); 562 572 } 563 573 564 void PopupContainer::refresh() 565 { 574 void 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 566 580 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(); 568 588 } 569 589 -
trunk/Source/WebCore/platform/chromium/PopupMenuChromium.h
r72403 r75982 169 169 170 170 // Refresh the popup values from the PopupMenuClient. 171 void refresh( );171 void refresh(const IntRect& targetControlRect); 172 172 173 173 // The menu per-item data. … … 193 193 // Paint the border. 194 194 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); 195 198 196 199 // Returns the ChromeClient of the page this popup is associated with. -
trunk/Source/WebKit/chromium/ChangeLog
r75938 r75982 1 2011-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 1 16 2011-01-17 Pavel Feldman <pfeldman@chromium.org> 2 17 -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r75815 r75982 2198 2198 } 2199 2199 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(); 2203 2203 // Let's resize the backing window if necessary. 2204 2204 if (oldBounds != newBounds) {
Note: See TracChangeset
for help on using the changeset viewer.