Bug 460946 - getBoundingClientRect on rotated svgElement with stroke is incorrect. r+sr=roc

This commit is contained in:
Robert Longson 2008-11-03 10:04:25 +00:00
Родитель 61e59e1ed3
Коммит 6599f35796
3 изменённых файлов: 26 добавлений и 27 удалений

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

@ -425,25 +425,31 @@ MakeTmpCtx() {
NS_IMETHODIMP
nsSVGGlyphFrame::UpdateCoveredRegion()
{
mRect.Empty();
nsRefPtr<gfxContext> tmpCtx = MakeTmpCtx();
SetupGlobalTransform(tmpCtx);
CharacterIterator iter(this, PR_TRUE);
iter.SetInitialMatrix(tmpCtx);
gfxRect extent;
if (SetupCairoStrokeGeometry(tmpCtx)) {
AddCharactersToPath(&iter, tmpCtx);
extent = tmpCtx->UserToDevice(tmpCtx->GetUserStrokeExtent());
extent = tmpCtx->GetUserStrokeExtent();
} else if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None) {
AddBoundingBoxesToPath(&iter, tmpCtx);
tmpCtx->IdentityMatrix();
extent = tmpCtx->GetUserPathExtent();
} else {
extent = gfxRect(0, 0, 0, 0);
}
mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
if (!extent.IsEmpty()) {
gfxMatrix matrix;
GetGlobalTransform(&matrix);
extent = matrix.TransformBounds(extent);
mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
}
return NS_OK;
}

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

@ -253,22 +253,27 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context);
static_cast<nsSVGPathGeometryElement*>(mContent)->ConstructPath(&context);
gfxRect extent;
if (SetupCairoStrokeGeometry(&context)) {
extent = context.GetUserStrokeExtent();
if (!IsDegeneratePath(extent)) {
extent = context.UserToDevice(extent);
mRect = nsSVGUtils::ToAppPixelRect(PresContext(),extent);
}
} else {
context.IdentityMatrix();
} else if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None) {
extent = context.GetUserPathExtent();
if (!IsDegeneratePath(extent)) {
mRect = nsSVGUtils::ToAppPixelRect(PresContext(),extent);
}
} else {
extent = gfxRect(0, 0, 0, 0);
}
if (!extent.IsEmpty()) {
nsCOMPtr<nsIDOMSVGMatrix> ctm;
GetCanvasTM(getter_AddRefs(ctm));
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
gfxMatrix matrix = nsSVGUtils::ConvertSVGMatrixToThebes(ctm);
extent = matrix.TransformBounds(extent);
mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
}
// Add in markers

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

@ -123,18 +123,6 @@ private:
void Render(nsSVGRenderState *aContext);
void GeneratePath(gfxContext *aContext);
/*
* Check for what cairo returns for the fill extents of a degenerate path
*
* @return PR_TRUE if the path is degenerate
*/
static PRBool
IsDegeneratePath(const gfxRect& rect)
{
return (rect.X() == 0 && rect.Y() == 0 &&
rect.Width() == 0 && rect.Height() == 0);
}
struct MarkerProperties {
nsSVGMarkerProperty* mMarkerStart;
nsSVGMarkerProperty* mMarkerMid;