Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp (255788 => 255789)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-05 07:12:53 UTC (rev 255788)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-05 09:14:17 UTC (rev 255789)
@@ -26,7 +26,14 @@
#include "config.h"
#include "RenderThemeWPE.h"
+#include "Color.h"
+#include "FloatRoundedRect.h"
+#include "GraphicsContext.h"
#include "NotImplemented.h"
+#include "PaintInfo.h"
+#include "RenderBox.h"
+#include "RenderObject.h"
+#include "RenderStyle.h"
#include "UserAgentScripts.h"
#include "UserAgentStyleSheets.h"
#include <wtf/text/StringBuilder.h>
@@ -33,6 +40,18 @@
namespace WebCore {
+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 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);
+
RenderTheme& RenderTheme::singleton()
{
static NeverDestroyed<RenderThemeWPE> theme;
@@ -39,6 +58,29 @@
return theme;
}
+bool RenderThemeWPE::supportsFocusRing(const RenderStyle& style) const
+{
+ switch (style.appearance()) {
+ case PushButtonPart:
+ case ButtonPart:
+ case TextFieldPart:
+ case TextAreaPart:
+ case SearchFieldPart:
+ return false;
+ case MenulistPart:
+ return true;
+ case RadioPart:
+ case CheckboxPart:
+ case SliderHorizontalPart:
+ case SliderVerticalPart:
+ return false;
+ default:
+ break;
+ }
+
+ return false;
+}
+
void RenderThemeWPE::updateCachedSystemFontDescription(CSSValueID, FontCascadeDescription&) const
{
notImplemented();
@@ -63,4 +105,89 @@
return scriptBuilder.toString();
}
#endif
+
+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;
+ 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);
+
+ return { menuListButtonPadding, rightPadding, menuListButtonPadding, leftPadding };
+}
+
+bool RenderThemeWPE::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
+{
+ 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);
+ if (isPressed(renderObject))
+ graphicsContext.setFillColor(menuListButtonBackgroundPressedColor);
+ else if (isHovered(renderObject))
+ graphicsContext.setFillColor(menuListButtonBackgroundHoveredColor);
+ else
+ graphicsContext.setFillColor(menuListButtonBackgroundColor);
+ graphicsContext.fillPath(path);
+ path.clear();
+
+ if (renderObject.style().direction() == TextDirection::LTR)
+ fieldRect.move(fieldRect.width() - (arrowSize + menuListButtonPadding), (fieldRect.height() / 2.) - (arrowSize / 2));
+ else
+ fieldRect.move(menuListButtonPadding, (fieldRect.height() / 2.) - (arrowSize / 2));
+ fieldRect.setWidth(arrowSize);
+ fieldRect.setHeight(arrowSize);
+ paintArrow(graphicsContext, fieldRect);
+
+ if (isFocused(renderObject))
+ paintFocus(graphicsContext, rect);
+
+ return false;
+}
+
+bool RenderThemeWPE::paintMenuListButtonDecorations(const RenderBox& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
+{
+ return paintMenuList(renderObject, paintInfo, rect);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h (255788 => 255789)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h 2020-02-05 07:12:53 UTC (rev 255788)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h 2020-02-05 09:14:17 UTC (rev 255789)
@@ -43,7 +43,15 @@
RenderThemeWPE() = default;
virtual ~RenderThemeWPE() = default;
+ bool supportsHover(const RenderStyle&) const override { return true; }
+ bool supportsFocusRing(const RenderStyle&) const override;
+
void updateCachedSystemFontDescription(CSSValueID, FontCascadeDescription&) const override;
+
+ bool popsMenuBySpaceOrReturn() const override { return true; }
+ LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
+ bool paintMenuList(const RenderObject&, const PaintInfo&, const FloatRect&) override;
+ bool paintMenuListButtonDecorations(const RenderBox&, const PaintInfo&, const FloatRect&) override;
};
} // namespace WebCore