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

Unified Diff: Source/core/html/canvas/CanvasStyle.h

Issue 752083003: Use IDL union types for CanvasRenderingContext2D.{fill,stroke}Style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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/html/canvas/CanvasStyle.h
diff --git a/Source/core/html/canvas/CanvasStyle.h b/Source/core/html/canvas/CanvasStyle.h
index a44af7a05876a9b1bd62616f541c4bddad777c28..e8190cbfe193e583d0bef5a4ea159449b501b35f 100644
--- a/Source/core/html/canvas/CanvasStyle.h
+++ b/Source/core/html/canvas/CanvasStyle.h
@@ -43,64 +43,34 @@ namespace blink {
class CanvasStyle final : public RefCountedWillBeGarbageCollected<CanvasStyle> {
public:
static PassRefPtrWillBeRawPtr<CanvasStyle> createFromRGBA(RGBA32 rgba) { return adoptRefWillBeNoop(new CanvasStyle(rgba)); }
- static PassRefPtrWillBeRawPtr<CanvasStyle> createFromString(const String& color);
- static PassRefPtrWillBeRawPtr<CanvasStyle> createFromStringWithOverrideAlpha(const String& color, float alpha);
- static PassRefPtrWillBeRawPtr<CanvasStyle> createFromGrayLevelWithAlpha(float grayLevel, float alpha) { return adoptRefWillBeNoop(new CanvasStyle(grayLevel, alpha)); }
- static PassRefPtrWillBeRawPtr<CanvasStyle> createFromRGBAChannels(float r, float g, float b, float a) { return adoptRefWillBeNoop(new CanvasStyle(r, g, b, a)); }
- static PassRefPtrWillBeRawPtr<CanvasStyle> createFromCMYKAChannels(float c, float m, float y, float k, float a) { return adoptRefWillBeNoop(new CanvasStyle(c, m, y, k, a)); }
static PassRefPtrWillBeRawPtr<CanvasStyle> createFromGradient(PassRefPtrWillBeRawPtr<CanvasGradient>);
static PassRefPtrWillBeRawPtr<CanvasStyle> createFromPattern(PassRefPtrWillBeRawPtr<CanvasPattern>);
- bool isCurrentColor() const { return m_type == CurrentColor || m_type == CurrentColorWithOverrideAlpha; }
- bool hasOverrideAlpha() const { return m_type == CurrentColorWithOverrideAlpha; }
- float overrideAlpha() const { ASSERT(m_type == CurrentColorWithOverrideAlpha); return m_overrideAlpha; }
-
- String color() const { ASSERT(m_type == RGBA || m_type == CMYKA); return Color(m_rgba).serialized(); }
+ String color() const { ASSERT(m_type == ColorRGBA); return Color(m_rgba).serialized(); }
CanvasGradient* canvasGradient() const { return m_gradient.get(); }
CanvasPattern* canvasPattern() const { return m_pattern.get(); }
void applyFillColor(GraphicsContext*);
void applyStrokeColor(GraphicsContext*);
- bool isEquivalentColor(const CanvasStyle&) const;
- bool isEquivalentRGBA(float r, float g, float b, float a) const;
- bool isEquivalentCMYKA(float c, float m, float y, float k, float a) const;
+ bool isEquivalentRGBA(RGBA32 rgba) const { return m_type == ColorRGBA && m_rgba == rgba; }
void trace(Visitor*);
private:
- enum Type { RGBA, CMYKA, Gradient, ImagePattern, CurrentColor, CurrentColorWithOverrideAlpha };
+ enum Type { ColorRGBA, Gradient, ImagePattern };
fs 2014/11/24 13:20:24 Renamed this to make presubmit happy.
- CanvasStyle(Type, float overrideAlpha = 0);
CanvasStyle(RGBA32 rgba);
- CanvasStyle(float grayLevel, float alpha);
- CanvasStyle(float r, float g, float b, float a);
- CanvasStyle(float c, float m, float y, float k, float a);
CanvasStyle(PassRefPtrWillBeRawPtr<CanvasGradient>);
CanvasStyle(PassRefPtrWillBeRawPtr<CanvasPattern>);
Type m_type;
-
- union {
- RGBA32 m_rgba;
- float m_overrideAlpha;
- };
+ RGBA32 m_rgba;
RefPtrWillBeMember<CanvasGradient> m_gradient;
RefPtrWillBeMember<CanvasPattern> m_pattern;
-
- struct CMYKAValues {
- CMYKAValues() : c(0), m(0), y(0), k(0), a(0) { }
- CMYKAValues(float cyan, float magenta, float yellow, float black, float alpha) : c(cyan), m(magenta), y(yellow), k(black), a(alpha) { }
- float c;
- float m;
- float y;
- float k;
- float a;
- } m_cmyka;
};
- RGBA32 currentColor(HTMLCanvasElement*);
bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement*);
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698