Diff
Modified: trunk/Source/WebCore/ChangeLog (257048 => 257049)
--- trunk/Source/WebCore/ChangeLog 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/ChangeLog 2020-02-20 10:32:04 UTC (rev 257049)
@@ -1,5 +1,25 @@
2020-02-20 Carlos Garcia Campos <[email protected]>
+ [WPE] Use the theme to render the focus ring
+ https://bugs.webkit.org/show_bug.cgi?id=207758
+
+ Reviewed by Adrian Perez de Castro.
+
+ This makes form controls consistent with elements having an auto outline.
+
+ * PlatformWPE.cmake: Add platform/wpe to include dirs.
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::drawFocusRing): Use ThemeWPE::focusColor.
+ * platform/wpe/RenderThemeWPE.cpp:
+ (WebCore::RenderThemeWPE::platformFocusRingColor const): Implement it to return the focus color used by ThemeWPE.
+ * platform/wpe/RenderThemeWPE.h:
+ * platform/wpe/ThemeWPE.cpp:
+ (WebCore::ThemeWPE::focusColor): Return the focus color.
+ (WebCore::ThemeWPE::paintFocus): Add new methods receiving a path or list of rectangles and a color.
+ * platform/wpe/ThemeWPE.h:
+
+2020-02-20 Carlos Garcia Campos <[email protected]>
+
[WPE] Add support for rendering sliders for range elements
https://bugs.webkit.org/show_bug.cgi?id=207694
Modified: trunk/Source/WebCore/PlatformWPE.cmake (257048 => 257049)
--- trunk/Source/WebCore/PlatformWPE.cmake 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/PlatformWPE.cmake 2020-02-20 10:32:04 UTC (rev 257049)
@@ -30,6 +30,7 @@
"${WEBCORE_DIR}/platform/mediacapabilities"
"${WEBCORE_DIR}/platform/mediastream/gstreamer"
"${WEBCORE_DIR}/platform/text/icu"
+ "${WEBCORE_DIR}/platform/wpe"
)
list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (257048 => 257049)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2020-02-20 10:32:04 UTC (rev 257049)
@@ -51,6 +51,9 @@
#include <cairo-win32.h>
#endif
+#if PLATFORM(WPE)
+#include "ThemeWPE.h"
+#endif
namespace WebCore {
@@ -289,6 +292,13 @@
if (paintingDisabled())
return;
+#if PLATFORM(WPE)
+ ThemeWPE::paintFocus(*this, path, color);
+ UNUSED_PARAM(width);
+ UNUSED_PARAM(offset);
+ return;
+#else
+
if (m_impl) {
m_impl->drawFocusRing(path, width, offset, color);
return;
@@ -296,6 +306,7 @@
ASSERT(hasPlatformContext());
Cairo::drawFocusRing(*platformContext(), path, width, color);
+#endif
}
void GraphicsContext::drawFocusRing(const Vector<FloatRect>& rects, float width, float offset, const Color& color)
@@ -303,6 +314,13 @@
if (paintingDisabled())
return;
+#if PLATFORM(WPE)
+ ThemeWPE::paintFocus(*this, rects, color);
+ UNUSED_PARAM(width);
+ UNUSED_PARAM(offset);
+ return;
+#else
+
if (m_impl) {
m_impl->drawFocusRing(rects, width, offset, color);
return;
@@ -310,6 +328,7 @@
ASSERT(hasPlatformContext());
Cairo::drawFocusRing(*platformContext(), rects, width, color);
+#endif
}
void GraphicsContext::drawLineForText(const FloatRect& rect, bool printing, bool doubleUnderlines, StrokeStyle)
Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp (257048 => 257049)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.cpp 2020-02-20 10:32:04 UTC (rev 257049)
@@ -103,6 +103,11 @@
notImplemented();
}
+Color RenderThemeWPE::platformFocusRingColor(OptionSet<StyleColor::Options>) const
+{
+ return ThemeWPE::focusColor();
+}
+
String RenderThemeWPE::extraDefaultStyleSheet()
{
return String(themeAdwaitaUserAgentStyleSheet, sizeof(themeAdwaitaUserAgentStyleSheet));
Modified: trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h (257048 => 257049)
--- trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/platform/wpe/RenderThemeWPE.h 2020-02-20 10:32:04 UTC (rev 257049)
@@ -47,6 +47,7 @@
bool supportsFocusRing(const RenderStyle&) const override;
void updateCachedSystemFontDescription(CSSValueID, FontCascadeDescription&) const override;
+ Color platformFocusRingColor(OptionSet<StyleColor::Options>) const override;
bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) override;
bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override;
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp (257048 => 257049)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.cpp 2020-02-20 10:32:04 UTC (rev 257049)
@@ -36,7 +36,7 @@
namespace WebCore {
static const unsigned focusLineWidth = 1;
-static const Color focusColor = makeRGBA(46, 52, 54, 150);
+static const Color focusRingColor = makeRGBA(46, 52, 54, 150);
static const unsigned arrowSize = 16;
static const Color arrowColor = makeRGB(46, 52, 54);
static const int buttonFocusOffset = -3;
@@ -65,19 +65,45 @@
return theme;
}
+Color ThemeWPE::focusColor()
+{
+ return focusRingColor;
+}
+
void ThemeWPE::paintFocus(GraphicsContext& graphicsContext, const FloatRect& rect, int offset)
{
FloatRect focusRect = rect;
focusRect.inflate(offset);
+ Path path;
+ path.addRoundedRect(focusRect, { 2, 2 });
+ paintFocus(graphicsContext, path, focusRingColor);
+}
+
+void ThemeWPE::paintFocus(GraphicsContext& graphicsContext, const Path& path, const Color& color)
+{
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+
+ graphicsContext.beginTransparencyLayer(color.alphaAsFloat());
graphicsContext.setStrokeThickness(focusLineWidth);
graphicsContext.setLineDash({ focusLineWidth, 2 * focusLineWidth }, 0);
graphicsContext.setLineCap(SquareCap);
graphicsContext.setLineJoin(MiterJoin);
+ graphicsContext.setStrokeColor(color.opaqueColor());
+ graphicsContext.strokePath(path);
+ graphicsContext.setFillRule(WindRule::NonZero);
+ graphicsContext.setCompositeOperation(CompositeOperator::Clear);
+ graphicsContext.fillPath(path);
+ graphicsContext.setCompositeOperation(CompositeOperator::SourceOver);
+ graphicsContext.endTransparencyLayer();
+}
+void ThemeWPE::paintFocus(GraphicsContext& graphicsContext, const Vector<FloatRect>& rects, const Color& color)
+{
+ FloatSize corner(2, 2);
Path path;
- path.addRoundedRect(focusRect, { 2, 2 });
- graphicsContext.setStrokeColor(focusColor);
- graphicsContext.strokePath(path);
+ for (const auto& rect : rects)
+ path.addRoundedRect(rect, corner);
+ paintFocus(graphicsContext, path, color);
}
void ThemeWPE::paintArrow(GraphicsContext& graphicsContext, ArrowDirection direction)
Modified: trunk/Source/WebCore/platform/wpe/ThemeWPE.h (257048 => 257049)
--- trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-20 10:03:21 UTC (rev 257048)
+++ trunk/Source/WebCore/platform/wpe/ThemeWPE.h 2020-02-20 10:32:04 UTC (rev 257049)
@@ -31,7 +31,10 @@
class ThemeWPE final : public Theme {
public:
+ static Color focusColor();
static void paintFocus(GraphicsContext&, const FloatRect&, int offset);
+ static void paintFocus(GraphicsContext&, const Path&, const Color&);
+ static void paintFocus(GraphicsContext&, const Vector<FloatRect>&, const Color&);
enum class ArrowDirection { Up, Down };
static void paintArrow(GraphicsContext&, ArrowDirection);