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

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

Issue 2600873002: Memoize LayoutThemeDefault::clampedMenuListArrowPaddingSize(). (Closed)
Patch Set: Update LayoutThemeDefault::didChangeThemeEngine Created 3 years, 11 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/LayoutThemeDefault.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/LayoutThemeDefault.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp b/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp
index 728b3e37c9154cbce2370da8ca8ef454da67350f..bd9f1cd71bb32755e9d2604f1d10468cfbdb8059 100644
--- a/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp
@@ -336,35 +336,41 @@ int LayoutThemeDefault::popupInternalPaddingBottom(
}
int LayoutThemeDefault::menuListArrowWidthInDIP() const {
- if (m_menuListArrowWidthInDIP > 0)
- return m_menuListArrowWidthInDIP;
int width = Platform::current()
->themeEngine()
->getSize(WebThemeEngine::PartScrollbarUpArrow)
.width;
- const_cast<LayoutThemeDefault*>(this)->m_menuListArrowWidthInDIP =
- width > 0 ? width : 15;
- return m_menuListArrowWidthInDIP;
+ return width > 0 ? width : 15;
}
float LayoutThemeDefault::clampedMenuListArrowPaddingSize(
const HostWindow* host,
const ComputedStyle& style) const {
+ if (m_cachedMenuListArrowPaddingSize > 0 &&
+ style.effectiveZoom() == m_cachedMenuListArrowZoomLevel)
+ return m_cachedMenuListArrowPaddingSize;
+ m_cachedMenuListArrowZoomLevel = style.effectiveZoom();
int originalSize = menuListArrowWidthInDIP();
int scaledSize =
host ? host->windowToViewportScalar(originalSize) : originalSize;
// The result should not be samller than the scrollbar thickness in order to
// secure space for scrollbar in popup.
float deviceScale = 1.0f * scaledSize / originalSize;
- if (style.effectiveZoom() < deviceScale)
- return scaledSize;
- // The value should be zoomed though scrollbars aren't scaled by zoom.
- // crbug.com/432795.
- return originalSize * style.effectiveZoom();
+ float size;
+ if (m_cachedMenuListArrowZoomLevel < deviceScale) {
+ size = scaledSize;
+ } else {
+ // The value should be zoomed though scrollbars aren't scaled by zoom.
+ // crbug.com/432795.
+ size = originalSize * m_cachedMenuListArrowZoomLevel;
+ }
+ m_cachedMenuListArrowPaddingSize = size;
+ return size;
}
void LayoutThemeDefault::didChangeThemeEngine() {
- m_menuListArrowWidthInDIP = 0;
+ m_cachedMenuListArrowZoomLevel = 0;
+ m_cachedMenuListArrowPaddingSize = 0;
}
// static
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeDefault.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698