Bug 1339728 - Part 2. Change return value type of nsSVGFilterInstance::ComputeBounds.
MozReview-Commit-ID: 6rvcQGJiaW6
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -49,24 +49,24 @@ nsSVGFilterInstance::nsSVGFilterInstance
if (!mFilterElement) {
NS_NOTREACHED("filter frame should have a related element");
return;
}
mPrimitiveUnits =
mFilterFrame->GetEnumValue(SVGFilterElement::PRIMITIVEUNITS);
- if (NS_FAILED(ComputeBounds())) {
+ if (!ComputeBounds()) {
return;
}
mInitialized = true;
}
-nsresult
+bool
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
@@ -74,44 +74,44 @@ nsSVGFilterInstance::ComputeBounds()
// 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));
+ 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);
+ 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;
+ return false;
}
// 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;
+ return false;
}
- return NS_OK;
+ return true;
}
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
@@ -187,17 +187,17 @@ private:
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();
+ bool ComputeBounds();
/**
* The SVG reference filter originally from the style system.
*/
const nsStyleFilter& mFilter;
/**
* The filtered element.