Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp (256822 => 256823)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-18 09:31:31 UTC (rev 256822)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-18 10:48:29 UTC (rev 256823)
@@ -47,8 +47,7 @@
static const Color textFieldBorderDisabledColor = makeRGB(213, 208, 204);
static const Color textFieldBackgroundColor = makeRGB(255, 255, 255);
static const Color textFieldBackgroundDisabledColor = makeRGB(252, 252, 252);
-static const unsigned arrowSize = 16;
-static const Color arrowColor = makeRGB(46, 52, 54);
+static const unsigned menuListButtonArrowSize = 16;
static const int menuListButtonFocusOffset = -3;
static const unsigned menuListButtonPadding = 5;
static const int menuListButtonBorderSize = 1; // Keep in sync with buttonBorderSize in ThemeWPE.
@@ -152,25 +151,13 @@
return paintTextField(renderObject, paintInfo, rect);
}
-static void paintArrow(GraphicsContext& graphicsContext, const FloatRect& rect)
-{
- Path path;
- path.moveTo({ rect.x() + 3, rect.y() + 6 });
- path.addLineTo({ rect.x() + 13, rect.y() + 6 });
- path.addLineTo({ rect.x() + 8, rect.y() + 11 });
- path.closeSubpath();
-
- graphicsContext.setFillColor(arrowColor);
- graphicsContext.fillPath(path);
-}
-
LengthBox RenderThemeWPE::popupInternalPaddingBox(const RenderStyle& style) const
{
if (style.appearance() == NoControlPart)
return { };
- int leftPadding = menuListButtonPadding + (style.direction() == TextDirection::RTL ? arrowSize : 0);
- int rightPadding = menuListButtonPadding + (style.direction() == TextDirection::LTR ? arrowSize : 0);
+ int leftPadding = menuListButtonPadding + (style.direction() == TextDirection::RTL ? menuListButtonArrowSize : 0);
+ int rightPadding = menuListButtonPadding + (style.direction() == TextDirection::LTR ? menuListButtonArrowSize : 0);
return { menuListButtonPadding, rightPadding, menuListButtonPadding, leftPadding };
}
@@ -193,12 +180,16 @@
FloatRect fieldRect = rect;
fieldRect.inflate(menuListButtonBorderSize);
if (renderObject.style().direction() == TextDirection::LTR)
- fieldRect.move(fieldRect.width() - (arrowSize + menuListButtonPadding), (fieldRect.height() / 2.) - (arrowSize / 2));
+ fieldRect.move(fieldRect.width() - (menuListButtonArrowSize + menuListButtonPadding), (fieldRect.height() / 2.) - (menuListButtonArrowSize / 2));
else
- fieldRect.move(menuListButtonPadding, (fieldRect.height() / 2.) - (arrowSize / 2));
- fieldRect.setWidth(arrowSize);
- fieldRect.setHeight(arrowSize);
- paintArrow(graphicsContext, fieldRect);
+ fieldRect.move(menuListButtonPadding, (fieldRect.height() / 2.) - (menuListButtonArrowSize / 2));
+ fieldRect.setWidth(menuListButtonArrowSize);
+ fieldRect.setHeight(menuListButtonArrowSize);
+ {
+ GraphicsContextStateSaver arrowStateSaver(graphicsContext);
+ graphicsContext.translate(fieldRect.x(), fieldRect.y());
+ ThemeWPE::paintArrow(graphicsContext, ThemeWPE::ArrowDirection::Down);
+ }
if (isFocused(renderObject))
ThemeWPE::paintFocus(graphicsContext, rect, menuListButtonFocusOffset);
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp (256822 => 256823)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-18 09:31:31 UTC (rev 256822)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-18 10:48:29 UTC (rev 256823)
@@ -37,6 +37,8 @@
static const unsigned focusLineWidth = 1;
static const Color focusColor = makeRGBA(46, 52, 54, 150);
+static const unsigned arrowSize = 16;
+static const Color arrowColor = makeRGB(46, 52, 54);
static const int buttonFocusOffset = -3;
static const unsigned buttonPadding = 5;
static const int buttonBorderSize = 1; // Keep in sync with menuListButtonBorderSize in RenderThemeWPE.
@@ -52,6 +54,10 @@
static const int toggleFocusOffset = 2;
static const Color toggleColor = makeRGB(46, 52, 54);
static const Color toggleDisabledColor = makeRGB(160, 160, 160);
+static const Color spinButtonBorderColor = makeRGB(220, 223, 227);
+static const Color spinButtonBackgroundColor = makeRGB(252, 252, 252);
+static const Color spinButtonBackgroundHoveredColor = makeRGBA(46, 52, 54, 50);
+static const Color spinButtonBackgroundPressedColor = makeRGBA(46, 52, 54, 70);
Theme& Theme::singleton()
{
@@ -74,6 +80,27 @@
graphicsContext.strokePath(path);
}
+void ThemeWPE::paintArrow(GraphicsContext& graphicsContext, ArrowDirection direction)
+{
+ Path path;
+ switch (direction) {
+ case ArrowDirection::Down:
+ path.moveTo({ 3, 6 });
+ path.addLineTo({ 13, 6 });
+ path.addLineTo({ 8, 11 });
+ break;
+ case ArrowDirection::Up:
+ path.moveTo({ 3, 10 });
+ path.addLineTo({ 8, 5 });
+ path.addLineTo({ 13, 10});
+ break;
+ }
+ path.closeSubpath();
+
+ graphicsContext.setFillColor(arrowColor);
+ graphicsContext.fillPath(path);
+}
+
LengthSize ThemeWPE::controlSize(ControlPart part, const FontCascade& fontCascade, const LengthSize& zoomedSize, float zoomFactor) const
{
if (!zoomedSize.width.isIntrinsicOrAuto() && !zoomedSize.height.isIntrinsicOrAuto())
@@ -83,6 +110,14 @@
case CheckboxPart:
case RadioPart:
return LengthSize { Length(12, Fixed), Length(12, Fixed) };
+ case InnerSpinButtonPart: {
+ LengthSize spinButtonSize = zoomedSize;
+ if (spinButtonSize.width.isIntrinsicOrAuto())
+ spinButtonSize.width = Length(static_cast<int>(arrowSize), Fixed);
+ if (spinButtonSize.height.isIntrinsicOrAuto() || fontCascade.pixelSize() > static_cast<int>(arrowSize))
+ spinButtonSize.height = Length(fontCascade.pixelSize(), Fixed);
+ return spinButtonSize;
+ }
default:
break;
}
@@ -105,6 +140,9 @@
case SquareButtonPart:
paintButton(states, context, zoomedRect, zoomFactor);
break;
+ case InnerSpinButtonPart:
+ paintSpinButton(states, context, zoomedRect, zoomFactor);
+ break;
default:
break;
}
@@ -233,4 +271,71 @@
paintFocus(graphicsContext, zoomedRect, buttonFocusOffset);
}
+void ThemeWPE::paintSpinButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
+{
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+
+ FloatRect fieldRect = zoomedRect;
+ FloatSize corner(2, 2);
+ Path path;
+ path.addRoundedRect(fieldRect, corner);
+ fieldRect.inflate(-buttonBorderSize);
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::EvenOdd);
+ graphicsContext.setFillColor(spinButtonBorderColor);
+ graphicsContext.fillPath(path);
+ path.clear();
+
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::NonZero);
+ graphicsContext.setFillColor(spinButtonBackgroundColor);
+ graphicsContext.fillPath(path);
+ path.clear();
+
+ FloatRect buttonRect = fieldRect;
+ buttonRect.setHeight(fieldRect.height() / 2.0);
+ {
+ if (states.states() & ControlStates::SpinUpState) {
+ path.addRoundedRect(FloatRoundedRect(buttonRect, corner, corner, { }, { }));
+ if (states.states() & ControlStates::PressedState)
+ graphicsContext.setFillColor(spinButtonBackgroundPressedColor);
+ else if (states.states() & ControlStates::HoverState)
+ graphicsContext.setFillColor(spinButtonBackgroundHoveredColor);
+ graphicsContext.fillPath(path);
+ path.clear();
+ }
+
+ GraphicsContextStateSaver buttonStateSaver(graphicsContext);
+ if (buttonRect.height() > arrowSize)
+ graphicsContext.translate(buttonRect.x(), buttonRect.y() + (buttonRect.height() / 2.0) - (arrowSize / 2.));
+ else {
+ graphicsContext.translate(buttonRect.x(), buttonRect.y());
+ graphicsContext.scale(FloatSize::narrowPrecision(buttonRect.width() / arrowSize, buttonRect.height() / arrowSize));
+ }
+ paintArrow(graphicsContext, ArrowDirection::Up);
+ }
+
+ buttonRect.move(0, buttonRect.height());
+ {
+ if (!(states.states() & ControlStates::SpinUpState)) {
+ path.addRoundedRect(FloatRoundedRect(buttonRect, { }, { }, corner, corner));
+ if (states.states() & ControlStates::PressedState)
+ graphicsContext.setFillColor(spinButtonBackgroundPressedColor);
+ else if (states.states() & ControlStates::HoverState)
+ graphicsContext.setFillColor(spinButtonBackgroundHoveredColor);
+ graphicsContext.fillPath(path);
+ path.clear();
+ }
+
+ GraphicsContextStateSaver buttonStateSaver(graphicsContext);
+ if (buttonRect.height() > arrowSize)
+ graphicsContext.translate(buttonRect.x(), buttonRect.y() + (buttonRect.height() / 2.0) - (arrowSize / 2.));
+ else {
+ graphicsContext.translate(buttonRect.x(), buttonRect.y());
+ graphicsContext.scale(FloatSize::narrowPrecision(buttonRect.width() / arrowSize, buttonRect.height() / arrowSize));
+ }
+ paintArrow(graphicsContext, ArrowDirection::Down);
+ }
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.h (256822 => 256823)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-18 09:31:31 UTC (rev 256822)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-18 10:48:29 UTC (rev 256823)
@@ -32,6 +32,8 @@
class ThemeWPE final : public Theme {
public:
static void paintFocus(GraphicsContext&, const FloatRect&, int offset);
+ enum class ArrowDirection { Up, Down };
+ static void paintArrow(GraphicsContext&, ArrowDirection);
private:
LengthSize controlSize(ControlPart, const FontCascade&, const LengthSize&, float) const final;
@@ -41,6 +43,7 @@
void paintCheckbox(ControlStates&, GraphicsContext&, const FloatRect&, float);
void paintRadio(ControlStates&, GraphicsContext&, const FloatRect&, float);
void paintButton(ControlStates&, GraphicsContext&, const FloatRect&, float);
+ void paintSpinButton(ControlStates&, GraphicsContext&, const FloatRect&, float);
};
} // namespace WebCore