Fix for select PopupMenuList appearance in rtl mode with overlay-scrollbar enabled.

The content should take total window width while overlay-scrollbar is enabled. 

BUG=382900

Review URL: https://codereview.chromium.org/333633003

git-svn-id: svn://svn.chromium.org/blink/trunk@176261 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 90889aa5
......@@ -80,7 +80,7 @@ HostWindow* FramelessScrollView::hostWindow() const
IntRect FramelessScrollView::windowClipRect(IncludeScrollbarsInRect scrollbarInclusion) const
{
IntRect clipRect = visibleContentRect(scrollbarInclusion);
if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar())
if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
clipRect.move(verticalScrollbar()->width(), 0);
return contentsToWindow(clipRect);
}
......
......@@ -349,7 +349,7 @@ void PopupListBox::paint(GraphicsContext* gc, const IntRect& rect)
{
// Adjust coords for scrolled frame.
IntRect r = intersection(rect, frameRect());
int tx = x() - scrollX() + ((shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar()) ? verticalScrollbar()->width() : 0);
int tx = x() - scrollX() + ((shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0);
int ty = y() - scrollY();
r.move(-tx, -ty);
......@@ -596,7 +596,7 @@ void PopupListBox::invalidateRow(int index)
// Invalidate in the window contents, as FramelessScrollView::invalidateRect
// paints in the window coordinates.
IntRect clipRect = contentsToWindow(getRowBounds(index));
if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar())
if (shouldPlaceVerticalScrollbarOnLeft() && verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar())
clipRect.move(verticalScrollbar()->width(), 0);
invalidateRect(clipRect);
}
......@@ -773,7 +773,8 @@ void PopupListBox::layout()
// Set our widget and scrollable contents sizes.
int scrollbarWidth = 0;
if (m_visibleRows < numItems()) {
scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness();
if (!ScrollbarTheme::theme()->usesOverlayScrollbars())
scrollbarWidth = ScrollbarTheme::theme()->scrollbarThickness();
// Use minEndOfLinePadding when there is a scrollbar so that we use
// as much as (lineEndPaddingWidth - minEndOfLinePadding) padding
......
......@@ -33,6 +33,7 @@
#include "RuntimeEnabledFeatures.h"
#include "core/dom/Element.h"
#include "core/frame/FrameView.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLSelectElement.h"
#include "core/page/EventHandler.h"
#include "platform/KeyboardCodes.h"
......@@ -40,6 +41,7 @@
#include "platform/PopupMenu.h"
#include "platform/PopupMenuClient.h"
#include "platform/graphics/Color.h"
#include "platform/scroll/ScrollbarTheme.h"
#include "public/platform/Platform.h"
#include "public/platform/WebScreenInfo.h"
#include "public/platform/WebString.h"
......@@ -57,6 +59,7 @@
#include "public/web/WebViewClient.h"
#include "v8.h"
#include "web/PopupContainer.h"
#include "web/PopupListBox.h"
#include "web/PopupMenuChromium.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebPopupMenuImpl.h"
......@@ -74,7 +77,7 @@ namespace {
class TestPopupMenuClient : public PopupMenuClient {
public:
// Item at index 0 is selected by default.
TestPopupMenuClient() : m_selectIndex(0), m_node(0) { }
TestPopupMenuClient() : m_selectIndex(0), m_node(0), m_listSize(10) { }
virtual ~TestPopupMenuClient() {}
virtual void valueChanged(unsigned listIndex, bool fireEvents = true)
{
......@@ -111,7 +114,7 @@ public:
virtual int clientInsetRight() const { return 0; }
virtual LayoutUnit clientPaddingLeft() const { return 0; }
virtual LayoutUnit clientPaddingRight() const { return 0; }
virtual int listSize() const { return 10; }
virtual int listSize() const { return m_listSize; }
virtual int selectedIndex() const { return m_selectIndex; }
virtual void popupDidHide() { }
virtual bool itemIsSeparator(unsigned listIndex) const { return false; }
......@@ -127,11 +130,13 @@ public:
void setDisabledIndex(unsigned index) { m_disabledIndexSet.insert(index); }
void setFocusedNode(Node* node) { m_node = node; }
void setListSize(int listSize) { m_listSize = listSize; }
private:
unsigned m_selectIndex;
std::set<unsigned> m_disabledIndexSet;
Node* m_node;
int m_listSize;
};
class TestWebWidgetClient : public WebWidgetClient {
......@@ -498,4 +503,41 @@ TEST_F(SelectPopupMenuTest, SelectItemRemoveSelectOnClick)
EXPECT_STREQ("click", element.innerText().utf8().data());
}
TEST_F(SelectPopupMenuTest, PopupListBoxWithOverlayScrollbarEnabled)
{
Settings::setMockScrollbarsEnabled(true);
RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true);
EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars());
registerMockedURLLoad("select_rtl.html");
loadFrame(mainFrame(), "select_rtl.html");
m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedElement());
m_popupMenuClient.setListSize(30);
showPopup();
PopupContainer* container = webView()->selectPopup();
PopupListBox* listBox = container->listBox();
EXPECT_EQ(container->width(), listBox->contentsSize().width() + 2);
Settings::setMockScrollbarsEnabled(false);
RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false);
EXPECT_FALSE(ScrollbarTheme::theme()->usesOverlayScrollbars());
}
TEST_F(SelectPopupMenuTest, PopupListBoxWithOverlayScrollbarDisabled)
{
EXPECT_FALSE(ScrollbarTheme::theme()->usesOverlayScrollbars());
registerMockedURLLoad("select_rtl.html");
loadFrame(mainFrame(), "select_rtl.html");
m_popupMenuClient.setFocusedNode(mainFrame()->frame()->document()->focusedElement());
m_popupMenuClient.setListSize(30);
showPopup();
PopupContainer* container = webView()->selectPopup();
PopupListBox* listBox = container->listBox();
EXPECT_EQ(container->width(), listBox->contentsSize().width() + ScrollbarTheme::theme()->scrollbarThickness() + 2);
}
} // namespace
<!DOCTYPE html>
<html>
<body dir="rtl">
<div id="message"></div>
<select id="s" autofocus>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
</body>
</html>
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