Bug 1110337 - Get bounds of image element using maths. r=jwatt

This commit is contained in:
Robert Longson 2015-01-21 13:09:45 +00:00
parent b92cad3917
commit 6383c920af
5 changed files with 23 additions and 5 deletions

View File

@ -90,8 +90,7 @@ SVGCircleElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
if (r <= 0.f) {
// Rendering of the element is disabled
aBounds->MoveTo(x, y);
aBounds->SetEmpty();
*aBounds = Rect(aTransform * Point(x, y), Size());
return true;
}

View File

@ -101,8 +101,7 @@ SVGEllipseElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
if (rx <= 0.f || ry <= 0.f) {
// Rendering of the element is disabled
aBounds->MoveTo(x, y);
aBounds->SetEmpty();
*aBounds = Rect(aTransform * Point(x, y), Size());
return true;
}

View File

@ -226,6 +226,23 @@ SVGImageElement::IsAttributeMapped(const nsIAtom* name) const
/* For the purposes of the update/invalidation logic pretend to
be a rectangle. */
bool
SVGImageElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
const Matrix& aTransform)
{
Rect rect;
GetAnimatedLengthValues(&rect.x, &rect.y, &rect.width,
&rect.height, nullptr);
if (rect.IsEmpty()) {
// Rendering of the element disabled
rect.SetEmpty(); // Make sure width/height are zero and not negative
}
*aBounds = aTransform.TransformBounds(rect);
return true;
}
TemporaryRef<Path>
SVGImageElement::BuildPath(PathBuilder* aBuilder)
{

View File

@ -53,6 +53,8 @@ public:
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE;
// nsSVGPathGeometryElement methods:
virtual bool GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
const Matrix& aTransform) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder) MOZ_OVERRIDE;
// nsSVGSVGElement methods:

View File

@ -122,7 +122,8 @@ SVGRectElement::GetGeometryBounds(Rect* aBounds, Float aStrokeWidth,
if (rect.IsEmpty()) {
// Rendering of the element disabled
rect.SetEmpty(); // Make sure width/height are zero and not negative
*aBounds = rect; // We still want the x/y position from 'rect'
// We still want the x/y position from 'rect'
*aBounds = aTransform.TransformBounds(rect);
return true;
}