Skip to content
Permalink
Browse files
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.

Canonical link: https://commits.webkit.org/76717@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed May 24, 2011
1 parent 91b2397 commit 7cd01bed2a32bf7d04fdbe68cc70ad6d6c811a97
Showing with 55 additions and 3 deletions.
  1. +18 −0 Source/WebCore/ChangeLog
  2. +12 −0 Source/WebCore/manual-tests/autofill-popup-location.html
  3. +25 −3 Source/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -1,3 +1,21 @@
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.

2011-05-24 James Robinson <jamesr@chromium.org>

Reviewed by Kenneth Russell.
@@ -16,5 +16,17 @@ <h3>Test autofill popup window shows at the correct location.</h3>
</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>
@@ -133,7 +133,7 @@ class PopupListBox : public FramelessScrollView {
// 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 @@ class PopupListBox : public FramelessScrollView {

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 @@ class PopupListBox : public FramelessScrollView {
, m_popupClient(client)
, m_repeatingChar(0)
, m_lastCharTime(0)
, m_maxWindowWidth(std::numeric_limits<int>::max())
{
setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
}
@@ -271,6 +274,9 @@ class PopupListBox : public FramelessScrollView {

// 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 @@ IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, co

// 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 @@ void PopupListBox::updateFromElement()
layout();
}

void PopupListBox::setMaxWidthAndLayout(int maxWidth)
{
m_maxWindowWidth = maxWidth;
layout();
}

void PopupListBox::layout()
{
bool isRightAligned = m_popupClient->menuStyle().textDirection() == RTL;
@@ -1362,7 +1378,13 @@ void PopupListBox::layout()
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;

0 comments on commit 7cd01be

Please sign in to comment.