Bug 538266. Part 3: move nsSVGUtils::GfxRectToIntRect to nsLayoutUtils. r=mats

This commit is contained in:
Robert O'Callahan 2010-03-02 12:08:28 +13:00
Родитель 0b71a67c4e
Коммит 4b4c15dbc9
7 изменённых файлов: 24 добавлений и 24 удалений

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

@ -175,7 +175,7 @@ nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance,
r.Scale(scaledSize.width/aTarget->mImage->Width(),
scaledSize.height/aTarget->mImage->Height());
r.RoundOut();
if (NS_FAILED(nsSVGUtils::GfxRectToIntRect(r, &result.mDataRect)))
if (NS_FAILED(nsLayoutUtils::GfxRectToIntRect(r, &result.mDataRect)))
return result;
#ifdef DEBUG_tor
@ -2908,7 +2908,7 @@ nsSVGFETileElement::Filter(nsSVGFilterInstance *instance,
// but nothing clips mFilterPrimitiveSubregion so this should be changed.
nsIntRect tile;
nsresult res = nsSVGUtils::GfxRectToIntRect(aSources[0]->mFilterPrimitiveSubregion, &tile);
nsresult res = nsLayoutUtils::GfxRectToIntRect(aSources[0]->mFilterPrimitiveSubregion, &tile);
NS_ENSURE_SUCCESS(res, res); // asserts on failure (not
if (tile.IsEmpty())

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

@ -892,6 +892,15 @@ nsLayoutUtils::InvertTransformsToRoot(nsIFrame *aFrame,
return MatrixTransformPoint(aPoint, ctm.Invert(), aFrame->PresContext()->AppUnitsPerDevPixel());
}
nsresult
nsLayoutUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
{
*aOut = nsIntRect(PRInt32(aIn.X()), PRInt32(aIn.Y()),
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height) == aIn
? NS_OK : NS_ERROR_FAILURE;
}
static nsIntPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
nsIntPoint offset(0, 0);
nsIWidget* parent = aWidget->GetParent();

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

@ -474,6 +474,12 @@ public:
*/
static nsRect RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor);
/**
* If aIn can be represented exactly using an nsIntRect (i.e.
* integer-aligned edges and coordinates in the PRInt32 range) then we
* set aOut to that rectangle, otherwise return failure.
*/
static nsresult GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
enum {
PAINT_IN_TRANSFORM = 0x01,

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

@ -67,7 +67,7 @@ MapDeviceRectToFilterSpace(const gfxMatrix& aMatrix,
aDeviceRect->width, aDeviceRect->height));
r.RoundOut();
nsIntRect intRect;
if (NS_SUCCEEDED(nsSVGUtils::GfxRectToIntRect(r, &intRect))) {
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(r, &intRect))) {
rect = intRect;
}
}
@ -236,7 +236,7 @@ TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRe
r = m.TransformBounds(r);
r.RoundOut();
nsIntRect deviceRect;
nsresult rv = nsSVGUtils::GfxRectToIntRect(r, &deviceRect);
nsresult rv = nsLayoutUtils::GfxRectToIntRect(r, &deviceRect);
if (NS_FAILED(rv))
return rv;
*aRect = deviceRect;

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

@ -40,6 +40,7 @@
#include "gfxPlatform.h"
#include "nsSVGFilterPaintCallback.h"
#include "nsSVGFilterElement.h"
#include "nsLayoutUtils.h"
static double Square(double aX)
{
@ -164,7 +165,7 @@ nsSVGFilterInstance::BuildSources()
gfxRect sourceBounds = UserSpaceToFilterSpace(mTargetBBox);
sourceBounds.RoundOut();
// Detect possible float->int overflow
if (NS_FAILED(nsSVGUtils::GfxRectToIntRect(sourceBounds, &sourceBoundsInt)))
if (NS_FAILED(nsLayoutUtils::GfxRectToIntRect(sourceBounds, &sourceBoundsInt)))
return NS_ERROR_FAILURE;
mSourceColorAlpha.mResultBoundingBox = sourceBoundsInt;
@ -355,7 +356,7 @@ nsSVGFilterInstance::BuildSourceImages()
r = m.TransformBounds(r);
r.RoundOut();
nsIntRect dirty;
nsresult rv = nsSVGUtils::GfxRectToIntRect(r, &dirty);
nsresult rv = nsLayoutUtils::GfxRectToIntRect(r, &dirty);
if (NS_FAILED(rv))
return rv;

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

@ -635,7 +635,7 @@ nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
TransformBounds(gfxRect(x, y, width, height));
bounds.RoundOut();
nsIntRect r;
if (NS_SUCCEEDED(nsSVGUtils::GfxRectToIntRect(bounds, &r))) {
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(bounds, &r))) {
rect = r;
} else {
NS_NOTREACHED("Not going to invalidate the correct area");
@ -953,7 +953,7 @@ public:
gfxRect dirtyBounds = userToDeviceSpace.TransformBounds(
gfxRect(aDirtyRect->x, aDirtyRect->y, aDirtyRect->width, aDirtyRect->height));
dirtyBounds.RoundOut();
if (NS_SUCCEEDED(nsSVGUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect))) {
if (NS_SUCCEEDED(nsLayoutUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect))) {
dirtyRect = &tmpDirtyRect;
}
}
@ -1347,15 +1347,6 @@ nsSVGUtils::ClipToGfxRect(nsIntRect* aRect, const gfxRect& aGfxRect)
PRInt32(r.Width()), PRInt32(r.Height()));
}
nsresult
nsSVGUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
{
*aOut = nsIntRect(PRInt32(aIn.X()), PRInt32(aIn.Y()),
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height) == aIn
? NS_OK : NS_ERROR_FAILURE;
}
gfxRect
nsSVGUtils::GetBBox(nsIFrame *aFrame)
{

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

@ -452,13 +452,6 @@ public:
const gfxMatrix &aCTM,
const gfxRect &aRect);
/**
* If aIn can be represented exactly using an nsIntRect (i.e. integer-aligned edges and
* coordinates in the PRInt32 range) then we set aOut to that rectangle, otherwise
* return failure.
*/
static nsresult GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut);
/**
* Restricts aRect to pixels that intersect aGfxRect.
*/