diff options
Diffstat (limited to 'layout/painting/ActiveLayerTracker.cpp')
-rw-r--r-- | layout/painting/ActiveLayerTracker.cpp | 50 |
1 files changed, 37 insertions, 13 deletions
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. |