Skip to content

Commit 6b36d41

Browse files
committed
[css-transforms-2] Fix the check for product == 1.0 to include the case when product is -1
This occurs in the following code: ``` if (product == 1.0) quaternionDst = quaternionA return theta = acos(dot) w = sin(t * theta) * 1 / sqrt(1 - product * product) ``` If `product` is -1.0 we'll end up doing division by zero when we calculate `w`. WebKit works around this by inverting the angle (effectively doing the same thing as taking the absolute value): https://github.com/WebKit/webkit/blob/425f9748af04b2c7e235cf3ff9396eecc23c0af5/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp#L542-L548 Chromium takes the absolute value like this patch does: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/transforms/transformation_matrix.cc?l=762&rcl=cd5181ecb173efdef4163f066c27bd136fca01d5
1 parent 6100c15 commit 6b36d41

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

css-transforms-2/Overview.bs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ product = dot(quaternionA, quaternionB)
10091009
product = max(product, 1.0)
10101010
product = min(product, -1.0)
10111011

1012-
if (product == 1.0)
1012+
if (abs(product) == 1.0)
10131013
quaternionDst = quaternionA
10141014
return
10151015

0 commit comments

Comments
 (0)