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

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

Issue 2077343002: Improve performance to remove OPTIONs from a single-selection SELECT. (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 7638c263e6adbf7391ce3099e7506b5619687518..2ac6a02cab55f1961cf548de77efea9222c5cdb3 100644
--- a/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
@@ -153,11 +153,14 @@ void LayoutMenuList::styleDidChange(StyleDifference diff, const ComputedStyle* o
bool fontChanged = !oldStyle || oldStyle->font() != style()->font();
if (fontChanged)
- updateOptionsHeightWidth();
+ m_optionsChanged = true;
}
-void LayoutMenuList::updateOptionsHeightWidth()
+void LayoutMenuList::updateOptionsHeightWidth() const
{
+ if (!m_optionsChanged)
+ return;
+
float maxOptionHeight = 0;
float maxOptionWidth = 0;
const HeapVector<Member<HTMLElement>>& listItems = selectElement()->listItems();
@@ -191,24 +194,16 @@ void LayoutMenuList::updateOptionsHeightWidth()
}
}
- int height = static_cast<int>(ceilf(maxOptionHeight));
- int width = static_cast<int>(ceilf(maxOptionWidth));
- if (m_optionsWidth == width && m_optionsHeight == height)
- return;
-
- auto invalidationReason = LayoutInvalidationReason::Unknown;
- if (m_optionsWidth != width) {
- m_optionsWidth = width;
- invalidationReason = LayoutInvalidationReason::MenuWidthChanged;
- }
-
- if (m_optionsHeight != height) {
- m_optionsHeight = height;
- invalidationReason = LayoutInvalidationReason::MenuHeightChanged;
- }
+ m_optionsWidth = static_cast<int>(ceilf(maxOptionWidth));
+ m_optionsHeight = static_cast<int>(ceilf(maxOptionHeight));
+ m_optionsChanged = false;
+}
- if (parent())
- setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(invalidationReason);
+void LayoutMenuList::setOptionsChanged(bool changed)
+{
+ m_optionsChanged = changed;
+ if (changed && parent())
+ setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::MenuOptionsChanged);
}
float LayoutMenuList::computeTextHeight(const TextRun& textRun, const ComputedStyle& computedStyle) const
@@ -225,16 +220,6 @@ float LayoutMenuList::computeTextWidth(const TextRun& textRun, const ComputedSty
void LayoutMenuList::updateFromElement()
{
- if (m_optionsChanged) {
- updateOptionsHeightWidth();
- m_optionsChanged = false;
- }
-
- updateText();
-}
-
-void LayoutMenuList::updateText()
-{
setTextFromOption(selectElement()->optionIndexToBeShown());
}
@@ -329,6 +314,7 @@ LayoutRect LayoutMenuList::controlClipRect(const LayoutPoint& additionalOffset)
void LayoutMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
+ updateOptionsHeightWidth();
maxLogicalWidth = std::max(m_optionsWidth, LayoutTheme::theme().minimumMenuListSize(styleRef())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
if (!style()->width().hasPercent())
minLogicalWidth = maxLogicalWidth;
@@ -337,6 +323,7 @@ void LayoutMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth,
void LayoutMenuList::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop,
LogicalExtentComputedValues& computedValues) const
{
+ updateOptionsHeightWidth();
logicalHeight = LayoutUnit(m_optionsHeight) + borderAndPaddingHeight()
+ LayoutUnit(cInnerBlockVerticalPaddingEm * style()->computedFontSize());
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