From 5ead3a7c0c99cd45266af0845e89a3928195980a Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 4 Feb 2014 12:25:22 +1300 Subject: [PATCH] Bug 952011 - Remove some nsLayoutUtils transform functions that are no longer needed. r=roc --- layout/base/nsDisplayList.cpp | 53 +++++++++-------------------------- layout/base/nsDisplayList.h | 10 +------ layout/base/nsLayoutUtils.cpp | 36 ------------------------ layout/base/nsLayoutUtils.h | 8 ------ 4 files changed, 15 insertions(+), 92 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 2a0bf6b82ed0..8835b620c26f 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -4459,13 +4459,8 @@ bool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder, * think that it's painting in its original rectangular coordinate space. * If we can't untransform, take the entire overflow rect */ nsRect untransformedVisibleRect; - // GetTransform always operates in dev pixels. - float factor = mFrame->PresContext()->AppUnitsPerDevPixel(); if (ShouldPrerenderTransformedContent(aBuilder, mFrame) || - !UntransformRectMatrix(mVisibleRect, - GetTransform(), - factor, - &untransformedVisibleRect)) + !UntransformVisibleRect(&untransformedVisibleRect)) { untransformedVisibleRect = mFrame->GetVisualOverflowRectRelativeToSelf(); } @@ -4606,8 +4601,6 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder, { *aSnap = false; nsRect untransformedVisible; - // GetTransform always operates in dev pixels. - float factor = mFrame->PresContext()->AppUnitsPerDevPixel(); // If we're going to prerender all our content, pretend like we // don't have opqaue content so that everything under us is rendered // as well. That will increase graphics memory usage if our frame @@ -4615,7 +4608,7 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder, // updated extremely cheaply, without invalidating any other // content. if (ShouldPrerenderTransformedContent(aBuilder, mFrame) || - !UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) { + !UntransformVisibleRect(&untransformedVisible)) { return nsRegion(); } @@ -4639,9 +4632,7 @@ nsRegion nsDisplayTransform::GetOpaqueRegion(nsDisplayListBuilder *aBuilder, bool nsDisplayTransform::IsUniform(nsDisplayListBuilder *aBuilder, nscolor* aColor) { nsRect untransformedVisible; - // GetTransform always operates in dev pixels. - float factor = mFrame->PresContext()->AppUnitsPerDevPixel(); - if (!UntransformRectMatrix(mVisibleRect, GetTransform(), factor, &untransformedVisible)) { + if (!UntransformVisibleRect(&untransformedVisible)) { return false; } const gfx3DMatrix& matrix = GetTransform(); @@ -4737,43 +4728,27 @@ nsRect nsDisplayTransform::TransformRectOut(const nsRect &aUntransformedBounds, factor); } -bool nsDisplayTransform::UntransformRectMatrix(const nsRect &aUntransformedBounds, - const gfx3DMatrix& aMatrix, - float aAppUnitsPerPixel, - nsRect *aOutRect) +bool nsDisplayTransform::UntransformVisibleRect(nsRect *aOutRect) { - if (aMatrix.IsSingular()) + const gfx3DMatrix& matrix = GetTransform(); + if (matrix.IsSingular()) return false; - gfxRect result(NSAppUnitsToFloatPixels(aUntransformedBounds.x, aAppUnitsPerPixel), - NSAppUnitsToFloatPixels(aUntransformedBounds.y, aAppUnitsPerPixel), - NSAppUnitsToFloatPixels(aUntransformedBounds.width, aAppUnitsPerPixel), - NSAppUnitsToFloatPixels(aUntransformedBounds.height, aAppUnitsPerPixel)); + // GetTransform always operates in dev pixels. + float factor = mFrame->PresContext()->AppUnitsPerDevPixel(); + gfxRect result(NSAppUnitsToFloatPixels(mVisibleRect.x, factor), + NSAppUnitsToFloatPixels(mVisibleRect.y, factor), + NSAppUnitsToFloatPixels(mVisibleRect.width, factor), + NSAppUnitsToFloatPixels(mVisibleRect.height, factor)); /* We want to untransform the matrix, so invert the transformation first! */ - result = aMatrix.Inverse().ProjectRectBounds(result); + result = matrix.Inverse().ProjectRectBounds(result); - *aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, aAppUnitsPerPixel); + *aOutRect = nsLayoutUtils::RoundGfxRectToAppRect(result, factor); return true; } -bool nsDisplayTransform::UntransformRect(const nsRect &aUntransformedBounds, - const nsIFrame* aFrame, - const nsPoint &aOrigin, - nsRect* aOutRect) -{ - NS_PRECONDITION(aFrame, "Can't take the transform based on a null frame!"); - - /* Grab the matrix. If the transform is degenerate, just hand back the - * empty rect. - */ - float factor = aFrame->PresContext()->AppUnitsPerDevPixel(); - gfx3DMatrix matrix = GetResultingTransformMatrix(aFrame, aOrigin, factor); - - return UntransformRectMatrix(aUntransformedBounds, matrix, factor, aOutRect); -} - nsDisplaySVGEffects::nsDisplaySVGEffects(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList) : nsDisplayWrapList(aBuilder, aFrame, aList), diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 2cf7118ea43a..9ad2b73cf83b 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -3084,15 +3084,7 @@ public: /* UntransformRect is like TransformRect, except that it inverts the * transform. */ - static bool UntransformRect(const nsRect &aUntransformedBounds, - const nsIFrame* aFrame, - const nsPoint &aOrigin, - nsRect* aOutRect); - - static bool UntransformRectMatrix(const nsRect &aUntransformedBounds, - const gfx3DMatrix& aMatrix, - float aAppUnitsPerPixel, - nsRect* aOutRect); + bool UntransformVisibleRect(nsRect* aOutRect); static gfxPoint3D GetDeltaToTransformOrigin(const nsIFrame* aFrame, float aAppUnitsPerPixel, diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 87bf48fc5c44..a9fa137146ae 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1847,15 +1847,6 @@ TransformGfxPointFromAncestor(nsIFrame *aFrame, return ctm.Inverse().ProjectPoint(aPoint); } -static gfxRect -TransformGfxRectFromAncestor(nsIFrame *aFrame, - const gfxRect &aRect, - const nsIFrame *aAncestor) -{ - gfx3DMatrix ctm = nsLayoutUtils::GetTransformToAncestor(aFrame, aAncestor); - return ctm.Inverse().ProjectRectBounds(aRect); -} - static gfxRect TransformGfxRectToAncestor(nsIFrame *aFrame, const gfxRect &aRect, @@ -1905,33 +1896,6 @@ nsLayoutUtils::TransformAncestorPointToFrame(nsIFrame* aFrame, NSFloatPixelsToAppUnits(float(result.y), factor)); } -nsRect -nsLayoutUtils::TransformAncestorRectToFrame(nsIFrame* aFrame, - const nsRect &aRect, - const nsIFrame* aAncestor) -{ - SVGTextFrame* text = GetContainingSVGTextFrame(aFrame); - - float srcAppUnitsPerDevPixel = aAncestor->PresContext()->AppUnitsPerDevPixel(); - gfxRect result(NSAppUnitsToFloatPixels(aRect.x, srcAppUnitsPerDevPixel), - NSAppUnitsToFloatPixels(aRect.y, srcAppUnitsPerDevPixel), - NSAppUnitsToFloatPixels(aRect.width, srcAppUnitsPerDevPixel), - NSAppUnitsToFloatPixels(aRect.height, srcAppUnitsPerDevPixel)); - - if (text) { - result = TransformGfxRectFromAncestor(text, result, aAncestor); - result = text->TransformFrameRectToTextChild(result, aFrame); - } else { - result = TransformGfxRectFromAncestor(aFrame, result, aAncestor); - } - - float destAppUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel(); - return nsRect(NSFloatPixelsToAppUnits(float(result.x), destAppUnitsPerDevPixel), - NSFloatPixelsToAppUnits(float(result.y), destAppUnitsPerDevPixel), - NSFloatPixelsToAppUnits(float(result.width), destAppUnitsPerDevPixel), - NSFloatPixelsToAppUnits(float(result.height), destAppUnitsPerDevPixel)); -} - nsRect nsLayoutUtils::TransformFrameRectToAncestor(nsIFrame* aFrame, const nsRect& aRect, diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 9adc72f22d8b..482433e14b33 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -653,14 +653,6 @@ public: nsTArray &aOutFrames, uint32_t aFlags = 0); - /** - * Transform aRect relative to aAncestor down to the coordinate system of - * aFrame. Computes the bounding-box of the true quadrilateral. - */ - static nsRect TransformAncestorRectToFrame(nsIFrame* aFrame, - const nsRect& aRect, - const nsIFrame* aAncestor); - /** * Transform aRect relative to aFrame up to the coordinate system of * aAncestor. Computes the bounding-box of the true quadrilateral.