diff --git a/content/svg/content/src/nsSVGForeignObjectElement.cpp b/content/svg/content/src/nsSVGForeignObjectElement.cpp index ca1b1f04695..2ecd373dc3f 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.cpp +++ b/content/svg/content/src/nsSVGForeignObjectElement.cpp @@ -101,6 +101,21 @@ NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aH return mLengthAttributes[HEIGHT].ToDOMAnimatedLength(aHeight, this); } +//---------------------------------------------------------------------- +// nsSVGElement methods + +/* virtual */ gfxMatrix +nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) +{ + // 'transform' attribute: + gfxMatrix matrix = nsSVGForeignObjectElementBase::PrependLocalTransformTo(aMatrix); + + // now translate by our 'x' and 'y': + float x, y; + GetAnimatedLengthValues(&x, &y, nsnull); + return gfxMatrix().Translate(gfxPoint(x, y)) * matrix; +} + //---------------------------------------------------------------------- // nsIContent methods diff --git a/content/svg/content/src/nsSVGForeignObjectElement.h b/content/svg/content/src/nsSVGForeignObjectElement.h index 6b8058e0ef8..4ba5c357774 100644 --- a/content/svg/content/src/nsSVGForeignObjectElement.h +++ b/content/svg/content/src/nsSVGForeignObjectElement.h @@ -66,6 +66,9 @@ public: NS_FORWARD_NSIDOMELEMENT(nsSVGForeignObjectElementBase::) NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::) + // nsSVGElement specializations: + virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix); + // nsIContent interface NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* name) const; diff --git a/content/svg/content/src/nsSVGMarkerElement.cpp b/content/svg/content/src/nsSVGMarkerElement.cpp index 2551754c474..9ef51066766 100644 --- a/content/svg/content/src/nsSVGMarkerElement.cpp +++ b/content/svg/content/src/nsSVGMarkerElement.cpp @@ -428,11 +428,12 @@ nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval) mPreserveAspectRatio, PR_TRUE); NS_ENSURE_TRUE(vb2vp, NS_ERROR_OUT_OF_MEMORY); - nsSVGUtils::TransformPoint(vb2vp, &refX, &refY); + gfxPoint ref = nsSVGUtils::ConvertSVGMatrixToThebes(vb2vp). + Transform(gfxPoint(refX, refY)); nsCOMPtr translate; NS_NewSVGMatrix(getter_AddRefs(translate), - 1.0f, 0.0f, 0.0f, 1.0f, -refX, -refY); + 1.0f, 0.0f, 0.0f, 1.0f, -ref.x, -ref.y); NS_ENSURE_TRUE(translate, NS_ERROR_OUT_OF_MEMORY); translate->Multiply(vb2vp, getter_AddRefs(mViewBoxToViewportTransform)); } diff --git a/gfx/thebes/public/gfxRect.h b/gfx/thebes/public/gfxRect.h index a2ab11b49c6..c024211aa5b 100644 --- a/gfx/thebes/public/gfxRect.h +++ b/gfx/thebes/public/gfxRect.h @@ -94,6 +94,7 @@ struct THEBES_API gfxRect { gfxRect Intersect(const gfxRect& aRect) const; gfxRect Union(const gfxRect& aRect) const; PRBool Contains(const gfxRect& aRect) const; + PRBool Contains(const gfxPoint& aPoint) const; // XXX figure out what methods (intersect, union, etc) we use and add them. gfxPoint TopLeft() { return pos; } diff --git a/gfx/thebes/src/gfxRect.cpp b/gfx/thebes/src/gfxRect.cpp index eda6f42948f..89b19659c8b 100644 --- a/gfx/thebes/src/gfxRect.cpp +++ b/gfx/thebes/src/gfxRect.cpp @@ -80,6 +80,13 @@ gfxRect::Contains(const gfxRect& aRect) const aRect.Y() >= Y() && aRect.YMost() <= YMost(); } +PRBool +gfxRect::Contains(const gfxPoint& aPoint) const +{ + return aPoint.x >= X() && aPoint.x <= XMost() && + aPoint.y >= Y() && aPoint.y <= YMost(); +} + void gfxRect::Round() { diff --git a/layout/svg/base/src/nsSVGFilterPaintCallback.h b/layout/svg/base/src/nsSVGFilterPaintCallback.h index 2ebb7b9e519..91e72a0ad93 100644 --- a/layout/svg/base/src/nsSVGFilterPaintCallback.h +++ b/layout/svg/base/src/nsSVGFilterPaintCallback.h @@ -40,7 +40,6 @@ #include "nsRect.h" class nsIFrame; -class nsIDOMSVGMatrix; class nsSVGRenderState; class nsSVGFilterPaintCallback { diff --git a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp index 6007a8606ca..4346d4d1d3c 100644 --- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp +++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp @@ -39,7 +39,6 @@ #include "nsSVGForeignObjectFrame.h" #include "nsIDOMSVGForeignObjectElem.h" -#include "nsIDOMSVGMatrix.h" #include "nsIDOMSVGSVGElement.h" #include "nsSVGOuterSVGFrame.h" #include "nsRegion.h" @@ -123,9 +122,8 @@ nsSVGForeignObjectFrame::AttributeChanged(PRInt32 aNameSpaceID, // XXXjwatt: why mark intrinsic widths dirty? can't we just use eResize? RequestReflow(nsIPresShell::eStyleChange); } else if (aAttribute == nsGkAtoms::x || - aAttribute == nsGkAtoms::y) { - UpdateGraphic(); - } else if (aAttribute == nsGkAtoms::transform) { + aAttribute == nsGkAtoms::y || + aAttribute == nsGkAtoms::transform) { // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nsnull; UpdateGraphic(); @@ -153,11 +151,10 @@ nsSVGForeignObjectFrame::Reflow(nsPresContext* aPresContext, DoReflow(); - // XXX why don't we convert from CSS pixels to app units? How does this work? aDesiredSize.width = aReflowState.ComputedWidth(); aDesiredSize.height = aReflowState.ComputedHeight(); aDesiredSize.mOverflowArea = - nsRect(nsPoint(0, 0), nsSize(aDesiredSize.width, aDesiredSize.height)); + nsRect(0, 0, aReflowState.ComputedWidth(), aReflowState.ComputedHeight()); aStatus = NS_FRAME_COMPLETE; return NS_OK; @@ -169,6 +166,8 @@ nsSVGForeignObjectFrame::InvalidateInternal(const nsRect& aDamageRect, nsIFrame* aForChild, PRUint32 aFlags) { + // This is called by our descendants when they change. + if (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD) return; @@ -179,47 +178,19 @@ nsSVGForeignObjectFrame::InvalidateInternal(const nsRect& aDamageRect, } -//---------------------------------------------------------------------- -// nsISVGChildFrame methods - /** - * Gets the rectangular region in app units (rounded out device pixels) - * that encloses the rectangle after it has been transformed by aMatrix. - * Useful in UpdateCoveredRegion/FlushDirtyRegion. + * Returns the app unit canvas bounds of a userspace rect. + * + * @param aToCanvas Transform from userspace to canvas device space. */ static nsRect -GetTransformedRegion(float aX, float aY, float aWidth, float aHeight, - nsIDOMSVGMatrix* aMatrix, nsPresContext *aPresContext) +ToCanvasBounds(const gfxRect &aUserspaceRect, + const gfxMatrix &aToCanvas, + const nsPresContext *presContext) { - float x[4], y[4]; - x[0] = aX; - y[0] = aY; - x[1] = aX + aWidth; - y[1] = aY; - x[2] = aX + aWidth; - y[2] = aY + aHeight; - x[3] = aX; - y[3] = aY + aHeight; - - for (int i = 0; i < 4; i++) { - nsSVGUtils::TransformPoint(aMatrix, &x[i], &y[i]); - } - - float xmin, xmax, ymin, ymax; - xmin = xmax = x[0]; - ymin = ymax = y[0]; - for (int i = 1; i < 4; i++) { - if (x[i] < xmin) - xmin = x[i]; - else if (x[i] > xmax) - xmax = x[i]; - if (y[i] < ymin) - ymin = y[i]; - else if (y[i] > ymax) - ymax = y[i]; - } - - return nsSVGUtils::ToAppPixelRect(aPresContext, xmin, ymin, xmax, ymax); + return nsLayoutUtils::RoundGfxRectToAppRect( + aToCanvas.TransformBounds(aUserspaceRect), + presContext->AppUnitsPerDevPixel()); } NS_IMETHODIMP @@ -233,9 +204,7 @@ nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext, if (!kid) return NS_OK; - nsCOMPtr tm = GetUnZoomedTMIncludingOffset(); - - gfxMatrix matrix = nsSVGUtils::ConvertSVGMatrixToThebes(tm); + gfxMatrix matrix = GetCanvasTMForChildren(); nsIRenderingContext *ctx = aContext->GetRenderingContext(this); @@ -246,13 +215,8 @@ nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext, /* Check if we need to draw anything. */ if (aDirtyRect) { - gfxRect extent = matrix.TransformBounds( - gfxRect(kid->GetRect().x, kid->GetRect().y, - kid->GetRect().width, kid->GetRect().height)); - extent.RoundOut(); - nsIntRect rect; - if (NS_SUCCEEDED(nsSVGUtils::GfxRectToIntRect(extent, &rect)) && - !aDirtyRect->Intersects(rect)) + PRInt32 appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel(); + if (!mRect.ToOutsidePixels(appUnitsPerDevPx).Intersects(*aDirtyRect)) return NS_OK; } @@ -265,10 +229,9 @@ nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext, static_cast(mContent)-> GetAnimatedLengthValues(&x, &y, &width, &height, nsnull); - nsCOMPtr ctm = NS_NewSVGMatrix(GetCanvasTM()); gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(gfx, ctm, clipRect); + nsSVGUtils::GetClipRectForFrame(this, 0.0f, 0.0f, width, height); + nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect); } gfx->Multiply(matrix); @@ -281,28 +244,6 @@ nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext, return rv; } -nsresult -nsSVGForeignObjectFrame::TransformPointFromOuterPx(const nsPoint &aIn, - nsPoint* aOut) -{ - if (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD) - return NS_ERROR_FAILURE; - - nsCOMPtr tm = GetUnZoomedTMIncludingOffset(); - - nsCOMPtr inverse; - nsresult rv = tm->Inverse(getter_AddRefs(inverse)); - if (NS_FAILED(rv)) - return rv; - - float x = PresContext()->AppUnitsToDevPixels(aIn.x); - float y = PresContext()->AppUnitsToDevPixels(aIn.y); - nsSVGUtils::TransformPoint(inverse, &x, &y); - *aOut = nsPoint(PresContext()->DevPixelsToAppUnits(NSToIntRound(x)), - PresContext()->DevPixelsToAppUnits(NSToIntRound(y))); - return NS_OK; -} - gfxMatrix nsSVGForeignObjectFrame::GetTransformMatrix(nsIFrame **aOutAncestor) { @@ -313,33 +254,41 @@ nsSVGForeignObjectFrame::GetTransformMatrix(nsIFrame **aOutAncestor) NS_ASSERTION(*aOutAncestor, "How did we end up without an outer frame?"); /* Return the matrix back to the root, factoring in the x and y offsets. */ - nsCOMPtr tm = GetUnZoomedTMIncludingOffset(); - - return nsSVGUtils::ConvertSVGMatrixToThebes(tm); + return GetCanvasTMForChildren(); } NS_IMETHODIMP_(nsIFrame*) nsSVGForeignObjectFrame::GetFrameForPoint(const nsPoint &aPoint) { - if (IsDisabled()) - return NS_OK; + if (IsDisabled() || (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) + return nsnull; nsIFrame* kid = GetFirstChild(nsnull); - if (!kid) { + if (!kid) return nsnull; - } - nsPoint pt; - if (NS_FAILED(TransformPointFromOuterPx(aPoint, &pt))) - return nsnull; - return nsLayoutUtils::GetFrameForPoint(kid, pt); -} -nsPoint -nsSVGForeignObjectFrame::TransformPointFromOuter(nsPoint aPt) -{ - nsPoint pt(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); - TransformPointFromOuterPx(aPt, &pt); - return pt; + float x, y, width, height; + static_cast(mContent)-> + GetAnimatedLengthValues(&x, &y, &width, &height, nsnull); + + gfxMatrix tm = GetCanvasTM().Invert(); + if (tm.IsSingular()) + return nsnull; + + // Convert aPoint from app units in canvas space to user space: + + gfxPoint pt = gfxPoint(aPoint.x, aPoint.y) / PresContext()->AppUnitsPerDevPixel(); + pt = tm.Transform(pt); + + if (!gfxRect(0.0f, 0.0f, width, height).Contains(pt)) + return nsnull; + + // Convert pt to app units in *local* space: + + pt = pt * nsPresContext::AppUnitsPerCSSPixel(); + nsPoint point = nsPoint(NSToIntRound(pt.x), NSToIntRound(pt.y)); + + return nsLayoutUtils::GetFrameForPoint(kid, point); } NS_IMETHODIMP_(nsRect) @@ -354,10 +303,6 @@ nsSVGForeignObjectFrame::UpdateCoveredRegion() if (GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD) return NS_ERROR_FAILURE; - nsCOMPtr ctm = NS_NewSVGMatrix(GetCanvasTM()); - if (!ctm) - return NS_ERROR_FAILURE; - float x, y, w, h; static_cast(mContent)-> GetAnimatedLengthValues(&x, &y, &w, &h, nsnull); @@ -366,8 +311,9 @@ nsSVGForeignObjectFrame::UpdateCoveredRegion() if (w < 0.0f) w = 0.0f; if (h < 0.0f) h = 0.0f; - mRect = GetTransformedRegion(x, y, w, h, ctm, PresContext()); - + // GetCanvasTM includes the x,y translation + mRect = ToCanvasBounds(gfxRect(0.0, 0.0, w, h), GetCanvasTM(), PresContext()); + return NS_OK; } @@ -495,7 +441,7 @@ nsSVGForeignObjectFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace) // XXX ReportToConsole return gfxRect(0.0, 0.0, 0.0, 0.0); } - return aToBBoxUserspace.TransformBounds(gfxRect(x, y, w, h)); + return aToBBoxUserspace.TransformBounds(gfxRect(0.0, 0.0, w, h)); } //---------------------------------------------------------------------- @@ -520,32 +466,13 @@ nsSVGForeignObjectFrame::GetCanvasTM() //---------------------------------------------------------------------- // Implementation helpers -already_AddRefed -nsSVGForeignObjectFrame::GetUnZoomedTMIncludingOffset() +gfxMatrix +nsSVGForeignObjectFrame::GetCanvasTMForChildren() { - nsCOMPtr ctm = NS_NewSVGMatrix(GetCanvasTM()); - if (!ctm) - return nsnull; + float cssPxPerDevPx = PresContext()-> + AppUnitsToFloatCSSPixels(PresContext()->AppUnitsPerDevPixel()); - nsSVGForeignObjectElement *fO = - static_cast(mContent); - float x, y; - fO->GetAnimatedLengthValues(&x, &y, nsnull); - nsCOMPtr localTM; - ctm->Translate(x, y, getter_AddRefs(localTM)); - - float cssPxPerDevPx = - PresContext()->AppUnitsToFloatCSSPixels( - PresContext()->AppUnitsPerDevPixel()); - nsCOMPtr cssPxToDevPxMatrix; - NS_NewSVGMatrix(getter_AddRefs(cssPxToDevPxMatrix), - cssPxPerDevPx, 0.0f, - 0.0f, cssPxPerDevPx); - - // POST-multiply px conversion! - nsIDOMSVGMatrix* matrix; - localTM->Multiply(cssPxToDevPxMatrix, &matrix); - return matrix; + return GetCanvasTM().Scale(cssPxPerDevPx, cssPxPerDevPx); } void nsSVGForeignObjectFrame::RequestReflow(nsIPresShell::IntrinsicDirty aType) @@ -574,12 +501,13 @@ void nsSVGForeignObjectFrame::UpdateGraphic() void nsSVGForeignObjectFrame::MaybeReflowFromOuterSVGFrame() { - // If we're already scheduled to reflow (i.e. our kid is dirty) we don't + nsIFrame* kid = GetFirstChild(nsnull); + + // If we're already scheduled to reflow (if we or our kid is dirty) we don't // want to reflow now or else our presShell will do extra work trying to // reflow us a second time. (It will also complain if it finds that a reflow // root scheduled for reflow isn't dirty). - nsIFrame* kid = GetFirstChild(nsnull); if (kid->GetStateBits() & NS_FRAME_IS_DIRTY) { return; } @@ -671,22 +599,15 @@ nsSVGForeignObjectFrame::InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter, if (aRect.IsEmpty()) return; - nsPresContext* presContext = PresContext(); - nsCOMPtr ctm = NS_NewSVGMatrix(GetCanvasTM()); + // The areas dirtied by children are in app units, relative to this frame. + // We need to convert the rect to userspace to use IntersectRect. - nsSVGForeignObjectElement *fO = - static_cast(mContent); - float x, y; - fO->GetAnimatedLengthValues(&x, &y, nsnull); - nsCOMPtr localTM; - ctm->Translate(x, y, getter_AddRefs(localTM)); + gfxRect r(aRect.x, aRect.y, aRect.width, aRect.height); + r.Scale(1.0 / nsPresContext::AppUnitsPerCSSPixel()); - nsIntRect r = aRect.ToOutsidePixels(presContext->AppUnitsPerDevPixel()); - nsRect rect = GetTransformedRegion(r.x, r.y, r.width, r.height, - localTM, presContext); + nsRect rect = ToCanvasBounds(r, GetCanvasTM(), PresContext()); - // Some or all of the areas invalidated by our descendants' - // InvalidateInternal() calls may be outside mRect. + // Don't invalidate areas outside our bounds: rect.IntersectRect(rect, mRect); if (rect.IsEmpty()) return; diff --git a/layout/svg/base/src/nsSVGForeignObjectFrame.h b/layout/svg/base/src/nsSVGForeignObjectFrame.h index 33157909859..288ff8e38aa 100644 --- a/layout/svg/base/src/nsSVGForeignObjectFrame.h +++ b/layout/svg/base/src/nsSVGForeignObjectFrame.h @@ -133,13 +133,6 @@ public: NS_IMETHOD_(PRBool) IsDisplayContainer() { return PR_TRUE; } NS_IMETHOD_(PRBool) HasValidCoveredRect() { return PR_TRUE; } - // foreignobject public methods - /** - * @param aPt a point in the app unit coordinate system of the SVG outer frame - * Transforms the point to a point in this frame's app unit coordinate system - */ - nsPoint TransformPointFromOuter(nsPoint aPt); - gfxMatrix GetCanvasTM(); // This method allows our nsSVGOuterSVGFrame to reflow us as necessary. @@ -150,8 +143,10 @@ protected: void DoReflow(); void RequestReflow(nsIPresShell::IntrinsicDirty aType); void UpdateGraphic(); - already_AddRefed GetUnZoomedTMIncludingOffset(); - nsresult TransformPointFromOuterPx(const nsPoint &aIn, nsPoint* aOut); + + // Returns GetCanvasTM followed by a scale from CSS px to Dev px. Used for + // painting, because children expect to paint to device space, not userspace. + gfxMatrix GetCanvasTMForChildren(); void InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter, const nsRect& aRect, PRUint32 aFlags); void FlushDirtyRegion(); diff --git a/layout/svg/base/src/nsSVGImageFrame.cpp b/layout/svg/base/src/nsSVGImageFrame.cpp index bd3164ecf49..e52fc0661c6 100644 --- a/layout/svg/base/src/nsSVGImageFrame.cpp +++ b/layout/svg/base/src/nsSVGImageFrame.cpp @@ -263,13 +263,9 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, if (GetStyleDisplay()->IsScrollableOverflow()) { gfx->Save(); - nsCOMPtr ctm = NS_NewSVGMatrix(GetCanvasTM()); - - if (ctm) { - gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(gfx, ctm, clipRect); - } + gfxRect clipRect = + nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); + nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect); } nsCOMPtr fini = GetImageTransform(); diff --git a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index d54d364c22e..ad3cb3ed3b0 100644 --- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -97,21 +97,14 @@ nsSVGInnerSVGFrame::PaintSVG(nsSVGRenderState *aContext, return NS_OK; } - nsCOMPtr clipTransform; - if (!GetMatrixPropagation()) { - NS_NewSVGMatrix(getter_AddRefs(clipTransform)); - } else { - nsSVGContainerFrame *parent = static_cast(mParent); - clipTransform = NS_NewSVGMatrix(parent->GetCanvasTM()); - } + nsSVGContainerFrame *parent = static_cast(mParent); + gfxMatrix clipTransform = parent->GetCanvasTM(); - if (clipTransform) { - gfxContext *gfx = aContext->GetGfxContext(); - autoSR.SetContext(gfx); - gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(gfx, clipTransform, clipRect); - } + gfxContext *gfx = aContext->GetGfxContext(); + autoSR.SetContext(gfx); + gfxRect clipRect = + nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); + nsSVGUtils::SetClipRect(gfx, clipTransform, clipRect); } return nsSVGInnerSVGFrameBase::PaintSVG(aContext, aDirtyRect); diff --git a/layout/svg/base/src/nsSVGMarkerFrame.cpp b/layout/svg/base/src/nsSVGMarkerFrame.cpp index dbe9f2f23cc..ec8b91a2fea 100644 --- a/layout/svg/base/src/nsSVGMarkerFrame.cpp +++ b/layout/svg/base/src/nsSVGMarkerFrame.cpp @@ -170,13 +170,10 @@ nsSVGMarkerFrame::PaintMark(nsSVGRenderState *aContext, gfxContext *gfx = aContext->GetGfxContext(); if (GetStyleDisplay()->IsScrollableOverflow()) { - nsCOMPtr matrix = NS_NewSVGMatrix(GetCanvasTM()); - NS_ENSURE_TRUE(matrix, NS_ERROR_OUT_OF_MEMORY); - gfx->Save(); gfxRect clipRect = nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(gfx, matrix, clipRect); + nsSVGUtils::SetClipRect(gfx, GetCanvasTM(), clipRect); } for (nsIFrame* kid = mFrames.FirstChild(); kid; diff --git a/layout/svg/base/src/nsSVGMaskFrame.cpp b/layout/svg/base/src/nsSVGMaskFrame.cpp index 2af5f88b192..ba4dc843f7c 100644 --- a/layout/svg/base/src/nsSVGMaskFrame.cpp +++ b/layout/svg/base/src/nsSVGMaskFrame.cpp @@ -84,7 +84,7 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext, &mask->mLengthAttributes[nsSVGMaskElement::X], bbox, aParent); gfx->Save(); - nsSVGUtils::SetClipRect(gfx, aMatrix, maskArea); + nsSVGUtils::SetClipRect(gfx, nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix), maskArea); } mMaskParent = aParent; diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 7d1790160af..285c8182202 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -582,7 +582,6 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext, // odd document is probably no worse than printing horribly for all // documents. Better to fix things so we don't need fallback. nsIFrame* frame = this; - nsPresContext* presContext = PresContext(); PRUint32 flags = 0; while (PR_TRUE) { nsIFrame* next = nsLayoutUtils::GetCrossDocParentFrame(frame); diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 5b9d4b7beb0..6ed5f60348f 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -51,7 +51,6 @@ #include "nsIPresShell.h" #include "nsISVGGlyphFragmentLeaf.h" #include "nsNetUtil.h" -#include "nsIDOMSVGRect.h" #include "nsFrameList.h" #include "nsISVGChildFrame.h" #include "nsContentDLF.h" @@ -81,7 +80,6 @@ #include "nsSVGForeignObjectFrame.h" #include "nsIFontMetrics.h" #include "nsIDOMSVGUnitTypes.h" -#include "nsSVGRect.h" #include "nsSVGEffects.h" #include "nsSVGIntegrationUtils.h" #include "nsSVGFilterPaintCallback.h" @@ -673,24 +671,6 @@ nsSVGUtils::UserSpace(nsIFrame *aNonSVGContext, const nsSVGLength2 *aLength) return aLength->GetAnimValue(aNonSVGContext); } -void -nsSVGUtils::TransformPoint(nsIDOMSVGMatrix *matrix, - float *x, float *y) -{ - nsCOMPtr point; - NS_NewSVGPoint(getter_AddRefs(point), *x, *y); - if (!point) - return; - - nsCOMPtr xfpoint; - point->MatrixTransform(matrix, getter_AddRefs(xfpoint)); - if (!xfpoint) - return; - - xfpoint->GetX(x); - xfpoint->GetY(y); -} - float nsSVGUtils::AngleBisect(float a1, float a2) { @@ -1291,7 +1271,7 @@ nsSVGUtils::CompositePatternMatrix(gfxContext *aContext, aContext->Save(); - SetClipRect(aContext, aCTM, gfxRect(0, 0, aWidth, aHeight)); + SetClipRect(aContext, ConvertSVGMatrixToThebes(aCTM), gfxRect(0, 0, aWidth, aHeight)); aContext->Multiply(matrix); @@ -1303,15 +1283,14 @@ nsSVGUtils::CompositePatternMatrix(gfxContext *aContext, void nsSVGUtils::SetClipRect(gfxContext *aContext, - nsIDOMSVGMatrix *aCTM, + const gfxMatrix &aCTM, const gfxRect &aRect) { - gfxMatrix matrix = ConvertSVGMatrixToThebes(aCTM); - if (matrix.IsSingular()) + if (aCTM.IsSingular()) return; gfxMatrix oldMatrix = aContext->CurrentMatrix(); - aContext->Multiply(matrix); + aContext->Multiply(aCTM); aContext->Clip(aRect); aContext->SetMatrix(oldMatrix); } diff --git a/layout/svg/base/src/nsSVGUtils.h b/layout/svg/base/src/nsSVGUtils.h index 941b4453967..8d82e1df213 100644 --- a/layout/svg/base/src/nsSVGUtils.h +++ b/layout/svg/base/src/nsSVGUtils.h @@ -53,7 +53,6 @@ class nsIDocument; class nsPresContext; class nsIContent; class nsStyleCoord; -class nsIDOMSVGRect; class nsFrameList; class nsIFrame; struct nsStyleSVGPaint; @@ -73,7 +72,6 @@ class gfxContext; class gfxASurface; class gfxPattern; class gfxImageSurface; -struct gfxMatrix; struct gfxSize; struct gfxIntSize; struct nsStyleFont; @@ -323,11 +321,6 @@ public: */ static float UserSpace(nsIFrame *aFrame, const nsSVGLength2 *aLength); - /* Tranforms point by the matrix. In/out: x,y */ - static void - TransformPoint(nsIDOMSVGMatrix *matrix, - float *x, float *y); - /* Returns the angle halfway between the two specified angles */ static float AngleBisect(float a1, float a2); @@ -451,7 +444,7 @@ public: nsIDOMSVGMatrix *aCTM, float aWidth, float aHeight, float aOpacity); static void SetClipRect(gfxContext *aContext, - nsIDOMSVGMatrix *aCTM, + const gfxMatrix &aCTM, const gfxRect &aRect); /**