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

Unified Diff: third_party/WebKit/Source/core/paint/ThemePainterDefault.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/paint/ThemePainterDefault.cpp
diff --git a/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp b/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
index 0b0fb12ed9bec925b9193a0af701cf971a0fc5cf..1ce8c7c30fdfea97f048d5527940c1fe8ca5a702 100644
--- a/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
+++ b/third_party/WebKit/Source/core/paint/ThemePainterDefault.cpp
@@ -24,9 +24,10 @@
#include "core/paint/ThemePainterDefault.h"
+#include "core/frame/FrameView.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutProgress.h"
-#include "core/layout/LayoutTheme.h"
+#include "core/layout/LayoutThemeDefault.h"
#include "core/paint/MediaControlsPainter.h"
#include "core/paint/PaintInfo.h"
#include "platform/LayoutTestSupport.h"
@@ -42,10 +43,6 @@ namespace blink {
namespace {
const unsigned defaultButtonBackgroundColor = 0xffdddddd;
-const unsigned mockDropdownMenuListArrowPadding = 3;
-// This is equal to the padding provided by the LayoutMenuList which is
-// calculated based on |menuListArrowPaddingSize| in LayoutThemeDefault.
-const unsigned mockDropdownMenuListArrowWidth = 18;
bool useMockTheme() {
return LayoutTestSupport::isMockThemeEnabledForTest();
@@ -142,7 +139,8 @@ IntRect convertToPaintingRect(const LayoutObject& inputLayoutObject,
} // namespace
-ThemePainterDefault::ThemePainterDefault() : ThemePainter() {}
+ThemePainterDefault::ThemePainterDefault(LayoutThemeDefault& theme)
+ : ThemePainter(), m_theme(theme) {}
bool ThemePainterDefault::paintCheckbox(const LayoutObject& o,
const PaintInfo& i,
@@ -285,34 +283,40 @@ void ThemePainterDefault::setupMenuListArrow(
const LayoutBox& box,
const IntRect& rect,
WebThemeEngine::ExtraParams& extraParams) {
- const int right = rect.x() + rect.width();
+ const int left = rect.x() + box.borderLeft();
+ const int right = rect.x() + rect.width() - box.borderRight();
const int middle = rect.y() + rect.height() / 2;
extraParams.menuList.arrowY = middle;
+ float arrowBoxWidth = m_theme.clampedMenuListArrowPaddingSize(
+ box.frameView()->getHostWindow(), box.styleRef());
+ float arrowScaleFactor = arrowBoxWidth / m_theme.scrollbarThicknessInDIP();
if (useMockTheme()) {
// The size and position of the drop-down button is different between
// the mock theme and the regular aura theme.
- int extraPadding =
- mockDropdownMenuListArrowPadding * box.styleRef().effectiveZoom();
- int arrowBoxWidth =
- mockDropdownMenuListArrowWidth * box.styleRef().effectiveZoom();
- int arrowSize = std::min(arrowBoxWidth, rect.height()) - 2 * extraPadding;
+
+ // Padding inside the arrowBox.
+ float extraPadding = 2 * arrowScaleFactor;
+ float arrowSize =
+ std::min(arrowBoxWidth,
+ static_cast<float>(rect.height() - box.borderTop() -
+ box.borderBottom())) -
+ 2 * extraPadding;
+ // |arrowX| is the middle position for mock theme engine.
extraParams.menuList.arrowX =
(box.styleRef().direction() == RTL)
? rect.x() + extraPadding + (arrowSize / 2)
: right - (arrowSize / 2) - extraPadding;
extraParams.menuList.arrowSize = arrowSize;
} else {
- const int arrowSize = 6;
- const int arrowPadding = 6;
- extraParams.menuList.arrowX =
- (box.styleRef().direction() == RTL)
- ? rect.x() + arrowPadding * box.styleRef().effectiveZoom() +
- box.borderLeft()
- : right -
- (arrowSize + arrowPadding) * box.styleRef().effectiveZoom() -
- box.borderRight();
- extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoom();
+ // TODO(tkent): This should be 7.0 to match scroll bar buttons.
+ float arrowSize = 6.0 * arrowScaleFactor;
+ // Put the 6px arrow at the center of paddingForArrow area.
+ // |arrowX| is the left position for Aura theme engine.
+ extraParams.menuList.arrowX = (box.styleRef().direction() == RTL)
+ ? left + (arrowBoxWidth - arrowSize) / 2
+ : right - (arrowBoxWidth + arrowSize) / 2;
+ extraParams.menuList.arrowSize = arrowSize;
}
extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb();
}
« no previous file with comments | « third_party/WebKit/Source/core/paint/ThemePainterDefault.h ('k') | third_party/WebKit/Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698