зеркало из https://github.com/mozilla/pjs.git
Bug 498275. Stop using nsIDOMSVGMatrix in nsSVGForeignObjectFrame + fixes. r=longsonr
This commit is contained in:
Родитель
9186b2660d
Коммит
b760f912f1
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<nsIDOMSVGMatrix> 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));
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "nsRect.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIDOMSVGMatrix;
|
||||
class nsSVGRenderState;
|
||||
|
||||
class nsSVGFilterPaintCallback {
|
||||
|
|
|
@ -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<nsIDOMSVGMatrix> 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<nsSVGElement*>(mContent)->
|
||||
GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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<nsIDOMSVGMatrix> tm = GetUnZoomedTMIncludingOffset();
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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<nsIDOMSVGMatrix> 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<nsSVGElement*>(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<nsIDOMSVGMatrix> ctm = NS_NewSVGMatrix(GetCanvasTM());
|
||||
if (!ctm)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
float x, y, w, h;
|
||||
static_cast<nsSVGForeignObjectElement*>(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<nsIDOMSVGMatrix>
|
||||
nsSVGForeignObjectFrame::GetUnZoomedTMIncludingOffset()
|
||||
gfxMatrix
|
||||
nsSVGForeignObjectFrame::GetCanvasTMForChildren()
|
||||
{
|
||||
nsCOMPtr<nsIDOMSVGMatrix> ctm = NS_NewSVGMatrix(GetCanvasTM());
|
||||
if (!ctm)
|
||||
return nsnull;
|
||||
float cssPxPerDevPx = PresContext()->
|
||||
AppUnitsToFloatCSSPixels(PresContext()->AppUnitsPerDevPixel());
|
||||
|
||||
nsSVGForeignObjectElement *fO =
|
||||
static_cast<nsSVGForeignObjectElement*>(mContent);
|
||||
float x, y;
|
||||
fO->GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> localTM;
|
||||
ctm->Translate(x, y, getter_AddRefs(localTM));
|
||||
|
||||
float cssPxPerDevPx =
|
||||
PresContext()->AppUnitsToFloatCSSPixels(
|
||||
PresContext()->AppUnitsPerDevPixel());
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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<nsIDOMSVGMatrix> 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<nsSVGForeignObjectElement*>(mContent);
|
||||
float x, y;
|
||||
fO->GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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;
|
||||
|
|
|
@ -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<nsIDOMSVGMatrix> 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();
|
||||
|
|
|
@ -263,13 +263,9 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
gfx->Save();
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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<nsIDOMSVGMatrix> fini = GetImageTransform();
|
||||
|
|
|
@ -97,21 +97,14 @@ nsSVGInnerSVGFrame::PaintSVG(nsSVGRenderState *aContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> clipTransform;
|
||||
if (!GetMatrixPropagation()) {
|
||||
NS_NewSVGMatrix(getter_AddRefs(clipTransform));
|
||||
} else {
|
||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(mParent);
|
||||
clipTransform = NS_NewSVGMatrix(parent->GetCanvasTM());
|
||||
}
|
||||
nsSVGContainerFrame *parent = static_cast<nsSVGContainerFrame*>(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);
|
||||
|
|
|
@ -170,13 +170,10 @@ nsSVGMarkerFrame::PaintMark(nsSVGRenderState *aContext,
|
|||
gfxContext *gfx = aContext->GetGfxContext();
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
nsCOMPtr<nsIDOMSVGMatrix> 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nsIDOMSVGPoint> point;
|
||||
NS_NewSVGPoint(getter_AddRefs(point), *x, *y);
|
||||
if (!point)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDOMSVGPoint> 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче