Title: [174739] trunk/Source
Revision
174739
Author
cdu...@apple.com
Date
2014-10-15 12:15:16 -0700 (Wed, 15 Oct 2014)

Log Message

Use is<>() / downcast<>() for TransformOperation subclasses
https://bugs.webkit.org/show_bug.cgi?id=137731

Reviewed by Darin Adler.

Use is<>() / downcast<>() for TransformOperation subclasses and clean
up the surrounding code.

Source/WebCore:

No new tests, no behavior change.

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::validateTransformOperations):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::getTransformFunctionValue):
* platform/graphics/transforms/IdentityTransformOperation.h:
* platform/graphics/transforms/Matrix3DTransformOperation.cpp:
(WebCore::Matrix3DTransformOperation::operator==):
* platform/graphics/transforms/Matrix3DTransformOperation.h:
* platform/graphics/transforms/MatrixTransformOperation.cpp:
(WebCore::MatrixTransformOperation::operator==):
(WebCore::MatrixTransformOperation::blend):
* platform/graphics/transforms/MatrixTransformOperation.h:
* platform/graphics/transforms/PerspectiveTransformOperation.cpp:
(WebCore::PerspectiveTransformOperation::operator==):
(WebCore::PerspectiveTransformOperation::blend):
* platform/graphics/transforms/PerspectiveTransformOperation.h:
* platform/graphics/transforms/RotateTransformOperation.cpp:
(WebCore::RotateTransformOperation::operator==):
(WebCore::RotateTransformOperation::blend):
* platform/graphics/transforms/RotateTransformOperation.h:
* platform/graphics/transforms/ScaleTransformOperation.cpp:
(WebCore::ScaleTransformOperation::operator==):
(WebCore::ScaleTransformOperation::blend):
* platform/graphics/transforms/ScaleTransformOperation.h:
* platform/graphics/transforms/SkewTransformOperation.cpp:
(WebCore::SkewTransformOperation::operator==):
(WebCore::SkewTransformOperation::blend):
* platform/graphics/transforms/SkewTransformOperation.h:
* platform/graphics/transforms/TransformOperation.h:
* platform/graphics/transforms/TranslateTransformOperation.cpp:
(WebCore::TranslateTransformOperation::operator==):
(WebCore::TranslateTransformOperation::blend):
* platform/graphics/transforms/TranslateTransformOperation.h:

Source/WebKit2:

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(IPC::ArgumentCoder<TransformOperations>::encode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (174738 => 174739)


--- trunk/Source/WebCore/ChangeLog	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/ChangeLog	2014-10-15 19:15:16 UTC (rev 174739)
@@ -1,5 +1,51 @@
 2014-10-15  Chris Dumez  <cdu...@apple.com>
 
+        Use is<>() / downcast<>() for TransformOperation subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137731
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for TransformOperation subclasses and clean
+        up the surrounding code.
+
+        No new tests, no behavior change.
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::validateTransformOperations):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::getTransformFunctionValue):
+        * platform/graphics/transforms/IdentityTransformOperation.h:
+        * platform/graphics/transforms/Matrix3DTransformOperation.cpp:
+        (WebCore::Matrix3DTransformOperation::operator==):
+        * platform/graphics/transforms/Matrix3DTransformOperation.h:
+        * platform/graphics/transforms/MatrixTransformOperation.cpp:
+        (WebCore::MatrixTransformOperation::operator==):
+        (WebCore::MatrixTransformOperation::blend):
+        * platform/graphics/transforms/MatrixTransformOperation.h:
+        * platform/graphics/transforms/PerspectiveTransformOperation.cpp:
+        (WebCore::PerspectiveTransformOperation::operator==):
+        (WebCore::PerspectiveTransformOperation::blend):
+        * platform/graphics/transforms/PerspectiveTransformOperation.h:
+        * platform/graphics/transforms/RotateTransformOperation.cpp:
+        (WebCore::RotateTransformOperation::operator==):
+        (WebCore::RotateTransformOperation::blend):
+        * platform/graphics/transforms/RotateTransformOperation.h:
+        * platform/graphics/transforms/ScaleTransformOperation.cpp:
+        (WebCore::ScaleTransformOperation::operator==):
+        (WebCore::ScaleTransformOperation::blend):
+        * platform/graphics/transforms/ScaleTransformOperation.h:
+        * platform/graphics/transforms/SkewTransformOperation.cpp:
+        (WebCore::SkewTransformOperation::operator==):
+        (WebCore::SkewTransformOperation::blend):
+        * platform/graphics/transforms/SkewTransformOperation.h:
+        * platform/graphics/transforms/TransformOperation.h:
+        * platform/graphics/transforms/TranslateTransformOperation.cpp:
+        (WebCore::TranslateTransformOperation::operator==):
+        (WebCore::TranslateTransformOperation::blend):
+        * platform/graphics/transforms/TranslateTransformOperation.h:
+
+2014-10-15  Chris Dumez  <cdu...@apple.com>
+
         Use is<>() / downcast<>() for RenderTextControl / RenderTextControlSingleLine
         https://bugs.webkit.org/show_bug.cgi?id=137727
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -521,8 +521,8 @@
     }
 
     // Keyframes are valid, check for big rotations.    
-    double lastRotAngle = 0.0;
-    double maxRotAngle = -1.0;
+    double lastRotationAngle = 0.0;
+    double maxRotationAngle = -1.0;
         
     for (size_t j = 0; j < firstVal.operations().size(); ++j) {
         TransformOperation::OperationType type = firstVal.operations().at(j)->type();
@@ -532,23 +532,23 @@
             type == TransformOperation::ROTATE_Y ||
             type == TransformOperation::ROTATE_Z ||
             type == TransformOperation::ROTATE_3D) {
-            lastRotAngle = toRotateTransformOperation(firstVal.operations().at(j).get())->angle();
+            lastRotationAngle = downcast<RotateTransformOperation>(*firstVal.operations().at(j)).angle();
             
-            if (maxRotAngle < 0)
-                maxRotAngle = fabs(lastRotAngle);
+            if (maxRotationAngle < 0)
+                maxRotationAngle = fabs(lastRotationAngle);
             
             for (size_t i = firstIndex + 1; i < valueList.size(); ++i) {
                 const TransformOperations& val = operationsAt(valueList, i);
-                double rotAngle = val.operations().isEmpty() ? 0 : (toRotateTransformOperation(val.operations().at(j).get())->angle());
-                double diffAngle = fabs(rotAngle - lastRotAngle);
-                if (diffAngle > maxRotAngle)
-                    maxRotAngle = diffAngle;
-                lastRotAngle = rotAngle;
+                double rotationAngle = val.operations().isEmpty() ? 0 : downcast<RotateTransformOperation>(*val.operations().at(j)).angle();
+                double diffAngle = fabs(rotationAngle - lastRotationAngle);
+                if (diffAngle > maxRotationAngle)
+                    maxRotationAngle = diffAngle;
+                lastRotationAngle = rotationAngle;
             }
         }
     }
     
-    hasBigRotation = maxRotAngle >= 180.0;
+    hasBigRotation = maxRotationAngle >= 180.0;
     
     return firstIndex;
 }

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -129,25 +129,25 @@
     case TransformOperation::ROTATE:
     case TransformOperation::ROTATE_X:
     case TransformOperation::ROTATE_Y:
-        value = transformOp ? narrowPrecisionToFloat(deg2rad(toRotateTransformOperation(transformOp)->angle())) : 0;
+        value = transformOp ? narrowPrecisionToFloat(deg2rad(downcast<RotateTransformOperation>(*transformOp).angle())) : 0;
         break;
     case TransformOperation::SCALE_X:
-        value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->x()) : 1;
+        value = transformOp ? narrowPrecisionToFloat(downcast<ScaleTransformOperation>(*transformOp).x()) : 1;
         break;
     case TransformOperation::SCALE_Y:
-        value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->y()) : 1;
+        value = transformOp ? narrowPrecisionToFloat(downcast<ScaleTransformOperation>(*transformOp).y()) : 1;
         break;
     case TransformOperation::SCALE_Z:
-        value = transformOp ? narrowPrecisionToFloat(toScaleTransformOperation(transformOp)->z()) : 1;
+        value = transformOp ? narrowPrecisionToFloat(downcast<ScaleTransformOperation>(*transformOp).z()) : 1;
         break;
     case TransformOperation::TRANSLATE_X:
-        value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->x(size)) : 0;
+        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).x(size)) : 0;
         break;
     case TransformOperation::TRANSLATE_Y:
-        value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->y(size)) : 0;
+        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).y(size)) : 0;
         break;
     case TransformOperation::TRANSLATE_Z:
-        value = transformOp ? narrowPrecisionToFloat(toTranslateTransformOperation(transformOp)->z(size)) : 0;
+        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).z(size)) : 0;
         break;
     default:
         break;
@@ -159,7 +159,7 @@
     switch (transformType) {
     case TransformOperation::SCALE:
     case TransformOperation::SCALE_3D: {
-        const ScaleTransformOperation* scaleTransformOp = toScaleTransformOperation(transformOp);
+        const auto* scaleTransformOp = downcast<ScaleTransformOperation>(transformOp);
         value.setX(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->x()) : 1);
         value.setY(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->y()) : 1);
         value.setZ(scaleTransformOp ? narrowPrecisionToFloat(scaleTransformOp->z()) : 1);
@@ -167,7 +167,7 @@
     }
     case TransformOperation::TRANSLATE:
     case TransformOperation::TRANSLATE_3D: {
-        const TranslateTransformOperation* translateTransformOp = toTranslateTransformOperation(transformOp);
+        const auto* translateTransformOp = downcast<TranslateTransformOperation>(transformOp);
         value.setX(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->x(size)) : 0);
         value.setY(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->y(size)) : 0);
         value.setZ(translateTransformOp ? narrowPrecisionToFloat(translateTransformOp->z(size)) : 0);

Modified: trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -62,8 +62,8 @@
 
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(IdentityTransformOperation, type() == TransformOperation::IDENTITY);
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::IdentityTransformOperation, type() == WebCore::TransformOperation::IDENTITY)
+
 #endif // IdentityTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -30,12 +30,9 @@
 
 namespace WebCore {
 
-bool Matrix3DTransformOperation::operator==(const TransformOperation& o) const
+bool Matrix3DTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
-        return false;
-    const Matrix3DTransformOperation& m = toMatrix3DTransformOperation(o);
-    return m_matrix == m.m_matrix;
+    return isSameType(other) && m_matrix == downcast<Matrix3DTransformOperation>(other).m_matrix;
 }
 
 PassRefPtr<TransformOperation> Matrix3DTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)

Modified: trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -63,8 +63,8 @@
     TransformationMatrix m_matrix;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(Matrix3DTransformOperation, type() == TransformOperation::MATRIX_3D);
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::Matrix3DTransformOperation, type() == WebCore::TransformOperation::MATRIX_3D)
+
 #endif // Matrix3DTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -26,11 +26,11 @@
 
 namespace WebCore {
 
-bool MatrixTransformOperation::operator==(const TransformOperation& o) const
+bool MatrixTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const MatrixTransformOperation& m = toMatrixTransformOperation(o);
+    const MatrixTransformOperation& m = downcast<MatrixTransformOperation>(other);
     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;
 }
 
@@ -40,11 +40,10 @@
         return this;
 
     // convert the TransformOperations into matrices
-    FloatSize size;
     TransformationMatrix fromT;
     TransformationMatrix toT(m_a, m_b, m_c, m_d, m_e, m_f);
     if (from) {
-        const MatrixTransformOperation& m = toMatrixTransformOperation(*from);
+        const MatrixTransformOperation& m = downcast<MatrixTransformOperation>(*from);
         fromT.setMatrix(m.m_a, m.m_b, m.m_c, m.m_d, m.m_e, m.m_f);
     }
     

Modified: trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -89,8 +89,8 @@
     double m_f;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(MatrixTransformOperation, type() == TransformOperation::MATRIX);
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::MatrixTransformOperation, type() == WebCore::TransformOperation::MATRIX)
+
 #endif // MatrixTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -31,12 +31,11 @@
 
 namespace WebCore {
 
-bool PerspectiveTransformOperation::operator==(const TransformOperation& o) const
+bool PerspectiveTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const PerspectiveTransformOperation& p = toPerspectiveTransformOperation(o);
-    return m_p == p.m_p;
+    return m_p == downcast<PerspectiveTransformOperation>(other).m_p;
 }
 
 PassRefPtr<TransformOperation> PerspectiveTransformOperation::blend(const TransformOperation* from, double progress, bool blendToIdentity)
@@ -50,7 +49,7 @@
         return PerspectiveTransformOperation::create(Length(clampToPositiveInteger(p), Fixed));
     }
     
-    const PerspectiveTransformOperation* fromOp = toPerspectiveTransformOperation(from);
+    const PerspectiveTransformOperation* fromOp = downcast<PerspectiveTransformOperation>(from);
     Length fromP = fromOp ? fromOp->m_p : Length(m_p.type());
     Length toP = m_p;
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -65,8 +65,8 @@
     Length m_p;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(PerspectiveTransformOperation, type() == TransformOperation::PERSPECTIVE);
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::PerspectiveTransformOperation, type() == WebCore::TransformOperation::PERSPECTIVE)
+
 #endif // PerspectiveTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -28,11 +28,11 @@
 
 namespace WebCore {
 
-bool RotateTransformOperation::operator==(const TransformOperation& o) const
+bool RotateTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const RotateTransformOperation& r = toRotateTransformOperation(o);
+    const RotateTransformOperation& r = downcast<RotateTransformOperation>(other);
     return m_x == r.m_x && m_y == r.m_y && m_z == r.m_z && m_angle == r.m_angle;
 }
 
@@ -44,7 +44,7 @@
     if (blendToIdentity)
         return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, m_type);
     
-    const RotateTransformOperation* fromOp = toRotateTransformOperation(from);
+    const RotateTransformOperation* fromOp = downcast<RotateTransformOperation>(from);
     
     // Optimize for single axis rotation
     if (!fromOp || (fromOp->m_x == 0 && fromOp->m_y == 0 && fromOp->m_z == 1) || 

Modified: trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -79,8 +79,8 @@
     OperationType m_type;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(RotateTransformOperation, isRotateTransformOperationType());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::RotateTransformOperation, isRotateTransformOperationType())
+
 #endif // RotateTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -26,11 +26,11 @@
 
 namespace WebCore {
 
-bool ScaleTransformOperation::operator==(const TransformOperation& o) const
+bool ScaleTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const ScaleTransformOperation& s = toScaleTransformOperation(o);
+    const ScaleTransformOperation& s = downcast<ScaleTransformOperation>(other);
     return m_x == s.m_x && m_y == s.m_y && m_z == s.m_z;
 }
 
@@ -44,7 +44,7 @@
                                                WebCore::blend(m_y, 1.0, progress),
                                                WebCore::blend(m_z, 1.0, progress), m_type);
     
-    const ScaleTransformOperation* fromOp = toScaleTransformOperation(from);
+    const ScaleTransformOperation* fromOp = downcast<ScaleTransformOperation>(from);
     double fromX = fromOp ? fromOp->m_x : 1.0;
     double fromY = fromOp ? fromOp->m_y : 1.0;
     double fromZ = fromOp ? fromOp->m_z : 1.0;

Modified: trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -76,8 +76,8 @@
     OperationType m_type;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(ScaleTransformOperation, isScaleTransformOperationType());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::ScaleTransformOperation, isScaleTransformOperationType())
+
 #endif // ScaleTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -26,11 +26,11 @@
 
 namespace WebCore {
 
-bool SkewTransformOperation::operator==(const TransformOperation& o) const
+bool SkewTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const SkewTransformOperation& s = toSkewTransformOperation(o);
+    const SkewTransformOperation& s = downcast<SkewTransformOperation>(other);
     return m_angleX == s.m_angleX && m_angleY == s.m_angleY;
 }
 
@@ -42,7 +42,7 @@
     if (blendToIdentity)
         return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, progress), WebCore::blend(m_angleY, 0.0, progress), m_type);
     
-    const SkewTransformOperation* fromOp = toSkewTransformOperation(from);
+    const SkewTransformOperation* fromOp = downcast<SkewTransformOperation>(from);
     double fromAngleX = fromOp ? fromOp->m_angleX : 0;
     double fromAngleY = fromOp ? fromOp->m_angleY : 0;
     return SkewTransformOperation::create(WebCore::blend(fromAngleX, m_angleX, progress), WebCore::blend(fromAngleY, m_angleY, progress), m_type);

Modified: trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -67,8 +67,8 @@
     OperationType m_type;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(SkewTransformOperation, isSkewTransformOperationType());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::SkewTransformOperation, isSkewTransformOperationType())
+
 #endif // SkewTransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -29,6 +29,7 @@
 #include "TransformationMatrix.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
 
 namespace WebCore {
 
@@ -101,9 +102,11 @@
     }
 };
 
-#define TRANSFORMOPERATION_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, WebCore::TransformOperation, value, value->predicate, value.predicate)
-
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
+    static bool isType(const WebCore::TransformOperation& operation) { return operation.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // TransformOperation_h

Modified: trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -25,11 +25,11 @@
 
 namespace WebCore {
 
-bool TranslateTransformOperation::operator==(const TransformOperation& o) const
+bool TranslateTransformOperation::operator==(const TransformOperation& other) const
 {
-    if (!isSameType(o))
+    if (!isSameType(other))
         return false;
-    const TranslateTransformOperation& t = toTranslateTransformOperation(o);
+    const TranslateTransformOperation& t = downcast<TranslateTransformOperation>(other);
     return m_x == t.m_x && m_y == t.m_y && m_z == t.m_z;
 }
 
@@ -42,7 +42,7 @@
     if (blendToIdentity)
         return TranslateTransformOperation::create(zeroLength.blend(m_x, progress), zeroLength.blend(m_y, progress), zeroLength.blend(m_z, progress), m_type);
 
-    const TranslateTransformOperation* fromOp = toTranslateTransformOperation(from);
+    const TranslateTransformOperation* fromOp = downcast<TranslateTransformOperation>(from);
     Length fromX = fromOp ? fromOp->m_x : zeroLength;
     Length fromY = fromOp ? fromOp->m_y : zeroLength;
     Length fromZ = fromOp ? fromOp->m_z : zeroLength;

Modified: trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h (174738 => 174739)


--- trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2014-10-15 19:15:16 UTC (rev 174739)
@@ -82,8 +82,8 @@
     OperationType m_type;
 };
 
-TRANSFORMOPERATION_TYPE_CASTS(TranslateTransformOperation, isTranslateTransformOperationType());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::TranslateTransformOperation, isTranslateTransformOperationType())
+
 #endif // TranslateTransformOperation_h

Modified: trunk/Source/WebKit2/ChangeLog (174738 => 174739)


--- trunk/Source/WebKit2/ChangeLog	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebKit2/ChangeLog	2014-10-15 19:15:16 UTC (rev 174739)
@@ -1,3 +1,16 @@
+2014-10-15  Chris Dumez  <cdu...@apple.com>
+
+        Use is<>() / downcast<>() for TransformOperation subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137731
+
+        Reviewed by Darin Adler.
+
+        Use is<>() / downcast<>() for TransformOperation subclasses and clean
+        up the surrounding code.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (IPC::ArgumentCoder<TransformOperations>::encode):
+
 2014-10-15  Alexey Proskuryakov  <a...@apple.com>
 
         [Mac] Allow some Kerberos related paths in sandbox

Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (174738 => 174739)


--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp	2014-10-15 19:04:08 UTC (rev 174738)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp	2014-10-15 19:15:16 UTC (rev 174739)
@@ -171,8 +171,7 @@
 void ArgumentCoder<TransformOperations>::encode(ArgumentEncoder& encoder, const TransformOperations& transformOperations)
 {
     encoder << static_cast<uint32_t>(transformOperations.size());
-    for (size_t i = 0; i < transformOperations.size(); ++i) {
-        const TransformOperation* operation = transformOperations.at(i);
+    for (const auto& operation : transformOperations.operations()) {
         encoder.encodeEnum(operation->type());
 
         switch (operation->type()) {
@@ -180,43 +179,51 @@
         case TransformOperation::SCALE_Y:
         case TransformOperation::SCALE:
         case TransformOperation::SCALE_Z:
-        case TransformOperation::SCALE_3D:
-            encoder << toScaleTransformOperation(operation)->x();
-            encoder << toScaleTransformOperation(operation)->y();
-            encoder << toScaleTransformOperation(operation)->z();
+        case TransformOperation::SCALE_3D: {
+            const auto& scaleOperation = downcast<ScaleTransformOperation>(*operation);
+            encoder << scaleOperation.x();
+            encoder << scaleOperation.y();
+            encoder << scaleOperation.z();
             break;
+        }
         case TransformOperation::TRANSLATE_X:
         case TransformOperation::TRANSLATE_Y:
         case TransformOperation::TRANSLATE:
         case TransformOperation::TRANSLATE_Z:
-        case TransformOperation::TRANSLATE_3D:
-            ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->x());
-            ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->y());
-            ArgumentCoder<Length>::encode(encoder, toTranslateTransformOperation(operation)->z());
+        case TransformOperation::TRANSLATE_3D: {
+            const auto& translateOperation = downcast<TranslateTransformOperation>(*operation);
+            ArgumentCoder<Length>::encode(encoder, translateOperation.x());
+            ArgumentCoder<Length>::encode(encoder, translateOperation.y());
+            ArgumentCoder<Length>::encode(encoder, translateOperation.z());
             break;
+        }
         case TransformOperation::ROTATE:
         case TransformOperation::ROTATE_X:
         case TransformOperation::ROTATE_Y:
-        case TransformOperation::ROTATE_3D:
-            encoder << toRotateTransformOperation(operation)->x();
-            encoder << toRotateTransformOperation(operation)->y();
-            encoder << toRotateTransformOperation(operation)->z();
-            encoder << toRotateTransformOperation(operation)->angle();
+        case TransformOperation::ROTATE_3D: {
+            const auto& rotateOperation = downcast<RotateTransformOperation>(*operation);
+            encoder << rotateOperation.x();
+            encoder << rotateOperation.y();
+            encoder << rotateOperation.z();
+            encoder << rotateOperation.angle();
             break;
+        }
         case TransformOperation::SKEW_X:
         case TransformOperation::SKEW_Y:
-        case TransformOperation::SKEW:
-            encoder << toSkewTransformOperation(operation)->angleX();
-            encoder << toSkewTransformOperation(operation)->angleY();
+        case TransformOperation::SKEW: {
+            const auto& skewOperation = downcast<SkewTransformOperation>(*operation);
+            encoder << skewOperation.angleX();
+            encoder << skewOperation.angleY();
             break;
+        }
         case TransformOperation::MATRIX:
-            ArgumentCoder<TransformationMatrix>::encode(encoder, toMatrixTransformOperation(operation)->matrix());
+            ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<MatrixTransformOperation>(*operation).matrix());
             break;
         case TransformOperation::MATRIX_3D:
-            ArgumentCoder<TransformationMatrix>::encode(encoder, toMatrix3DTransformOperation(operation)->matrix());
+            ArgumentCoder<TransformationMatrix>::encode(encoder, downcast<Matrix3DTransformOperation>(*operation).matrix());
             break;
         case TransformOperation::PERSPECTIVE:
-            ArgumentCoder<Length>::encode(encoder, toPerspectiveTransformOperation(operation)->perspective());
+            ArgumentCoder<Length>::encode(encoder, downcast<PerspectiveTransformOperation>(*operation).perspective());
             break;
         case TransformOperation::IDENTITY:
             break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to