Title: [268714] trunk/Source/WebCore
Revision
268714
Author
grao...@webkit.org
Date
2020-10-19 23:20:03 -0700 (Mon, 19 Oct 2020)

Log Message

TranslateTransformOperation shouldn't take in a FloatSize to convert z as a double
https://bugs.webkit.org/show_bug.cgi?id=217246

Reviewed by Darin Adler.

The method used to get z as a double didn't use the FloatSize parameter, so we remove it. Since there already is a z()
method without an argument returning the underlying Length, we rename the method returning a double to make it clear
what type of value it's returning a double, and given how the call sites converts to a float eventually, we return
a float directly. We also follow the same pattern for x and y.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::getTransformFunctionValue):
* platform/graphics/transforms/TranslateTransformOperation.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268713 => 268714)


--- trunk/Source/WebCore/ChangeLog	2020-10-20 03:45:59 UTC (rev 268713)
+++ trunk/Source/WebCore/ChangeLog	2020-10-20 06:20:03 UTC (rev 268714)
@@ -1,3 +1,19 @@
+2020-10-02  Antoine Quint  <grao...@webkit.org>
+
+        TranslateTransformOperation shouldn't take in a FloatSize to convert z as a double
+        https://bugs.webkit.org/show_bug.cgi?id=217246
+
+        Reviewed by Darin Adler.
+
+        The method used to get z as a double didn't use the FloatSize parameter, so we remove it. Since there already is a z()
+        method without an argument returning the underlying Length, we rename the method returning a double to make it clear
+        what type of value it's returning a double, and given how the call sites converts to a float eventually, we return
+        a float directly. We also follow the same pattern for x and y.
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::getTransformFunctionValue):
+        * platform/graphics/transforms/TranslateTransformOperation.h:
+
 2020-10-19  Simon Fraser  <simon.fra...@apple.com>
 
         Fix crash in RenderLayerBacking::updateClippingStackLayerGeometry()

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2020-10-20 03:45:59 UTC (rev 268713)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2020-10-20 06:20:03 UTC (rev 268714)
@@ -157,13 +157,13 @@
         value = transformOp ? narrowPrecisionToFloat(downcast<ScaleTransformOperation>(*transformOp).z()) : 1;
         break;
     case TransformOperation::TRANSLATE_X:
-        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).x(size)) : 0;
+        value = transformOp ? downcast<TranslateTransformOperation>(*transformOp).xAsFloat(size) : 0;
         break;
     case TransformOperation::TRANSLATE_Y:
-        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).y(size)) : 0;
+        value = transformOp ? downcast<TranslateTransformOperation>(*transformOp).yAsFloat(size) : 0;
         break;
     case TransformOperation::TRANSLATE_Z:
-        value = transformOp ? narrowPrecisionToFloat(downcast<TranslateTransformOperation>(*transformOp).z(size)) : 0;
+        value = transformOp ? downcast<TranslateTransformOperation>(*transformOp).zAsFloat() : 0;
         break;
     default:
         break;
@@ -184,9 +184,9 @@
     case TransformOperation::TRANSLATE:
     case TransformOperation::TRANSLATE_3D: {
         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);
+        value.setX(translateTransformOp ? translateTransformOp->xAsFloat(size) : 0);
+        value.setY(translateTransformOp ? translateTransformOp->yAsFloat(size) : 0);
+        value.setZ(translateTransformOp ? translateTransformOp->zAsFloat() : 0);
         break;
     }
     default:

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


--- trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2020-10-20 03:45:59 UTC (rev 268713)
+++ trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2020-10-20 06:20:03 UTC (rev 268714)
@@ -48,9 +48,9 @@
         return adoptRef(*new TranslateTransformOperation(m_x, m_y, m_z, type()));
     }
 
-    double x(const FloatSize& borderBoxSize) const { return floatValueForLength(m_x, borderBoxSize.width()); }
-    double y(const FloatSize& borderBoxSize) const { return floatValueForLength(m_y, borderBoxSize.height()); }
-    double z(const FloatSize&) const { return floatValueForLength(m_z, 1); }
+    float xAsFloat(const FloatSize& borderBoxSize) const { return floatValueForLength(m_x, borderBoxSize.width()); }
+    float yAsFloat(const FloatSize& borderBoxSize) const { return floatValueForLength(m_y, borderBoxSize.height()); }
+    float zAsFloat() const { return floatValueForLength(m_z, 1); }
 
     Length x() const { return m_x; }
     Length y() const { return m_y; }
@@ -58,7 +58,7 @@
 
     bool apply(TransformationMatrix& transform, const FloatSize& borderBoxSize) const final
     {
-        transform.translate3d(x(borderBoxSize), y(borderBoxSize), z(borderBoxSize));
+        transform.translate3d(xAsFloat(borderBoxSize), yAsFloat(borderBoxSize), zAsFloat());
         return m_x.isPercent() || m_y.isPercent();
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to