Commit b1824215 authored by ager@chromium.org's avatar ager@chromium.org

Add RGBColor::create to handle ref counts for RGBColor objects

correctly.  Currently, we leak all allocated RGBColor values because
we are messing up the refcounting.

This is part one of three of fixing http://crbug.com/9514.  Part two
is landing the corresponding codegenerator change upstream.  Part
three is making the RGBColor constructor private.

TEST=LayoutTests/transitions/shorthand-border-transitions.html
BUG=9514
Review URL: http://codereview.chromium.org/155049

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19911 0039d316-1c4b-4281-b951-d872f2087c98
parent 3e90d4a0
......@@ -31,19 +31,27 @@
namespace WebCore {
PassRefPtr<CSSPrimitiveValue> RGBColor::red() {
unsigned int value = (m_rgbcolor >> 16) & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
PassRefPtr<RGBColor> RGBColor::create(unsigned rgbcolor)
{
return adoptRef(new RGBColor(rgbcolor));
}
PassRefPtr<CSSPrimitiveValue> RGBColor::green() {
unsigned int value = (m_rgbcolor >> 8) & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
PassRefPtr<CSSPrimitiveValue> RGBColor::red()
{
unsigned int value = (m_rgbcolor >> 16) & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
}
PassRefPtr<CSSPrimitiveValue> RGBColor::blue() {
unsigned int value = m_rgbcolor & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
PassRefPtr<CSSPrimitiveValue> RGBColor::green()
{
unsigned int value = (m_rgbcolor >> 8) & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
}
PassRefPtr<CSSPrimitiveValue> RGBColor::blue()
{
unsigned int value = m_rgbcolor & 0xFF;
return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
}
} // namespace WebCore
......
......@@ -12,15 +12,19 @@
namespace WebCore {
class RGBColor : public RefCounted<RGBColor> {
public:
RGBColor(unsigned rgbcolor) : m_rgbcolor(rgbcolor) { }
public:
// TODO(ager): Make constructor private once codegenerator changes
// have landed upstream.
RGBColor(unsigned rgbcolor) : m_rgbcolor(rgbcolor) { }
PassRefPtr<CSSPrimitiveValue> red();
PassRefPtr<CSSPrimitiveValue> green();
PassRefPtr<CSSPrimitiveValue> blue();
static PassRefPtr<RGBColor> create(unsigned rgbcolor);
private:
unsigned m_rgbcolor;
PassRefPtr<CSSPrimitiveValue> red();
PassRefPtr<CSSPrimitiveValue> green();
PassRefPtr<CSSPrimitiveValue> blue();
private:
unsigned m_rgbcolor;
};
} // namespace WebCore
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment