Bug 1339728 - Part 2. Change return value type of nsSVGFilterInstance::ComputeBounds. r=mstange
authorcku <cku@mozilla.com>
Tue, 14 Feb 2017 10:32:10 +0800
changeset 343166 30cd8908e5ffb8fb980bf1485cef330484c0453c
parent 343165 d5360d0cfeca42939288e55d5054e580be60365b
child 343167 2b147f3dcae89e547ce05bae480389eed1aa45f6
push id31371
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:15:11 +0000
treeherdermozilla-central@8c8b54b13be7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1339728
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339728 - Part 2. Change return value type of nsSVGFilterInstance::ComputeBounds. r=mstange MozReview-Commit-ID: 6rvcQGJiaW6
layout/svg/nsSVGFilterInstance.cpp
layout/svg/nsSVGFilterInstance.h
--- 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.