Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutMenuList.cpp

Issue 2086663007: Use fixed logical height in LayoutMenuList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutMenuList.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp b/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
index afb32e7c1a740e375692fea01066f4d002058b7b..04b1aec36161d85c16773f5a20dd9be33fd77105 100644
--- a/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
@@ -35,17 +35,13 @@
namespace blink {
-// Vertical padding that is added to the element's logical height.
-// This is needed so that the select's layout is consistent with other browsers, e.g. Gecko.
-const int cInnerBlockVerticalPaddingEm = 1;
-
LayoutMenuList::LayoutMenuList(Element* element)
: LayoutFlexibleBox(element)
, m_buttonText(nullptr)
, m_innerBlock(nullptr)
, m_isEmpty(false)
, m_hasUpdatedActiveOption(false)
- , m_optionsHeight(0)
+ , m_innerBlockHeight(LayoutUnit())
, m_optionsWidth(0)
, m_lastActiveIndex(-1)
{
@@ -84,6 +80,8 @@ void LayoutMenuList::createInnerBlock()
adjustInnerStyle();
LayoutFlexibleBox::addChild(m_innerBlock);
+
+ m_innerBlockHeight = style()->getFontMetrics().height() + m_innerBlock->borderAndPaddingHeight();
}
void LayoutMenuList::adjustInnerStyle()
@@ -151,9 +149,8 @@ void LayoutMenuList::styleDidChange(StyleDifference diff, const ComputedStyle* o
adjustInnerStyle();
}
-void LayoutMenuList::updateOptionsHeightWidth() const
+void LayoutMenuList::updateOptionsWidth() const
{
- float maxOptionHeight = 0;
float maxOptionWidth = 0;
for (const auto& element : selectElement()->listItems()) {
@@ -165,20 +162,11 @@ void LayoutMenuList::updateOptionsHeightWidth() const
applyTextTransform(itemStyle, text, ' ');
TextRun textRun = constructTextRun(itemStyle->font(), text, *itemStyle);
- maxOptionHeight = std::max(maxOptionHeight, computeTextHeight(textRun, *itemStyle));
maxOptionWidth = std::max(maxOptionWidth, computeTextWidth(textRun, *itemStyle));
}
- m_optionsHeight = static_cast<int>(ceilf(maxOptionHeight));
m_optionsWidth = static_cast<int>(ceilf(maxOptionWidth));
}
-float LayoutMenuList::computeTextHeight(const TextRun& textRun, const ComputedStyle& computedStyle) const
-{
- FloatRect glyphBounds;
- computedStyle.font().width(textRun, nullptr /* fallbackFonts */, &glyphBounds);
- return glyphBounds.height();
-}
-
float LayoutMenuList::computeTextWidth(const TextRun& textRun, const ComputedStyle& computedStyle) const
{
return computedStyle.font().width(textRun);
@@ -280,7 +268,7 @@ LayoutRect LayoutMenuList::controlClipRect(const LayoutPoint& additionalOffset)
void LayoutMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
- updateOptionsHeightWidth();
+ updateOptionsWidth();
maxLogicalWidth = std::max(m_optionsWidth, LayoutTheme::theme().minimumMenuListSize(styleRef()))
+ m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
@@ -293,10 +281,7 @@ void LayoutMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth,
void LayoutMenuList::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop,
LogicalExtentComputedValues& computedValues) const
{
- if (!m_optionsHeight)
- updateOptionsHeightWidth();
- logicalHeight = LayoutUnit(m_optionsHeight) + borderAndPaddingHeight()
- + LayoutUnit(cInnerBlockVerticalPaddingEm * style()->computedFontSize());
+ logicalHeight = m_innerBlockHeight + borderAndPaddingHeight();
LayoutBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues);
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutMenuList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698