Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp (256725 => 256726)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-17 09:37:15 UTC (rev 256725)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-17 10:13:00 UTC (rev 256726)
@@ -34,6 +34,7 @@
#include "RenderBox.h"
#include "RenderObject.h"
#include "RenderStyle.h"
+#include "ThemeWPE.h"
#include "UserAgentScripts.h"
#include "UserAgentStyleSheets.h"
#include <wtf/text/StringBuilder.h>
@@ -46,17 +47,11 @@
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 int focusOffset = 3;
-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 menuListButtonFocusOffset = -3;
static const unsigned menuListButtonPadding = 5;
-static const int menuListButtonBorderSize = 1;
-static const Color menuListButtonBackgroundBorderColor = makeRGB(205, 199, 194);
-static const Color menuListButtonBackgroundColor = makeRGB(244, 242, 241);
-static const Color menuListButtonBackgroundPressedColor = makeRGB(214, 209, 205);
-static const Color menuListButtonBackgroundHoveredColor = makeRGB(248, 248, 247);
+static const int menuListButtonBorderSize = 1; // Keep in sync with buttonBorderSize in ThemeWPE.
RenderTheme& RenderTheme::singleton()
{
@@ -69,14 +64,13 @@
switch (style.appearance()) {
case PushButtonPart:
case ButtonPart:
- return false;
case TextFieldPart:
case TextAreaPart:
case SearchFieldPart:
case MenulistPart:
- return true;
case RadioPart:
case CheckboxPart:
+ return true;
case SliderHorizontalPart:
case SliderVerticalPart:
return false;
@@ -158,21 +152,6 @@
return paintTextField(renderObject, paintInfo, rect);
}
-static void paintFocus(GraphicsContext& graphicsContext, const FloatRect& rect)
-{
- FloatRect focusRect = rect;
- focusRect.inflate(-focusOffset);
- graphicsContext.setStrokeThickness(focusLineWidth);
- graphicsContext.setLineDash({ focusLineWidth, 2 * focusLineWidth }, 0);
- graphicsContext.setLineCap(SquareCap);
- graphicsContext.setLineJoin(MiterJoin);
-
- Path path;
- path.addRoundedRect(focusRect, { 5, 5 });
- graphicsContext.setStrokeColor(focusColor);
- graphicsContext.strokePath(path);
-}
-
static void paintArrow(GraphicsContext& graphicsContext, const FloatRect& rect)
{
Path path;
@@ -201,28 +180,18 @@
auto& graphicsContext = paintInfo.context();
GraphicsContextStateSaver stateSaver(graphicsContext);
- FloatRect fieldRect = rect;
- FloatSize corner(5, 5);
- Path path;
- path.addRoundedRect(fieldRect, corner);
- fieldRect.inflate(-menuListButtonBorderSize);
- path.addRoundedRect(fieldRect, corner);
- graphicsContext.setFillRule(WindRule::EvenOdd);
- graphicsContext.setFillColor(menuListButtonBackgroundBorderColor);
- graphicsContext.fillPath(path);
- path.clear();
-
- path.addRoundedRect(fieldRect, corner);
- graphicsContext.setFillRule(WindRule::NonZero);
+ ControlStates::States states = 0;
+ if (isEnabled(renderObject))
+ states |= ControlStates::EnabledState;
if (isPressed(renderObject))
- graphicsContext.setFillColor(menuListButtonBackgroundPressedColor);
- else if (isHovered(renderObject))
- graphicsContext.setFillColor(menuListButtonBackgroundHoveredColor);
- else
- graphicsContext.setFillColor(menuListButtonBackgroundColor);
- graphicsContext.fillPath(path);
- path.clear();
+ states |= ControlStates::PressedState;
+ if (isHovered(renderObject))
+ states |= ControlStates::HoverState;
+ ControlStates controlStates(states);
+ Theme::singleton().paint(ButtonPart, controlStates, graphicsContext, rect, 1., nullptr, 1., 1., false, false);
+ FloatRect fieldRect = rect;
+ fieldRect.inflate(menuListButtonBorderSize);
if (renderObject.style().direction() == TextDirection::LTR)
fieldRect.move(fieldRect.width() - (arrowSize + menuListButtonPadding), (fieldRect.height() / 2.) - (arrowSize / 2));
else
@@ -232,7 +201,7 @@
paintArrow(graphicsContext, fieldRect);
if (isFocused(renderObject))
- paintFocus(graphicsContext, rect);
+ ThemeWPE::paintFocus(graphicsContext, rect, menuListButtonFocusOffset);
return false;
}
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp (256725 => 256726)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-17 09:37:15 UTC (rev 256725)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-17 10:13:00 UTC (rev 256726)
@@ -35,6 +35,24 @@
namespace WebCore {
+static const unsigned focusLineWidth = 1;
+static const Color focusColor = makeRGBA(46, 52, 54, 150);
+static const int buttonFocusOffset = -3;
+static const unsigned buttonPadding = 5;
+static const int buttonBorderSize = 1; // Keep in sync with menuListButtonBorderSize in RenderThemeWPE.
+static const Color buttonBorderColor = makeRGB(205, 199, 194);
+static const Color buttonBackgroundColor = makeRGB(244, 242, 241);
+static const Color buttonBackgroundPressedColor = makeRGB(214, 209, 205);
+static const Color buttonBackgroundHoveredColor = makeRGB(248, 248, 247);
+static const Color buttonBackgroundDisabledColor = makeRGB(246, 246, 244);
+static const Color toggleBackgroundColor = makeRGB(255, 255, 255);
+static const Color toggleBackgroundHoveredColor = makeRGB(242, 242, 242);
+static const Color toggleBackgroundDisabledColor = makeRGB(252, 252, 252);
+static const double toggleSize = 14.;
+static const int toggleFocusOffset = 2;
+static const Color toggleColor = makeRGB(46, 52, 54);
+static const Color toggleDisabledColor = makeRGB(160, 160, 160);
+
Theme& Theme::singleton()
{
static NeverDestroyed<ThemeWPE> theme;
@@ -41,6 +59,21 @@
return theme;
}
+void ThemeWPE::paintFocus(GraphicsContext& graphicsContext, const FloatRect& rect, int offset)
+{
+ FloatRect focusRect = rect;
+ focusRect.inflate(offset);
+ graphicsContext.setStrokeThickness(focusLineWidth);
+ graphicsContext.setLineDash({ focusLineWidth, 2 * focusLineWidth }, 0);
+ graphicsContext.setLineCap(SquareCap);
+ graphicsContext.setLineJoin(MiterJoin);
+
+ Path path;
+ path.addRoundedRect(focusRect, { 2, 2 });
+ graphicsContext.setStrokeColor(focusColor);
+ graphicsContext.strokePath(path);
+}
+
LengthSize ThemeWPE::controlSize(ControlPart part, const FontCascade& fontCascade, const LengthSize& zoomedSize, float zoomFactor) const
{
if (!zoomedSize.width.isIntrinsicOrAuto() && !zoomedSize.height.isIntrinsicOrAuto())
@@ -70,7 +103,7 @@
case DefaultButtonPart:
case ButtonPart:
case SquareButtonPart:
- paintButton(part, states, context, zoomedRect, zoomFactor);
+ paintButton(states, context, zoomedRect, zoomFactor);
break;
default:
break;
@@ -77,79 +110,127 @@
}
}
-void ThemeWPE::paintCheckbox(ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float)
+void ThemeWPE::paintCheckbox(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
{
- GraphicsContextStateSaver stateSaver(context);
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ FloatRect fieldRect = zoomedRect;
FloatSize corner(2, 2);
- FloatRoundedRect roundedRect(zoomedRect, corner, corner, corner, corner);
Path path;
- path.addRoundedRect(roundedRect);
+ path.addRoundedRect(fieldRect, corner);
+ fieldRect.inflate(-buttonBorderSize);
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::EvenOdd);
+ graphicsContext.setFillColor(buttonBorderColor);
+ graphicsContext.fillPath(path);
+ path.clear();
- context.setFillColor(makeRGB(224, 224, 224));
- context.fillPath(path);
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::NonZero);
+ if (!(states.states() & ControlStates::EnabledState))
+ graphicsContext.setFillColor(toggleBackgroundDisabledColor);
+ else if (states.states() & ControlStates::HoverState)
+ graphicsContext.setFillColor(toggleBackgroundHoveredColor);
+ else
+ graphicsContext.setFillColor(toggleBackgroundColor);
+ graphicsContext.fillPath(path);
+ path.clear();
- context.setStrokeThickness(1);
- context.setStrokeColor(makeRGB(94, 94, 94));
- context.strokePath(path);
+ if (states.states() & (ControlStates::CheckedState | ControlStates::IndeterminateState)) {
+ GraphicsContextStateSaver checkedStateSaver(graphicsContext);
+ graphicsContext.translate(fieldRect.x(), fieldRect.y());
+ graphicsContext.scale(FloatSize::narrowPrecision(fieldRect.width() / toggleSize, fieldRect.height() / toggleSize));
+ if (states.states() & ControlStates::CheckedState) {
+ path.moveTo({ 2.43, 6.57 });
+ path.addLineTo({ 7.5, 11.63 });
+ path.addLineTo({ 14, 5 });
+ path.addLineTo({ 14, 1 });
+ path.addLineTo({ 7.5, 7.38 });
+ path.addLineTo({ 4.56, 4.44 });
+ path.closeSubpath();
+ } else
+ path.addRoundedRect(FloatRect(2, 5, 10, 4), corner);
- if (states.states() & ControlStates::CheckedState) {
- auto& rect = roundedRect.rect();
+ if (!(states.states() & ControlStates::EnabledState))
+ graphicsContext.setFillColor(toggleDisabledColor);
+ else
+ graphicsContext.setFillColor(toggleColor);
- Path checkerPath;
- checkerPath.moveTo(FloatPoint(rect.x() + 3, rect.maxY() - 3));
- checkerPath.addLineTo(FloatPoint(rect.maxX() - 3, rect.y() + 3));
+ graphicsContext.fillPath(path);
+ path.clear();
+ }
- context.setStrokeThickness(2);
- context.setStrokeColor(makeRGB(84, 84, 84));
- context.strokePath(checkerPath);
- }
+ if (states.states() & ControlStates::FocusState)
+ paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
}
-void ThemeWPE::paintRadio(ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float)
+void ThemeWPE::paintRadio(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
{
- GraphicsContextStateSaver stateSaver(context);
-
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ FloatRect fieldRect = zoomedRect;
Path path;
- path.addEllipse(zoomedRect);
+ path.addEllipse(fieldRect);
+ fieldRect.inflate(-buttonBorderSize);
+ path.addEllipse(fieldRect);
+ graphicsContext.setFillRule(WindRule::EvenOdd);
+ graphicsContext.setFillColor(buttonBorderColor);
+ graphicsContext.fillPath(path);
+ path.clear();
- context.setFillColor(makeRGB(224, 224, 224));
- context.fillPath(path);
+ path.addEllipse(fieldRect);
+ graphicsContext.setFillRule(WindRule::NonZero);
+ if (!(states.states() & ControlStates::EnabledState))
+ graphicsContext.setFillColor(toggleBackgroundDisabledColor);
+ else if (states.states() & ControlStates::HoverState)
+ graphicsContext.setFillColor(toggleBackgroundHoveredColor);
+ else
+ graphicsContext.setFillColor(toggleBackgroundColor);
+ graphicsContext.fillPath(path);
+ path.clear();
- context.setStrokeThickness(1);
- context.setStrokeColor(makeRGB(94, 94, 94));
- context.strokePath(path);
-
if (states.states() & ControlStates::CheckedState) {
- FloatRect checkerRect = zoomedRect;
- checkerRect.inflate(-3);
+ fieldRect.inflate(-(fieldRect.width() - fieldRect.width() * 0.70));
+ path.addEllipse(fieldRect);
+ if (!(states.states() & ControlStates::EnabledState))
+ graphicsContext.setFillColor(toggleDisabledColor);
+ else
+ graphicsContext.setFillColor(toggleColor);
+ graphicsContext.fillPath(path);
+ }
- Path checkerPath;
- checkerPath.addEllipse(checkerRect);
-
- context.setFillColor(makeRGB(84, 84, 84));
- context.fillPath(checkerPath);
- }
+ if (states.states() & ControlStates::FocusState)
+ paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
}
-void ThemeWPE::paintButton(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float)
+void ThemeWPE::paintButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
{
- GraphicsContextStateSaver stateSaver(context);
+ GraphicsContextStateSaver stateSaver(graphicsContext);
- float roundness = (part == SquareButtonPart) ? 0 : 2;
-
- FloatSize corner(roundness, roundness);
- FloatRoundedRect roundedRect(zoomedRect, corner, corner, corner, corner);
+ FloatRect fieldRect = zoomedRect;
+ FloatSize corner(5, 5);
Path path;
- path.addRoundedRect(roundedRect);
+ path.addRoundedRect(fieldRect, corner);
+ fieldRect.inflate(-buttonBorderSize);
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::EvenOdd);
+ graphicsContext.setFillColor(buttonBorderColor);
+ graphicsContext.fillPath(path);
+ path.clear();
- Color fillColor = states.states() & ControlStates::PressedState ? makeRGB(244, 244, 244) : makeRGB(224, 224, 224);
- context.setFillColor(fillColor);
- context.fillPath(path);
+ path.addRoundedRect(fieldRect, corner);
+ graphicsContext.setFillRule(WindRule::NonZero);
+ if (!(states.states() & ControlStates::EnabledState))
+ graphicsContext.setFillColor(buttonBackgroundDisabledColor);
+ else if (states.states() & ControlStates::PressedState)
+ graphicsContext.setFillColor(buttonBackgroundPressedColor);
+ else if (states.states() & ControlStates::HoverState)
+ graphicsContext.setFillColor(buttonBackgroundHoveredColor);
+ else
+ graphicsContext.setFillColor(buttonBackgroundColor);
+ graphicsContext.fillPath(path);
- context.setStrokeThickness(1);
- context.setStrokeColor(makeRGB(94, 94, 94));
- context.strokePath(path);
+ if (states.states() & ControlStates::FocusState)
+ paintFocus(graphicsContext, zoomedRect, buttonFocusOffset);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.h (256725 => 256726)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-17 09:37:15 UTC (rev 256725)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-17 10:13:00 UTC (rev 256726)
@@ -30,6 +30,9 @@
namespace WebCore {
class ThemeWPE final : public Theme {
+public:
+ static void paintFocus(GraphicsContext&, const FloatRect&, int offset);
+
private:
LengthSize controlSize(ControlPart, const FontCascade&, const LengthSize&, float) const final;
@@ -37,7 +40,7 @@
void paintCheckbox(ControlStates&, GraphicsContext&, const FloatRect&, float);
void paintRadio(ControlStates&, GraphicsContext&, const FloatRect&, float);
- void paintButton(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float);
+ void paintButton(ControlStates&, GraphicsContext&, const FloatRect&, float);
};
} // namespace WebCore