Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1599)

Unified Diff: Source/core/platform/graphics/Color.h

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/Color.h
diff --git a/Source/core/platform/graphics/Color.h b/Source/core/platform/graphics/Color.h
index 1288d4b7110c2b8a1a825d1c1d2e3ee57d8a9d9d..1734fb19caaa92d4b944f30bbe412a710a5d9344 100644
--- a/Source/core/platform/graphics/Color.h
+++ b/Source/core/platform/graphics/Color.h
@@ -55,16 +55,14 @@ inline int alphaChannel(RGBA32 color) { return (color >> 24) & 0xFF; }
class Color {
WTF_MAKE_FAST_ALLOCATED;
public:
- Color() : m_color(0), m_valid(false) { }
- Color(RGBA32 color, bool valid = true) : m_color(color), m_valid(valid) { ASSERT(!m_color || m_valid); }
- Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { }
- Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { }
+ Color() : m_color(0) { }
+ Color(RGBA32 color) : m_color(color) { }
+ Color(int r, int g, int b) : m_color(makeRGB(r, g, b)) { }
+ Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)) { }
// Color is currently limited to 32bit RGBA, perhaps some day we'll support better colors
- Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)), m_valid(true) { }
+ Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)) { }
// Creates a new color from the specific CMYK and alpha values.
- Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)), m_valid(true) { }
- explicit Color(const String&);
- explicit Color(const char*);
+ Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)) { }
static Color createUnchecked(int r, int g, int b)
{
@@ -85,10 +83,6 @@ public:
// The latter format is not a valid CSS color, and should only be seen in DRT dumps.
String nameForRenderTreeAsText() const;
- void setNamedColor(const String&);
-
- bool isValid() const { return m_valid; }
-
bool hasAlpha() const { return alpha() < 255; }
int red() const { return redChannel(m_color); }
@@ -97,8 +91,8 @@ public:
int alpha() const { return alphaChannel(m_color); }
RGBA32 rgb() const { return m_color; } // Preserve the alpha.
- void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); m_valid = true; }
- void setRGB(RGBA32 rgb) { m_color = rgb; m_valid = true; }
+ void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); }
+ void setRGB(RGBA32 rgb) { m_color = rgb; }
void getRGBA(float& r, float& g, float& b, float& a) const;
void getRGBA(double& r, double& g, double& b, double& a) const;
void getHSL(double& h, double& s, double& l) const;
@@ -120,15 +114,15 @@ public:
static const RGBA32 gray = 0xFFA0A0A0;
static const RGBA32 lightGray = 0xFFC0C0C0;
static const RGBA32 transparent = 0x00000000;
+ static const RGBA32 stdShadowColor = 0x00000055;
private:
RGBA32 m_color;
- bool m_valid;
};
inline bool operator==(const Color& a, const Color& b)
{
- return a.rgb() == b.rgb() && a.isValid() == b.isValid();
+ return a.rgb() == b.rgb();
}
inline bool operator!=(const Color& a, const Color& b)
@@ -141,10 +135,6 @@ RGBA32 premultipliedARGBFromColor(const Color&);
inline Color blend(const Color& from, const Color& to, double progress, bool blendPremultiplied = true)
{
- // We need to preserve the state of the valid flag at the end of the animation
- if (progress == 1 && !to.isValid())
- return Color();
-
if (blendPremultiplied) {
// Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor().
// Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that.

Powered by Google App Engine
This is Rietveld 408576698