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

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

Issue 2560733002: SELECT element: Fix a bug that intrinsic width is too narrow in less-than-100% zoom level. (Closed)
Patch Set: PartScrollbarVerticalTrack -> PartScrollbarDownArrow to fix Android crash Created 4 years 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
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 e880c74791c84f5c2a48fb54f8ea100cd68c10e0..a23b70c8538d4e26f1c5f5eb040d9158654d2b14 100644
--- a/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp
@@ -28,6 +28,7 @@
#include "core/layout/LayoutThemeFontProvider.h"
#include "core/paint/MediaControlsPainter.h"
#include "core/style/ComputedStyle.h"
+#include "platform/HostWindow.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformResourceLoader.h"
#include "platform/graphics/Color.h"
@@ -42,7 +43,6 @@ static const float defaultControlFontPixelSize = 13;
static const float defaultCancelButtonSize = 9;
static const float minCancelButtonSize = 5;
static const float maxCancelButtonSize = 21;
-static const int menuListArrowPaddingSize = 14;
static bool useMockTheme() {
return LayoutTestSupport::isMockThemeEnabledForTest();
@@ -55,7 +55,8 @@ unsigned LayoutThemeDefault::m_inactiveSelectionForegroundColor = 0xff323232;
double LayoutThemeDefault::m_caretBlinkInterval;
-LayoutThemeDefault::LayoutThemeDefault() : LayoutTheme(nullptr) {
+LayoutThemeDefault::LayoutThemeDefault()
+ : LayoutTheme(nullptr), m_painter(*this) {
m_caretBlinkInterval = LayoutTheme::caretBlinkInterval();
}
@@ -316,8 +317,12 @@ int LayoutThemeDefault::popupInternalPaddingStart(
}
int LayoutThemeDefault::popupInternalPaddingEnd(
+ const HostWindow* host,
const ComputedStyle& style) const {
- return menuListInternalPadding(style, 4 + menuListArrowPaddingSize);
+ if (style.appearance() == NoControlPart)
+ return 0;
+ return 1 * style.effectiveZoom() +
+ clampedMenuListArrowPaddingSize(host, style);
}
int LayoutThemeDefault::popupInternalPaddingTop(
@@ -331,6 +336,32 @@ int LayoutThemeDefault::popupInternalPaddingBottom(
}
// static
+int LayoutThemeDefault::scrollbarThicknessInDIP() {
+ int width = Platform::current()
+ ->themeEngine()
+ ->getSize(WebThemeEngine::PartScrollbarDownArrow)
+ .width;
+ return width > 0 ? width : 15;
+}
+
+// static
+float LayoutThemeDefault::clampedMenuListArrowPaddingSize(
+ const HostWindow* host,
+ const ComputedStyle& style) {
+ int originalSize = scrollbarThicknessInDIP();
+ 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();
+}
+
+// static
void LayoutThemeDefault::setDefaultFontSize(int fontSize) {
LayoutThemeFontProvider::setDefaultFontSize(fontSize);
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeDefault.h ('k') | third_party/WebKit/Source/core/layout/LayoutThemeMac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698