Bug 355844 - fix marker positioning and clipping when viewBox specified.

r=amenzie, sr=roc
This commit is contained in:
tor%cs.brown.edu 2006-10-19 23:51:41 +00:00
Родитель c87d2fa60b
Коммит 1cc51ad5c4
2 изменённых файлов: 28 добавлений и 27 удалений

Просмотреть файл

@ -424,12 +424,20 @@ nsSVGMarkerElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval)
float refY =
mLengthAttributes[REFY].GetAnimValue(mCoordCtx);
mViewBoxToViewportTransform =
nsCOMPtr<nsIDOMSVGMatrix> vb2vp =
nsSVGUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
viewboxX + refX, viewboxY + refY,
viewboxX, viewboxY,
viewboxWidth, viewboxHeight,
mPreserveAspectRatio,
PR_TRUE);
NS_ENSURE_TRUE(vb2vp, NS_ERROR_OUT_OF_MEMORY);
nsSVGUtils::TransformPoint(vb2vp, &refX, &refY);
nsCOMPtr<nsIDOMSVGMatrix> translate;
NS_NewSVGMatrix(getter_AddRefs(translate),
1.0f, 0.0f, 0.0f, 1.0f, -refX, -refY);
NS_ENSURE_TRUE(translate, NS_ERROR_OUT_OF_MEMORY);
translate->Multiply(vb2vp, getter_AddRefs(mViewBoxToViewportTransform));
}
*_retval = mViewBoxToViewportTransform;

Просмотреть файл

@ -234,32 +234,25 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
marker->SetParentCoordCtxProvider(ctx);
if (GetStyleDisplay()->IsScrollableOverflow()) {
nsCOMPtr<nsIDOMSVGAnimatedRect> arect;
nsresult rv = marker->GetViewBox(getter_AddRefs(arect));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMSVGRect> rect;
rv = arect->GetAnimVal(getter_AddRefs(rect));
NS_ENSURE_SUCCESS(rv, rv);
float x, y, width, height;
rect->GetX(&x);
rect->GetY(&y);
rect->GetWidth(&width);
rect->GetHeight(&height);
nsCOMPtr<nsIDOMSVGMatrix> matrix = GetCanvasTM();
NS_ENSURE_TRUE(matrix, NS_ERROR_OUT_OF_MEMORY);
aCanvas->PushClip();
nsCOMPtr<nsIDOMSVGMatrix> parentTransform, markerTransform, clipTransform;
nsCOMPtr<nsIDOMSVGMatrix> viewTransform;
mMarkerParent->GetCanvasTM(getter_AddRefs(parentTransform));
nsSVGMarkerElement *element = NS_STATIC_CAST(nsSVGMarkerElement*, 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);
width = marker->mLengthAttributes[nsSVGMarkerElement::MARKERWIDTH].GetAnimValue(ctx);
height = marker->mLengthAttributes[nsSVGMarkerElement::MARKERHEIGHT].GetAnimValue(ctx);
aCanvas->SetClipRect(clipTransform, x, y, width, height);
}
aCanvas->SetClipRect(matrix, x, y, width, height);
}
for (nsIFrame* kid = mFrames.FirstChild(); kid;