Modified: trunk/Source/WebCore/ChangeLog (149695 => 149696)
--- trunk/Source/WebCore/ChangeLog 2013-05-07 22:06:15 UTC (rev 149695)
+++ trunk/Source/WebCore/ChangeLog 2013-05-07 22:14:04 UTC (rev 149696)
@@ -1,3 +1,23 @@
+2013-05-07 Benjamin Poulain <bpoul...@apple.com>
+
+ Move CanvasGradient and CanvasPattern in the union of CanvasStyle
+ https://bugs.webkit.org/show_bug.cgi?id=115759
+
+ Reviewed by Andreas Kling.
+
+ The Gradient and Pattern are exclusive with the other values, but they
+ were left out of the union because they are ref-counted.
+
+ This patch moves them in the union, and simply does the ref-counting manually.
+
+ * html/canvas/CanvasStyle.cpp:
+ (WebCore::CanvasStyle::CanvasStyle):
+ (WebCore::CanvasStyle::~CanvasStyle):
+ * html/canvas/CanvasStyle.h:
+ (CanvasStyle):
+ (WebCore::CanvasStyle::canvasGradient):
+ (WebCore::CanvasStyle::canvasPattern):
+
2013-05-07 Anders Carlsson <ander...@apple.com>
Remove custom allocator support from PODArena
Modified: trunk/Source/WebCore/html/canvas/CanvasStyle.cpp (149695 => 149696)
--- trunk/Source/WebCore/html/canvas/CanvasStyle.cpp 2013-05-07 22:06:15 UTC (rev 149695)
+++ trunk/Source/WebCore/html/canvas/CanvasStyle.cpp 2013-05-07 22:14:04 UTC (rev 149696)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2007 Alp Toker <a...@atoker.com>
* Copyright (C) 2008 Eric Seidel <e...@webkit.org>
@@ -125,16 +125,26 @@
CanvasStyle::CanvasStyle(PassRefPtr<CanvasGradient> gradient)
: m_type(Gradient)
- , m_gradient(gradient)
+ , m_gradient(gradient.leakRef())
{
+ m_gradient->ref();
}
CanvasStyle::CanvasStyle(PassRefPtr<CanvasPattern> pattern)
: m_type(ImagePattern)
- , m_pattern(pattern)
+ , m_pattern(pattern.leakRef())
{
+ m_pattern->ref();
}
+CanvasStyle::~CanvasStyle()
+{
+ if (m_type == Gradient)
+ m_gradient->deref();
+ else if (m_type == ImagePattern)
+ m_pattern->deref();
+}
+
PassRefPtr<CanvasStyle> CanvasStyle::createFromString(const String& color, Document* document)
{
RGBA32 rgba;
Modified: trunk/Source/WebCore/html/canvas/CanvasStyle.h (149695 => 149696)
--- trunk/Source/WebCore/html/canvas/CanvasStyle.h 2013-05-07 22:06:15 UTC (rev 149695)
+++ trunk/Source/WebCore/html/canvas/CanvasStyle.h 2013-05-07 22:14:04 UTC (rev 149696)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,11 @@
class HTMLCanvasElement;
class CanvasStyle : public RefCounted<CanvasStyle> {
+ WTF_MAKE_FAST_ALLOCATED;
+ WTF_MAKE_NONCOPYABLE(CanvasStyle);
public:
+ ~CanvasStyle();
+
static PassRefPtr<CanvasStyle> createFromRGBA(RGBA32 rgba) { return adoptRef(new CanvasStyle(rgba)); }
static PassRefPtr<CanvasStyle> createFromString(const String& color, Document* = 0);
static PassRefPtr<CanvasStyle> createFromStringWithOverrideAlpha(const String& color, float alpha);
@@ -56,8 +60,8 @@
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(); }
- CanvasGradient* canvasGradient() const { return m_gradient.get(); }
- CanvasPattern* canvasPattern() const { return m_pattern.get(); }
+ CanvasGradient* canvasGradient() const;
+ CanvasPattern* canvasPattern() const;
void applyFillColor(GraphicsContext*);
void applyStrokeColor(GraphicsContext*);
@@ -82,11 +86,10 @@
union {
RGBA32 m_rgba;
float m_overrideAlpha;
+ CanvasGradient* m_gradient;
+ CanvasPattern* m_pattern;
};
- RefPtr<CanvasGradient> m_gradient;
- RefPtr<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) { }
@@ -101,6 +104,20 @@
RGBA32 currentColor(HTMLCanvasElement*);
bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement*);
+ inline CanvasGradient* CanvasStyle::canvasGradient() const
+ {
+ if (m_type == Gradient)
+ return m_gradient;
+ return 0;
+ }
+
+ inline CanvasPattern* CanvasStyle::canvasPattern() const
+ {
+ if (m_type == ImagePattern)
+ return m_pattern;
+ return 0;
+ }
+
} // namespace WebCore
#endif