Bug 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in image/*. r=aosmond
authorMilan Sreckovic <milan@mozilla.com>
Mon, 14 Aug 2017 08:29:56 -0400
changeset 374631 d093907b21addffff1273cbc4bae652e6994f2ed
parent 374630 2a8f664f107efeaa3be4dee08b3ac340df88892f
child 374632 1a5fb194a79cb848dbb50e0efbda46cd01566d96
push id93728
push userkwierso@gmail.com
push dateTue, 15 Aug 2017 00:58:32 +0000
treeherdermozilla-inbound@ec83c820877e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1387514
milestone57.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 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in image/*. r=aosmond MozReview-Commit-ID: 8gyxxLziVe7
image/ClippedImage.cpp
image/Decoder.cpp
image/Downscaler.cpp
image/Downscaler.h
image/FrameAnimator.cpp
image/OrientedImage.cpp
image/SurfaceFilters.h
image/SurfacePipe.cpp
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsPNGDecoder.cpp
image/imgFrame.cpp
image/test/gtest/Common.cpp
widget/IMEData.h
--- a/image/ClippedImage.cpp
+++ b/image/ClippedImage.cpp
@@ -214,50 +214,50 @@ NS_IMPL_ISUPPORTS_INHERITED0(ClippedImag
 
 NS_IMETHODIMP
 ClippedImage::GetWidth(int32_t* aWidth)
 {
   if (!ShouldClip()) {
     return InnerImage()->GetWidth(aWidth);
   }
 
-  *aWidth = mClip.width;
+  *aWidth = mClip.Width();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ClippedImage::GetHeight(int32_t* aHeight)
 {
   if (!ShouldClip()) {
     return InnerImage()->GetHeight(aHeight);
   }
 
-  *aHeight = mClip.height;
+  *aHeight = mClip.Height();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ClippedImage::GetIntrinsicSize(nsSize* aSize)
 {
   if (!ShouldClip()) {
     return InnerImage()->GetIntrinsicSize(aSize);
   }
 
-  *aSize = nsSize(mClip.width, mClip.height);
+  *aSize = nsSize(mClip.Width(), mClip.Height());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ClippedImage::GetIntrinsicRatio(nsSize* aRatio)
 {
   if (!ShouldClip()) {
     return InnerImage()->GetIntrinsicRatio(aRatio);
   }
 
-  *aRatio = nsSize(mClip.width, mClip.height);
+  *aRatio = nsSize(mClip.Width(), mClip.Height());
   return NS_OK;
 }
 
 NS_IMETHODIMP_(already_AddRefed<SourceSurface>)
 ClippedImage::GetFrame(uint32_t aWhichFrame,
                        uint32_t aFlags)
 {
   DrawResult result;
@@ -423,33 +423,33 @@ ClippedImage::DrawSingleTile(gfxContext*
                              SamplingFilter aSamplingFilter,
                              const Maybe<SVGImageContext>& aSVGContext,
                              uint32_t aFlags,
                              float aOpacity)
 {
   MOZ_ASSERT(!MustCreateSurface(aContext, aSize, aRegion, aFlags),
              "Shouldn't need to create a surface");
 
-  gfxRect clip(mClip.x, mClip.y, mClip.width, mClip.height);
+  gfxRect clip(mClip.x, mClip.y, mClip.Width(), mClip.Height());
   nsIntSize size(aSize), innerSize(aSize);
   bool needScale = false;
   if (mSVGViewportSize && !mSVGViewportSize->IsEmpty()) {
     innerSize = *mSVGViewportSize;
     needScale = true;
   } else if (NS_SUCCEEDED(InnerImage()->GetWidth(&innerSize.width)) &&
              NS_SUCCEEDED(InnerImage()->GetHeight(&innerSize.height))) {
     needScale = true;
   } else {
     MOZ_ASSERT_UNREACHABLE(
                "If ShouldClip() led us to draw then we should never get here");
   }
 
   if (needScale) {
-    double scaleX = aSize.width / clip.width;
-    double scaleY = aSize.height / clip.height;
+    double scaleX = aSize.width / clip.Width();
+    double scaleY = aSize.height / clip.Height();
 
     // Map the clip and size to the scale requested by the caller.
     clip.Scale(scaleX, scaleY);
     size = innerSize;
     size.Scale(scaleX, scaleY);
   }
 
   // We restrict our drawing to only the clipping region, and translate so that
@@ -467,19 +467,19 @@ ClippedImage::DrawSingleTile(gfxContext*
     // The size in pixels at which the output will ultimately be drawn is
     // irrelevant here since the purpose of the SVG viewport size is to
     // determine what *region* of the SVG document will be drawn.
     SVGImageContext context(aOldContext);
     auto oldViewport = aOldContext.GetViewportSize();
     if (oldViewport) {
       CSSIntSize newViewport;
       newViewport.width =
-        ceil(oldViewport->width * double(innerSize.width) / mClip.width);
+        ceil(oldViewport->width * double(innerSize.width) / mClip.Width());
       newViewport.height =
-        ceil(oldViewport->height * double(innerSize.height) / mClip.height);
+        ceil(oldViewport->height * double(innerSize.height) / mClip.Height());
       context.SetViewportSize(Some(newViewport));
     }
     return context;
   };
 
   return InnerImage()->Draw(aContext, size, region,
                             aWhichFrame, aSamplingFilter,
                             aSVGContext.map(unclipViewport),
@@ -528,18 +528,18 @@ ClippedImage::OptimalImageSizeForDest(co
   }
 
   if (needScale) {
     // To avoid ugly sampling artifacts, ClippedImage needs the image size to
     // be chosen such that the clipping region lies on pixel boundaries.
 
     // First, we select a scale that's good for ClippedImage. An integer
     // multiple of the size of the clipping region is always fine.
-    IntSize scale = IntSize::Ceil(aDest.width / mClip.width,
-                                  aDest.height / mClip.height);
+    IntSize scale = IntSize::Ceil(aDest.width / mClip.Width(),
+                                  aDest.height / mClip.Height());
 
     if (forceUniformScaling) {
       scale.width = scale.height = max(scale.height, scale.width);
     }
 
     // Determine the size we'd prefer to render the inner image at, and ask the
     // inner image what size we should actually use.
     gfxSize desiredSize(imgWidth * scale.width, imgHeight * scale.height);
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -322,17 +322,17 @@ Decoder::AllocateFrameInternal(uint32_t 
   }
 
   if (aFrameNum != mFrameCount) {
     MOZ_ASSERT_UNREACHABLE("Allocating frames out of order");
     return RawAccessFrameRef();
   }
 
   if (aOutputSize.width <= 0 || aOutputSize.height <= 0 ||
-      aFrameRect.width <= 0 || aFrameRect.height <= 0) {
+      aFrameRect.Width() <= 0 || aFrameRect.Height() <= 0) {
     NS_WARNING("Trying to add frame with zero or negative size");
     return RawAccessFrameRef();
   }
 
   NotNull<RefPtr<imgFrame>> frame = WrapNotNull(new imgFrame());
   bool nonPremult = bool(mSurfaceFlags & SurfaceFlags::NO_PREMULTIPLY_ALPHA);
   if (NS_FAILED(frame->InitForDecoder(aOutputSize, aFrameRect, aFormat,
                                       aPaletteDepth, nonPremult,
--- a/image/Downscaler.cpp
+++ b/image/Downscaler.cpp
@@ -74,17 +74,17 @@ Downscaler::BeginFrame(const nsIntSize& 
   // downscaling and decoding. 1 << 20 == 1,048,576 seems a reasonable limit.
   if (aOriginalSize.width > (1 << 20) || aOriginalSize.height > (1 << 20)) {
     NS_WARNING("Trying to downscale image frame that is too large");
     return NS_ERROR_INVALID_ARG;
   }
 
   mFrameRect = aFrameRect.valueOr(nsIntRect(nsIntPoint(), aOriginalSize));
   MOZ_ASSERT(mFrameRect.x >= 0 && mFrameRect.y >= 0 &&
-             mFrameRect.width >= 0 && mFrameRect.height >= 0,
+             mFrameRect.Width() >= 0 && mFrameRect.Height() >= 0,
              "Frame rect must have non-negative components");
   MOZ_ASSERT(nsIntRect(0, 0, aOriginalSize.width, aOriginalSize.height)
                .Contains(mFrameRect),
              "Frame rect must fit inside image");
   MOZ_ASSERT_IF(!nsIntRect(0, 0, aOriginalSize.width, aOriginalSize.height)
                   .IsEqualEdges(mFrameRect),
                 aHasAlpha);
 
@@ -214,17 +214,17 @@ Downscaler::CommitRow()
                                         &filterOffset, &filterLength);
     }
   }
 
   mCurrentInLine += 1;
 
   // If we're at the end of the part of the original image that has data, commit
   // rows to shift us to the end.
-  if (mCurrentInLine == (mFrameRect.y + mFrameRect.height)) {
+  if (mCurrentInLine == (mFrameRect.y + mFrameRect.Height())) {
     SkipToRow(mOriginalSize.height - 1);
   }
 }
 
 bool
 Downscaler::HasInvalidation() const
 {
   return mCurrentOutLine > mPrevInvalidatedLine;
--- a/image/Downscaler.h
+++ b/image/Downscaler.h
@@ -51,17 +51,17 @@ class Downscaler
 {
 public:
   /// Constructs a new Downscaler which to scale to size @aTargetSize.
   explicit Downscaler(const nsIntSize& aTargetSize);
   ~Downscaler();
 
   const nsIntSize& OriginalSize() const { return mOriginalSize; }
   const nsIntSize& TargetSize() const { return mTargetSize; }
-  const nsIntSize FrameSize() const { return nsIntSize(mFrameRect.width, mFrameRect.height); }
+  const nsIntSize FrameSize() const { return nsIntSize(mFrameRect.Width(), mFrameRect.Height()); }
   const gfxSize& Scale() const { return mScale; }
 
   /**
    * Begins a new frame and reinitializes the Downscaler.
    *
    * @param aOriginalSize The original size of this frame, before scaling.
    * @param aFrameRect The region of  the original image which has data.
    *                   Every pixel outside @aFrameRect is considered blank and
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -596,35 +596,35 @@ FrameAnimator::DoBlend(DrawableSurface& 
     prevFrameData.mDisposalMethod = DisposalMethod::CLEAR;
   }
 
   IntRect prevRect = prevFrameData.mBlendRect
                    ? prevFrameData.mRect.Intersect(*prevFrameData.mBlendRect)
                    : prevFrameData.mRect;
 
   bool isFullPrevFrame = prevRect.x == 0 && prevRect.y == 0 &&
-                         prevRect.width == mSize.width &&
-                         prevRect.height == mSize.height;
+                         prevRect.Width() == mSize.width &&
+                         prevRect.Height() == mSize.height;
 
   // Optimization: DisposeClearAll if the previous frame is the same size as
   //               container and it's clearing itself
   if (isFullPrevFrame &&
       (prevFrameData.mDisposalMethod == DisposalMethod::CLEAR)) {
     prevFrameData.mDisposalMethod = DisposalMethod::CLEAR_ALL;
   }
 
   AnimationData nextFrameData = nextFrame->GetAnimationData();
 
   IntRect nextRect = nextFrameData.mBlendRect
                    ? nextFrameData.mRect.Intersect(*nextFrameData.mBlendRect)
                    : nextFrameData.mRect;
 
   bool isFullNextFrame = nextRect.x == 0 && nextRect.y == 0 &&
-                         nextRect.width == mSize.width &&
-                         nextRect.height == mSize.height;
+                         nextRect.Width() == mSize.width &&
+                         nextRect.Height() == mSize.height;
 
   if (!nextFrame->GetIsPaletted()) {
     // Optimization: Skip compositing if the previous frame wants to clear the
     //               whole image
     if (prevFrameData.mDisposalMethod == DisposalMethod::CLEAR_ALL) {
       aDirtyRect->SetRect(0, 0, mSize.width, mSize.height);
       return true;
     }
@@ -713,18 +713,18 @@ FrameAnimator::DoBlend(DrawableSurface& 
     if (isFullNextFrame) {
       // Optimization: No need to dispose prev.frame when
       // next frame is full frame and not transparent.
       doDisposal = false;
       // No need to blank the composite frame
       needToBlankComposite = false;
     } else {
       if ((prevRect.x >= nextRect.x) && (prevRect.y >= nextRect.y) &&
-          (prevRect.x + prevRect.width <= nextRect.x + nextRect.width) &&
-          (prevRect.y + prevRect.height <= nextRect.y + nextRect.height)) {
+          (prevRect.XMost() <= nextRect.XMost()) &&
+          (prevRect.YMost() <= nextRect.YMost())) {
         // Optimization: No need to dispose prev.frame when
         // next frame fully overlaps previous frame.
         doDisposal = false;
       }
     }
   }
 
   if (doDisposal) {
@@ -867,52 +867,52 @@ FrameAnimator::DoBlend(DrawableSurface& 
 // Fill aFrame with black. Does also clears the mask.
 void
 FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect)
 {
   if (!aFrameData) {
     return;
   }
 
-  memset(aFrameData, 0, aFrameRect.width * aFrameRect.height * 4);
+  memset(aFrameData, 0, aFrameRect.Width() * aFrameRect.Height() * 4);
 }
 
 //******************************************************************************
 void
 FrameAnimator::ClearFrame(uint8_t* aFrameData, const IntRect& aFrameRect,
                           const IntRect& aRectToClear)
 {
-  if (!aFrameData || aFrameRect.width <= 0 || aFrameRect.height <= 0 ||
-      aRectToClear.width <= 0 || aRectToClear.height <= 0) {
+  if (!aFrameData || aFrameRect.Width() <= 0 || aFrameRect.Height() <= 0 ||
+      aRectToClear.Width() <= 0 || aRectToClear.Height() <= 0) {
     return;
   }
 
   IntRect toClear = aFrameRect.Intersect(aRectToClear);
   if (toClear.IsEmpty()) {
     return;
   }
 
-  uint32_t bytesPerRow = aFrameRect.width * 4;
-  for (int row = toClear.y; row < toClear.y + toClear.height; ++row) {
+  uint32_t bytesPerRow = aFrameRect.Width() * 4;
+  for (int row = toClear.y; row < toClear.YMost(); ++row) {
     memset(aFrameData + toClear.x * 4 + row * bytesPerRow, 0,
-           toClear.width * 4);
+           toClear.Width() * 4);
   }
 }
 
 //******************************************************************************
 // Whether we succeed or fail will not cause a crash, and there's not much
 // we can do about a failure, so there we don't return a nsresult
 bool
 FrameAnimator::CopyFrameImage(const uint8_t* aDataSrc,
                               const IntRect& aRectSrc,
                               uint8_t* aDataDest,
                               const IntRect& aRectDest)
 {
-  uint32_t dataLengthSrc = aRectSrc.width * aRectSrc.height * 4;
-  uint32_t dataLengthDest = aRectDest.width * aRectDest.height * 4;
+  uint32_t dataLengthSrc = aRectSrc.Width() * aRectSrc.Height() * 4;
+  uint32_t dataLengthDest = aRectDest.Width() * aRectDest.Height() * 4;
 
   if (!aDataDest || !aDataSrc || dataLengthSrc != dataLengthDest) {
     return false;
   }
 
   memcpy(aDataDest, aDataSrc, dataLengthDest);
 
   return true;
@@ -928,80 +928,80 @@ FrameAnimator::DrawFrameTo(const uint8_t
   NS_ENSURE_ARG_POINTER(aDstPixels);
 
   // According to both AGIF and APNG specs, offsets are unsigned
   if (aSrcRect.x < 0 || aSrcRect.y < 0) {
     NS_WARNING("FrameAnimator::DrawFrameTo: negative offsets not allowed");
     return NS_ERROR_FAILURE;
   }
   // Outside the destination frame, skip it
-  if ((aSrcRect.x > aDstRect.width) || (aSrcRect.y > aDstRect.height)) {
+  if ((aSrcRect.x > aDstRect.Width()) || (aSrcRect.y > aDstRect.Height())) {
     return NS_OK;
   }
 
   if (aSrcPaletteLength) {
     // Larger than the destination frame, clip it
-    int32_t width = std::min(aSrcRect.width, aDstRect.width - aSrcRect.x);
-    int32_t height = std::min(aSrcRect.height, aDstRect.height - aSrcRect.y);
+    int32_t width = std::min(aSrcRect.Width(), aDstRect.Width() - aSrcRect.x);
+    int32_t height = std::min(aSrcRect.Height(), aDstRect.Height() - aSrcRect.y);
 
     // The clipped image must now fully fit within destination image frame
     NS_ASSERTION((aSrcRect.x >= 0) && (aSrcRect.y >= 0) &&
-                 (aSrcRect.x + width <= aDstRect.width) &&
-                 (aSrcRect.y + height <= aDstRect.height),
+                 (aSrcRect.x + width <= aDstRect.Width()) &&
+                 (aSrcRect.y + height <= aDstRect.Height()),
                 "FrameAnimator::DrawFrameTo: Invalid aSrcRect");
 
     // clipped image size may be smaller than source, but not larger
-    NS_ASSERTION((width <= aSrcRect.width) && (height <= aSrcRect.height),
+    NS_ASSERTION((width <= aSrcRect.Width()) && (height <= aSrcRect.Height()),
       "FrameAnimator::DrawFrameTo: source must be smaller than dest");
 
     // Get pointers to image data
     const uint8_t* srcPixels = aSrcData + aSrcPaletteLength;
     uint32_t* dstPixels = reinterpret_cast<uint32_t*>(aDstPixels);
     const uint32_t* colormap = reinterpret_cast<const uint32_t*>(aSrcData);
 
     // Skip to the right offset
-    dstPixels += aSrcRect.x + (aSrcRect.y * aDstRect.width);
+    dstPixels += aSrcRect.x + (aSrcRect.y * aDstRect.Width());
     if (!aSrcHasAlpha) {
       for (int32_t r = height; r > 0; --r) {
         for (int32_t c = 0; c < width; c++) {
           dstPixels[c] = colormap[srcPixels[c]];
         }
         // Go to the next row in the source resp. destination image
-        srcPixels += aSrcRect.width;
-        dstPixels += aDstRect.width;
+        srcPixels += aSrcRect.Width();
+        dstPixels += aDstRect.Width();
       }
     } else {
       for (int32_t r = height; r > 0; --r) {
         for (int32_t c = 0; c < width; c++) {
           const uint32_t color = colormap[srcPixels[c]];
           if (color) {
             dstPixels[c] = color;
           }
         }
         // Go to the next row in the source resp. destination image
-        srcPixels += aSrcRect.width;
-        dstPixels += aDstRect.width;
+        srcPixels += aSrcRect.Width();
+        dstPixels += aDstRect.Width();
       }
     }
   } else {
     pixman_image_t* src =
       pixman_image_create_bits(
           aSrcHasAlpha ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
-          aSrcRect.width, aSrcRect.height,
+          aSrcRect.Width(), aSrcRect.Height(),
           reinterpret_cast<uint32_t*>(const_cast<uint8_t*>(aSrcData)),
-          aSrcRect.width * 4);
+          aSrcRect.Width() * 4);
     if (!src) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     pixman_image_t* dst =
       pixman_image_create_bits(PIXMAN_a8r8g8b8,
-                               aDstRect.width,
-                               aDstRect.height,
+                               aDstRect.Width(),
+                               aDstRect.Height(),
                                reinterpret_cast<uint32_t*>(aDstPixels),
-                               aDstRect.width * 4);
+                               aDstRect.Width() * 4);
     if (!dst) {
       pixman_image_unref(src);
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     // XXX(seth): This is inefficient but we'll remove it quite soon when we
     // move frame compositing into SurfacePipe. For now we need this because
     // RemoveFrameRectFilter has transformed PNG frames with frame rects into
@@ -1024,35 +1024,35 @@ FrameAnimator::DrawFrameTo(const uint8_t
       // rect was specified, we can't.)
       pixman_image_composite32(op,
                                src,
                                nullptr,
                                dst,
                                0, 0,
                                0, 0,
                                aSrcRect.x, aSrcRect.y,
-                               aSrcRect.width, aSrcRect.height);
+                               aSrcRect.Width(), aSrcRect.Height());
     } else {
       // We need to do the OVER followed by SOURCE trick above.
       pixman_image_composite32(PIXMAN_OP_OVER,
                                src,
                                nullptr,
                                dst,
                                0, 0,
                                0, 0,
                                aSrcRect.x, aSrcRect.y,
-                               aSrcRect.width, aSrcRect.height);
+                               aSrcRect.Width(), aSrcRect.Height());
       pixman_image_composite32(PIXMAN_OP_SRC,
                                src,
                                nullptr,
                                dst,
                                aBlendRect->x, aBlendRect->y,
                                0, 0,
                                aBlendRect->x, aBlendRect->y,
-                               aBlendRect->width, aBlendRect->height);
+                               aBlendRect->Width(), aBlendRect->Height());
     }
 
     pixman_image_unref(src);
     pixman_image_unref(dst);
   }
 
   return NS_OK;
 }
--- a/image/OrientedImage.cpp
+++ b/image/OrientedImage.cpp
@@ -360,16 +360,16 @@ OrientedImage::GetImageSpaceInvalidation
   if (NS_FAILED(rv)) {
     // Fall back to identity if the width and height aren't available.
     return rect;
   }
 
   // Transform the invalidation rect into the correct orientation.
   gfxMatrix matrix(OrientationMatrix(innerSize));
   gfxRect invalidRect(matrix.TransformBounds(gfxRect(rect.x, rect.y,
-                                                     rect.width, rect.height)));
+                                                     rect.Width(), rect.Height())));
 
   return IntRect::RoundOut(invalidRect.x, invalidRect.y,
-                           invalidRect.width, invalidRect.height);
+                           invalidRect.Width(), invalidRect.Height());
 }
 
 } // namespace image
 } // namespace mozilla
--- a/image/SurfaceFilters.h
+++ b/image/SurfaceFilters.h
@@ -371,17 +371,17 @@ public:
       NS_WARNING("RemoveFrameRectFilter used with paletted pipe?");
       return NS_ERROR_INVALID_ARG;
     }
 
     mFrameRect = mUnclampedFrameRect = aConfig.mFrameRect;
     gfx::IntSize outputSize = mNext.InputSize();
 
     // Forbid frame rects with negative size.
-    if (aConfig.mFrameRect.width < 0 || aConfig.mFrameRect.height < 0) {
+    if (aConfig.mFrameRect.Width() < 0 || aConfig.mFrameRect.Height() < 0) {
       return NS_ERROR_INVALID_ARG;
     }
 
     // Clamp mFrameRect to the output size.
     gfx::IntRect outputRect(0, 0, outputSize.width, outputSize.height);
     mFrameRect = mFrameRect.Intersect(outputRect);
 
     // If there's no intersection, |mFrameRect| will be an empty rect positioned
@@ -390,24 +390,24 @@ public:
     if (mFrameRect.IsEmpty()) {
       mFrameRect.MoveTo(0, 0);
     }
 
     // We don't need an intermediate buffer unless the unclamped frame rect
     // width is larger than the clamped frame rect width. In that case, the
     // caller will end up writing data that won't end up in the final image at
     // all, and we'll need a buffer to give that data a place to go.
-    if (mFrameRect.width < mUnclampedFrameRect.width) {
-      mBuffer.reset(new (fallible) uint8_t[mUnclampedFrameRect.width *
+    if (mFrameRect.Width() < mUnclampedFrameRect.Width()) {
+      mBuffer.reset(new (fallible) uint8_t[mUnclampedFrameRect.Width() *
                                            sizeof(uint32_t)]);
       if (MOZ_UNLIKELY(!mBuffer)) {
         return NS_ERROR_OUT_OF_MEMORY;
       }
 
-      memset(mBuffer.get(), 0, mUnclampedFrameRect.width * sizeof(uint32_t));
+      memset(mBuffer.get(), 0, mUnclampedFrameRect.Width() * sizeof(uint32_t));
     }
 
     ConfigureFilter(mUnclampedFrameRect.Size(), sizeof(uint32_t));
     return NS_OK;
   }
 
   Maybe<SurfaceInvalidRect> TakeInvalidRect() override
   {
@@ -475,17 +475,17 @@ protected:
       // unclamped frame rect that's outside the row.
       uint32_t* source = reinterpret_cast<uint32_t*>(mBuffer.get()) -
                          std::min(mUnclampedFrameRect.x, 0);
 
       // We write |mFrameRect.width| columns starting at |mFrameRect.x|; we've
       // already clamped these values to the size of the output, so we don't
       // have to worry about bounds checking here (though WriteBuffer() will do
       // it for us in any case).
-      WriteState state = mNext.WriteBuffer(source, mFrameRect.x, mFrameRect.width);
+      WriteState state = mNext.WriteBuffer(source, mFrameRect.x, mFrameRect.Width());
 
       rowPtr = state == WriteState::NEED_MORE_DATA ? mBuffer.get()
                                                    : nullptr;
     } else {
       rowPtr = mNext.AdvanceRow();
     }
 
     // If there's still more data coming or we're already done, just adjust the
--- a/image/SurfacePipe.cpp
+++ b/image/SurfacePipe.cpp
@@ -138,17 +138,17 @@ PalettedSurfaceSink::Configure(const Pal
 
   mImageData = aConfig.mDecoder->mImageData;
   mImageDataLength = aConfig.mDecoder->mImageDataLength;
   mFlipVertically = aConfig.mFlipVertically;
   mFrameRect = aConfig.mFrameRect;
 
   MOZ_ASSERT(mImageData);
   MOZ_ASSERT(mImageDataLength ==
-               uint32_t(mFrameRect.width * mFrameRect.height * sizeof(uint8_t)));
+             uint32_t(mFrameRect.Width() * mFrameRect.Height() * sizeof(uint8_t)));
 
   ConfigureFilter(surfaceSize, sizeof(uint8_t));
   return NS_OK;
 }
 
 uint8_t*
 PalettedSurfaceSink::GetRowPointer() const
 {
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -794,30 +794,30 @@ nsGIFDecoder2::ReadImageDescriptor(const
 LexerTransition<nsGIFDecoder2::State>
 nsGIFDecoder2::FinishImageDescriptor(const char* aData)
 {
   IntRect frameRect;
 
   // Get image offsets with respect to the screen origin.
   frameRect.x = LittleEndian::readUint16(aData + 0);
   frameRect.y = LittleEndian::readUint16(aData + 2);
-  frameRect.width = LittleEndian::readUint16(aData + 4);
-  frameRect.height = LittleEndian::readUint16(aData + 6);
+  frameRect.SetWidth(LittleEndian::readUint16(aData + 4));
+  frameRect.SetHeight(LittleEndian::readUint16(aData + 6));
 
   if (!mGIFStruct.images_decoded) {
     // Work around GIF files where
     //   * at least one of the logical screen dimensions is smaller than the
     //     same dimension in the first image, or
     //   * GIF87a files where the first image's dimensions do not match the
     //     logical screen dimensions.
-    if (mGIFStruct.screen_height < frameRect.height ||
-        mGIFStruct.screen_width < frameRect.width ||
+    if (mGIFStruct.screen_height < frameRect.Height() ||
+        mGIFStruct.screen_width < frameRect.Width() ||
         mGIFStruct.version == 87) {
-      mGIFStruct.screen_height = frameRect.height;
-      mGIFStruct.screen_width = frameRect.width;
+      mGIFStruct.screen_height = frameRect.Height();
+      mGIFStruct.screen_width = frameRect.Width();
       frameRect.MoveTo(0, 0);
     }
 
     // Create the image container with the right size.
     BeginGIF();
     if (HasError()) {
       // Setting the size led to an error.
       return Transition::TerminateFailure();
@@ -828,22 +828,22 @@ nsGIFDecoder2::FinishImageDescriptor(con
       CheckForTransparency(frameRect);
       FinishInternal();
       return Transition::TerminateSuccess();
     }
   }
 
   // Work around broken GIF files that have zero frame width or height; in this
   // case, we'll treat the frame as having the same size as the overall image.
-  if (frameRect.height == 0 || frameRect.width == 0) {
-    frameRect.height = mGIFStruct.screen_height;
-    frameRect.width = mGIFStruct.screen_width;
+  if (frameRect.Height() == 0 || frameRect.Width() == 0) {
+    frameRect.SetHeight(mGIFStruct.screen_height);
+    frameRect.SetWidth(mGIFStruct.screen_width);
 
     // If that still resulted in zero frame width or height, give up.
-    if (frameRect.height == 0 || frameRect.width == 0) {
+    if (frameRect.Height() == 0 || frameRect.Width() == 0) {
       return Transition::TerminateFailure();
     }
   }
 
   // Determine |depth| (log base 2 of the number of colors in the palette).
   bool haveLocalColorTable = false;
   uint16_t depth = 0;
   uint8_t packedFields = aData[8];
@@ -875,17 +875,17 @@ nsGIFDecoder2::FinishImageDescriptor(con
   const bool isInterlaced = packedFields & PACKED_FIELDS_INTERLACED_BIT;
 
   // Create the SurfacePipe we'll use to write output for this frame.
   if (NS_FAILED(BeginImageFrame(frameRect, realDepth, isInterlaced))) {
     return Transition::TerminateFailure();
   }
 
   // Clear state from last image.
-  mGIFStruct.pixels_remaining = frameRect.width * frameRect.height;
+  mGIFStruct.pixels_remaining = frameRect.Width() * frameRect.Height();
 
   if (haveLocalColorTable) {
     // We have a local color table, so prepare to read it into the palette of
     // the current frame.
     mGIFStruct.local_colormap_size = 1 << depth;
 
     if (mGIFStruct.images_decoded == 0) {
       // The first frame has a local color table. Allocate space for it as we
--- a/image/decoders/nsPNGDecoder.cpp
+++ b/image/decoders/nsPNGDecoder.cpp
@@ -227,17 +227,17 @@ nsPNGDecoder::CreateFrame(const FrameInf
   mPipe = Move(*pipe);
 
   mFrameRect = aFrameInfo.mFrameRect;
   mPass = 0;
 
   MOZ_LOG(sPNGDecoderAccountingLog, LogLevel::Debug,
          ("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
           "image frame with %dx%d pixels for decoder %p",
-          mFrameRect.width, mFrameRect.height, this));
+          mFrameRect.Width(), mFrameRect.Height(), this));
 
 #ifdef PNG_APNG_SUPPORTED
   if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {
     mAnimInfo = AnimFrameInfo(mPNG, mInfo);
 
     if (mAnimInfo.mDispose == DisposalMethod::CLEAR) {
       // We may have to display the background under this image during
       // animation playback, so we regard it as transparent.
@@ -565,17 +565,17 @@ nsPNGDecoder::info_callback(png_structp 
 
   // Always decode to 24-bit RGB or 32-bit RGBA
   png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
                &interlace_type, &compression_type, &filter_type);
 
   const IntRect frameRect(0, 0, width, height);
 
   // Post our size to the superclass
-  decoder->PostSize(frameRect.width, frameRect.height);
+  decoder->PostSize(frameRect.Width(), frameRect.Height());
 
   if (width >
     SurfaceCache::MaximumCapacity()/(bit_depth > 8 ? 16:8)) {
     // libpng needs space to allocate two row buffers
     png_error(decoder->mPNG, "Image is too wide");
   }
 
   if (decoder->HasError()) {
@@ -730,25 +730,25 @@ nsPNGDecoder::info_callback(png_structp 
     MOZ_ASSERT(decoder->mImageData, "Should have a buffer now");
 #ifdef PNG_APNG_SUPPORTED
   }
 #endif
 
   if (decoder->mTransform && (channels <= 2 || isInterlaced)) {
     uint32_t bpp[] = { 0, 3, 4, 3, 4 };
     decoder->mCMSLine =
-      static_cast<uint8_t*>(malloc(bpp[channels] * frameRect.width));
+      static_cast<uint8_t*>(malloc(bpp[channels] * frameRect.Width()));
     if (!decoder->mCMSLine) {
       png_error(decoder->mPNG, "malloc of mCMSLine failed");
     }
   }
 
   if (interlace_type == PNG_INTERLACE_ADAM7) {
-    if (frameRect.height < INT32_MAX / (frameRect.width * int32_t(channels))) {
-      const size_t bufferSize = channels * frameRect.width * frameRect.height;
+    if (frameRect.Height() < INT32_MAX / (frameRect.Width() * int32_t(channels))) {
+      const size_t bufferSize = channels * frameRect.Width() * frameRect.Height();
 
       if (bufferSize > SurfaceCache::MaximumCapacity()) {
         png_error(decoder->mPNG, "Insufficient memory to deinterlace image");
       }
 
       decoder->interlacebuf = static_cast<uint8_t*>(malloc(bufferSize));
     }
     if (!decoder->interlacebuf) {
@@ -844,32 +844,32 @@ nsPNGDecoder::row_callback(png_structp p
     // libpng will skip passes if the image is so small that no pixels have
     // changed on a given pass, but ADAM7InterpolatingFilter needs to be reset
     // once for every pass to perform interpolation properly.
     decoder->mPipe.ResetToFirstRow();
     decoder->mPass++;
   }
 
   const png_uint_32 height =
-    static_cast<png_uint_32>(decoder->mFrameRect.height);
+    static_cast<png_uint_32>(decoder->mFrameRect.Height());
 
   if (row_num >= height) {
     // Bail if we receive extra rows. This is especially important because if we
     // didn't, we might overflow the deinterlacing buffer.
     MOZ_ASSERT_UNREACHABLE("libpng producing extra rows?");
     return;
   }
 
   // Note that |new_row| may be null here, indicating that this is an interlaced
   // image and |row_callback| is being called for a row that hasn't changed.
   MOZ_ASSERT_IF(!new_row, decoder->interlacebuf);
   uint8_t* rowToWrite = new_row;
 
   if (decoder->interlacebuf) {
-    uint32_t width = uint32_t(decoder->mFrameRect.width);
+    uint32_t width = uint32_t(decoder->mFrameRect.Width());
 
     // We'll output the deinterlaced version of the row.
     rowToWrite = decoder->interlacebuf + (row_num * decoder->mChannels * width);
 
     // Update the deinterlaced version of this row with the new data.
     png_progressive_combine_row(png_ptr, rowToWrite, new_row);
   }
 
@@ -877,17 +877,17 @@ nsPNGDecoder::row_callback(png_structp p
 }
 
 void
 nsPNGDecoder::WriteRow(uint8_t* aRow)
 {
   MOZ_ASSERT(aRow);
 
   uint8_t* rowToWrite = aRow;
-  uint32_t width = uint32_t(mFrameRect.width);
+  uint32_t width = uint32_t(mFrameRect.Width());
 
   // Apply color management to the row, if necessary, before writing it out.
   if (mTransform) {
     if (mCMSLine) {
       qcms_transform_data(mTransform, rowToWrite, mCMSLine, width);
 
       // Copy alpha over.
       if (HasAlphaChannel()) {
--- a/image/imgFrame.cpp
+++ b/image/imgFrame.cpp
@@ -160,17 +160,17 @@ AllowedImageSize(int32_t aWidth, int32_t
 }
 
 static bool AllowedImageAndFrameDimensions(const nsIntSize& aImageSize,
                                            const nsIntRect& aFrameRect)
 {
   if (!AllowedImageSize(aImageSize.width, aImageSize.height)) {
     return false;
   }
-  if (!AllowedImageSize(aFrameRect.width, aFrameRect.height)) {
+  if (!AllowedImageSize(aFrameRect.Width(), aFrameRect.Height())) {
     return false;
   }
   nsIntRect imageRect(0, 0, aImageSize.width, aImageSize.height);
   if (!imageRect.Contains(aFrameRect)) {
     NS_WARNING("Animated image frame does not fit inside bounds of image");
   }
   return true;
 }
@@ -487,18 +487,18 @@ imgFrame::SurfaceForDrawing(bool        
   MOZ_ASSERT(NS_IsMainThread());
   mMonitor.AssertCurrentThreadOwns();
 
   if (!aDoPartialDecode) {
     return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, mImageSize),
                              mFormat);
   }
 
-  gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.width,
-                              mDecoded.height);
+  gfxRect available = gfxRect(mDecoded.x, mDecoded.y, mDecoded.Width(),
+                              mDecoded.Height());
 
   if (aDoTile) {
     // Create a temporary surface.
     // Give this surface an alpha channel because there are
     // transparent pixels in the padding or undecoded area
     RefPtr<DrawTarget> target =
       gfxPlatform::GetPlatform()->
         CreateOffscreenContentDrawTarget(mImageSize, SurfaceFormat::B8G8R8A8);
@@ -514,17 +514,17 @@ imgFrame::SurfaceForDrawing(bool        
     RefPtr<SourceSurface> newsurf = target->Snapshot();
     return SurfaceWithFormat(new gfxSurfaceDrawable(newsurf, mImageSize),
                              target->GetFormat());
   }
 
   // Not tiling, and we have a surface, so we can account for
   // a partial decode just by twiddling parameters.
   aRegion = aRegion.Intersect(available);
-  IntSize availableSize(mDecoded.width, mDecoded.height);
+  IntSize availableSize(mDecoded.Width(), mDecoded.Height());
 
   return SurfaceWithFormat(new gfxSurfaceDrawable(aSurface, availableSize),
                            mFormat);
 }
 
 bool imgFrame::Draw(gfxContext* aContext, const ImageRegion& aRegion,
                     SamplingFilter aSamplingFilter, uint32_t aImageFlags,
                     float aOpacity)
@@ -627,30 +627,30 @@ imgFrame::Finish(Opacity aFrameOpacity /
 }
 
 uint32_t
 imgFrame::GetImageBytesPerRow() const
 {
   mMonitor.AssertCurrentThreadOwns();
 
   if (mRawSurface) {
-    return mFrameRect.width * BytesPerPixel(mFormat);
+    return mFrameRect.Width() * BytesPerPixel(mFormat);
   }
 
   if (mPaletteDepth) {
-    return mFrameRect.width;
+    return mFrameRect.Width();
   }
 
   return 0;
 }
 
 uint32_t
 imgFrame::GetImageDataLength() const
 {
-  return GetImageBytesPerRow() * mFrameRect.height;
+  return GetImageBytesPerRow() * mFrameRect.Height();
 }
 
 void
 imgFrame::GetImageData(uint8_t** aData, uint32_t* aLength) const
 {
   MonitorAutoLock lock(mMonitor);
   GetImageDataInternal(aData, aLength);
 }
--- a/image/test/gtest/Common.cpp
+++ b/image/test/gtest/Common.cpp
@@ -165,17 +165,17 @@ RowsAreSolidColor(SourceSurface* aSurfac
 bool
 PalettedRowsAreSolidColor(Decoder* aDecoder,
                           int32_t aStartRow,
                           int32_t aRowCount,
                           uint8_t aColor)
 {
   RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
   IntRect frameRect = currentFrame->GetRect();
-  IntRect solidColorRect(frameRect.x, aStartRow, frameRect.width, aRowCount);
+  IntRect solidColorRect(frameRect.x, aStartRow, frameRect.Width(), aRowCount);
   return PalettedRectIsSolidColor(aDecoder, solidColorRect, aColor);
 }
 
 bool
 RectIsSolidColor(SourceSurface* aSurface,
                  const IntRect& aRect,
                  BGRAColor aColor,
                  uint8_t aFuzz /* = 0 */)
@@ -238,17 +238,17 @@ PalettedRectIsSolidColor(Decoder* aDecod
   // Translate |rect| by |frameRect.TopLeft()| to reflect the fact that the
   // frame rect's offset doesn't actually mean anything in terms of the
   // in-memory representation of the surface. The image data starts at the upper
   // left corner of the frame rect, in other words.
   rect -= frameRect.TopLeft();
 
   // Walk through the image data and make sure that the entire rect has the
   // palette index |aColor|.
-  int32_t rowLength = frameRect.width;
+  int32_t rowLength = frameRect.Width();
   for (int32_t row = rect.y; row < rect.YMost(); ++row) {
     for (int32_t col = rect.x; col < rect.XMost(); ++col) {
       int32_t i = row * rowLength + col;
       ASSERT_EQ_OR_RETURN(aColor, imageData[i], false);
     }
   }
 
   return true;
@@ -425,17 +425,17 @@ CheckWritePixels(Decoder* aDecoder,
 
   // Fill the image.
   int32_t count = 0;
   auto result = aFilter->WritePixels<uint32_t>([&] {
     ++count;
     return AsVariant(BGRAColor::Green().AsPixel());
   });
   EXPECT_EQ(WriteState::FINISHED, result);
-  EXPECT_EQ(inputWriteRect.width * inputWriteRect.height, count);
+  EXPECT_EQ(inputWriteRect.Width() * inputWriteRect.Height(), count);
 
   AssertCorrectPipelineFinalState(aFilter, inputRect, outputRect);
 
   // Attempt to write more data and make sure nothing changes.
   const int32_t oldCount = count;
   result = aFilter->WritePixels<uint32_t>([&] {
     ++count;
     return AsVariant(BGRAColor::Green().AsPixel());
@@ -472,17 +472,17 @@ CheckPalettedWritePixels(Decoder* aDecod
 
   // Fill the image.
   int32_t count = 0;
   auto result = aFilter->WritePixels<uint8_t>([&] {
     ++count;
     return AsVariant(uint8_t(255));
   });
   EXPECT_EQ(WriteState::FINISHED, result);
-  EXPECT_EQ(inputWriteRect.width * inputWriteRect.height, count);
+  EXPECT_EQ(inputWriteRect.Width() * inputWriteRect.Height(), count);
 
   AssertCorrectPipelineFinalState(aFilter, inputRect, outputRect);
 
   // Attempt to write more data and make sure nothing changes.
   const int32_t oldCount = count;
   result = aFilter->WritePixels<uint8_t>([&] {
     ++count;
     return AsVariant(uint8_t(255));
@@ -500,17 +500,17 @@ CheckPalettedWritePixels(Decoder* aDecod
   EXPECT_TRUE(invalidRect.isNothing());
 
   // Check that the generated image is correct.
   RawAccessFrameRef currentFrame = aDecoder->GetCurrentFrameRef();
   uint8_t* imageData;
   uint32_t imageLength;
   currentFrame->GetImageData(&imageData, &imageLength);
   ASSERT_TRUE(imageData != nullptr);
-  ASSERT_EQ(outputWriteRect.width * outputWriteRect.height, int32_t(imageLength));
+  ASSERT_EQ(outputWriteRect.Width() * outputWriteRect.Height(), int32_t(imageLength));
   for (uint32_t i = 0; i < imageLength; ++i) {
     ASSERT_EQ(uint8_t(255), imageData[i]);
   }
 }
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // Test Data
--- a/widget/IMEData.h
+++ b/widget/IMEData.h
@@ -601,18 +601,18 @@ struct IMENotification final
     int32_t mY;
     int32_t mWidth;
     int32_t mHeight;
 
     void Set(const nsIntRect& aRect)
     {
       mX = aRect.x;
       mY = aRect.y;
-      mWidth = aRect.width;
-      mHeight = aRect.height;
+      mWidth = aRect.Width();
+      mHeight = aRect.Height();
     }
     nsIntRect AsIntRect() const
     {
       return nsIntRect(mX, mY, mWidth, mHeight);
     }
   };
 
   // NOTIFY_IME_OF_SELECTION_CHANGE specific data