Modified: trunk/Source/WebCore/ChangeLog (263712 => 263713)
--- trunk/Source/WebCore/ChangeLog 2020-06-30 01:12:31 UTC (rev 263712)
+++ trunk/Source/WebCore/ChangeLog 2020-06-30 01:32:01 UTC (rev 263713)
@@ -1,3 +1,21 @@
+2020-06-29 Sam Weinig <wei...@apple.com>
+
+ Simplify Color's interface by removing isDark()
+ https://bugs.webkit.org/show_bug.cgi?id=213707
+
+ Reviewed by Darin Adler.
+
+ - Move Color::isDark to RenderThemeIOS.mm, its one client and rename it
+ to useConvexGradient() to indicate what it is actually determining.
+
+ * platform/graphics/Color.cpp:
+ (WebCore::Color::isDark const): Deleted.
+ * platform/graphics/Color.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::useConvexGradient):
+ (WebCore::RenderThemeIOS::paintPushButtonDecorations):
+ (WebCore::RenderThemeIOS::paintFileUploadIconDecorations):
+
2020-06-29 Peng Liu <peng.l...@apple.com>
Video spills over PiP screen a little when using Picture in Picture
Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (263712 => 263713)
--- trunk/Source/WebCore/platform/graphics/Color.cpp 2020-06-30 01:12:31 UTC (rev 263712)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp 2020-06-30 01:32:01 UTC (rev 263713)
@@ -131,14 +131,6 @@
return makeSimpleColor(SRGBA { multiplier * r, multiplier * g, multiplier * b, a });
}
-bool Color::isDark() const
-{
- // FIXME: This should probably be using luminance.
- auto [r, g, b, a] = toSRGBALossy();
- float largestNonAlphaChannel = std::max({ r, g, b });
- return a > 0.5 && largestNonAlphaChannel < 0.5;
-}
-
float Color::lightness() const
{
// FIXME: This can probably avoid conversion to sRGB by having per-colorspace algorithms for HSL.
Modified: trunk/Source/WebCore/platform/graphics/Color.h (263712 => 263713)
--- trunk/Source/WebCore/platform/graphics/Color.h 2020-06-30 01:12:31 UTC (rev 263712)
+++ trunk/Source/WebCore/platform/graphics/Color.h 2020-06-30 01:32:01 UTC (rev 263713)
@@ -141,7 +141,6 @@
WEBCORE_EXPORT float luminance() const;
// FIXME: Replace remaining uses with luminance.
- WEBCORE_EXPORT bool isDark() const;
WEBCORE_EXPORT float lightness() const;
// This is an implementation of Porter-Duff's "source-over" equation
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (263712 => 263713)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-06-30 01:12:31 UTC (rev 263712)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-06-30 01:32:01 UTC (rev 263713)
@@ -1052,6 +1052,14 @@
return paintPushButtonDecorations(box, paintInfo, rect);
}
+static bool shouldUseConvexGradient(const Color& backgroundColor)
+{
+ // FIXME: This should probably be using luminance.
+ auto [r, g, b, a] = backgroundColor.toSRGBALossy();
+ float largestNonAlphaChannel = std::max({ r, g, b });
+ return a > 0.5 && largestNonAlphaChannel < 0.5;
+}
+
bool RenderThemeIOS::paintPushButtonDecorations(const RenderObject& box, const PaintInfo& paintInfo, const IntRect& rect)
{
GraphicsContextStateSaver stateSaver(paintInfo.context());
@@ -1058,7 +1066,7 @@
FloatRect clip = addRoundedBorderClip(box, paintInfo.context(), rect);
CGContextRef cgContext = paintInfo.context().platformContext();
- if (box.style().visitedDependentColor(CSSPropertyBackgroundColor).isDark())
+ if (shouldUseConvexGradient(box.style().visitedDependentColor(CSSPropertyBackgroundColor)))
drawAxialGradient(cgContext, gradientWithName(ConvexGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation);
else {
drawAxialGradient(cgContext, gradientWithName(ShadeGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation);
@@ -1107,7 +1115,7 @@
GraphicsContextStateSaver stateSaver2(paintInfo.context());
CGContextRef cgContext = paintInfo.context().platformContext();
paintInfo.context().clip(thumbnailRect);
- if (backgroundImageColor.isDark())
+ if (shouldUseConvexGradient(backgroundImageColor))
drawAxialGradient(cgContext, gradientWithName(ConvexGradient), thumbnailRect.location(), FloatPoint(thumbnailRect.x(), thumbnailRect.maxY()), LinearInterpolation);
else {
drawAxialGradient(cgContext, gradientWithName(ShadeGradient), thumbnailRect.location(), FloatPoint(thumbnailRect.x(), thumbnailRect.maxY()), LinearInterpolation);