Diff
Modified: trunk/Source/WebCore/ChangeLog (174804 => 174805)
--- trunk/Source/WebCore/ChangeLog 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/ChangeLog 2014-10-17 01:54:17 UTC (rev 174805)
@@ -1,5 +1,57 @@
2014-10-16 Chris Dumez <[email protected]>
+ Use is<>() / downcast<>() for BasicShape subclasses
+ https://bugs.webkit.org/show_bug.cgi?id=137766
+
+ Reviewed by Andreas Kling.
+
+ Use is<>() / downcast<>() for BasicShape subclasses and clean up the
+ surrounding code.
+
+ No new tests, no behavior change.
+
+ * css/BasicShapeFunctions.cpp:
+ (WebCore::valueForBasicShape):
+ (WebCore::basicShapeForValue):
+ * css/BasicShapeFunctions.h:
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::shapePropertyValue):
+ * page/animation/CSSPropertyAnimation.cpp:
+ (WebCore::blendFunc):
+ * rendering/ClipPathOperation.h:
+ (WebCore::ShapeClipPathOperation::create):
+ Take a PassRef<BasicShape> in argument to make it obvious it is never
+ null.
+
+ (WebCore::ShapeClipPathOperation::basicShape):
+ Return a reference instead of a pointer as it can never return null.
+
+ (WebCore::ShapeClipPathOperation::windRule):
+ (WebCore::ShapeClipPathOperation::pathForReferenceRect):
+ Make it non-const due to the const-correctness of Ref::get().
+
+ (WebCore::ShapeClipPathOperation::ShapeClipPathOperation):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::nodeAtPoint):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::setupClipPath):
+ * rendering/shapes/Shape.cpp:
+ (WebCore::Shape::createShape):
+ * rendering/shapes/Shape.h:
+ * rendering/shapes/ShapeOutsideInfo.cpp:
+ (WebCore::ShapeOutsideInfo::computedShape):
+ * rendering/style/BasicShapes.cpp:
+ (WebCore::BasicShape::canBlend):
+ (WebCore::BasicShapeCircle::blend):
+ (WebCore::BasicShapeEllipse::blend):
+ (WebCore::BasicShapePolygon::blend):
+ (WebCore::BasicShapeInset::blend):
+ * rendering/style/BasicShapes.h:
+ * rendering/svg/SVGRenderingContext.cpp:
+ (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+
+2014-10-16 Chris Dumez <[email protected]>
+
Leverage the new RenderElement::m_isCSSAnimating flag in more places
https://bugs.webkit.org/show_bug.cgi?id=137786
Modified: trunk/Source/WebCore/css/BasicShapeFunctions.cpp (174804 => 174805)
--- trunk/Source/WebCore/css/BasicShapeFunctions.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/css/BasicShapeFunctions.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -64,39 +64,39 @@
return 0;
}
-PassRef<CSSValue> valueForBasicShape(const RenderStyle* style, const BasicShape* basicShape)
+PassRef<CSSValue> valueForBasicShape(const RenderStyle* style, const BasicShape& basicShape)
{
CSSValuePool& pool = cssValuePool();
RefPtr<CSSBasicShape> basicShapeValue;
- switch (basicShape->type()) {
+ switch (basicShape.type()) {
case BasicShape::BasicShapeCircleType: {
- const BasicShapeCircle* circle = toBasicShapeCircle(basicShape);
+ const auto& circle = downcast<BasicShapeCircle>(basicShape);
RefPtr<CSSBasicShapeCircle> circleValue = CSSBasicShapeCircle::create();
- circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->centerX(), HORIZONTAL));
- circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->centerY(), VERTICAL));
- circleValue->setRadius(basicShapeRadiusToCSSValue(style, pool, circle->radius()));
+ circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle.centerX(), HORIZONTAL));
+ circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle.centerY(), VERTICAL));
+ circleValue->setRadius(basicShapeRadiusToCSSValue(style, pool, circle.radius()));
basicShapeValue = circleValue.release();
break;
}
case BasicShape::BasicShapeEllipseType: {
- const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape);
+ const auto& ellipse = downcast<BasicShapeEllipse>(basicShape);
RefPtr<CSSBasicShapeEllipse> ellipseValue = CSSBasicShapeEllipse::create();
- ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->centerX(), HORIZONTAL));
- ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->centerY(), VERTICAL));
- ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusX()));
- ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(style, pool, ellipse->radiusY()));
+ ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse.centerX(), HORIZONTAL));
+ ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse.centerY(), VERTICAL));
+ ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(style, pool, ellipse.radiusX()));
+ ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(style, pool, ellipse.radiusY()));
basicShapeValue = ellipseValue.release();
break;
}
case BasicShape::BasicShapePolygonType: {
- const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape);
+ const auto& polygon = downcast<BasicShapePolygon>(basicShape);
RefPtr<CSSBasicShapePolygon> polygonValue = CSSBasicShapePolygon::create();
- polygonValue->setWindRule(polygon->windRule());
- const Vector<Length>& values = polygon->values();
+ polygonValue->setWindRule(polygon.windRule());
+ const Vector<Length>& values = polygon.values();
for (unsigned i = 0; i < values.size(); i += 2)
polygonValue->appendPoint(pool.createValue(values.at(i), style), pool.createValue(values.at(i + 1), style));
@@ -104,18 +104,18 @@
break;
}
case BasicShape::BasicShapeInsetType: {
- const BasicShapeInset* inset = toBasicShapeInset(basicShape);
+ const auto& inset = downcast<BasicShapeInset>(basicShape);
RefPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset::create();
- insetValue->setTop(pool.createValue(inset->top(), style));
- insetValue->setRight(pool.createValue(inset->right(), style));
- insetValue->setBottom(pool.createValue(inset->bottom(), style));
- insetValue->setLeft(pool.createValue(inset->left(), style));
+ insetValue->setTop(pool.createValue(inset.top(), style));
+ insetValue->setRight(pool.createValue(inset.right(), style));
+ insetValue->setBottom(pool.createValue(inset.bottom(), style));
+ insetValue->setLeft(pool.createValue(inset.left(), style));
- insetValue->setTopLeftRadius(pool.createValue(inset->topLeftRadius(), style));
- insetValue->setTopRightRadius(pool.createValue(inset->topRightRadius(), style));
- insetValue->setBottomRightRadius(pool.createValue(inset->bottomRightRadius(), style));
- insetValue->setBottomLeftRadius(pool.createValue(inset->bottomLeftRadius(), style));
+ insetValue->setTopLeftRadius(pool.createValue(inset.topLeftRadius(), style));
+ insetValue->setTopRightRadius(pool.createValue(inset.topRightRadius(), style));
+ insetValue->setBottomRightRadius(pool.createValue(inset.bottomRightRadius(), style));
+ insetValue->setBottomLeftRadius(pool.createValue(inset.bottomLeftRadius(), style));
basicShapeValue = insetValue.release();
break;
@@ -199,7 +199,7 @@
return BasicShapeRadius(convertToLength(conversionData, radius.get()));
}
-PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionData, const CSSBasicShape* basicShapeValue)
+PassRef<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionData, const CSSBasicShape* basicShapeValue)
{
RefPtr<BasicShape> basicShape;
@@ -261,7 +261,7 @@
break;
}
- return basicShape.release();
+ return basicShape.releaseNonNull();
}
float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate& center, float boxDimension)
Modified: trunk/Source/WebCore/css/BasicShapeFunctions.h (174804 => 174805)
--- trunk/Source/WebCore/css/BasicShapeFunctions.h 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/css/BasicShapeFunctions.h 2014-10-17 01:54:17 UTC (rev 174805)
@@ -42,8 +42,8 @@
class CSSValue;
class RenderStyle;
-PassRef<CSSValue> valueForBasicShape(const RenderStyle*, const BasicShape*);
-PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape*);
+PassRef<CSSValue> valueForBasicShape(const RenderStyle*, const BasicShape&);
+PassRef<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape*);
float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate&, float);
}
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (174804 => 174805)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -1693,7 +1693,7 @@
ASSERT(shapeValue->type() == ShapeValue::Type::Shape);
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- list->append(valueForBasicShape(style, shapeValue->shape()));
+ list->append(valueForBasicShape(style, *shapeValue->shape()));
if (shapeValue->cssBox() != BoxMissing)
list->append(cssValuePool().createValue(shapeValue->cssBox()));
return list.releaseNonNull();
Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (174804 => 174805)
--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -130,13 +130,13 @@
if (from->type() != ClipPathOperation::Shape || to->type() != ClipPathOperation::Shape)
return to;
- const BasicShape* fromShape = static_cast<ShapeClipPathOperation*>(from)->basicShape();
- const BasicShape* toShape = static_cast<ShapeClipPathOperation*>(to)->basicShape();
+ const BasicShape& fromShape = downcast<ShapeClipPathOperation>(*from).basicShape();
+ const BasicShape& toShape = downcast<ShapeClipPathOperation>(*to).basicShape();
- if (!fromShape->canBlend(toShape))
+ if (!fromShape.canBlend(toShape))
return to;
- return ShapeClipPathOperation::create(toShape->blend(fromShape, progress));
+ return ShapeClipPathOperation::create(toShape.blend(fromShape, progress));
}
#if ENABLE(CSS_SHAPES)
@@ -151,13 +151,13 @@
if (from->cssBox() != to->cssBox())
return to;
- const BasicShape* fromShape = from->shape();
- const BasicShape* toShape = to->shape();
+ const BasicShape& fromShape = *from->shape();
+ const BasicShape& toShape = *to->shape();
- if (!fromShape->canBlend(toShape))
+ if (!fromShape.canBlend(toShape))
return to;
- return ShapeValue::createShapeValue(toShape->blend(fromShape, progress), to->cssBox());
+ return ShapeValue::createShapeValue(toShape.blend(fromShape, progress), to->cssBox());
}
#endif
Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (174804 => 174805)
--- trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-10-17 01:54:17 UTC (rev 174805)
@@ -96,18 +96,17 @@
class ShapeClipPathOperation : public ClipPathOperation {
public:
- static PassRefPtr<ShapeClipPathOperation> create(PassRefPtr<BasicShape> shape)
+ static PassRefPtr<ShapeClipPathOperation> create(PassRef<BasicShape> shape)
{
- return adoptRef(new ShapeClipPathOperation(shape));
+ return adoptRef(new ShapeClipPathOperation(WTF::move(shape)));
}
- const BasicShape* basicShape() const { return m_shape.get(); }
- WindRule windRule() const { return m_shape->windRule(); }
- const Path pathForReferenceRect(const FloatRect& boundingRect) const
+ const BasicShape& basicShape() const { return m_shape.get(); }
+ WindRule windRule() const { return m_shape.get().windRule(); }
+ const Path pathForReferenceRect(const FloatRect& boundingRect)
{
- ASSERT(m_shape);
Path path;
- m_shape->path(path, boundingRect);
+ m_shape.get().path(path, boundingRect);
return path;
}
@@ -115,22 +114,22 @@
CSSBoxType referenceBox() const { return m_referenceBox; }
private:
- virtual bool operator==(const ClipPathOperation& o) const override
+ virtual bool operator==(const ClipPathOperation& other) const override
{
- if (!isSameType(o))
+ if (!isSameType(other))
return false;
- const ShapeClipPathOperation* other = static_cast<const ShapeClipPathOperation*>(&o);
- return m_shape == other->m_shape;
+ const auto& shapeClip = downcast<ShapeClipPathOperation>(other);
+ return &m_shape.get() == &shapeClip.m_shape.get();
}
- explicit ShapeClipPathOperation(PassRefPtr<BasicShape> shape)
+ explicit ShapeClipPathOperation(PassRef<BasicShape> shape)
: ClipPathOperation(Shape)
- , m_shape(shape)
+ , m_shape(WTF::move(shape))
, m_referenceBox(BoxMissing)
{
}
- RefPtr<BasicShape> m_shape;
+ Ref<BasicShape> m_shape;
CSSBoxType m_referenceBox;
};
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -2467,7 +2467,7 @@
if (style().clipPath()) {
switch (style().clipPath()->type()) {
case ClipPathOperation::Shape: {
- const auto& clipPath = downcast<ShapeClipPathOperation>(*style().clipPath());
+ auto& clipPath = downcast<ShapeClipPathOperation>(*style().clipPath());
LayoutRect referenceBoxRect;
switch (clipPath.referenceBox()) {
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -3920,7 +3920,7 @@
RenderStyle& style = renderer().style();
ASSERT(style.clipPath());
if (is<ShapeClipPathOperation>(*style.clipPath())) {
- const auto& clipPath = downcast<ShapeClipPathOperation>(*style.clipPath());
+ auto& clipPath = downcast<ShapeClipPathOperation>(*style.clipPath());
LayoutRect referenceBox = computeReferenceBox(renderer(), clipPath, offsetFromRoot, rootRelativeBounds);
context->save();
@@ -3929,7 +3929,7 @@
}
if (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) {
- const auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
+ auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
RoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer()));
shapeRect.move(offsetFromRoot);
Modified: trunk/Source/WebCore/rendering/shapes/Shape.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/shapes/Shape.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/shapes/Shape.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -90,22 +90,20 @@
return size.transposedSize();
}
-std::unique_ptr<Shape> Shape::createShape(const BasicShape* basicShape, const LayoutSize& logicalBoxSize, WritingMode writingMode, float margin)
+std::unique_ptr<Shape> Shape::createShape(const BasicShape& basicShape, const LayoutSize& logicalBoxSize, WritingMode writingMode, float margin)
{
- ASSERT(basicShape);
-
bool horizontalWritingMode = isHorizontalWritingMode(writingMode);
float boxWidth = horizontalWritingMode ? logicalBoxSize.width() : logicalBoxSize.height();
float boxHeight = horizontalWritingMode ? logicalBoxSize.height() : logicalBoxSize.width();
std::unique_ptr<Shape> shape;
- switch (basicShape->type()) {
+ switch (basicShape.type()) {
case BasicShape::BasicShapeCircleType: {
- const BasicShapeCircle* circle = toBasicShapeCircle(basicShape);
- float centerX = floatValueForCenterCoordinate(circle->centerX(), boxWidth);
- float centerY = floatValueForCenterCoordinate(circle->centerY(), boxHeight);
- float radius = circle->floatValueForRadiusInBox(boxWidth, boxHeight);
+ const auto& circle = downcast<BasicShapeCircle>(basicShape);
+ float centerX = floatValueForCenterCoordinate(circle.centerX(), boxWidth);
+ float centerY = floatValueForCenterCoordinate(circle.centerY(), boxHeight);
+ float radius = circle.floatValueForRadiusInBox(boxWidth, boxHeight);
FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, centerY), logicalBoxSize.height(), writingMode);
shape = createCircleShape(logicalCenter, radius);
@@ -113,11 +111,11 @@
}
case BasicShape::BasicShapeEllipseType: {
- const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape);
- float centerX = floatValueForCenterCoordinate(ellipse->centerX(), boxWidth);
- float centerY = floatValueForCenterCoordinate(ellipse->centerY(), boxHeight);
- float radiusX = ellipse->floatValueForRadiusInBox(ellipse->radiusX(), centerX, boxWidth);
- float radiusY = ellipse->floatValueForRadiusInBox(ellipse->radiusY(), centerY, boxHeight);
+ const auto& ellipse = downcast<BasicShapeEllipse>(basicShape);
+ float centerX = floatValueForCenterCoordinate(ellipse.centerX(), boxWidth);
+ float centerY = floatValueForCenterCoordinate(ellipse.centerY(), boxHeight);
+ float radiusX = ellipse.floatValueForRadiusInBox(ellipse.radiusX(), centerX, boxWidth);
+ float radiusY = ellipse.floatValueForRadiusInBox(ellipse.radiusY(), centerY, boxHeight);
FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, centerY), logicalBoxSize.height(), writingMode);
shape = createEllipseShape(logicalCenter, FloatSize(radiusX, radiusY));
@@ -125,7 +123,7 @@
}
case BasicShape::BasicShapePolygonType: {
- const BasicShapePolygon& polygon = *toBasicShapePolygon(basicShape);
+ const auto& polygon = downcast<BasicShapePolygon>(basicShape);
const Vector<Length>& values = polygon.values();
size_t valuesSize = values.size();
ASSERT(!(valuesSize % 2));
@@ -142,7 +140,7 @@
}
case BasicShape::BasicShapeInsetType: {
- const BasicShapeInset& inset = *toBasicShapeInset(basicShape);
+ const auto& inset = downcast<BasicShapeInset>(basicShape);
float left = floatValueForLength(inset.left(), boxWidth);
float top = floatValueForLength(inset.top(), boxHeight);
FloatRect rect(left,
Modified: trunk/Source/WebCore/rendering/shapes/Shape.h (174804 => 174805)
--- trunk/Source/WebCore/rendering/shapes/Shape.h 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/shapes/Shape.h 2014-10-17 01:54:17 UTC (rev 174805)
@@ -72,7 +72,7 @@
Path marginShape;
};
- static std::unique_ptr<Shape> createShape(const BasicShape*, const LayoutSize& logicalBoxSize, WritingMode, float margin);
+ static std::unique_ptr<Shape> createShape(const BasicShape&, const LayoutSize& logicalBoxSize, WritingMode, float margin);
static std::unique_ptr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin);
static std::unique_ptr<Shape> createBoxShape(const RoundedRect&, WritingMode, float margin);
Modified: trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -177,7 +177,7 @@
switch (shapeValue.type()) {
case ShapeValue::Type::Shape:
ASSERT(shapeValue.shape());
- m_shape = Shape::createShape(shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin);
+ m_shape = Shape::createShape(*shapeValue.shape(), m_referenceBoxLogicalSize, writingMode, margin);
break;
case ShapeValue::Type::Image:
ASSERT(shapeValue.isImageValid());
Modified: trunk/Source/WebCore/rendering/style/BasicShapes.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/style/BasicShapes.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/style/BasicShapes.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -58,34 +58,34 @@
m_computedLength = Length(CalculationValue::create(WTF::move(op), CalculationRangeAll));
}
-bool BasicShape::canBlend(const BasicShape* other) const
+bool BasicShape::canBlend(const BasicShape& other) const
{
// FIXME: Support animations between different shapes in the future.
- if (type() != other->type())
+ if (type() != other.type())
return false;
// Just polygons with same number of vertices can be animated.
- if (type() == BasicShape::BasicShapePolygonType
- && (toBasicShapePolygon(this)->values().size() != toBasicShapePolygon(other)->values().size()
- || toBasicShapePolygon(this)->windRule() != toBasicShapePolygon(other)->windRule()))
+ if (is<BasicShapePolygon>(*this)
+ && (downcast<BasicShapePolygon>(*this).values().size() != downcast<BasicShapePolygon>(other).values().size()
+ || downcast<BasicShapePolygon>(*this).windRule() != downcast<BasicShapePolygon>(other).windRule()))
return false;
// Circles with keywords for radii coordinates cannot be animated.
- if (type() == BasicShape::BasicShapeCircleType) {
- const BasicShapeCircle* thisCircle = toBasicShapeCircle(this);
- const BasicShapeCircle* otherCircle = toBasicShapeCircle(other);
- if (!thisCircle->radius().canBlend(otherCircle->radius()))
+ if (is<BasicShapeCircle>(*this)) {
+ const auto& thisCircle = downcast<BasicShapeCircle>(*this);
+ const auto& otherCircle = downcast<BasicShapeCircle>(other);
+ if (!thisCircle.radius().canBlend(otherCircle.radius()))
return false;
}
// Ellipses with keywords for radii coordinates cannot be animated.
- if (type() != BasicShape::BasicShapeEllipseType)
+ if (!is<BasicShapeEllipse>(*this))
return true;
- const BasicShapeEllipse* thisEllipse = toBasicShapeEllipse(this);
- const BasicShapeEllipse* otherEllipse = toBasicShapeEllipse(other);
- return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX())
- && thisEllipse->radiusY().canBlend(otherEllipse->radiusY()));
+ const auto& thisEllipse = downcast<BasicShapeEllipse>(*this);
+ const auto& otherEllipse = downcast<BasicShapeEllipse>(other);
+ return (thisEllipse.radiusX().canBlend(otherEllipse.radiusX())
+ && thisEllipse.radiusY().canBlend(otherEllipse.radiusY()));
}
float BasicShapeCircle::floatValueForRadiusInBox(float boxWidth, float boxHeight) const
@@ -118,16 +118,16 @@
));
}
-PassRefPtr<BasicShape> BasicShapeCircle::blend(const BasicShape* other, double progress) const
+PassRef<BasicShape> BasicShapeCircle::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
- const BasicShapeCircle* o = toBasicShapeCircle(other);
+ ASSERT(type() == other.type());
+ const auto& otherCircle = downcast<BasicShapeCircle>(other);
RefPtr<BasicShapeCircle> result = BasicShapeCircle::create();
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadius(m_radius.blend(o->radius(), progress));
- return result.release();
+ result->setCenterX(m_centerX.blend(otherCircle.centerX(), progress));
+ result->setCenterY(m_centerY.blend(otherCircle.centerY(), progress));
+ result->setRadius(m_radius.blend(otherCircle.radius(), progress));
+ return result.releaseNonNull();
}
float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius, float center, float boxWidthOrHeight) const
@@ -157,26 +157,26 @@
radiusY * 2));
}
-PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double progress) const
+PassRef<BasicShape> BasicShapeEllipse::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
- const BasicShapeEllipse* o = toBasicShapeEllipse(other);
+ ASSERT(type() == other.type());
+ const auto& otherEllipse = downcast<BasicShapeEllipse>(other);
RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create();
- if (m_radiusX.type() != BasicShapeRadius::Value || o->radiusX().type() != BasicShapeRadius::Value
- || m_radiusY.type() != BasicShapeRadius::Value || o->radiusY().type() != BasicShapeRadius::Value) {
- result->setCenterX(o->centerX());
- result->setCenterY(o->centerY());
- result->setRadiusX(o->radiusX());
- result->setRadiusY(o->radiusY());
- return result;
+ if (m_radiusX.type() != BasicShapeRadius::Value || otherEllipse.radiusX().type() != BasicShapeRadius::Value
+ || m_radiusY.type() != BasicShapeRadius::Value || otherEllipse.radiusY().type() != BasicShapeRadius::Value) {
+ result->setCenterX(otherEllipse.centerX());
+ result->setCenterY(otherEllipse.centerY());
+ result->setRadiusX(otherEllipse.radiusX());
+ result->setRadiusY(otherEllipse.radiusY());
+ return result.releaseNonNull();
}
- result->setCenterX(m_centerX.blend(o->centerX(), progress));
- result->setCenterY(m_centerY.blend(o->centerY(), progress));
- result->setRadiusX(m_radiusX.blend(o->radiusX(), progress));
- result->setRadiusY(m_radiusY.blend(o->radiusY(), progress));
- return result.release();
+ result->setCenterX(m_centerX.blend(otherEllipse.centerX(), progress));
+ result->setCenterY(m_centerY.blend(otherEllipse.centerY(), progress));
+ result->setRadiusX(m_radiusX.blend(otherEllipse.radiusX(), progress));
+ result->setRadiusY(m_radiusY.blend(otherEllipse.radiusY(), progress));
+ return result.releaseNonNull();
}
void BasicShapePolygon::path(Path& path, const FloatRect& boundingBox)
@@ -197,27 +197,27 @@
path.closeSubpath();
}
-PassRefPtr<BasicShape> BasicShapePolygon::blend(const BasicShape* other, double progress) const
+PassRef<BasicShape> BasicShapePolygon::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
+ ASSERT(type() == other.type());
- const BasicShapePolygon* o = toBasicShapePolygon(other);
- ASSERT(m_values.size() == o->values().size());
+ const auto& otherPolygon = downcast<BasicShapePolygon>(other);
+ ASSERT(m_values.size() == otherPolygon.values().size());
ASSERT(!(m_values.size() % 2));
size_t length = m_values.size();
RefPtr<BasicShapePolygon> result = BasicShapePolygon::create();
if (!length)
- return result.release();
+ return result.releaseNonNull();
- result->setWindRule(o->windRule());
+ result->setWindRule(otherPolygon.windRule());
for (size_t i = 0; i < length; i = i + 2) {
- result->appendPoint(m_values.at(i).blend(o->values().at(i), progress),
- m_values.at(i + 1).blend(o->values().at(i + 1), progress));
+ result->appendPoint(m_values.at(i).blend(otherPolygon.values().at(i), progress),
+ m_values.at(i + 1).blend(otherPolygon.values().at(i + 1), progress));
}
- return result.release();
+ return result.releaseNonNull();
}
static FloatSize floatSizeForLengthSize(const LengthSize& lengthSize, const FloatRect& boundingBox)
@@ -246,22 +246,22 @@
path.addRoundedRect(r);
}
-PassRefPtr<BasicShape> BasicShapeInset::blend(const BasicShape* other, double progress) const
+PassRef<BasicShape> BasicShapeInset::blend(const BasicShape& other, double progress) const
{
- ASSERT(type() == other->type());
+ ASSERT(type() == other.type());
- const BasicShapeInset* o = toBasicShapeInset(other);
+ const auto& otherInset = downcast<BasicShapeInset>(other);
RefPtr<BasicShapeInset> result = BasicShapeInset::create();
- result->setTop(m_top.blend(o->top(), progress));
- result->setRight(m_right.blend(o->right(), progress));
- result->setBottom(m_bottom.blend(o->bottom(), progress));
- result->setLeft(m_left.blend(o->left(), progress));
+ result->setTop(m_top.blend(otherInset.top(), progress));
+ result->setRight(m_right.blend(otherInset.right(), progress));
+ result->setBottom(m_bottom.blend(otherInset.bottom(), progress));
+ result->setLeft(m_left.blend(otherInset.left(), progress));
- result->setTopLeftRadius(m_topLeftRadius.blend(o->topLeftRadius(), progress));
- result->setTopRightRadius(m_topRightRadius.blend(o->topRightRadius(), progress));
- result->setBottomRightRadius(m_bottomRightRadius.blend(o->bottomRightRadius(), progress));
- result->setBottomLeftRadius(m_bottomLeftRadius.blend(o->bottomLeftRadius(), progress));
+ result->setTopLeftRadius(m_topLeftRadius.blend(otherInset.topLeftRadius(), progress));
+ result->setTopRightRadius(m_topRightRadius.blend(otherInset.topRightRadius(), progress));
+ result->setBottomRightRadius(m_bottomRightRadius.blend(otherInset.bottomRightRadius(), progress));
+ result->setBottomLeftRadius(m_bottomLeftRadius.blend(otherInset.bottomLeftRadius(), progress));
- return result.release();
+ return result.releaseNonNull();
}
}
Modified: trunk/Source/WebCore/rendering/style/BasicShapes.h (174804 => 174805)
--- trunk/Source/WebCore/rendering/style/BasicShapes.h 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/style/BasicShapes.h 2014-10-17 01:54:17 UTC (rev 174805)
@@ -36,6 +36,7 @@
#include "WindRule.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -55,18 +56,15 @@
BasicShapeInsetType
};
- bool canBlend(const BasicShape*) const;
+ bool canBlend(const BasicShape&) const;
virtual void path(Path&, const FloatRect&) = 0;
virtual WindRule windRule() const { return RULE_NONZERO; }
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const = 0;
+ virtual PassRef<BasicShape> blend(const BasicShape&, double) const = 0;
virtual Type type() const = 0;
};
-#define BASIC_SHAPES_TYPE_CASTS(ToValueTypeName, predicate) \
- TYPE_CASTS_BASE(ToValueTypeName, BasicShape, basicShape, basicShape->type() == predicate, basicShape.type() == predicate)
-
class BasicShapeCenterCoordinate {
public:
enum Direction {
@@ -161,7 +159,7 @@
void setRadius(BasicShapeRadius radius) { m_radius = WTF::move(radius); }
virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual PassRef<BasicShape> blend(const BasicShape&, double) const override;
virtual Type type() const override { return BasicShapeCircleType; }
private:
@@ -172,8 +170,6 @@
BasicShapeRadius m_radius;
};
-BASIC_SHAPES_TYPE_CASTS(BasicShapeCircle, BasicShape::BasicShapeCircleType)
-
class BasicShapeEllipse : public BasicShape {
public:
static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicShapeEllipse); }
@@ -190,7 +186,7 @@
void setRadiusY(BasicShapeRadius radiusY) { m_radiusY = WTF::move(radiusY); }
virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual PassRef<BasicShape> blend(const BasicShape&, double) const override;
virtual Type type() const override { return BasicShapeEllipseType; }
private:
@@ -202,8 +198,6 @@
BasicShapeRadius m_radiusY;
};
-BASIC_SHAPES_TYPE_CASTS(BasicShapeEllipse, BasicShape::BasicShapeEllipseType)
-
class BasicShapePolygon : public BasicShape {
public:
static PassRefPtr<BasicShapePolygon> create() { return adoptRef(new BasicShapePolygon); }
@@ -216,7 +210,7 @@
void appendPoint(Length x, Length y) { m_values.append(WTF::move(x)); m_values.append(WTF::move(y)); }
virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual PassRef<BasicShape> blend(const BasicShape&, double) const override;
virtual WindRule windRule() const override { return m_windRule; }
@@ -230,8 +224,6 @@
Vector<Length> m_values;
};
-BASIC_SHAPES_TYPE_CASTS(BasicShapePolygon, BasicShape::BasicShapePolygonType)
-
class BasicShapeInset : public BasicShape {
public:
static PassRefPtr<BasicShapeInset> create() { return adoptRef(new BasicShapeInset); }
@@ -257,7 +249,7 @@
void setBottomLeftRadius(LengthSize radius) { m_bottomLeftRadius = WTF::move(radius); }
virtual void path(Path&, const FloatRect&) override;
- virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const override;
+ virtual PassRef<BasicShape> blend(const BasicShape&, double) const override;
virtual Type type() const override { return BasicShapeInsetType; }
private:
@@ -274,7 +266,16 @@
LengthSize m_bottomLeftRadius;
};
-BASIC_SHAPES_TYPE_CASTS(BasicShapeInset, BasicShape::BasicShapeInsetType)
+} // namespace WebCore
-}
-#endif
+#define SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+ static bool isType(const WebCore::BasicShape& basicShape) { return basicShape.type() == WebCore::predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeCircle, BasicShape::BasicShapeCircleType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeEllipse, BasicShape::BasicShapeEllipseType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapePolygon, BasicShape::BasicShapePolygonType)
+SPECIALIZE_TYPE_TRAITS_BASIC_SHAPE(BasicShapeInset, BasicShape::BasicShapeInsetType)
+
+#endif // BasicShapes_h
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (174804 => 174805)
--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-10-17 01:53:09 UTC (rev 174804)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-10-17 01:54:17 UTC (rev 174805)
@@ -137,7 +137,7 @@
ClipPathOperation* clipPathOperation = style.clipPath();
if (is<ShapeClipPathOperation>(clipPathOperation)) {
- const auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation);
+ auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation);
FloatRect referenceBox;
if (clipPath.referenceBox() == Stroke)
// FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.