From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- layout/painting/ActiveLayerTracker.cpp | 50 +++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'layout/painting/ActiveLayerTracker.cpp') diff --git a/layout/painting/ActiveLayerTracker.cpp b/layout/painting/ActiveLayerTracker.cpp index 053445e486..b30ecdf5c2 100644 --- a/layout/painting/ActiveLayerTracker.cpp +++ b/layout/painting/ActiveLayerTracker.cpp @@ -218,23 +218,47 @@ void ActiveLayerTracker::TransferActivityToFrame(nsIContent* aContent, static void IncrementScaleRestyleCountIfNeeded(nsIFrame* aFrame, LayerActivity* aActivity) { + // This function is basically a simplified copy of + // nsDisplayTransform::GetResultingTransformMatrixInternal. + + Matrix svgTransform, parentsChildrenOnlyTransform; + const bool hasSVGTransforms = + aFrame->HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED) && + aFrame->IsSVGTransformed(&svgTransform, &parentsChildrenOnlyTransform); + const nsStyleDisplay* display = aFrame->StyleDisplay(); - if (!display->HasTransformProperty() && !display->HasIndividualTransform() && - display->mOffsetPath.IsNone()) { - // The transform was removed. - aActivity->mPreviousTransformScale = Nothing(); - IncrementMutationCount( - &aActivity->mRestyleCounts[LayerActivity::ACTIVITY_SCALE]); + if (!aFrame->HasAnyStateBits(NS_FRAME_MAY_BE_TRANSFORMED) || + (!display->HasTransformProperty() && !display->HasIndividualTransform() && + display->mOffsetPath.IsNone() && !hasSVGTransforms)) { + if (aActivity->mPreviousTransformScale.isSome()) { + // The transform was removed. + aActivity->mPreviousTransformScale = Nothing(); + IncrementMutationCount( + &aActivity->mRestyleCounts[LayerActivity::ACTIVITY_SCALE]); + } + return; } - // Compute the new scale due to the CSS transform property. - // Note: Motion path doesn't contribute to scale factor. (It only has 2d - // translate and 2d rotate, so we use Nothing() for it.) - nsStyleTransformMatrix::TransformReferenceBox refBox(aFrame); - Matrix4x4 transform = nsStyleTransformMatrix::ReadTransforms( - display->mTranslate, display->mRotate, display->mScale, nullptr, - display->mTransform, refBox, AppUnitsPerCSSPixel()); + Matrix4x4 transform; + if (aFrame->IsCSSTransformed()) { + // Compute the new scale due to the CSS transform property. + // Note: Motion path doesn't contribute to scale factor. (It only has 2d + // translate and 2d rotate, so we use Nothing() for it.) + nsStyleTransformMatrix::TransformReferenceBox refBox(aFrame); + transform = nsStyleTransformMatrix::ReadTransforms( + display->mTranslate, display->mRotate, display->mScale, nullptr, + display->mTransform, refBox, AppUnitsPerCSSPixel()); + } else if (hasSVGTransforms) { + transform = Matrix4x4::From2D(svgTransform); + } + + const bool parentHasChildrenOnlyTransform = + hasSVGTransforms && !parentsChildrenOnlyTransform.IsIdentity(); + if (parentHasChildrenOnlyTransform) { + transform *= Matrix4x4::From2D(parentsChildrenOnlyTransform); + } + Matrix transform2D; if (!transform.Is2D(&transform2D)) { // We don't attempt to handle 3D transforms; just assume the scale changed. -- cgit v1.2.3