Changeset 263713 in webkit
- Timestamp:
- Jun 29, 2020 6:32:01 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r263707 r263713 1 2020-06-29 Sam Weinig <weinig@apple.com> 2 3 Simplify Color's interface by removing isDark() 4 https://bugs.webkit.org/show_bug.cgi?id=213707 5 6 Reviewed by Darin Adler. 7 8 - Move Color::isDark to RenderThemeIOS.mm, its one client and rename it 9 to useConvexGradient() to indicate what it is actually determining. 10 11 * platform/graphics/Color.cpp: 12 (WebCore::Color::isDark const): Deleted. 13 * platform/graphics/Color.h: 14 * rendering/RenderThemeIOS.mm: 15 (WebCore::useConvexGradient): 16 (WebCore::RenderThemeIOS::paintPushButtonDecorations): 17 (WebCore::RenderThemeIOS::paintFileUploadIconDecorations): 18 1 19 2020-06-29 Peng Liu <peng.liu6@apple.com> 2 20 -
trunk/Source/WebCore/platform/graphics/Color.cpp
r263688 r263713 132 132 } 133 133 134 bool Color::isDark() const135 {136 // FIXME: This should probably be using luminance.137 auto [r, g, b, a] = toSRGBALossy();138 float largestNonAlphaChannel = std::max({ r, g, b });139 return a > 0.5 && largestNonAlphaChannel < 0.5;140 }141 142 134 float Color::lightness() const 143 135 { -
trunk/Source/WebCore/platform/graphics/Color.h
r263000 r263713 142 142 143 143 // FIXME: Replace remaining uses with luminance. 144 WEBCORE_EXPORT bool isDark() const;145 144 WEBCORE_EXPORT float lightness() const; 146 145 -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r263688 r263713 1053 1053 } 1054 1054 1055 static bool shouldUseConvexGradient(const Color& backgroundColor) 1056 { 1057 // FIXME: This should probably be using luminance. 1058 auto [r, g, b, a] = backgroundColor.toSRGBALossy(); 1059 float largestNonAlphaChannel = std::max({ r, g, b }); 1060 return a > 0.5 && largestNonAlphaChannel < 0.5; 1061 } 1062 1055 1063 bool RenderThemeIOS::paintPushButtonDecorations(const RenderObject& box, const PaintInfo& paintInfo, const IntRect& rect) 1056 1064 { … … 1059 1067 1060 1068 CGContextRef cgContext = paintInfo.context().platformContext(); 1061 if ( box.style().visitedDependentColor(CSSPropertyBackgroundColor).isDark())1069 if (shouldUseConvexGradient(box.style().visitedDependentColor(CSSPropertyBackgroundColor))) 1062 1070 drawAxialGradient(cgContext, gradientWithName(ConvexGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation); 1063 1071 else { … … 1108 1116 CGContextRef cgContext = paintInfo.context().platformContext(); 1109 1117 paintInfo.context().clip(thumbnailRect); 1110 if ( backgroundImageColor.isDark())1118 if (shouldUseConvexGradient(backgroundImageColor)) 1111 1119 drawAxialGradient(cgContext, gradientWithName(ConvexGradient), thumbnailRect.location(), FloatPoint(thumbnailRect.x(), thumbnailRect.maxY()), LinearInterpolation); 1112 1120 else {
Note: See TracChangeset
for help on using the changeset viewer.