Bug 377085 - line svg element getBBox() returns bad rect. r+sr=tor,a1.9=blocking1.9+
--- a/gfx/thebes/public/gfxContext.h
+++ b/gfx/thebes/public/gfxContext.h
@@ -533,16 +533,17 @@ public:
** Hit Testing - check if given point is in the current path
**/
PRBool PointInFill(const gfxPoint& pt);
PRBool PointInStroke(const gfxPoint& pt);
/**
** Extents - returns user space extent of current path
**/
+ gfxRect GetUserPathExtent();
gfxRect GetUserFillExtent();
gfxRect GetUserStrokeExtent();
/**
** Obtaining a "flattened" path - path converted to all line segments
**/
already_AddRefed<gfxFlattenedPath> GetFlattenedPath();
--- a/gfx/thebes/src/gfxContext.cpp
+++ b/gfx/thebes/src/gfxContext.cpp
@@ -736,16 +736,24 @@ gfxContext::PointInFill(const gfxPoint&
PRBool
gfxContext::PointInStroke(const gfxPoint& pt)
{
return cairo_in_stroke(mCairo, pt.x, pt.y);
}
gfxRect
+gfxContext::GetUserPathExtent()
+{
+ double xmin, ymin, xmax, ymax;
+ cairo_path_extents(mCairo, &xmin, &ymin, &xmax, &ymax);
+ return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
+}
+
+gfxRect
gfxContext::GetUserFillExtent()
{
double xmin, ymin, xmax, ymax;
cairo_fill_extents(mCairo, &xmin, &ymin, &xmax, &ymax);
return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin);
}
gfxRect
--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
+++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
@@ -445,17 +445,17 @@ nsSVGGlyphFrame::UpdateCoveredRegion()
gfxRect extent;
if (hasStroke) {
SetupCairoStrokeGeometry(gfx);
extent = gfx->GetUserStrokeExtent();
extent = gfx->UserToDevice(extent);
} else {
gfx->IdentityMatrix();
- extent = gfx->GetUserFillExtent();
+ extent = gfx->GetUserPathExtent();
}
mRect = nsSVGUtils::ToBoundingPixelRect(extent);
return NS_OK;
}
NS_IMETHODIMP
@@ -515,17 +515,17 @@ nsSVGGlyphFrame::GetBBox(nsIDOMSVGRect *
if (!gfx)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = GetGlobalTransform(gfx);
NS_ENSURE_SUCCESS(rv, rv);
LoopCharacters(gfx, text, cp, STROKE);
gfx->IdentityMatrix();
- gfxRect rect = gfx->GetUserFillExtent();
+ gfxRect rect = gfx->GetUserPathExtent();
return NS_NewSVGRect(_retval, rect);
}
//----------------------------------------------------------------------
// nsSVGGeometryFrame methods:
/* readonly attribute nsIDOMSVGMatrix canvasTM; */
@@ -884,17 +884,17 @@ nsSVGGlyphFrame::GetExtentOfChar(PRUint3
gfx->MoveTo(cp[charnum].pos);
gfx->Rotate(cp[charnum].angle);
gfx->Rectangle(metrics.mBoundingBox + gfx->CurrentPoint());
gfx->IdentityMatrix();
- gfxRect rect = gfx->GetUserFillExtent();
+ gfxRect rect = gfx->GetUserPathExtent();
gfx->SetMatrix(matrix);
return NS_NewSVGRect(_retval, rect);
}
gfxPoint pt = mPosition;
--- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
@@ -435,17 +435,17 @@ nsSVGPathGeometryFrame::UpdateCoveredReg
SetupCairoStrokeGeometry(&context);
extent = context.GetUserStrokeExtent();
if (!IsDegeneratePath(extent)) {
extent = context.UserToDevice(extent);
mRect = nsSVGUtils::ToBoundingPixelRect(extent);
}
} else {
context.IdentityMatrix();
- extent = context.GetUserFillExtent();
+ extent = context.GetUserPathExtent();
if (!IsDegeneratePath(extent)) {
mRect = nsSVGUtils::ToBoundingPixelRect(extent);
}
}
// Add in markers
mRect = GetCoveredRegion();
@@ -517,24 +517,17 @@ nsSVGPathGeometryFrame::GetOverrideCTM()
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetBBox(nsIDOMSVGRect **_retval)
{
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context);
context.IdentityMatrix();
- gfxRect extent = context.GetUserFillExtent();
-
- if (IsDegeneratePath(extent)) {
- context.SetLineWidth(0);
- extent = context.GetUserStrokeExtent();
- }
-
- return NS_NewSVGRect(_retval, extent);
+ return NS_NewSVGRect(_retval, context.GetUserPathExtent());
}
//----------------------------------------------------------------------
// nsSVGGeometryFrame methods:
/* readonly attribute nsIDOMSVGMatrix canvasTM; */
NS_IMETHODIMP
nsSVGPathGeometryFrame::GetCanvasTM(nsIDOMSVGMatrix * *aCTM)