Extended Color: Rename Color::lighten() and Color::darken() to Color::lightened(...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2020 00:10:55 +0000 (00:10 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Jun 2020 00:10:55 +0000 (00:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212917

Reviewed by Darin Adler.

Addresses feedback from Darin.

Source/WebCore:

* platform/graphics/Color.cpp:
(WebCore::Color::lightened const):
(WebCore::Color::darkened const):
(WebCore::Color::lighten const): Deleted.
(WebCore::Color::darken const): Deleted.
* platform/graphics/Color.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::calculateBorderStyleColor):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::disabledTextColor const):
* rendering/TextPaintStyle.cpp:
(WebCore::adjustColorForVisibilityOnBackground):

Tools:

* TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262753 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/Color.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/TextPaintStyle.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp

index 1c0a7db..e727161 100644 (file)
@@ -1,3 +1,25 @@
+2020-06-08  Sam Weinig  <weinig@apple.com>
+
+        Extended Color: Rename Color::lighten() and Color::darken() to Color::lightened() and Color::darkened()
+        https://bugs.webkit.org/show_bug.cgi?id=212917
+
+        Reviewed by Darin Adler.
+
+        Addresses feedback from Darin.
+
+        * platform/graphics/Color.cpp:
+        (WebCore::Color::lightened const):
+        (WebCore::Color::darkened const):
+        (WebCore::Color::lighten const): Deleted.
+        (WebCore::Color::darken const): Deleted.
+        * platform/graphics/Color.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::calculateBorderStyleColor):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::disabledTextColor const):
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::adjustColorForVisibilityOnBackground):
+
 2020-06-08  Devin Rousso  <drousso@apple.com>
 
         Remove unnecessary variable in `WindowProxy::createJSWindowProxy`
index e89cc27..8ed75fd 100644 (file)
@@ -100,7 +100,7 @@ String Color::nameForRenderTreeAsText() const
     return asSimple().serializationForRenderTreeAsText();
 }
 
-Color Color::lighten() const
+Color Color::lightened() const
 {
     // Hardcode this common case for speed.
     if (!isExtended() && asSimple() == black)
@@ -117,7 +117,7 @@ Color Color::lighten() const
     return makeSimpleColorFromFloats(multiplier * r, multiplier * g, multiplier * b, a);
 }
 
-Color Color::darken() const
+Color Color::darkened() const
 {
     // Hardcode this common case for speed.
     if (!isExtended() && asSimple() == white)
index f9dd618..8ff1d01 100644 (file)
@@ -135,8 +135,8 @@ public:
     // This will convert non-sRGB colorspace colors into sRGB.
     WEBCORE_EXPORT ColorComponents<float> toSRGBAComponentsLossy() const;
 
-    WEBCORE_EXPORT Color lighten() const;
-    WEBCORE_EXPORT Color darken() const;
+    WEBCORE_EXPORT Color lightened() const;
+    WEBCORE_EXPORT Color darkened() const;
 
     WEBCORE_EXPORT float luminance() const;
 
index 82735a3..637e247 100644 (file)
@@ -1815,10 +1815,10 @@ void RenderObject::calculateBorderStyleColor(const BorderStyle& style, const Box
     // Here we will darken the border decoration color when needed. This will yield a similar behavior as in FF.
     if (operation == Darken) {
         if (color.luminance() > baseDarkColorLuminance)
-            color = color.darken();
+            color = color.darkened();
     } else {
         if (color.luminance() < baseLightColorLuminance)
-            color = color.lighten();
+            color = color.lightened();
     }
 }
 
index 35a60ab..a125516 100644 (file)
@@ -1394,9 +1394,9 @@ Color RenderTheme::disabledTextColor(const Color& textColor, const Color& backgr
     // This also means that black on black will turn into grey on black when disabled.
     Color disabledColor;
     if (equalIgnoringSemanticColor(textColor, Color::black) || backgroundColor.alphaAsFloat() < minDisabledColorAlphaValue || textColor.luminance() < backgroundColor.luminance())
-        disabledColor = textColor.lighten();
+        disabledColor = textColor.lightened();
     else
-        disabledColor = textColor.darken();
+        disabledColor = textColor.darkened();
     
     // If there's not very much contrast between the disabled color and the background color,
     // just leave the text color alone. We don't want to change a good contrast color scheme so that it has really bad contrast.
index ab2baa3..8e72a95 100644 (file)
@@ -72,8 +72,8 @@ static Color adjustColorForVisibilityOnBackground(const Color& textColor, const
         return textColor;
 
     if (textColor.luminance() > 0.5)
-        return textColor.darken();
-    return textColor.lighten();
+        return textColor.darkened();
+    return textColor.lightened();
 }
 
 TextPaintStyle computeTextPaintStyle(const Frame& frame, const RenderStyle& lineStyle, const PaintInfo& paintInfo)
index 773d29d..e405b94 100644 (file)
@@ -1,5 +1,17 @@
 2020-06-08  Sam Weinig  <weinig@apple.com>
 
+        Extended Color: Rename Color::lighten() and Color::darken() to Color::lightened() and Color::darkened()
+        https://bugs.webkit.org/show_bug.cgi?id=212917
+
+        Reviewed by Darin Adler.
+
+        Addresses feedback from Darin.
+
+        * TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
+        (TestWebKitAPI::TEST):
+
+2020-06-08  Sam Weinig  <weinig@apple.com>
+
         Fix test results after r262733.
 
         * TestWebKitAPI/Tests/WebCore/ColorTests.cpp:
index 7eb329f..37e9509 100644 (file)
@@ -219,17 +219,17 @@ TEST(Color, Luminance)
     EXPECT_EQ(c.greenComponent(), 90);
     EXPECT_EQ(c.blueComponent(), 160);
 
-    auto cLigtened = Color(c).lighten().toSRGBASimpleColorLossy();
+    auto cLigtened = Color(c).lightened().toSRGBASimpleColorLossy();
     EXPECT_FLOAT_EQ(Color(cLigtened).luminance(), 0.29168808);
     EXPECT_EQ(cLigtened.redComponent(), 130);
     EXPECT_EQ(cLigtened.greenComponent(), 137);
     EXPECT_EQ(cLigtened.blueComponent(), 244);
 
-    auto cDarken = Color(c).darken().toSRGBASimpleColorLossy();
-    EXPECT_FLOAT_EQ(Color(cDarken).luminance(), 0.027006727);
-    EXPECT_EQ(cDarken.redComponent(), 40);
-    EXPECT_EQ(cDarken.greenComponent(), 43);
-    EXPECT_EQ(cDarken.blueComponent(), 76);
+    auto cDarkened = Color(c).darkened().toSRGBASimpleColorLossy();
+    EXPECT_FLOAT_EQ(Color(cDarkened).luminance(), 0.027006727);
+    EXPECT_EQ(cDarkened.redComponent(), 40);
+    EXPECT_EQ(cDarkened.greenComponent(), 43);
+    EXPECT_EQ(cDarkened.blueComponent(), 76);
 }
 
 } // namespace TestWebKitAPI