Bug 298283 - fix overflow property for inner <svg>, implement for
<image> and <marker>. r=jwatt, a=asa. git-svn-id: svn://10.0.0.236/trunk@175543 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -333,6 +333,8 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectT
|
||||
}
|
||||
}
|
||||
|
||||
canvas->PushClip();
|
||||
|
||||
/* check for a clip path */
|
||||
nsIURI *aURI;
|
||||
nsSVGClipPathFrame *clip = NULL;
|
||||
@@ -343,7 +345,6 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectT
|
||||
if (clip) {
|
||||
nsCOMPtr<nsIDOMSVGMatrix> matrix;
|
||||
GetCanvasTM(getter_AddRefs(matrix));
|
||||
canvas->PushClip();
|
||||
clip->ClipPaint(canvas, this, matrix);
|
||||
}
|
||||
}
|
||||
@@ -352,9 +353,15 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectT
|
||||
nsCOMPtr<nsIDOMSVGMatrix> ctm;
|
||||
GetCanvasTM(getter_AddRefs(ctm));
|
||||
|
||||
float width, height;
|
||||
float x, y, width, height;
|
||||
mX->GetValue(&x);
|
||||
mY->GetValue(&y);
|
||||
mWidth->GetValue(&width);
|
||||
mHeight->GetValue(&height);
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow())
|
||||
canvas->SetClipRect(ctm, x, y, width, height);
|
||||
|
||||
PRUint32 nativeWidth, nativeHeight;
|
||||
mSurface->GetWidth(&nativeWidth);
|
||||
mSurface->GetHeight(&nativeHeight);
|
||||
@@ -429,9 +436,6 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectT
|
||||
else NS_NOTREACHED("Unknown value for meetOrSlice");
|
||||
}
|
||||
|
||||
float x, y;
|
||||
mX->GetValue(&x);
|
||||
mY->GetValue(&y);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> trans;
|
||||
ctm->Translate(x + e, y + f, getter_AddRefs(trans));
|
||||
|
||||
@@ -443,8 +447,7 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRectT
|
||||
mStyleContext->GetStyleDisplay()->mOpacity);
|
||||
}
|
||||
|
||||
if (clip)
|
||||
canvas->PopClip();
|
||||
canvas->PopClip();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -360,23 +360,32 @@ nsSVGInnerSVGFrame::PaintSVG(nsISVGRendererCanvas* canvas, const nsRect& dirtyRe
|
||||
canvas->PushClip();
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
nsCOMPtr<nsIDOMSVGRect> vb;
|
||||
nsCOMPtr<nsIDOMSVGAnimatedRect> viewBox;
|
||||
nsCOMPtr<nsIDOMSVGFitToViewBox> svgElement = do_QueryInterface(mContent);
|
||||
nsCOMPtr<nsIDOMSVGAnimatedLength> anim;
|
||||
nsCOMPtr<nsIDOMSVGLength> val;
|
||||
nsCOMPtr<nsISVGSVGElement> svg = do_QueryInterface(mContent);
|
||||
|
||||
if (svgElement)
|
||||
svgElement->GetViewBox(getter_AddRefs(viewBox));
|
||||
if (viewBox)
|
||||
viewBox->GetAnimVal(getter_AddRefs(vb));
|
||||
if (vb) {
|
||||
float x, y, width, height;
|
||||
vb->GetX(&x);
|
||||
vb->GetY(&y);
|
||||
vb->GetWidth(&width);
|
||||
vb->GetHeight(&height);
|
||||
nsCOMPtr<nsIDOMSVGMatrix> ctm = GetCanvasTM();
|
||||
canvas->SetClipRect(ctm, x, y, width, height);
|
||||
float x, y, width, height;
|
||||
mX->GetValue(&x);
|
||||
mY->GetValue(&y);
|
||||
svg->GetWidth(getter_AddRefs(anim));
|
||||
anim->GetAnimVal(getter_AddRefs(val));
|
||||
val->GetValue(&width);
|
||||
svg->GetHeight(getter_AddRefs(anim));
|
||||
anim->GetAnimVal(getter_AddRefs(val));
|
||||
val->GetValue(&height);
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> clipTransform;
|
||||
if (!mPropagateTransform) {
|
||||
NS_NewSVGMatrix(getter_AddRefs(clipTransform));
|
||||
} else {
|
||||
nsISVGContainerFrame *parent;
|
||||
CallQueryInterface(mParent, &parent);
|
||||
if (parent)
|
||||
clipTransform = parent->GetCanvasTM();
|
||||
}
|
||||
|
||||
if (clipTransform)
|
||||
canvas->SetClipRect(clipTransform, x, y, width, height);
|
||||
}
|
||||
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsSVGMarkerFrame.h"
|
||||
#include "nsSVGPathGeometryFrame.h"
|
||||
#include "nsISVGRendererCanvas.h"
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsSVGMarkerFrame::AddRef()
|
||||
@@ -335,6 +336,38 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
|
||||
mAngle = aMark->angle;
|
||||
mMarkerParent = aParent;
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow()) {
|
||||
aCanvas->PushClip();
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMatrix> parentTransform, markerTransform, clipTransform;
|
||||
nsCOMPtr<nsIDOMSVGMatrix> viewTransform;
|
||||
|
||||
nsISVGGeometrySource *parent;
|
||||
CallQueryInterface(mMarkerParent, &parent);
|
||||
if (parent)
|
||||
parent->GetCanvasTM(getter_AddRefs(parentTransform));
|
||||
|
||||
nsCOMPtr<nsIDOMSVGMarkerElement> element = do_QueryInterface(mContent);
|
||||
element->GetMarkerTransform(mStrokeWidth, mX, mY, mAngle,
|
||||
getter_AddRefs(markerTransform));
|
||||
|
||||
element->GetViewboxToViewportTransform(getter_AddRefs(viewTransform));
|
||||
|
||||
if (parentTransform && markerTransform)
|
||||
parentTransform->Multiply(markerTransform,
|
||||
getter_AddRefs(clipTransform));
|
||||
|
||||
if (clipTransform && viewTransform) {
|
||||
float x, y, width, height;
|
||||
|
||||
viewTransform->GetE(&x);
|
||||
viewTransform->GetF(&y);
|
||||
mMarkerWidth->GetValue(&width);
|
||||
mMarkerHeight->GetValue(&height);
|
||||
aCanvas->SetClipRect(clipTransform, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
nsRect dirtyRectTwips;
|
||||
for (nsIFrame* kid = mFrames.FirstChild(); kid;
|
||||
kid = kid->GetNextSibling()) {
|
||||
@@ -345,6 +378,10 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
|
||||
SVGFrame->PaintSVG(aCanvas, dirtyRectTwips);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetStyleDisplay()->IsScrollableOverflow())
|
||||
aCanvas->PopClip();
|
||||
|
||||
mMarkerParent = nsnull;
|
||||
mInUse = PR_FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user