Diff
Modified: trunk/Source/WebCore/ChangeLog (174235 => 174236)
--- trunk/Source/WebCore/ChangeLog 2014-10-02 22:49:06 UTC (rev 174235)
+++ trunk/Source/WebCore/ChangeLog 2014-10-02 22:53:18 UTC (rev 174236)
@@ -1,3 +1,23 @@
+2014-10-02 Christophe Dumez <[email protected]>
+
+ Use is<>() / downcast<>() for CSSBasicShape objects
+ https://bugs.webkit.org/show_bug.cgi?id=137331
+
+ Reviewed by Andreas Kling.
+
+ Use is<>() / downcast<>() for CSSBasicShape objects.
+
+ No new tests, no behavior change.
+
+ * css/BasicShapeFunctions.cpp:
+ (WebCore::basicShapeForValue):
+ * css/CSSBasicShapes.cpp:
+ (WebCore::CSSBasicShapeCircle::equals):
+ (WebCore::CSSBasicShapeEllipse::equals):
+ (WebCore::CSSBasicShapePolygon::equals):
+ (WebCore::CSSBasicShapeInset::equals):
+ * css/CSSBasicShapes.h:
+
2014-10-02 Chris Dumez <[email protected]>
XMLHttpRequestProgressEventThrottle shouldn't throttle / defer progress events if there are no listeners
Modified: trunk/Source/WebCore/css/BasicShapeFunctions.cpp (174235 => 174236)
--- trunk/Source/WebCore/css/BasicShapeFunctions.cpp 2014-10-02 22:49:06 UTC (rev 174235)
+++ trunk/Source/WebCore/css/BasicShapeFunctions.cpp 2014-10-02 22:53:18 UTC (rev 174236)
@@ -205,35 +205,35 @@
switch (basicShapeValue->type()) {
case CSSBasicShape::CSSBasicShapeCircleType: {
- const CSSBasicShapeCircle* circleValue = toCSSBasicShapeCircle(basicShapeValue);
+ const CSSBasicShapeCircle& circleValue = downcast<CSSBasicShapeCircle>(*basicShapeValue);
RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
- circle->setCenterX(convertToCenterCoordinate(conversionData, circleValue->centerX()));
- circle->setCenterY(convertToCenterCoordinate(conversionData, circleValue->centerY()));
- circle->setRadius(cssValueToBasicShapeRadius(conversionData, circleValue->radius()));
+ circle->setCenterX(convertToCenterCoordinate(conversionData, circleValue.centerX()));
+ circle->setCenterY(convertToCenterCoordinate(conversionData, circleValue.centerY()));
+ circle->setRadius(cssValueToBasicShapeRadius(conversionData, circleValue.radius()));
basicShape = circle.release();
break;
}
case CSSBasicShape::CSSBasicShapeEllipseType: {
- const CSSBasicShapeEllipse* ellipseValue = toCSSBasicShapeEllipse(basicShapeValue);
+ const CSSBasicShapeEllipse& ellipseValue = downcast<CSSBasicShapeEllipse>(*basicShapeValue);
RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
- ellipse->setCenterX(convertToCenterCoordinate(conversionData, ellipseValue->centerX()));
- ellipse->setCenterY(convertToCenterCoordinate(conversionData, ellipseValue->centerY()));
+ ellipse->setCenterX(convertToCenterCoordinate(conversionData, ellipseValue.centerX()));
+ ellipse->setCenterY(convertToCenterCoordinate(conversionData, ellipseValue.centerY()));
- ellipse->setRadiusX(cssValueToBasicShapeRadius(conversionData, ellipseValue->radiusX()));
- ellipse->setRadiusY(cssValueToBasicShapeRadius(conversionData, ellipseValue->radiusY()));
+ ellipse->setRadiusX(cssValueToBasicShapeRadius(conversionData, ellipseValue.radiusX()));
+ ellipse->setRadiusY(cssValueToBasicShapeRadius(conversionData, ellipseValue.radiusY()));
basicShape = ellipse.release();
break;
}
case CSSBasicShape::CSSBasicShapePolygonType: {
- const CSSBasicShapePolygon* polygonValue = toCSSBasicShapePolygon(basicShapeValue);
+ const CSSBasicShapePolygon& polygonValue = downcast<CSSBasicShapePolygon>(*basicShapeValue);
RefPtr<BasicShapePolygon> polygon = BasicShapePolygon::create();
- polygon->setWindRule(polygonValue->windRule());
- const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue->values();
+ polygon->setWindRule(polygonValue.windRule());
+ const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue.values();
for (unsigned i = 0; i < values.size(); i += 2)
polygon->appendPoint(convertToLength(conversionData, values.at(i).get()), convertToLength(conversionData, values.at(i + 1).get()));
@@ -241,18 +241,18 @@
break;
}
case CSSBasicShape::CSSBasicShapeInsetType: {
- const CSSBasicShapeInset* rectValue = toCSSBasicShapeInset(basicShapeValue);
+ const CSSBasicShapeInset& rectValue = downcast<CSSBasicShapeInset>(*basicShapeValue);
RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
- rect->setTop(convertToLength(conversionData, rectValue->top()));
- rect->setRight(convertToLength(conversionData, rectValue->right()));
- rect->setBottom(convertToLength(conversionData, rectValue->bottom()));
- rect->setLeft(convertToLength(conversionData, rectValue->left()));
+ rect->setTop(convertToLength(conversionData, rectValue.top()));
+ rect->setRight(convertToLength(conversionData, rectValue.right()));
+ rect->setBottom(convertToLength(conversionData, rectValue.bottom()));
+ rect->setLeft(convertToLength(conversionData, rectValue.left()));
- rect->setTopLeftRadius(convertToLengthSize(conversionData, rectValue->topLeftRadius()));
- rect->setTopRightRadius(convertToLengthSize(conversionData, rectValue->topRightRadius()));
- rect->setBottomRightRadius(convertToLengthSize(conversionData, rectValue->bottomRightRadius()));
- rect->setBottomLeftRadius(convertToLengthSize(conversionData, rectValue->bottomLeftRadius()));
+ rect->setTopLeftRadius(convertToLengthSize(conversionData, rectValue.topLeftRadius()));
+ rect->setTopRightRadius(convertToLengthSize(conversionData, rectValue.topRightRadius()));
+ rect->setBottomRightRadius(convertToLengthSize(conversionData, rectValue.bottomRightRadius()));
+ rect->setBottomLeftRadius(convertToLengthSize(conversionData, rectValue.bottomLeftRadius()));
basicShape = rect.release();
break;
Modified: trunk/Source/WebCore/css/CSSBasicShapes.cpp (174235 => 174236)
--- trunk/Source/WebCore/css/CSSBasicShapes.cpp 2014-10-02 22:49:06 UTC (rev 174235)
+++ trunk/Source/WebCore/css/CSSBasicShapes.cpp 2014-10-02 22:53:18 UTC (rev 174236)
@@ -125,10 +125,10 @@
bool CSSBasicShapeCircle::equals(const CSSBasicShape& shape) const
{
- if (shape.type() != CSSBasicShapeCircleType)
+ if (!is<CSSBasicShapeCircle>(shape))
return false;
- const CSSBasicShapeCircle& other = toCSSBasicShapeCircle(shape);
+ const CSSBasicShapeCircle& other = downcast<CSSBasicShapeCircle>(shape);
return compareCSSValuePtr(m_centerX, other.m_centerX)
&& compareCSSValuePtr(m_centerY, other.m_centerY)
&& compareCSSValuePtr(m_radius, other.m_radius)
@@ -198,10 +198,10 @@
bool CSSBasicShapeEllipse::equals(const CSSBasicShape& shape) const
{
- if (shape.type() != CSSBasicShapeEllipseType)
+ if (!is<CSSBasicShapeEllipse>(shape))
return false;
- const CSSBasicShapeEllipse& other = toCSSBasicShapeEllipse(shape);
+ const CSSBasicShapeEllipse& other = downcast<CSSBasicShapeEllipse>(shape);
return compareCSSValuePtr(m_centerX, other.m_centerX)
&& compareCSSValuePtr(m_centerY, other.m_centerY)
&& compareCSSValuePtr(m_radiusX, other.m_radiusX)
@@ -269,10 +269,10 @@
bool CSSBasicShapePolygon::equals(const CSSBasicShape& shape) const
{
- if (shape.type() != CSSBasicShapePolygonType)
+ if (!is<CSSBasicShapePolygon>(shape))
return false;
- const CSSBasicShapePolygon& rhs = toCSSBasicShapePolygon(shape);
+ const CSSBasicShapePolygon& rhs = downcast<CSSBasicShapePolygon>(shape);
return compareCSSValuePtr(m_referenceBox, rhs.m_referenceBox)
&& compareCSSValueVector<CSSPrimitiveValue>(m_values, rhs.m_values);
}
@@ -404,10 +404,10 @@
bool CSSBasicShapeInset::equals(const CSSBasicShape& shape) const
{
- if (shape.type() != CSSBasicShapeInsetType)
+ if (!is<CSSBasicShapeInset>(shape))
return false;
- const CSSBasicShapeInset& other = toCSSBasicShapeInset(shape);
+ const CSSBasicShapeInset& other = downcast<CSSBasicShapeInset>(shape);
return compareCSSValuePtr(m_top, other.m_top)
&& compareCSSValuePtr(m_right, other.m_right)
&& compareCSSValuePtr(m_bottom, other.m_bottom)
Modified: trunk/Source/WebCore/css/CSSBasicShapes.h (174235 => 174236)
--- trunk/Source/WebCore/css/CSSBasicShapes.h 2014-10-02 22:49:06 UTC (rev 174235)
+++ trunk/Source/WebCore/css/CSSBasicShapes.h 2014-10-02 22:53:18 UTC (rev 174236)
@@ -33,6 +33,7 @@
#include "CSSPrimitiveValue.h"
#include "WindRule.h"
#include <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -62,9 +63,6 @@
RefPtr<CSSPrimitiveValue> m_referenceBox;
};
-#define CSS_BASIC_SHAPES_TYPE_CASTS(ToValueTypeName, predicate) \
- TYPE_CASTS_BASE(ToValueTypeName, CSSBasicShape, basicShape, basicShape->type() == predicate, basicShape.type() == predicate)
-
class CSSBasicShapeInset : public CSSBasicShape {
public:
static PassRefPtr<CSSBasicShapeInset> create() { return adoptRef(new CSSBasicShapeInset); }
@@ -130,8 +128,6 @@
RefPtr<CSSPrimitiveValue> m_bottomLeftRadius;
};
-CSS_BASIC_SHAPES_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShape::CSSBasicShapeInsetType)
-
class CSSBasicShapeCircle : public CSSBasicShape {
public:
static PassRefPtr<CSSBasicShapeCircle> create() { return adoptRef(new CSSBasicShapeCircle); }
@@ -156,8 +152,6 @@
RefPtr<CSSPrimitiveValue> m_radius;
};
-CSS_BASIC_SHAPES_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShape::CSSBasicShapeCircleType)
-
class CSSBasicShapeEllipse : public CSSBasicShape {
public:
static PassRefPtr<CSSBasicShapeEllipse> create() { return adoptRef(new CSSBasicShapeEllipse); }
@@ -185,8 +179,6 @@
RefPtr<CSSPrimitiveValue> m_radiusY;
};
-CSS_BASIC_SHAPES_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShape::CSSBasicShapeEllipseType)
-
class CSSBasicShapePolygon : public CSSBasicShape {
public:
static PassRefPtr<CSSBasicShapePolygon> create() { return adoptRef(new CSSBasicShapePolygon); }
@@ -218,8 +210,16 @@
WindRule m_windRule;
};
-CSS_BASIC_SHAPES_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShape::CSSBasicShapePolygonType)
-
} // namespace WebCore
+#define SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(ToValueTypeName) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+ static bool isType(const WebCore::CSSBasicShape& basicShape) { return basicShape.type() == WebCore::CSSBasicShape::ToValueTypeName##Type; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeInset)
+SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeCircle)
+SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeEllipse)
+SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapePolygon)
+
#endif // CSSBasicShapes_h