WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
237590
Extract transform-origin handling out of RenderStyle::applyTransform()
https://bugs.webkit.org/show_bug.cgi?id=237590
Summary
Extract transform-origin handling out of RenderStyle::applyTransform()
Nikolas Zimmermann
Reported
2022-03-08 01:50:30 PST
RenderStyle::applyTransform() implements the algorithm given in CSS Transforms Module Level 2 (
https://www.w3.org/TR/css-transforms-2/#ctm
) that yields the "current transformation matrix". It is used e.g. in RenderLayer::updateTransform() to compute the layer transformation matrix, that's used for rendering. Make it possible to re-use all steps of the algorithm for SVG, by allowing to override the CSS transform by an external matrix that's used instead (SVG 2D transform).
Attachments
Patch, v1
(7.90 KB, patch)
2022-03-08 01:53 PST
,
Nikolas Zimmermann
no flags
Details
Formatted Diff
Diff
Patch, v2
(10.07 KB, patch)
2022-03-09 02:31 PST
,
Nikolas Zimmermann
no flags
Details
Formatted Diff
Diff
Patch, v3
(10.07 KB, patch)
2022-03-09 03:08 PST
,
Nikolas Zimmermann
no flags
Details
Formatted Diff
Diff
Patch, v4
(9.08 KB, patch)
2022-03-10 05:52 PST
,
Nikolas Zimmermann
simon.fraser
: review+
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Nikolas Zimmermann
Comment 1
2022-03-08 01:53:53 PST
Created
attachment 454086
[details]
Patch, v1
Rob Buis
Comment 2
2022-03-08 07:25:11 PST
Comment on
attachment 454086
[details]
Patch, v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
> Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp:1536 > +TransformationMatrix& TransformationMatrix::multiplyAffineTransform(const AffineTransform& mat)
We probably should not abbreviate here, so either 'matrix' or 'affineTransform'.
Simon Fraser (smfr)
Comment 3
2022-03-08 09:26:58 PST
Comment on
attachment 454086
[details]
Patch, v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
> Source/WebCore/rendering/style/RenderStyle.cpp:1474 > + if (transformOperations.size()) { > + for (auto& operation : transformOperations.operations()) > + operation->apply(transform, boundingBox.size()); > + } else if (externalAffineTransformationSource) { > + // SVG may provide additional non-CSS transformation operations. > + transform.multiplyAffineTransform(externalAffineTransformationSource()); > + }
It's weird that this is either-or. From the function signature I would expect that the result of externalAffineTransformationSource would get multiplied with the style's transforms. Especially since this function DOES use the individual transform properties.
Simon Fraser (smfr)
Comment 4
2022-03-08 09:33:27 PST
Comment on
attachment 454086
[details]
Patch, v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
>> Source/WebCore/rendering/style/RenderStyle.cpp:1474 >> + } > > It's weird that this is either-or. From the function signature I would expect that the result of externalAffineTransformationSource would get multiplied with the style's transforms. Especially since this function DOES use the individual transform properties.
One option would be to add another function that knows how to apply/unapply transform origin, and call it from this function, and to add a third function for the custom SVG case.
Nikolas Zimmermann
Comment 5
2022-03-09 01:46:59 PST
(In reply to Simon Fraser (smfr) from
comment #3
)
> Comment on
attachment 454086
[details]
> Patch, v1 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
> > > Source/WebCore/rendering/style/RenderStyle.cpp:1474 > > + if (transformOperations.size()) { > > + for (auto& operation : transformOperations.operations()) > > + operation->apply(transform, boundingBox.size()); > > + } else if (externalAffineTransformationSource) { > > + // SVG may provide additional non-CSS transformation operations. > > + transform.multiplyAffineTransform(externalAffineTransformationSource()); > > + } > > It's weird that this is either-or. From the function signature I would > expect that the result of externalAffineTransformationSource would get > multiplied with the style's transforms. Especially since this function DOES > use the individual transform properties.
Good catch, the intention was to only look at 'externalAffineTransformSource' if neither the transform property nor the individual transform properties are given, but the "if (transformOperatations.size())" case only catches the transform attribute, not the rest.
Nikolas Zimmermann
Comment 6
2022-03-09 01:47:44 PST
(In reply to Simon Fraser (smfr) from
comment #4
)
> > It's weird that this is either-or. From the function signature I would expect that the result of externalAffineTransformationSource would get multiplied with the style's transforms. Especially since this function DOES use the individual transform properties. > > One option would be to add another function that knows how to apply/unapply > transform origin, and call it from this function, and to add a third > function for the custom SVG case.
+1 that sounds much nicer.
Nikolas Zimmermann
Comment 7
2022-03-09 02:31:01 PST
Created
attachment 454212
[details]
Patch, v2
Nikolas Zimmermann
Comment 8
2022-03-09 03:08:44 PST
Created
attachment 454217
[details]
Patch, v3
Nikolas Zimmermann
Comment 9
2022-03-10 01:31:33 PST
(In reply to Rob Buis from
comment #2
)
> Comment on
attachment 454086
[details]
> Patch, v1 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
> > > Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp:1536 > > +TransformationMatrix& TransformationMatrix::multiplyAffineTransform(const AffineTransform& mat) > > We probably should not abbreviate here, so either 'matrix' or > 'affineTransform'.
Missed that comment, I can apply s/mat/matrix/ before landing.
Nikolas Zimmermann
Comment 10
2022-03-10 05:52:51 PST
Created
attachment 454348
[details]
Patch, v4
Nikolas Zimmermann
Comment 11
2022-03-10 05:53:08 PST
(In reply to Nikolas Zimmermann from
comment #9
)
> (In reply to Rob Buis from
comment #2
) > > Comment on
attachment 454086
[details]
> > Patch, v1 > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=454086&action=review
> > > > > Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp:1536 > > > +TransformationMatrix& TransformationMatrix::multiplyAffineTransform(const AffineTransform& mat) > > > > We probably should not abbreviate here, so either 'matrix' or > > 'affineTransform'. > > Missed that comment, I can apply s/mat/matrix/ before landing.
Even easier, the changes are not needed here anymore, leaving this out for another LBSE patch.
Nikolas Zimmermann
Comment 12
2022-03-10 15:48:15 PST
Simon, can you have another look? This slightly deviates from your proposal -- it might be helpful to look at this patch and also at
https://bugs.webkit.org/show_bug.cgi?id=237711
, which is the patch that enables SVG/CSS transform support for LBSE (RenderLayerModelObject::applySVGTransform() makes use of the new methods introduced here: applyTransformOrigin/unapplyTransformOrigin/affectedByTransformOrigin/etc.) The patch on ticket 237711 depends on all of these tickets: 237553 (done), 237554 (r?), 237590 (this one), 237701 (depends on 2357554). Once these are in, I can proceed to the patches that enable transform-box support for composited elements -- which is trivial after the cleanups are all in.
Radar WebKit Bug Importer
Comment 13
2022-03-14 08:54:29 PDT
<
rdar://problem/90248514
>
Simon Fraser (smfr)
Comment 14
2022-03-14 11:21:18 PDT
Comment on
attachment 454348
[details]
Patch, v4 View in context:
https://bugs.webkit.org/attachment.cgi?id=454348&action=review
> Source/WebCore/rendering/style/RenderStyle.cpp:1508 > + // 8. Translate by the negated computed X, Y and Z values of transform-origin. (see unapplyTransformOrigin)
Weird to have this dangling comment here.
Nikolas Zimmermann
Comment 15
2022-03-16 03:18:17 PDT
(In reply to Simon Fraser (smfr) from
comment #14
)
> Comment on
attachment 454348
[details]
> Patch, v4 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=454348&action=review
> > > Source/WebCore/rendering/style/RenderStyle.cpp:1508 > > + // 8. Translate by the negated computed X, Y and Z values of transform-origin. (see unapplyTransformOrigin) > > Weird to have this dangling comment here.
I've added (see unapplyTransformOrigin) -- modified to: + // 8. Translate by the negated computed X, Y and Z values of transform-origin. + // (implemented in unapplyTransformOrigin) before landing. I hope that's better :-)
Nikolas Zimmermann
Comment 16
2022-03-16 03:20:04 PDT
Committed
r291338
(
248477@trunk
): <
https://commits.webkit.org/248477@trunk
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug