Bug 1338393 - Part 1. Remove nsSVGFilterInstance::mUserSpaceBounds.
mUserSpaceBounds is not used at all. Remove it and all calculation relative to
it.
MozReview-Commit-ID: 7vJmZP4jC5F
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -51,74 +51,19 @@ nsSVGFilterInstance::nsSVGFilterInstance
if (!mFilterElement) {
NS_NOTREACHED("filter frame should have a related element");
return;
}
mPrimitiveUnits =
mFilterFrame->GetEnumValue(SVGFilterElement::PRIMITIVEUNITS);
- nsresult rv = ComputeBounds();
- if (NS_FAILED(rv)) {
- return;
- }
-
mInitialized = true;
}
-nsresult
-nsSVGFilterInstance::ComputeBounds()
-{
- // XXX if filterUnits is set (or has defaulted) to objectBoundingBox, we
- // should send a warning to the error console if the author has used lengths
- // with units. This is a common mistake and can result in the filter region
- // being *massive* below (because we ignore the units and interpret the number
- // as a factor of the bbox width/height). We should also send a warning if the
- // user uses a number without units (a future SVG spec should really
- // deprecate that, since it's too confusing for a bare number to be sometimes
- // interpreted as a fraction of the bounding box and sometimes as user-space
- // units). So really only percentage values should be used in this case.
-
- // Set the user space bounds (i.e. the filter region in user space).
- nsSVGLength2 XYWH[4];
- static_assert(sizeof(mFilterElement->mLengthAttributes) == sizeof(XYWH),
- "XYWH size incorrect");
- memcpy(XYWH, mFilterElement->mLengthAttributes,
- sizeof(mFilterElement->mLengthAttributes));
- XYWH[0] = *mFilterFrame->GetLengthValue(SVGFilterElement::ATTR_X);
- XYWH[1] = *mFilterFrame->GetLengthValue(SVGFilterElement::ATTR_Y);
- XYWH[2] = *mFilterFrame->GetLengthValue(SVGFilterElement::ATTR_WIDTH);
- XYWH[3] = *mFilterFrame->GetLengthValue(SVGFilterElement::ATTR_HEIGHT);
- uint16_t filterUnits =
- mFilterFrame->GetEnumValue(SVGFilterElement::FILTERUNITS);
- gfxRect userSpaceBounds = nsSVGUtils::GetRelativeRect(filterUnits,
- XYWH, mTargetBBox, mMetrics);
-
- // Transform the user space bounds to filter space, so we
- // can align them with the pixel boundries of the offscreen surface.
- // The offscreen surface has the same scale as filter space.
- gfxRect filterSpaceBounds = UserSpaceToFilterSpace(userSpaceBounds);
- filterSpaceBounds.RoundOut();
- if (filterSpaceBounds.width <= 0 || filterSpaceBounds.height <= 0) {
- // 0 disables rendering, < 0 is error. dispatch error console warning
- // or error as appropriate.
- return NS_ERROR_FAILURE;
- }
-
- // Set the filter space bounds.
- if (!gfxUtils::GfxRectToIntRect(filterSpaceBounds, &mFilterSpaceBounds)) {
- // The filter region is way too big if there is float -> int overflow.
- return NS_ERROR_FAILURE;
- }
-
- mUserSpaceBounds = FilterSpaceToUserSpace(filterSpaceBounds);
-
- return NS_OK;
-}
-
nsSVGFilterFrame*
nsSVGFilterInstance::GetFilterFrame(nsIFrame* aTargetFrame)
{
if (mFilter.GetType() != NS_STYLE_FILTER_URL) {
// The filter is not an SVG reference filter.
return nullptr;
}
--- a/layout/svg/nsSVGFilterInstance.h
+++ b/layout/svg/nsSVGFilterInstance.h
@@ -106,24 +106,16 @@ public:
* element in aPrimitiveDescrs, or the SourceGraphic input if this is the first
* filter in the filter chain.
*/
nsresult BuildPrimitives(nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
nsTArray<RefPtr<SourceSurface>>& aInputImages,
bool aInputIsTainted);
/**
- * Returns the user specified "filter region", in the filtered element's user
- * space, after it has been adjusted out (if necessary) so that its edges
- * coincide with pixel boundaries of the offscreen surface into which the
- * filtered output would/will be painted.
- */
- gfxRect GetFilterRegion() const { return mUserSpaceBounds; }
-
- /**
* Returns the size of the user specified "filter region", in filter space.
*/
nsIntRect GetFilterSpaceBounds() const { return mFilterSpaceBounds; }
float GetPrimitiveNumber(uint8_t aCtxType, const nsSVGNumber2 *aNumber) const
{
return GetPrimitiveNumber(aCtxType, aNumber->GetAnimValue());
}
@@ -203,22 +195,16 @@ private:
* FilterPrimitiveDescription representing "another-primitive".
*/
nsresult GetSourceIndices(nsSVGFE* aPrimitiveElement,
nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
const nsDataHashtable<nsStringHashKey, int32_t>& aImageTable,
nsTArray<int32_t>& aSourceIndices);
/**
- * Compute the filter region in user space, filter space, and filter
- * space.
- */
- nsresult ComputeBounds();
-
- /**
* The SVG reference filter originally from the style system.
*/
const nsStyleFilter& mFilter;
/**
* The filtered element.
*/
nsIContent* mTargetContent;
@@ -241,17 +227,16 @@ private:
/**
* The SVG bbox of the element that is being filtered, in user space.
*/
gfxRect mTargetBBox;
/**
* The "filter region" in various spaces.
*/
- gfxRect mUserSpaceBounds;
nsIntRect mFilterSpaceBounds;
/**
* The scale factors between user space and filter space.
*/
gfxSize mUserSpaceToFilterSpaceScale;
gfxSize mFilterSpaceToUserSpaceScale;