Commit 1ce7a1f1 authored by jhoneycutt@apple.com's avatar jhoneycutt@apple.com

Select menus with short option titles do not paint properly

https://bugs.webkit.org/show_bug.cgi?id=50860
<rdar://problem/8660807>

The backing stores used for painting the popup menu items were only as
wide as the widest option title, but the popup window that we create is
at least as wide as the <select> element. This adjusts the backing
stores to be at least as wide as the <select>, as well.

Reviewed by Sam Weinig.

* UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::paint):
Paint using the width of the backing store.

* WebProcess/WebCoreSupport/WebPopupMenu.cpp:
(WebKit::WebPopupMenu::show):
Pass the page coordinates of the <select> element to
setUpPlatformData().

* WebProcess/WebCoreSupport/WebPopupMenu.h:
Added new parameter to setUpPlatformData().

* WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
(WebKit::WebPopupMenu::setUpPlatformData):
Ditto.

* WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp:
(WebKit::WebPopupMenu::setUpPlatformData):
Ditto.

* WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData):
Fixed a typo in a comment. Adjust the backing store size to be at least
as wide as the <select> element, and use that width when painting the
items to the backing store.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 260fc021
2010-12-10 Jon Honeycutt <jhoneycutt@apple.com>
Select menus with short option titles do not paint properly
https://bugs.webkit.org/show_bug.cgi?id=50860
<rdar://problem/8660807>
The backing stores used for painting the popup menu items were only as
wide as the widest option title, but the popup window that we create is
at least as wide as the <select> element. This adjusts the backing
stores to be at least as wide as the <select>, as well.
Reviewed by Sam Weinig.
* UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::paint):
Paint using the width of the backing store.
* WebProcess/WebCoreSupport/WebPopupMenu.cpp:
(WebKit::WebPopupMenu::show):
Pass the page coordinates of the <select> element to
setUpPlatformData().
* WebProcess/WebCoreSupport/WebPopupMenu.h:
Added new parameter to setUpPlatformData().
* WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
(WebKit::WebPopupMenu::setUpPlatformData):
Ditto.
* WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp:
(WebKit::WebPopupMenu::setUpPlatformData):
Ditto.
* WebProcess/WebCoreSupport/win/WebPopupMenuWin.cpp:
(WebKit::WebPopupMenu::setUpPlatformData):
Fixed a typo in a comment. Adjust the backing store size to be at least
as wide as the <select> element, and use that width when painting the
items to the backing store.
2010-12-11 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed Qt buildfix after r73808.
......@@ -816,7 +816,7 @@ void WebPopupMenuProxyWin::paint(const IntRect& damageRect, HDC hdc)
translatedDamageRect.move(IntSize(0, m_scrollOffset * m_itemHeight));
m_data.m_notSelectedBackingStore->paint(context, damageRect.location(), translatedDamageRect);
IntRect selectedIndexRectInBackingStore(0, focusedIndex() * m_itemHeight, m_data.m_popupWidth, m_itemHeight);
IntRect selectedIndexRectInBackingStore(0, focusedIndex() * m_itemHeight, m_data.m_selectedBackingStore->size().width(), m_itemHeight);
IntPoint selectedIndexDstPoint = selectedIndexRectInBackingStore.location();
selectedIndexDstPoint.move(0, -m_scrollOffset * m_itemHeight);
......
......@@ -100,7 +100,7 @@ void WebPopupMenu::show(const IntRect& rect, FrameView* view, int index)
IntRect pageCoordinates(view->contentsToWindow(rect.location()), rect.size());
PlatformPopupMenuData platformData;
setUpPlatformData(platformData);
setUpPlatformData(pageCoordinates, platformData);
WebProcess::shared().connection()->send(Messages::WebPageProxy::ShowPopupMenu(pageCoordinates, items, index, platformData), m_page->pageID());
}
......
......@@ -55,7 +55,7 @@ private:
WebPopupMenu(WebPage*, WebCore::PopupMenuClient*);
Vector<WebPopupItem> populateItems();
void setUpPlatformData(PlatformPopupMenuData&);
void setUpPlatformData(const WebCore::IntRect& pageCoordinates, PlatformPopupMenuData&);
WebCore::PopupMenuClient* m_popupClient;
WebPage* m_page;
......
......@@ -27,9 +27,11 @@
#include "PlatformPopupMenuData.h"
using namespace WebCore;
namespace WebKit {
void WebPopupMenu::setUpPlatformData(PlatformPopupMenuData&)
void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&)
{
}
......
......@@ -27,9 +27,11 @@
#include "PlatformPopupMenuData.h"
using namespace WebCore;
namespace WebKit {
void WebPopupMenu::setUpPlatformData(PlatformPopupMenuData&)
void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData&)
{
}
......
......@@ -41,7 +41,7 @@ static const int separatorPadding = 4;
static const int separatorHeight = 1;
static const int popupWindowBorderWidth = 1;
void WebPopupMenu::setUpPlatformData(PlatformPopupMenuData& data)
void WebPopupMenu::setUpPlatformData(const WebCore::IntRect& pageCoordinates, PlatformPopupMenuData& data)
{
int itemCount = m_popupClient->listSize();
......@@ -68,13 +68,16 @@ void WebPopupMenu::setUpPlatformData(PlatformPopupMenuData& data)
popupWidth = std::max(popupWidth, itemFont.width(TextRun(text.characters(), text.length())));
}
// FIXME: popupWidth should probably take into account monitor constraits as is done with WebPopupMenuProxyWin::calculatePositionAndSize.
// FIXME: popupWidth should probably take into account monitor constraints as is done with WebPopupMenuProxyWin::calculatePositionAndSize.
popupWidth += max(0, data.m_clientPaddingRight - data.m_clientInsetRight) + max(0, data.m_clientPaddingLeft - data.m_clientInsetLeft);
popupWidth += 2 * popupWindowBorderWidth;
data.m_popupWidth = popupWidth;
data.m_backingStoreSize = IntSize(data.m_popupWidth, (itemCount * data.m_itemHeight));
// The backing stores should be drawn at least as wide as the control on the page to match the width of the popup window we'll create.
int backingStoreWidth = max(pageCoordinates.width() - m_popupClient->clientInsetLeft() - m_popupClient->clientInsetRight(), popupWidth);
data.m_backingStoreSize = IntSize(backingStoreWidth, (itemCount * data.m_itemHeight));
data.m_notSelectedBackingStore = BackingStore::createSharable(data.m_backingStoreSize);
data.m_selectedBackingStore = BackingStore::createSharable(data.m_backingStoreSize);
......@@ -92,7 +95,7 @@ void WebPopupMenu::setUpPlatformData(PlatformPopupMenuData& data)
Color optionBackgroundColor = itemStyle.backgroundColor();
Color optionTextColor = itemStyle.foregroundColor();
IntRect itemRect(0, y, data.m_popupWidth, data.m_itemHeight);
IntRect itemRect(0, y, backingStoreWidth, data.m_itemHeight);
// Draw the background for this menu item
if (itemStyle.isVisible()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment