Index: Source/web/PopupListBox.cpp |
diff --git a/Source/web/PopupListBox.cpp b/Source/web/PopupListBox.cpp |
index 6975b3179de6e80210ef33b6c02ea550b2b0bdcf..343ede041e38504eb465f88c182f1ad85958e95a 100644 |
--- a/Source/web/PopupListBox.cpp |
+++ b/Source/web/PopupListBox.cpp |
@@ -727,6 +727,17 @@ void PopupListBox::setMaxWidthAndLayout(int maxWidth) |
layout(); |
} |
+int PopupListBox::getRowBaseWidth(int index) |
+{ |
+ Font font = getRowFont(index); |
+ PopupMenuStyle style = m_popupClient->itemStyle(index); |
+ String text = m_popupClient->itemText(index); |
+ if (text.isEmpty()) |
+ return 0; |
+ TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride()); |
+ return font.width(textRun); |
+} |
+ |
void PopupListBox::layout() |
{ |
bool isRightAligned = m_popupClient->menuStyle().textDirection() == RTL; |
@@ -744,13 +755,7 @@ void PopupListBox::layout() |
y += getRowHeight(i); |
// Ensure the popup is wide enough to fit this item. |
- Font itemFont = getRowFont(i); |
- String text = m_popupClient->itemText(i); |
- int width = 0; |
- if (!text.isEmpty()) |
- width = itemFont.width(TextRun(text)); |
- |
- baseWidth = max(baseWidth, width); |
+ baseWidth = max(baseWidth, getRowBaseWidth(i)); |
// FIXME: http://b/1210481 We should get the padding of individual |
// option elements. |
paddingWidth = max<int>(paddingWidth, |