Commit 6ac9e50e authored by andersca@apple.com's avatar andersca@apple.com

Reviewed by Darin.

        Move remaining render style objects over to start with a refcount of 1 and get
        rid of DeprecatedDataRef.
        
        * rendering/DataRef.h:
        (WebCore::DataRef::operator*):
        (WebCore::DataRef::operator->):
        * rendering/RenderStyle.h:
        * rendering/SVGRenderStyle.cpp:
        (WebCore::SVGRenderStyle::SVGRenderStyle):
        * rendering/SVGRenderStyle.h:
        (WebCore::SVGRenderStyle::create):
        (WebCore::SVGRenderStyle::copy):
        * rendering/SVGRenderStyleDefs.cpp:
        (StyleFillData::StyleFillData):
        (StyleStrokeData::StyleStrokeData):
        (StyleStopData::StyleStopData):
        (StyleTextData::StyleTextData):
        (StyleClipData::StyleClipData):
        (StyleMaskData::StyleMaskData):
        (StyleMarkerData::StyleMarkerData):
        (StyleMiscData::StyleMiscData):
        * rendering/SVGRenderStyleDefs.h:
        (WebCore::StyleFillData::create):
        (WebCore::StyleFillData::copy):
        (WebCore::StyleStrokeData::create):
        (WebCore::StyleStrokeData::copy):
        (WebCore::StyleStopData::create):
        (WebCore::StyleStopData::copy):
        (WebCore::StyleTextData::create):
        (WebCore::StyleTextData::copy):
        (WebCore::StyleClipData::create):
        (WebCore::StyleClipData::copy):
        (WebCore::StyleMaskData::create):
        (WebCore::StyleMaskData::copy):
        (WebCore::StyleMarkerData::create):
        (WebCore::StyleMarkerData::copy):
        (WebCore::StyleMiscData::create):
        (WebCore::StyleMiscData::copy):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30577 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3b6e3b06
2008-02-25 Anders Carlsson <andersca@apple.com>
Reviewed by Darin.
Move remaining render style objects over to start with a refcount of 1 and get
rid of DeprecatedDataRef.
* rendering/DataRef.h:
(WebCore::DataRef::operator*):
(WebCore::DataRef::operator->):
* rendering/RenderStyle.h:
* rendering/SVGRenderStyle.cpp:
(WebCore::SVGRenderStyle::SVGRenderStyle):
* rendering/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::create):
(WebCore::SVGRenderStyle::copy):
* rendering/SVGRenderStyleDefs.cpp:
(StyleFillData::StyleFillData):
(StyleStrokeData::StyleStrokeData):
(StyleStopData::StyleStopData):
(StyleTextData::StyleTextData):
(StyleClipData::StyleClipData):
(StyleMaskData::StyleMaskData):
(StyleMarkerData::StyleMarkerData):
(StyleMiscData::StyleMiscData):
* rendering/SVGRenderStyleDefs.h:
(WebCore::StyleFillData::create):
(WebCore::StyleFillData::copy):
(WebCore::StyleStrokeData::create):
(WebCore::StyleStrokeData::copy):
(WebCore::StyleStopData::create):
(WebCore::StyleStopData::copy):
(WebCore::StyleTextData::create):
(WebCore::StyleTextData::copy):
(WebCore::StyleClipData::create):
(WebCore::StyleClipData::copy):
(WebCore::StyleMaskData::create):
(WebCore::StyleMaskData::copy):
(WebCore::StyleMarkerData::create):
(WebCore::StyleMarkerData::copy):
(WebCore::StyleMiscData::create):
(WebCore::StyleMiscData::copy):
2008-02-25 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
......@@ -32,8 +32,8 @@ template <typename T> class DataRef {
public:
const T* get() const { return m_data.get(); }
const T& operator*() const { return *m_data; }
const T* operator->() const { return m_data.get(); }
const T& operator*() const { return *get(); }
const T* operator->() const { return get(); }
T* access()
{
......@@ -66,76 +66,6 @@ private:
RefPtr<T> m_data;
};
template <typename T> class DeprecatedDataRef {
public:
DeprecatedDataRef()
: m_data(0)
{
}
DeprecatedDataRef(const DeprecatedDataRef<T>& d)
{
ASSERT(d.m_data);
m_data = d.m_data;
m_data->ref();
}
~DeprecatedDataRef()
{
if (m_data)
m_data->deref();
}
const T* get() const { return m_data; }
T& operator*() const { return *m_data; }
const T* operator->() const { return m_data; }
T* access()
{
if (!m_data->hasOneRef()) {
m_data->deref();
m_data = new T(*m_data);
m_data->ref();
}
return m_data;
}
void init()
{
ASSERT(!m_data);
m_data = new T;
m_data->ref();
}
DeprecatedDataRef<T>& operator=(const DeprecatedDataRef<T>& d)
{
ASSERT(d.m_data);
d.m_data->ref();
if (m_data)
m_data->deref();
m_data = d.m_data;
return *this;
}
bool operator==(const DeprecatedDataRef<T>& o) const
{
ASSERT(m_data);
ASSERT(o.m_data);
return m_data == o.m_data || *m_data == *o.m_data;
}
bool operator!=(const DeprecatedDataRef<T>& o) const
{
ASSERT(m_data);
ASSERT(o.m_data);
return m_data != o.m_data && *m_data != *o.m_data;
}
private:
T* m_data;
};
} // namespace WebCore
#endif // DataRef_h
......@@ -1523,7 +1523,7 @@ protected:
int m_ref;
#if ENABLE(SVG)
DeprecatedDataRef<SVGRenderStyle> m_svgStyle;
DataRef<SVGRenderStyle> m_svgStyle;
#endif
// !END SYNC!
......
......@@ -38,28 +38,23 @@
namespace WebCore {
SVGRenderStyle *SVGRenderStyle::s_defaultStyle = 0;
SVGRenderStyle::SVGRenderStyle()
: RefCounted<SVGRenderStyle>(0)
{
if (!s_defaultStyle)
s_defaultStyle = new SVGRenderStyle(true);
fill = s_defaultStyle->fill;
stroke = s_defaultStyle->stroke;
text = s_defaultStyle->text;
stops = s_defaultStyle->stops;
clip = s_defaultStyle->clip;
mask = s_defaultStyle->mask;
misc = s_defaultStyle->misc;
markers = s_defaultStyle->markers;
static SVGRenderStyle* defaultStyle = new SVGRenderStyle(CreateDefault);
fill = defaultStyle->fill;
stroke = defaultStyle->stroke;
text = defaultStyle->text;
stops = defaultStyle->stops;
clip = defaultStyle->clip;
mask = defaultStyle->mask;
misc = defaultStyle->misc;
markers = defaultStyle->markers;
setBitDefaults();
}
SVGRenderStyle::SVGRenderStyle(bool)
: RefCounted<SVGRenderStyle>(0)
SVGRenderStyle::SVGRenderStyle(CreateDefaultType)
{
setBitDefaults();
......@@ -74,7 +69,7 @@ SVGRenderStyle::SVGRenderStyle(bool)
}
SVGRenderStyle::SVGRenderStyle(const SVGRenderStyle& other)
: RefCounted<SVGRenderStyle>(0)
: RefCounted<SVGRenderStyle>()
{
fill = other.fill;
stroke = other.stroke;
......
......@@ -40,9 +40,8 @@ namespace WebCore {
class SVGRenderStyle : public RefCounted<SVGRenderStyle> {
public:
SVGRenderStyle();
SVGRenderStyle(bool); // Used to create the default style.
SVGRenderStyle(const SVGRenderStyle&);
static PassRefPtr<SVGRenderStyle> create() { return adoptRef(new SVGRenderStyle); }
PassRefPtr<SVGRenderStyle> copy() const { return adoptRef(new SVGRenderStyle(*this));}
~SVGRenderStyle();
bool inheritedNotEqual(const SVGRenderStyle*) const;
......@@ -169,22 +168,23 @@ namespace WebCore {
} svg_noninherited_flags;
// inherited attributes
DeprecatedDataRef<StyleFillData> fill;
DeprecatedDataRef<StyleStrokeData> stroke;
DeprecatedDataRef<StyleMarkerData> markers;
DeprecatedDataRef<StyleTextData> text;
DataRef<StyleFillData> fill;
DataRef<StyleStrokeData> stroke;
DataRef<StyleMarkerData> markers;
DataRef<StyleTextData> text;
// non-inherited attributes
DeprecatedDataRef<StyleStopData> stops;
DeprecatedDataRef<StyleClipData> clip;
DeprecatedDataRef<StyleMaskData> mask;
DeprecatedDataRef<StyleMiscData> misc;
// static default style
static SVGRenderStyle *s_defaultStyle;
DataRef<StyleStopData> stops;
DataRef<StyleClipData> clip;
DataRef<StyleMaskData> mask;
DataRef<StyleMiscData> misc;
private:
SVGRenderStyle(const SVGRenderStyle*) : RefCounted<SVGRenderStyle>(0) { }
enum CreateDefaultType { CreateDefault };
SVGRenderStyle();
SVGRenderStyle(const SVGRenderStyle&);
SVGRenderStyle(CreateDefaultType); // Used to create the default style.
void setBitDefaults()
{
......
......@@ -36,14 +36,13 @@
using namespace WebCore;
StyleFillData::StyleFillData()
: RefCounted<StyleFillData>(0)
{
paint = SVGRenderStyle::initialFillPaint();
opacity = SVGRenderStyle::initialFillOpacity();
}
StyleFillData::StyleFillData(const StyleFillData& other)
: RefCounted<StyleFillData>(0)
: RefCounted<StyleFillData>()
{
paint = other.paint;
opacity = other.opacity;
......@@ -70,7 +69,6 @@ bool StyleFillData::operator==(const StyleFillData &other) const
}
StyleStrokeData::StyleStrokeData()
: RefCounted<StyleStrokeData>(0)
{
width = SVGRenderStyle::initialStrokeWidth();
paint = SVGRenderStyle::initialStrokePaint();
......@@ -81,7 +79,7 @@ StyleStrokeData::StyleStrokeData()
}
StyleStrokeData::StyleStrokeData(const StyleStrokeData& other)
: RefCounted<StyleStrokeData>(0)
: RefCounted<StyleStrokeData>()
{
width = other.width;
paint = other.paint;
......@@ -102,14 +100,13 @@ bool StyleStrokeData::operator==(const StyleStrokeData &other) const
}
StyleStopData::StyleStopData()
: RefCounted<StyleStopData>(0)
{
color = SVGRenderStyle::initialStopColor();
opacity = SVGRenderStyle::initialStopOpacity();
}
StyleStopData::StyleStopData(const StyleStopData& other)
: RefCounted<StyleStopData>(0)
: RefCounted<StyleStopData>()
{
color = other.color;
opacity = other.opacity;
......@@ -122,13 +119,12 @@ bool StyleStopData::operator==(const StyleStopData &other) const
}
StyleTextData::StyleTextData()
: RefCounted<StyleTextData>(0)
{
kerning = SVGRenderStyle::initialKerning();
}
StyleTextData::StyleTextData(const StyleTextData& other)
: RefCounted<StyleTextData>(0)
: RefCounted<StyleTextData>()
{
kerning = other.kerning;
}
......@@ -139,13 +135,12 @@ bool StyleTextData::operator==(const StyleTextData& other) const
}
StyleClipData::StyleClipData()
: RefCounted<StyleClipData>(0)
{
clipPath = SVGRenderStyle::initialClipPath();
}
StyleClipData::StyleClipData(const StyleClipData& other)
: RefCounted<StyleClipData>(0)
: RefCounted<StyleClipData>()
{
clipPath = other.clipPath;
}
......@@ -156,13 +151,12 @@ bool StyleClipData::operator==(const StyleClipData &other) const
}
StyleMaskData::StyleMaskData()
: RefCounted<StyleMaskData>(0)
{
maskElement = SVGRenderStyle::initialMaskElement();
}
StyleMaskData::StyleMaskData(const StyleMaskData& other)
: RefCounted<StyleMaskData>(0)
: RefCounted<StyleMaskData>()
{
maskElement = other.maskElement;
}
......@@ -173,7 +167,6 @@ bool StyleMaskData::operator==(const StyleMaskData &other) const
}
StyleMarkerData::StyleMarkerData()
: RefCounted<StyleMarkerData>(0)
{
startMarker = SVGRenderStyle::initialStartMarker();
midMarker = SVGRenderStyle::initialMidMarker();
......@@ -181,7 +174,7 @@ StyleMarkerData::StyleMarkerData()
}
StyleMarkerData::StyleMarkerData(const StyleMarkerData& other)
: RefCounted<StyleMarkerData>(0)
: RefCounted<StyleMarkerData>()
{
startMarker = other.startMarker;
midMarker = other.midMarker;
......@@ -194,7 +187,6 @@ bool StyleMarkerData::operator==(const StyleMarkerData &other) const
}
StyleMiscData::StyleMiscData()
: RefCounted<StyleMiscData>(0)
{
floodColor = SVGRenderStyle::initialFloodColor();
floodOpacity = SVGRenderStyle::initialFloodOpacity();
......@@ -203,7 +195,7 @@ StyleMiscData::StyleMiscData()
}
StyleMiscData::StyleMiscData(const StyleMiscData& other)
: RefCounted<StyleMiscData>(0)
: RefCounted<StyleMiscData>()
{
filter = other.filter;
floodColor = other.floodColor;
......
......@@ -131,9 +131,9 @@ namespace WebCore {
// Inherited/Non-Inherited Style Datastructures
class StyleFillData : public RefCounted<StyleFillData> {
public:
StyleFillData();
StyleFillData(const StyleFillData &other);
static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); }
PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); }
bool operator==(const StyleFillData &other) const;
bool operator!=(const StyleFillData &other) const
{
......@@ -144,13 +144,14 @@ namespace WebCore {
RefPtr<SVGPaint> paint;
private:
StyleFillData &operator=(const StyleFillData &);
StyleFillData();
StyleFillData(const StyleFillData&);
};
class StyleStrokeData : public RefCounted<StyleStrokeData> {
public:
StyleStrokeData();
StyleStrokeData(const StyleStrokeData&);
static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); }
PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); }
bool operator==(const StyleStrokeData&) const;
bool operator!=(const StyleStrokeData& other) const
......@@ -167,14 +168,15 @@ namespace WebCore {
RefPtr<SVGPaint> paint;
RefPtr<CSSValueList> dashArray;
private:
StyleStrokeData &operator=(const StyleStrokeData&);
private:
StyleStrokeData();
StyleStrokeData(const StyleStrokeData&);
};
class StyleStopData : public RefCounted<StyleStopData> {
public:
StyleStopData();
StyleStopData(const StyleStopData &other);
static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); }
PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); }
bool operator==(const StyleStopData &other) const;
bool operator!=(const StyleStopData &other) const
......@@ -185,15 +187,16 @@ namespace WebCore {
float opacity;
Color color;
private:
StyleStopData &operator=(const StyleStopData &);
private:
StyleStopData();
StyleStopData(const StyleStopData&);
};
class StyleTextData : public RefCounted<StyleTextData> {
public:
StyleTextData();
StyleTextData(const StyleTextData& other);
static PassRefPtr<StyleTextData> create() { return adoptRef(new StyleTextData); }
PassRefPtr<StyleTextData> copy() const { return adoptRef(new StyleTextData(*this)); }
bool operator==(const StyleTextData& other) const;
bool operator!=(const StyleTextData& other) const
{
......@@ -203,13 +206,14 @@ namespace WebCore {
RefPtr<CSSValue> kerning;
private:
StyleTextData& operator=(const StyleTextData&);
StyleTextData();
StyleTextData(const StyleTextData& other);
};
class StyleClipData : public RefCounted<StyleClipData> {
public:
StyleClipData();
StyleClipData(const StyleClipData &other);
static PassRefPtr<StyleClipData> create() { return adoptRef(new StyleClipData); }
PassRefPtr<StyleClipData> copy() const { return adoptRef(new StyleClipData(*this)); }
bool operator==(const StyleClipData &other) const;
bool operator!=(const StyleClipData &other) const
......@@ -220,27 +224,29 @@ namespace WebCore {
String clipPath;
private:
StyleClipData &operator=(const StyleClipData &);
StyleClipData();
StyleClipData(const StyleClipData&);
};
class StyleMaskData : public RefCounted<StyleMaskData> {
public:
StyleMaskData();
StyleMaskData(const StyleMaskData &other);
static PassRefPtr<StyleMaskData> create() { return adoptRef(new StyleMaskData); }
PassRefPtr<StyleMaskData> copy() const { return adoptRef(new StyleMaskData(*this)); }
bool operator==(const StyleMaskData &other) const;
bool operator!=(const StyleMaskData &other) const { return !(*this == other); }
String maskElement;
private:
StyleMaskData &operator=(const StyleMaskData &);
private:
StyleMaskData();
StyleMaskData(const StyleMaskData&);
};
class StyleMarkerData : public RefCounted<StyleMarkerData> {
public:
StyleMarkerData();
StyleMarkerData(const StyleMarkerData &other);
static PassRefPtr<StyleMarkerData> create() { return adoptRef(new StyleMarkerData); }
PassRefPtr<StyleMarkerData> copy() const { return adoptRef(new StyleMarkerData(*this)); }
bool operator==(const StyleMarkerData &other) const;
bool operator!=(const StyleMarkerData &other) const
......@@ -253,14 +259,15 @@ namespace WebCore {
String endMarker;
private:
StyleMarkerData &operator=(const StyleMarkerData &);
StyleMarkerData();
StyleMarkerData(const StyleMarkerData&);
};
// Note : the rule for this class is, *no inheritance* of these props
class StyleMiscData : public RefCounted<StyleMiscData> {
public:
StyleMiscData();
StyleMiscData(const StyleMiscData &other);
static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); }
PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); }
bool operator==(const StyleMiscData &other) const;
bool operator!=(const StyleMiscData &other) const
......@@ -278,7 +285,8 @@ namespace WebCore {
RefPtr<CSSValue> baselineShiftValue;
private:
StyleMiscData &operator=(const StyleMiscData &);
StyleMiscData();
StyleMiscData(const StyleMiscData&);
};
} // 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