Modified: trunk/Source/WebCore/ChangeLog (87136 => 87137)
--- trunk/Source/WebCore/ChangeLog 2011-05-24 08:42:44 UTC (rev 87136)
+++ trunk/Source/WebCore/ChangeLog 2011-05-24 09:02:49 UTC (rev 87137)
@@ -1,3 +1,21 @@
+2011-05-24 Naoki Takano <[email protected]>
+
+ 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.
+
2011-05-24 James Robinson <[email protected]>
Reviewed by Kenneth Russell.
Modified: trunk/Source/WebCore/manual-tests/autofill-popup-location.html (87136 => 87137)
--- trunk/Source/WebCore/manual-tests/autofill-popup-location.html 2011-05-24 08:42:44 UTC (rev 87136)
+++ trunk/Source/WebCore/manual-tests/autofill-popup-location.html 2011-05-24 09:02:49 UTC (rev 87137)
@@ -16,5 +16,17 @@
</ol>
<br>
<form><input name=q autofocus></form>
+
+ <ol>
+ <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>
+ <li>Return to this page</li>
+ <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.
+ <li> Type the text 'This is short text.' in the following text input area. And press ENTER to submit.</li>
+ <li> Press 't' and make sure the input text which you typed in is displayed in autofill popup window.</li>
+ <li> Press 'h' and make sure the popup window location is correct.</li>
+ <li> Press arrow key down and make sure the popup window text is not broken.</li>
+ </ol>
+ <br>
+ <form><input name=p></form>
</body>
</html>
Modified: trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp (87136 => 87137)
--- trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp 2011-05-24 08:42:44 UTC (rev 87136)
+++ trunk/Source/WebCore/platform/chromium/PopupMenuChromium.cpp 2011-05-24 09:02:49 UTC (rev 87137)
@@ -133,7 +133,7 @@
// Returns the number of items in the list.
int numItems() const { return static_cast<int>(m_items.size()); }
- void setBaseWidth(int width) { m_baseWidth = width; }
+ void setBaseWidth(int width) { m_baseWidth = min(m_maxWindowWidth, width); }
// Computes the size of widget and children.
void layout();
@@ -146,6 +146,8 @@
void setMaxHeight(int maxHeight) { m_maxHeight = maxHeight; }
+ void setMaxWidthAndLayout(int);
+
void disconnectClient() { m_popupClient = 0; }
const Vector<PopupItem*>& items() const { return m_items; }
@@ -165,6 +167,7 @@
, m_popupClient(client)
, m_repeatingChar(0)
, m_lastCharTime(0)
+ , m_maxWindowWidth(std::numeric_limits<int>::max())
{
setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
}
@@ -271,6 +274,9 @@
// The last time the user hit a key. Used for typeAheadFind.
TimeStamp m_lastCharTime;
+
+ // If width exeeds screen width, we have to clip it.
+ int m_maxWindowWidth;
};
static PlatformMouseEvent constructRelativeMouseEvent(const PlatformMouseEvent& e,
@@ -355,13 +361,17 @@
// If we have multiple screens and the browser rect is in one screen, we have
// to clip the window width to the screen width.
+ // When clipping, we also need to set a maximum width for the list box.
FloatRect windowRect = chromeClient->windowRect();
if (windowRect.x() >= screen.x() && windowRect.maxX() <= screen.maxX()) {
if (m_listBox->m_popupClient->menuStyle().textDirection() == RTL && widgetRect.x() < screen.x()) {
widgetRect.setWidth(widgetRect.maxX() - screen.x());
widgetRect.setX(screen.x());
- } else if (widgetRect.maxX() > screen.maxX())
+ listBox()->setMaxWidthAndLayout(max(widgetRect.width() - kBorderSize * 2, 0));
+ } else if (widgetRect.maxX() > screen.maxX()) {
widgetRect.setWidth(screen.maxX() - widgetRect.x());
+ listBox()->setMaxWidthAndLayout(max(widgetRect.width() - kBorderSize * 2, 0));
+ }
}
// Calculate Y axis size.
@@ -1283,6 +1293,12 @@
layout();
}
+void PopupListBox::setMaxWidthAndLayout(int maxWidth)
+{
+ m_maxWindowWidth = maxWidth;
+ layout();
+}
+
void PopupListBox::layout()
{
bool isRightAligned = m_popupClient->menuStyle().textDirection() == RTL;
@@ -1362,7 +1378,13 @@
contentWidth = m_baseWidth - scrollbarWidth;
} else {
windowWidth = baseWidth + scrollbarWidth + paddingWidth;
- contentWidth = baseWidth + paddingWidth;
+ if (windowWidth > m_maxWindowWidth) {
+ // windowWidth exceeds m_maxWindowWidth, so we have to clip.
+ windowWidth = m_maxWindowWidth;
+ baseWidth = windowWidth - scrollbarWidth - paddingWidth;
+ m_baseWidth = baseWidth;
+ }
+ contentWidth = windowWidth - scrollbarWidth;
if (windowWidth < m_baseWidth) {
windowWidth = m_baseWidth;