Changeset 263713 in webkit


Ignore:
Timestamp:
Jun 29, 2020 6:32:01 PM (4 years ago)
Author:
weinig@apple.com
Message:

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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263707 r263713  
     12020-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
    1192020-06-29  Peng Liu  <peng.liu6@apple.com>
    220
  • trunk/Source/WebCore/platform/graphics/Color.cpp

    r263688 r263713  
    132132}
    133133
    134 bool Color::isDark() const
    135 {
    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 
    142134float Color::lightness() const
    143135{
  • trunk/Source/WebCore/platform/graphics/Color.h

    r263000 r263713  
    142142
    143143    // FIXME: Replace remaining uses with luminance.
    144     WEBCORE_EXPORT bool isDark() const;
    145144    WEBCORE_EXPORT float lightness() const;
    146145
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r263688 r263713  
    10531053}
    10541054
     1055static 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
    10551063bool RenderThemeIOS::paintPushButtonDecorations(const RenderObject& box, const PaintInfo& paintInfo, const IntRect& rect)
    10561064{
     
    10591067
    10601068    CGContextRef cgContext = paintInfo.context().platformContext();
    1061     if (box.style().visitedDependentColor(CSSPropertyBackgroundColor).isDark())
     1069    if (shouldUseConvexGradient(box.style().visitedDependentColor(CSSPropertyBackgroundColor)))
    10621070        drawAxialGradient(cgContext, gradientWithName(ConvexGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation);
    10631071    else {
     
    11081116            CGContextRef cgContext = paintInfo.context().platformContext();
    11091117            paintInfo.context().clip(thumbnailRect);
    1110             if (backgroundImageColor.isDark())
     1118            if (shouldUseConvexGradient(backgroundImageColor))
    11111119                drawAxialGradient(cgContext, gradientWithName(ConvexGradient), thumbnailRect.location(), FloatPoint(thumbnailRect.x(), thumbnailRect.maxY()), LinearInterpolation);
    11121120            else {
Note: See TracChangeset for help on using the changeset viewer.