Changeset 169320 in webkit
- Timestamp:
- May 25, 2014 11:09:16 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r169318 r169320 1 2014-05-25 David Kilzer <ddkilzer@apple.com> 2 3 Add type-checked casts for TransformOperations 4 <http://webkit.org/b/133217> 5 6 Reviewed by Simon Fraser. 7 8 * platform/graphics/GraphicsLayer.cpp: 9 (WebCore::GraphicsLayer::validateTransformOperations): 10 * platform/graphics/ca/GraphicsLayerCA.cpp: 11 (WebCore::getTransformFunctionValue): 12 - Switch to type-checked casts. 13 14 * platform/graphics/transforms/IdentityTransformOperation.h: 15 * platform/graphics/transforms/Matrix3DTransformOperation.h: 16 * platform/graphics/transforms/MatrixTransformOperation.h: 17 * platform/graphics/transforms/PerspectiveTransformOperation.h: 18 * platform/graphics/transforms/RotateTransformOperation.h: 19 * platform/graphics/transforms/ScaleTransformOperation.h: 20 * platform/graphics/transforms/SkewTransformOperation.h: 21 * platform/graphics/transforms/TranslateTransformOperation.h: 22 - Add 'final' to class declaration. 23 - Add 'override' to overridden methods. 24 - Add type-checked cast via TRANSFORMOPERATION_TYPE_CASTS macro. 25 - Move implementation of operator==(const TransformOperation&) 26 from header to source file so it is able to use a type-checked 27 cast, and switch back to using a reference instead of a 28 pointer. 29 - Add or update ASSERT in private constructor to check for 30 correct OperationType in classes that represent multiple 31 types. 32 33 * platform/graphics/transforms/Matrix3DTransformOperation.cpp: 34 (WebCore::Matrix3DTransformOperation::operator==): Added. 35 36 * platform/graphics/transforms/MatrixTransformOperation.cpp: 37 (WebCore::Matrix3DTransformOperation::operator==): Added. 38 (WebCore::MatrixTransformOperation::blend): 39 - Switch to type-checked casts and use a reference. 40 41 * platform/graphics/transforms/PerspectiveTransformOperation.cpp: 42 (WebCore::Matrix3DTransformOperation::operator==): Added. 43 (WebCore::PerspectiveTransformOperation::blend): 44 * platform/graphics/transforms/RotateTransformOperation.cpp: 45 (WebCore::Matrix3DTransformOperation::operator==): Added. 46 (WebCore::RotateTransformOperation::blend): 47 * platform/graphics/transforms/ScaleTransformOperation.cpp: 48 (WebCore::Matrix3DTransformOperation::operator==): Added. 49 (WebCore::ScaleTransformOperation::blend): 50 * platform/graphics/transforms/SkewTransformOperation.cpp: 51 (WebCore::Matrix3DTransformOperation::operator==): Added. 52 (WebCore::SkewTransformOperation::blend): 53 * platform/graphics/transforms/TranslateTransformOperation.cpp: 54 (WebCore::Matrix3DTransformOperation::operator==): Added. 55 (WebCore::TranslateTransformOperation::blend): 56 - Switch to type-checked casts. 57 58 * platform/graphics/transforms/TransformOperation.h: 59 (WebCore::TransformOperation::isRotateTransformOperationType): 60 (WebCore::TransformOperation::isScaleTransformOperationType): 61 (WebCore::TransformOperation::isSkewTransformOperationType): 62 (WebCore::TransformOperation::isTranslateTransformOperationType): 63 - Add type-checking methods used in constructors and type-checked 64 casts. 65 - Define TRANSFORMOPERATION_TYPE_CASTS macro used by subclasses. 66 1 67 2014-05-25 David Kilzer <ddkilzer@apple.com> 2 68 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp
r168423 r169320 517 517 type == TransformOperation::ROTATE_Z || 518 518 type == TransformOperation::ROTATE_3D) { 519 lastRotAngle = static_cast<RotateTransformOperation*>(firstVal.operations().at(j).get())->angle();519 lastRotAngle = toRotateTransformOperation(firstVal.operations().at(j).get())->angle(); 520 520 521 521 if (maxRotAngle < 0) … … 524 524 for (size_t i = firstIndex + 1; i < valueList.size(); ++i) { 525 525 const TransformOperations& val = operationsAt(valueList, i); 526 double rotAngle = val.operations().isEmpty() ? 0 : ( static_cast<RotateTransformOperation*>(val.operations().at(j).get())->angle());526 double rotAngle = val.operations().isEmpty() ? 0 : (toRotateTransformOperation(val.operations().at(j).get())->angle()); 527 527 double diffAngle = fabs(rotAngle - lastRotAngle); 528 528 if (diffAngle > maxRotAngle) -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r169229 r169320 130 130 case TransformOperation::ROTATE_X: 131 131 case TransformOperation::ROTATE_Y: 132 value = transformOp ? narrowPrecisionToFloat(deg2rad( static_cast<const RotateTransformOperation*>(transformOp)->angle())) : 0;132 value = transformOp ? narrowPrecisionToFloat(deg2rad(toRotateTransformOperation(transformOp)->angle())) : 0; 133 133 break; 134 134 case TransformOperation::SCALE_X: 135 value = transformOp ? narrowPrecisionToFloat( static_cast<const ScaleTransformOperation*>(transformOp)->x()) : 1;135 value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->x()) : 1; 136 136 break; 137 137 case TransformOperation::SCALE_Y: 138 value = transformOp ? narrowPrecisionToFloat( static_cast<const ScaleTransformOperation*>(transformOp)->y()) : 1;138 value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->y()) : 1; 139 139 break; 140 140 case TransformOperation::SCALE_Z: 141 value = transformOp ? narrowPrecisionToFloat( static_cast<const ScaleTransformOperation*>(transformOp)->z()) : 1;141 value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->z()) : 1; 142 142 break; 143 143 case TransformOperation::TRANSLATE_X: 144 value = transformOp ? narrowPrecisionToFloat( static_cast<const TranslateTransformOperation*>(transformOp)->x(size)) : 0;144 value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->x(size)) : 0; 145 145 break; 146 146 case TransformOperation::TRANSLATE_Y: 147 value = transformOp ? narrowPrecisionToFloat( static_cast<const TranslateTransformOperation*>(transformOp)->y(size)) : 0;147 value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->y(size)) : 0; 148 148 break; 149 149 case TransformOperation::TRANSLATE_Z: 150 value = transformOp ? narrowPrecisionToFloat( static_cast<const TranslateTransformOperation*>(transformOp)->z(size)) : 0;150 value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->z(size)) : 0; 151 151 break; 152 152 default: … … 159 159 switch (transformType) { 160 160 case TransformOperation::SCALE: 161 case TransformOperation::SCALE_3D: 162 value.setX(transformOp ? narrowPrecisionToFloat(static_cast<const ScaleTransformOperation*>(transformOp)->x()) : 1); 163 value.setY(transformOp ? narrowPrecisionToFloat(static_cast<const ScaleTransformOperation*>(transformOp)->y()) : 1); 164 value.setZ(transformOp ? narrowPrecisionToFloat(static_cast<const ScaleTransformOperation*>(transformOp)->z()) : 1); 161 case TransformOperation::SCALE_3D: { 162 const ScaleTransformOperation* scaleTransformOp = toScaleTransformOperation(transformOp); 163 value.setX(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->x()) : 1); 164 value.setY(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->y()) : 1); 165 value.setZ(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->z()) : 1); 165 166 break; 167 } 166 168 case TransformOperation::TRANSLATE: 167 case TransformOperation::TRANSLATE_3D: 168 value.setX(transformOp ? narrowPrecisionToFloat(static_cast<const TranslateTransformOperation*>(transformOp)->x(size)) : 0); 169 value.setY(transformOp ? narrowPrecisionToFloat(static_cast<const TranslateTransformOperation*>(transformOp)->y(size)) : 0); 170 value.setZ(transformOp ? narrowPrecisionToFloat(static_cast<const TranslateTransformOperation*>(transformOp)->z(size)) : 0); 169 case TransformOperation::TRANSLATE_3D: { 170 const TranslateTransformOperation* translateTransformOp = toTranslateTransformOperation(transformOp); 171 value.setX(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->x(size)) : 0); 172 value.setY(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->y(size)) : 0); 173 value.setZ(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->z(size)) : 0); 171 174 break; 175 } 172 176 default: 173 177 break; -
trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h
r157823 r169320 30 30 namespace WebCore { 31 31 32 class IdentityTransformOperation : public TransformOperation {32 class IdentityTransformOperation final : public TransformOperation { 33 33 public: 34 34 static PassRefPtr<IdentityTransformOperation> create() … … 38 38 39 39 private: 40 virtual bool isIdentity() const { return true; }41 virtual OperationType type() const { return IDENTITY; }42 virtual bool isSameType(const TransformOperation& o) const { return o.type() == IDENTITY; }40 virtual bool isIdentity() const override { return true; } 41 virtual OperationType type() const override { return IDENTITY; } 42 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == IDENTITY; } 43 43 44 virtual bool operator==(const TransformOperation& o) const 44 virtual bool operator==(const TransformOperation& o) const override 45 45 { 46 46 return isSameType(o); 47 47 } 48 48 49 virtual bool apply(TransformationMatrix&, const FloatSize&) const 49 virtual bool apply(TransformationMatrix&, const FloatSize&) const override 50 50 { 51 51 return false; 52 52 } 53 53 54 virtual PassRefPtr<TransformOperation> blend(const TransformOperation*, double, bool = false) 54 virtual PassRefPtr<TransformOperation> blend(const TransformOperation*, double, bool = false) override 55 55 { 56 56 return this; … … 63 63 }; 64 64 65 TRANSFORMOPERATION_TYPE_CASTS(IdentityTransformOperation, type() == TransformOperation::IDENTITY); 66 65 67 } // namespace WebCore 66 68 -
trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp
r165676 r169320 31 31 namespace WebCore { 32 32 33 bool Matrix3DTransformOperation::operator==(const TransformOperation& o) const 34 { 35 if (!isSameType(o)) 36 return false; 37 const Matrix3DTransformOperation& m = toMatrix3DTransformOperation(o); 38 return m_matrix == m.m_matrix; 39 } 40 33 41 PassRefPtr<TransformOperation> Matrix3DTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 34 42 { -
trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h
r165676 r169320 31 31 namespace WebCore { 32 32 33 class Matrix3DTransformOperation : public TransformOperation {33 class Matrix3DTransformOperation final : public TransformOperation { 34 34 public: 35 35 static PassRefPtr<Matrix3DTransformOperation> create(const TransformationMatrix& matrix) … … 41 41 42 42 private: 43 virtual bool isIdentity() const { return m_matrix.isIdentity(); }43 virtual bool isIdentity() const override { return m_matrix.isIdentity(); } 44 44 45 virtual OperationType type() const { return MATRIX_3D; }46 virtual bool isSameType(const TransformOperation& o) const { return o.type() == MATRIX_3D; }45 virtual OperationType type() const override { return MATRIX_3D; } 46 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == MATRIX_3D; } 47 47 48 virtual bool operator==(const TransformOperation& o) const 49 { 50 if (!isSameType(o)) 51 return false; 52 const Matrix3DTransformOperation* m = static_cast<const Matrix3DTransformOperation*>(&o); 53 return m_matrix == m->m_matrix; 54 } 48 virtual bool operator==(const TransformOperation&) const override; 55 49 56 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const 50 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override 57 51 { 58 52 transform.multiply(TransformationMatrix(m_matrix)); … … 60 54 } 61 55 62 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;56 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 63 57 64 58 Matrix3DTransformOperation(const TransformationMatrix& mat) … … 70 64 }; 71 65 66 TRANSFORMOPERATION_TYPE_CASTS(Matrix3DTransformOperation, type() == TransformOperation::MATRIX_3D); 67 72 68 } // namespace WebCore 73 69 -
trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp
r159027 r169320 27 27 namespace WebCore { 28 28 29 bool MatrixTransformOperation::operator==(const TransformOperation& o) const 30 { 31 if (!isSameType(o)) 32 return false; 33 const MatrixTransformOperation& m = toMatrixTransformOperation(o); 34 return m_a == m.m_a && m_b == m.m_b && m_c == m.m_c && m_d == m.m_d && m_e == m.m_e && m_f == m.m_f; 35 } 36 29 37 PassRefPtr<TransformOperation> MatrixTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 30 38 { … … 37 45 TransformationMatrix toT(m_a, m_b, m_c, m_d, m_e, m_f); 38 46 if (from) { 39 const MatrixTransformOperation * m = static_cast<const MatrixTransformOperation*>(from);40 fromT.setMatrix(m ->m_a, m->m_b, m->m_c, m->m_d, m->m_e, m->m_f);47 const MatrixTransformOperation& m = toMatrixTransformOperation(*from); 48 fromT.setMatrix(m.m_a, m.m_b, m.m_c, m.m_d, m.m_e, m.m_f); 41 49 } 42 50 -
trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h
r157823 r169320 31 31 namespace WebCore { 32 32 33 class MatrixTransformOperation : public TransformOperation {33 class MatrixTransformOperation final : public TransformOperation { 34 34 public: 35 35 static PassRefPtr<MatrixTransformOperation> create(double a, double b, double c, double d, double e, double f) … … 46 46 47 47 private: 48 virtual bool isIdentity() const { return m_a == 1 && m_b == 0 && m_c == 0 && m_d == 1 && m_e == 0 && m_f == 0; }48 virtual bool isIdentity() const override { return m_a == 1 && m_b == 0 && m_c == 0 && m_d == 1 && m_e == 0 && m_f == 0; } 49 49 50 virtual OperationType type() const { return MATRIX; }51 virtual bool isSameType(const TransformOperation& o) const { return o.type() == MATRIX; }50 virtual OperationType type() const override { return MATRIX; } 51 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == MATRIX; } 52 52 53 virtual bool operator==(const TransformOperation& o) const 54 { 55 if (!isSameType(o)) 56 return false; 53 virtual bool operator==(const TransformOperation&) const override; 57 54 58 const MatrixTransformOperation* m = static_cast<const MatrixTransformOperation*>(&o); 59 return m_a == m->m_a && m_b == m->m_b && m_c == m->m_c && m_d == m->m_d && m_e == m->m_e && m_f == m->m_f; 60 } 61 62 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const 55 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override 63 56 { 64 57 TransformationMatrix matrix(m_a, m_b, m_c, m_d, m_e, m_f); … … 67 60 } 68 61 69 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;62 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 70 63 71 64 MatrixTransformOperation(double a, double b, double c, double d, double e, double f) … … 97 90 }; 98 91 92 TRANSFORMOPERATION_TYPE_CASTS(MatrixTransformOperation, type() == TransformOperation::MATRIX); 93 99 94 } // namespace WebCore 100 95 -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp
r165676 r169320 32 32 namespace WebCore { 33 33 34 bool PerspectiveTransformOperation::operator==(const TransformOperation& o) const 35 { 36 if (!isSameType(o)) 37 return false; 38 const PerspectiveTransformOperation& p = toPerspectiveTransformOperation(o); 39 return m_p == p.m_p; 40 } 41 34 42 PassRefPtr<TransformOperation> PerspectiveTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 35 43 { … … 43 51 } 44 52 45 const PerspectiveTransformOperation* fromOp = static_cast<const PerspectiveTransformOperation*>(from);53 const PerspectiveTransformOperation* fromOp = toPerspectiveTransformOperation(from); 46 54 Length fromP = fromOp ? fromOp->m_p : Length(m_p.type()); 47 55 Length toP = m_p; -
trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h
r165676 r169320 33 33 namespace WebCore { 34 34 35 class PerspectiveTransformOperation : public TransformOperation {35 class PerspectiveTransformOperation final : public TransformOperation { 36 36 public: 37 37 static PassRefPtr<PerspectiveTransformOperation> create(const Length& p) … … 43 43 44 44 private: 45 virtual bool isIdentity() const { return !floatValueForLength(m_p, 1); }46 virtual OperationType type() const { return PERSPECTIVE; }47 virtual bool isSameType(const TransformOperation& o) const { return o.type() == PERSPECTIVE; }45 virtual bool isIdentity() const override { return !floatValueForLength(m_p, 1); } 46 virtual OperationType type() const override { return PERSPECTIVE; } 47 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == PERSPECTIVE; } 48 48 49 virtual bool operator==(const TransformOperation& o) const 50 { 51 if (!isSameType(o)) 52 return false; 53 const PerspectiveTransformOperation* p = static_cast<const PerspectiveTransformOperation*>(&o); 54 return m_p == p->m_p; 55 } 49 virtual bool operator==(const TransformOperation&) const override; 56 50 57 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const 51 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override 58 52 { 59 53 transform.applyPerspective(floatValueForLength(m_p, 1)); … … 61 55 } 62 56 63 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;57 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 64 58 65 59 PerspectiveTransformOperation(const Length& p) … … 72 66 }; 73 67 68 TRANSFORMOPERATION_TYPE_CASTS(PerspectiveTransformOperation, type() == TransformOperation::PERSPECTIVE); 69 74 70 } // namespace WebCore 75 71 -
trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp
r159027 r169320 29 29 namespace WebCore { 30 30 31 bool RotateTransformOperation::operator==(const TransformOperation& o) const 32 { 33 if (!isSameType(o)) 34 return false; 35 const RotateTransformOperation& r = toRotateTransformOperation(o); 36 return m_x == r.m_x && m_y == r.m_y && m_z == r.m_z && m_angle == r.m_angle; 37 } 38 31 39 PassRefPtr<TransformOperation> RotateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 32 40 { … … 37 45 return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, m_type); 38 46 39 const RotateTransformOperation* fromOp = static_cast<const RotateTransformOperation*>(from);47 const RotateTransformOperation* fromOp = toRotateTransformOperation(from); 40 48 41 49 // Optimize for single axis rotation -
trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h
r157823 r169320 30 30 namespace WebCore { 31 31 32 class RotateTransformOperation : public TransformOperation {32 class RotateTransformOperation final : public TransformOperation { 33 33 public: 34 34 static PassRefPtr<RotateTransformOperation> create(double angle, OperationType type) … … 48 48 49 49 private: 50 virtual bool isIdentity() const { return m_angle == 0; }50 virtual bool isIdentity() const override { return m_angle == 0; } 51 51 52 virtual OperationType type() const { return m_type; }53 virtual bool isSameType(const TransformOperation& o) const { return o.type() == m_type; }52 virtual OperationType type() const override { return m_type; } 53 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; } 54 54 55 virtual bool operator==(const TransformOperation& o) const 56 { 57 if (!isSameType(o)) 58 return false; 59 const RotateTransformOperation* r = static_cast<const RotateTransformOperation*>(&o); 60 return m_x == r->m_x && m_y == r->m_y && m_z == r->m_z && m_angle == r->m_angle; 61 } 55 virtual bool operator==(const TransformOperation&) const override; 62 56 63 virtual bool apply(TransformationMatrix& transform, const FloatSize& /*borderBoxSize*/) const 57 virtual bool apply(TransformationMatrix& transform, const FloatSize& /*borderBoxSize*/) const override 64 58 { 65 59 transform.rotate3d(m_x, m_y, m_z, m_angle); … … 67 61 } 68 62 69 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;63 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 70 64 71 65 RotateTransformOperation(double x, double y, double z, double angle, OperationType type) … … 76 70 , m_type(type) 77 71 { 78 ASSERT( type == ROTATE_X || type == ROTATE_Y || type == ROTATE_Z || type == ROTATE_3D);72 ASSERT(isRotateTransformOperationType()); 79 73 } 80 74 … … 86 80 }; 87 81 82 TRANSFORMOPERATION_TYPE_CASTS(RotateTransformOperation, isRotateTransformOperationType()); 83 88 84 } // namespace WebCore 89 85 -
trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp
r102740 r169320 27 27 namespace WebCore { 28 28 29 bool ScaleTransformOperation::operator==(const TransformOperation& o) const 30 { 31 if (!isSameType(o)) 32 return false; 33 const ScaleTransformOperation& s = toScaleTransformOperation(o); 34 return m_x == s.m_x && m_y == s.m_y && m_z == s.m_z; 35 } 36 29 37 PassRefPtr<TransformOperation> ScaleTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 30 38 { … … 37 45 WebCore::blend(m_z, 1.0, progress), m_type); 38 46 39 const ScaleTransformOperation* fromOp = static_cast<const ScaleTransformOperation*>(from);47 const ScaleTransformOperation* fromOp = toScaleTransformOperation(from); 40 48 double fromX = fromOp ? fromOp->m_x : 1.0; 41 49 double fromY = fromOp ? fromOp->m_y : 1.0; -
trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h
r157823 r169320 30 30 namespace WebCore { 31 31 32 class ScaleTransformOperation : public TransformOperation {32 class ScaleTransformOperation final : public TransformOperation { 33 33 public: 34 34 static PassRefPtr<ScaleTransformOperation> create(double sx, double sy, OperationType type) … … 47 47 48 48 private: 49 virtual bool isIdentity() const { return m_x == 1 && m_y == 1 && m_z == 1; }49 virtual bool isIdentity() const override { return m_x == 1 && m_y == 1 && m_z == 1; } 50 50 51 virtual OperationType type() const { return m_type; }52 virtual bool isSameType(const TransformOperation& o) const { return o.type() == m_type; }51 virtual OperationType type() const override { return m_type; } 52 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; } 53 53 54 virtual bool operator==(const TransformOperation& o) const 55 { 56 if (!isSameType(o)) 57 return false; 58 const ScaleTransformOperation* s = static_cast<const ScaleTransformOperation*>(&o); 59 return m_x == s->m_x && m_y == s->m_y && m_z == s->m_z; 60 } 54 virtual bool operator==(const TransformOperation&) const override; 61 55 62 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const 56 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override 63 57 { 64 58 transform.scale3d(m_x, m_y, m_z); … … 66 60 } 67 61 68 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;62 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 69 63 70 64 ScaleTransformOperation(double sx, double sy, double sz, OperationType type) … … 74 68 , m_type(type) 75 69 { 76 ASSERT( type == SCALE_X || type == SCALE_Y || type == SCALE_Z || type == SCALE || type == SCALE_3D);70 ASSERT(isScaleTransformOperationType()); 77 71 } 78 72 … … 83 77 }; 84 78 79 TRANSFORMOPERATION_TYPE_CASTS(ScaleTransformOperation, isScaleTransformOperationType()); 80 85 81 } // namespace WebCore 86 82 -
trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp
r102740 r169320 27 27 namespace WebCore { 28 28 29 bool SkewTransformOperation::operator==(const TransformOperation& o) const 30 { 31 if (!isSameType(o)) 32 return false; 33 const SkewTransformOperation& s = toSkewTransformOperation(o); 34 return m_angleX == s.m_angleX && m_angleY == s.m_angleY; 35 } 36 29 37 PassRefPtr<TransformOperation> SkewTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 30 38 { … … 35 43 return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, progress), WebCore::blend(m_angleY, 0.0, progress), m_type); 36 44 37 const SkewTransformOperation* fromOp = static_cast<const SkewTransformOperation*>(from);45 const SkewTransformOperation* fromOp = toSkewTransformOperation(from); 38 46 double fromAngleX = fromOp ? fromOp->m_angleX : 0; 39 47 double fromAngleY = fromOp ? fromOp->m_angleY : 0; -
trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h
r157823 r169320 30 30 namespace WebCore { 31 31 32 class SkewTransformOperation : public TransformOperation {32 class SkewTransformOperation final : public TransformOperation { 33 33 public: 34 34 static PassRefPtr<SkewTransformOperation> create(double angleX, double angleY, OperationType type) … … 41 41 42 42 private: 43 virtual bool isIdentity() const { return m_angleX == 0 && m_angleY == 0; }44 virtual OperationType type() const { return m_type; }45 virtual bool isSameType(const TransformOperation& o) const { return o.type() == m_type; }43 virtual bool isIdentity() const override { return m_angleX == 0 && m_angleY == 0; } 44 virtual OperationType type() const override { return m_type; } 45 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; } 46 46 47 virtual bool operator==(const TransformOperation& o) const 48 { 49 if (!isSameType(o)) 50 return false; 51 const SkewTransformOperation* s = static_cast<const SkewTransformOperation*>(&o); 52 return m_angleX == s->m_angleX && m_angleY == s->m_angleY; 53 } 47 virtual bool operator==(const TransformOperation&) const override; 54 48 55 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const 49 virtual bool apply(TransformationMatrix& transform, const FloatSize&) const override 56 50 { 57 51 transform.skew(m_angleX, m_angleY); … … 59 53 } 60 54 61 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;55 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 62 56 63 57 SkewTransformOperation(double angleX, double angleY, OperationType type) … … 66 60 , m_type(type) 67 61 { 62 ASSERT(isSkewTransformOperationType()); 68 63 } 69 64 … … 73 68 }; 74 69 70 TRANSFORMOPERATION_TYPE_CASTS(SkewTransformOperation, isSkewTransformOperationType()); 71 75 72 } // namespace WebCore 76 73 -
trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h
r157823 r169320 80 80 opType == PERSPECTIVE; 81 81 } 82 83 bool isRotateTransformOperationType() const 84 { 85 return type() == ROTATE_X || type() == ROTATE_Y || type() == ROTATE_Z || type() == ROTATE || type() == ROTATE_3D; 86 } 87 88 bool isScaleTransformOperationType() const 89 { 90 return type() == SCALE_X || type() == SCALE_Y || type() == SCALE_Z || type() == SCALE || type() == SCALE_3D; 91 } 92 93 bool isSkewTransformOperationType() const 94 { 95 return type() == SKEW_X || type() == SKEW_Y || type() == SKEW; 96 } 97 98 bool isTranslateTransformOperationType() const 99 { 100 return type() == TRANSLATE_X || type() == TRANSLATE_Y || type() == TRANSLATE_Z || type() == TRANSLATE || type() == TRANSLATE_3D; 101 } 82 102 }; 103 104 #define TRANSFORMOPERATION_TYPE_CASTS(ToValueTypeName, predicate) \ 105 TYPE_CASTS_BASE(ToValueTypeName, WebCore::TransformOperation, value, value->predicate, value.predicate) 83 106 84 107 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp
r152825 r169320 26 26 namespace WebCore { 27 27 28 bool TranslateTransformOperation::operator==(const TransformOperation& o) const 29 { 30 if (!isSameType(o)) 31 return false; 32 const TranslateTransformOperation& t = toTranslateTransformOperation(o); 33 return m_x == t.m_x && m_y == t.m_y && m_z == t.m_z; 34 } 35 28 36 PassRefPtr<TransformOperation> TranslateTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity) 29 37 { … … 35 43 return TranslateTransformOperation::create(zeroLength.blend(m_x, progress), zeroLength.blend(m_y, progress), zeroLength.blend(m_z, progress), m_type); 36 44 37 const TranslateTransformOperation* fromOp = static_cast<const TranslateTransformOperation*>(from);45 const TranslateTransformOperation* fromOp = toTranslateTransformOperation(from); 38 46 Length fromX = fromOp ? fromOp->m_x : zeroLength; 39 47 Length fromY = fromOp ? fromOp->m_y : zeroLength; -
trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h
r166920 r169320 32 32 namespace WebCore { 33 33 34 class TranslateTransformOperation : public TransformOperation {34 class TranslateTransformOperation final : public TransformOperation { 35 35 public: 36 36 static PassRefPtr<TranslateTransformOperation> create(const Length& tx, const Length& ty, OperationType type) … … 53 53 54 54 private: 55 virtual bool isIdentity() const { return !floatValueForLength(m_x, 1) && !floatValueForLength(m_y, 1) && !floatValueForLength(m_z, 1); }55 virtual bool isIdentity() const override { return !floatValueForLength(m_x, 1) && !floatValueForLength(m_y, 1) && !floatValueForLength(m_z, 1); } 56 56 57 virtual OperationType type() const { return m_type; }58 virtual bool isSameType(const TransformOperation& o) const { return o.type() == m_type; }57 virtual OperationType type() const override { return m_type; } 58 virtual bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; } 59 59 60 virtual bool operator==(const TransformOperation& o) const 61 { 62 if (!isSameType(o)) 63 return false; 64 const TranslateTransformOperation* t = static_cast<const TranslateTransformOperation*>(&o); 65 return m_x == t->m_x && m_y == t->m_y && m_z == t->m_z; 66 } 60 virtual bool operator==(const TransformOperation&) const override; 67 61 68 virtual bool apply(TransformationMatrix& transform, const FloatSize& borderBoxSize) const 62 virtual bool apply(TransformationMatrix& transform, const FloatSize& borderBoxSize) const override 69 63 { 70 64 transform.translate3d(x(borderBoxSize), y(borderBoxSize), z(borderBoxSize)); … … 72 66 } 73 67 74 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) ;68 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) override; 75 69 76 70 TranslateTransformOperation(const Length& tx, const Length& ty, const Length& tz, OperationType type) … … 80 74 , m_type(type) 81 75 { 82 ASSERT( type == TRANSLATE_X || type == TRANSLATE_Y || type == TRANSLATE_Z || type == TRANSLATE || type == TRANSLATE_3D);76 ASSERT(isTranslateTransformOperationType()); 83 77 } 84 78 … … 89 83 }; 90 84 85 TRANSFORMOPERATION_TYPE_CASTS(TranslateTransformOperation, isTranslateTransformOperationType()); 86 91 87 } // namespace WebCore 92 88 -
trunk/Source/WebKit2/ChangeLog
r169319 r169320 1 2014-05-25 David Kilzer <ddkilzer@apple.com> 2 3 Add type-checked casts for TransformOperations 4 <http://webkit.org/b/133217> 5 6 Reviewed by Simon Fraser. 7 8 * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp: 9 (IPC::ArgumentCoder<TransformOperations>::encode): 10 - Switch to type-checked casts. 11 1 12 2014-05-25 David Kilzer <ddkilzer@apple.com> 2 13 -
trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
r169319 r169320 187 187 case TransformOperation::SCALE_Z: 188 188 case TransformOperation::SCALE_3D: 189 encoder << static_cast<const ScaleTransformOperation*>(operation)->x();190 encoder << static_cast<const ScaleTransformOperation*>(operation)->y();191 encoder << static_cast<const ScaleTransformOperation*>(operation)->z();189 encoder << toScaleTransformOperation(operation)->x(); 190 encoder << toScaleTransformOperation(operation)->y(); 191 encoder << toScaleTransformOperation(operation)->z(); 192 192 break; 193 193 case TransformOperation::TRANSLATE_X: … … 196 196 case TransformOperation::TRANSLATE_Z: 197 197 case TransformOperation::TRANSLATE_3D: 198 ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->x());199 ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->y());200 ArgumentCoder<Length>::encode(encoder, static_cast<const TranslateTransformOperation*>(operation)->z());198 ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->x()); 199 ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->y()); 200 ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->z()); 201 201 break; 202 202 case TransformOperation::ROTATE: … … 204 204 case TransformOperation::ROTATE_Y: 205 205 case TransformOperation::ROTATE_3D: 206 encoder << static_cast<const RotateTransformOperation*>(operation)->x();207 encoder << static_cast<const RotateTransformOperation*>(operation)->y();208 encoder << static_cast<const RotateTransformOperation*>(operation)->z();209 encoder << static_cast<const RotateTransformOperation*>(operation)->angle();206 encoder << toRotateTransformOperation(operation)->x(); 207 encoder << toRotateTransformOperation(operation)->y(); 208 encoder << toRotateTransformOperation(operation)->z(); 209 encoder << toRotateTransformOperation(operation)->angle(); 210 210 break; 211 211 case TransformOperation::SKEW_X: 212 212 case TransformOperation::SKEW_Y: 213 213 case TransformOperation::SKEW: 214 encoder << static_cast<const SkewTransformOperation*>(operation)->angleX();215 encoder << static_cast<const SkewTransformOperation*>(operation)->angleY();214 encoder << toSkewTransformOperation(operation)->angleX(); 215 encoder << toSkewTransformOperation(operation)->angleY(); 216 216 break; 217 217 case TransformOperation::MATRIX: 218 ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const MatrixTransformOperation*>(operation)->matrix());218 ArgumentCoder<TransformationMatrix>::encode(encoder, toMatrixTransformOperation(operation)->matrix()); 219 219 break; 220 220 case TransformOperation::MATRIX_3D: 221 ArgumentCoder<TransformationMatrix>::encode(encoder, static_cast<const Matrix3DTransformOperation*>(operation)->matrix());221 ArgumentCoder<TransformationMatrix>::encode(encoder, toMatrix3DTransformOperation(operation)->matrix()); 222 222 break; 223 223 case TransformOperation::PERSPECTIVE: 224 ArgumentCoder<Length>::encode(encoder, static_cast<const PerspectiveTransformOperation*>(operation)->perspective());224 ArgumentCoder<Length>::encode(encoder, toPerspectiveTransformOperation(operation)->perspective()); 225 225 break; 226 226 case TransformOperation::IDENTITY:
Note: See TracChangeset
for help on using the changeset viewer.