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

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

Issue 2093563005: Improve performance to remove OPTIONs from a single-selection SELECT. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
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 866f3b680c2bd168e5b47e4d3d86821f2c7caa39..db7d5dc758dedb184a56ac40d75f3643e702d8d4 100644
--- a/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutMenuList.cpp
@@ -159,11 +159,14 @@ void LayoutMenuList::styleDidChange(StyleDifference diff, const ComputedStyle* o
bool fontChanged = !oldStyle || oldStyle->font() != style()->font();
if (fontChanged)
- updateOptionsWidth();
+ m_optionsChanged = true;
}
-void LayoutMenuList::updateOptionsWidth()
+void LayoutMenuList::updateOptionsWidth() const
{
+ if (!m_optionsChanged)
+ return;
+
float maxOptionWidth = 0;
const HeapVector<Member<HTMLElement>>& listItems = selectElement()->listItems();
int size = listItems.size();
@@ -188,13 +191,15 @@ void LayoutMenuList::updateOptionsWidth()
}
}
- int width = static_cast<int>(ceilf(maxOptionWidth));
- if (m_optionsWidth == width)
- return;
+ m_optionsWidth = static_cast<int>(ceilf(maxOptionWidth));
+ m_optionsChanged = false;
+}
- m_optionsWidth = width;
- if (parent())
- setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::MenuWidthChanged);
+void LayoutMenuList::setOptionsChanged(bool changed)
+{
+ m_optionsChanged = changed;
+ if (changed && parent())
+ setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalidationReason::MenuOptionsChanged);
}
float LayoutMenuList::computeTextWidth(const String& text) const
@@ -204,16 +209,6 @@ float LayoutMenuList::computeTextWidth(const String& text) const
void LayoutMenuList::updateFromElement()
{
- if (m_optionsChanged) {
- updateOptionsWidth();
- m_optionsChanged = false;
- }
-
- updateText();
-}
-
-void LayoutMenuList::updateText()
-{
setTextFromOption(selectElement()->optionIndexToBeShown());
}
@@ -308,6 +303,7 @@ LayoutRect LayoutMenuList::controlClipRect(const LayoutPoint& additionalOffset)
void LayoutMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
+ updateOptionsWidth();
maxLogicalWidth = std::max(m_optionsWidth, LayoutTheme::theme().minimumMenuListSize(styleRef())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
if (!style()->width().hasPercent())
minLogicalWidth = maxLogicalWidth;
« 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