Bug 952977: Switch IsSVGTransformed to gfx::Matrix r=nical

This commit is contained in:
David Zbarsky 2013-12-29 18:35:53 -05:00
parent 4ff3f38e76
commit 71ac1019d5
14 changed files with 42 additions and 42 deletions

View File

@ -4102,7 +4102,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
gfx3DMatrix result;
// Call IsSVGTransformed() regardless of the value of
// disp->mSpecifiedTransform, since we still need any transformFromSVGParent.
gfxMatrix svgTransform, transformFromSVGParent;
mozilla::gfx::Matrix svgTransform, transformFromSVGParent;
bool hasSVGTransforms =
frame && frame->IsSVGTransformed(&svgTransform, &transformFromSVGParent);
/* Transformed frames always have a transform, or are preserving 3d (and might still have perspective!) */
@ -4115,18 +4115,18 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(const FrameTransformProp
// Correct the translation components for zoom:
float pixelsPerCSSPx = frame->PresContext()->AppUnitsPerCSSPixel() /
aAppUnitsPerPixel;
svgTransform.x0 *= pixelsPerCSSPx;
svgTransform.y0 *= pixelsPerCSSPx;
result = gfx3DMatrix::From2D(svgTransform);
svgTransform._31 *= pixelsPerCSSPx;
svgTransform._32 *= pixelsPerCSSPx;
result = gfx3DMatrix::From2D(ThebesMatrix(svgTransform));
}
if (hasSVGTransforms && !transformFromSVGParent.IsIdentity()) {
// Correct the translation components for zoom:
float pixelsPerCSSPx = frame->PresContext()->AppUnitsPerCSSPixel() /
aAppUnitsPerPixel;
transformFromSVGParent.x0 *= pixelsPerCSSPx;
transformFromSVGParent.y0 *= pixelsPerCSSPx;
result = result * gfx3DMatrix::From2D(transformFromSVGParent);
transformFromSVGParent._31 *= pixelsPerCSSPx;
transformFromSVGParent._32 *= pixelsPerCSSPx;
result = result * gfx3DMatrix::From2D(ThebesMatrix(transformFromSVGParent));
}
if (aProperties.mChildPerspective > 0.0) {

View File

@ -1026,8 +1026,8 @@ nsIFrame::HasOpacity() const
}
bool
nsIFrame::IsSVGTransformed(gfxMatrix *aOwnTransforms,
gfxMatrix *aFromParentTransforms) const
nsIFrame::IsSVGTransformed(gfx::Matrix *aOwnTransforms,
gfx::Matrix *aFromParentTransforms) const
{
return false;
}

View File

@ -1337,8 +1337,8 @@ public:
* is non-null and the frame has an SVG parent with children-only transforms,
* then aFromParentTransforms will be set to these transforms.
*/
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransforms = nullptr,
gfxMatrix *aFromParentTransforms = nullptr) const;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransforms = nullptr,
mozilla::gfx::Matrix *aFromParentTransforms = nullptr) const;
/**
* Returns whether this frame will attempt to preserve the 3d transforms of its

View File

@ -220,8 +220,8 @@ nsSVGDisplayContainerFrame::RemoveFrame(ChildListID aListID,
}
bool
nsSVGDisplayContainerFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
gfxMatrix *aFromParentTransform) const
nsSVGDisplayContainerFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
gfx::Matrix *aFromParentTransform) const
{
bool foundTransform = false;
@ -240,8 +240,8 @@ nsSVGDisplayContainerFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent);
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
}
foundTransform = true;
}

View File

@ -69,7 +69,7 @@ public:
* due to a root-<svg> having its currentScale/currentTransform properties
* set. If aTransform is non-null, then it will be set to the transform.
*/
virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const {
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const {
return false;
}
@ -142,8 +142,8 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform = nullptr,
gfxMatrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform = nullptr,
mozilla::gfx::Matrix *aFromParentTransform = nullptr) const MOZ_OVERRIDE;
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsRenderingContext* aContext,

View File

@ -165,8 +165,8 @@ nsSVGForeignObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
bool
nsSVGForeignObjectFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
gfxMatrix *aFromParentTransform) const
nsSVGForeignObjectFrame::IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const
{
bool foundTransform = false;
@ -184,8 +184,8 @@ nsSVGForeignObjectFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent);
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
}
foundTransform = true;
}

View File

@ -65,8 +65,8 @@ public:
~(nsIFrame::eSVG | nsIFrame::eSVGForeignObject));
}
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform,
gfxMatrix *aFromParentTransform) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE

View File

@ -293,14 +293,14 @@ nsSVGInnerSVGFrame::GetCanvasTM(uint32_t aFor, nsIFrame* aTransformRoot)
}
bool
nsSVGInnerSVGFrame::HasChildrenOnlyTransform(gfxMatrix *aTransform) const
nsSVGInnerSVGFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
{
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
if (content->HasViewBoxOrSyntheticViewBox()) {
// XXX Maybe return false if the transform is the identity transform?
if (aTransform) {
*aTransform = content->GetViewBoxTransform();
*aTransform = gfx::ToMatrix(content->GetViewBoxTransform());
}
return true;
}

View File

@ -65,7 +65,7 @@ public:
virtual gfxMatrix GetCanvasTM(uint32_t aFor,
nsIFrame* aTransformRoot = nullptr) MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
// nsISVGSVGFrame interface:
virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) MOZ_OVERRIDE;

View File

@ -932,7 +932,7 @@ nsSVGOuterSVGAnonChildFrame::GetType() const
}
bool
nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfxMatrix *aTransform) const
nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfx::Matrix *aTransform) const
{
// We must claim our nsSVGOuterSVGFrame's children-only transforms as our own
// so that the children we are used to wrap are transformed properly.
@ -944,9 +944,9 @@ nsSVGOuterSVGAnonChildFrame::HasChildrenOnlyTransform(gfxMatrix *aTransform) con
if (hasTransform && aTransform) {
// Outer-<svg> doesn't use x/y, so we can pass eChildToUserSpace here.
gfxMatrix identity;
*aTransform =
*aTransform = gfx::ToMatrix(
content->PrependLocalTransformsTo(identity,
nsSVGElement::eChildToUserSpace);
nsSVGElement::eChildToUserSpace));
}
return hasTransform;

View File

@ -98,8 +98,8 @@ public:
return GetFirstPrincipalChild()->GetContentInsertionFrame();
}
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransform,
gfxMatrix *aFromParentTransform) const MOZ_OVERRIDE {
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransform,
mozilla::gfx::Matrix *aFromParentTransform) const MOZ_OVERRIDE {
// Our anonymous wrapper performs the transforms. We simply
// return whether we are transformed here but don't apply the transforms
// themselves.
@ -133,7 +133,7 @@ public:
void RegisterForeignObject(nsSVGForeignObjectFrame* aFrame);
void UnregisterForeignObject(nsSVGForeignObjectFrame* aFrame);
virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const MOZ_OVERRIDE {
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE {
// Our anonymous wrapper child must claim our children-only transforms as
// its own so that our real children (the frames it wraps) are transformed
// by them, and we must pretend we don't have any children-only transforms
@ -271,7 +271,7 @@ public:
return static_cast<nsSVGOuterSVGFrame*>(mParent)->GetCanvasTM(aFor, aTransformRoot);
}
virtual bool HasChildrenOnlyTransform(gfxMatrix *aTransform) const MOZ_OVERRIDE;
virtual bool HasChildrenOnlyTransform(mozilla::gfx::Matrix *aTransform) const MOZ_OVERRIDE;
};
#endif

View File

@ -144,8 +144,8 @@ nsSVGPathGeometryFrame::GetType() const
}
bool
nsSVGPathGeometryFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
gfxMatrix *aFromParentTransform) const
nsSVGPathGeometryFrame::IsSVGTransformed(gfx::Matrix *aOwnTransform,
gfx::Matrix *aFromParentTransform) const
{
bool foundTransform = false;
@ -163,8 +163,8 @@ nsSVGPathGeometryFrame::IsSVGTransformed(gfxMatrix *aOwnTransform,
if ((transformList && transformList->HasTransform()) ||
content->GetAnimateMotionTransform()) {
if (aOwnTransform) {
*aOwnTransform = content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent);
*aOwnTransform = gfx::ToMatrix(content->PrependLocalTransformsTo(gfxMatrix(),
nsSVGElement::eUserSpaceToParent));
}
foundTransform = true;
}

View File

@ -66,8 +66,8 @@ public:
*/
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(gfxMatrix *aOwnTransforms = nullptr,
gfxMatrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
virtual bool IsSVGTransformed(mozilla::gfx::Matrix *aOwnTransforms = nullptr,
mozilla::gfx::Matrix *aFromParentTransforms = nullptr) const MOZ_OVERRIDE;
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE

View File

@ -763,11 +763,11 @@ nsSVGUtils::PaintFrameWithEffects(nsRenderingContext *aContext,
int32_t appUnitsPerDevPx = aFrame->PresContext()->AppUnitsPerDevPixel();
gfxMatrix tm = GetCanvasTM(aFrame, nsISVGChildFrame::FOR_PAINTING, aTransformRoot);
if (aFrame->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer)) {
gfxMatrix childrenOnlyTM;
gfx::Matrix childrenOnlyTM;
if (static_cast<nsSVGContainerFrame*>(aFrame)->
HasChildrenOnlyTransform(&childrenOnlyTM)) {
// Undo the children-only transform:
tm = childrenOnlyTM.Invert() * tm;
tm = ThebesMatrix(childrenOnlyTM).Invert() * tm;
}
}
nsIntRect bounds = TransformFrameRectToOuterSVG(overflowRect,