Bug 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in layout/*. r?dholbert draft
authorMilan Sreckovic <milan@mozilla.com>
Mon, 14 Aug 2017 08:30:04 -0400
changeset 645902 4722d3582415f1c7641599a2ef530f370740240e
parent 645901 db9afec653a10f7ee00dff7a96000833cad80fd6
child 645903 07c3c6af00d3d15f357626e923340ef248e5f1ae
push id73926
push userbmo:milan@mozilla.com
push dateMon, 14 Aug 2017 12:31:01 +0000
reviewersdholbert
bugs1387514
milestone57.0a1
Bug 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in layout/*. r?dholbert MozReview-Commit-ID: AfAbr74e1Yh
layout/base/UnitTransforms.h
layout/base/Units.h
layout/base/nsPresContext.h
layout/generic/nsIFrame.h
--- a/layout/base/UnitTransforms.h
+++ b/layout/base/UnitTransforms.h
@@ -80,21 +80,21 @@ gfx::PointTyped<TargetUnits> ViewAs(cons
   return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits, class SourceUnits>
 gfx::IntPointTyped<TargetUnits> ViewAs(const gfx::IntPointTyped<SourceUnits>& aPoint, PixelCastJustification) {
   return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits, class SourceUnits>
 gfx::RectTyped<TargetUnits> ViewAs(const gfx::RectTyped<SourceUnits>& aRect, PixelCastJustification) {
-  return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
+  return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.Width(), aRect.Height());
 }
 template <class TargetUnits, class SourceUnits>
 gfx::IntRectTyped<TargetUnits> ViewAs(const gfx::IntRectTyped<SourceUnits>& aRect, PixelCastJustification) {
-  return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
+  return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.Width(), aRect.Height());
 }
 template <class TargetUnits, class SourceUnits>
 gfx::MarginTyped<TargetUnits> ViewAs(const gfx::MarginTyped<SourceUnits>& aMargin, PixelCastJustification) {
   return gfx::MarginTyped<TargetUnits>(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
 }
 template <class TargetUnits, class SourceUnits>
 gfx::IntMarginTyped<TargetUnits> ViewAs(const gfx::IntMarginTyped<SourceUnits>& aMargin, PixelCastJustification) {
   return gfx::IntMarginTyped<TargetUnits>(aMargin.top, aMargin.right, aMargin.bottom, aMargin.left);
@@ -138,29 +138,29 @@ gfx::PointTyped<TargetUnits> ViewAs(cons
   return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits>
 gfx::PointTyped<TargetUnits> ViewAs(const gfx::Point& aPoint) {
   return gfx::PointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits>
 gfx::RectTyped<TargetUnits> ViewAs(const gfx::Rect& aRect) {
-  return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
+  return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.Width(), aRect.Height());
 }
 template <class TargetUnits>
 gfx::IntSizeTyped<TargetUnits> ViewAs(const nsIntSize& aSize) {
   return gfx::IntSizeTyped<TargetUnits>(aSize.width, aSize.height);
 }
 template <class TargetUnits>
 gfx::IntPointTyped<TargetUnits> ViewAs(const nsIntPoint& aPoint) {
   return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
 }
 template <class TargetUnits>
 gfx::IntRectTyped<TargetUnits> ViewAs(const nsIntRect& aRect) {
-  return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
+  return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.Width(), aRect.Height());
 }
 template <class TargetUnits>
 gfx::IntRegionTyped<TargetUnits> ViewAs(const nsIntRegion& aRegion) {
   return gfx::IntRegionTyped<TargetUnits>::FromUnknownRegion(aRegion);
 }
 // Unlike the other functions in this category, this function takes the
 // target matrix type, rather than its source and target unit types, as
 // the template argument, so an example invocation is:
--- a/layout/base/Units.h
+++ b/layout/base/Units.h
@@ -206,18 +206,18 @@ struct CSSPixel {
   static CSSSize FromAppUnits(const nsSize& aSize) {
     return CSSSize(NSAppUnitsToFloatPixels(aSize.width, float(AppUnitsPerCSSPixel())),
                    NSAppUnitsToFloatPixels(aSize.height, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSRect FromAppUnits(const nsRect& aRect) {
     return CSSRect(NSAppUnitsToFloatPixels(aRect.x, float(AppUnitsPerCSSPixel())),
                    NSAppUnitsToFloatPixels(aRect.y, float(AppUnitsPerCSSPixel())),
-                   NSAppUnitsToFloatPixels(aRect.width, float(AppUnitsPerCSSPixel())),
-                   NSAppUnitsToFloatPixels(aRect.height, float(AppUnitsPerCSSPixel())));
+                   NSAppUnitsToFloatPixels(aRect.Width(), float(AppUnitsPerCSSPixel())),
+                   NSAppUnitsToFloatPixels(aRect.Height(), float(AppUnitsPerCSSPixel())));
   }
 
   static CSSMargin FromAppUnits(const nsMargin& aMargin) {
     return CSSMargin(NSAppUnitsToFloatPixels(aMargin.top, float(AppUnitsPerCSSPixel())),
                      NSAppUnitsToFloatPixels(aMargin.right, float(AppUnitsPerCSSPixel())),
                      NSAppUnitsToFloatPixels(aMargin.bottom, float(AppUnitsPerCSSPixel())),
                      NSAppUnitsToFloatPixels(aMargin.left, float(AppUnitsPerCSSPixel())));
   }
@@ -231,18 +231,18 @@ struct CSSPixel {
   {
     return CSSIntSize(NSAppUnitsToIntPixels(aSize.width, float(AppUnitsPerCSSPixel())),
                       NSAppUnitsToIntPixels(aSize.height, float(AppUnitsPerCSSPixel())));
   }
 
   static CSSIntRect FromAppUnitsRounded(const nsRect& aRect) {
     return CSSIntRect(NSAppUnitsToIntPixels(aRect.x, float(AppUnitsPerCSSPixel())),
                       NSAppUnitsToIntPixels(aRect.y, float(AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aRect.width, float(AppUnitsPerCSSPixel())),
-                      NSAppUnitsToIntPixels(aRect.height, float(AppUnitsPerCSSPixel())));
+                      NSAppUnitsToIntPixels(aRect.Width(), float(AppUnitsPerCSSPixel())),
+                      NSAppUnitsToIntPixels(aRect.Height(), float(AppUnitsPerCSSPixel())));
   }
 
   static CSSIntRect FromAppUnitsToNearest(const nsRect& aRect) {
     return CSSIntRect::FromUnknownRect(aRect.ToNearestPixels(AppUnitsPerCSSPixel()));
   }
 
   // Conversions to app units
 
@@ -268,42 +268,42 @@ struct CSSPixel {
   static nsSize ToAppUnits(const CSSIntSize& aSize) {
     return nsSize(NSToCoordRoundWithClamp(float(aSize.width)  * float(AppUnitsPerCSSPixel())),
                   NSToCoordRoundWithClamp(float(aSize.height) * float(AppUnitsPerCSSPixel())));
   }
 
   static nsRect ToAppUnits(const CSSRect& aRect) {
     return nsRect(NSToCoordRoundWithClamp(aRect.x * float(AppUnitsPerCSSPixel())),
                   NSToCoordRoundWithClamp(aRect.y * float(AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(aRect.width * float(AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(aRect.height * float(AppUnitsPerCSSPixel())));
+                  NSToCoordRoundWithClamp(aRect.Width() * float(AppUnitsPerCSSPixel())),
+                  NSToCoordRoundWithClamp(aRect.Height() * float(AppUnitsPerCSSPixel())));
   }
 
   static nsRect ToAppUnits(const CSSIntRect& aRect) {
     return nsRect(NSToCoordRoundWithClamp(float(aRect.x) * float(AppUnitsPerCSSPixel())),
                   NSToCoordRoundWithClamp(float(aRect.y) * float(AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(float(aRect.width) * float(AppUnitsPerCSSPixel())),
-                  NSToCoordRoundWithClamp(float(aRect.height) * float(AppUnitsPerCSSPixel())));
+                  NSToCoordRoundWithClamp(float(aRect.Width()) * float(AppUnitsPerCSSPixel())),
+                  NSToCoordRoundWithClamp(float(aRect.Height()) * float(AppUnitsPerCSSPixel())));
   }
 };
 
 /*
  * The pixels that are referred to as "device pixels" in layout code. In
  * general values measured in LayoutDevicePixels are obtained by dividing a
  * value in app units by AppUnitsPerDevPixel(). Conversion between CSS pixels
  * and LayoutDevicePixels is affected by:
  * 1) the "full zoom" (see nsPresContext::SetFullZoom)
  * 2) the "widget scale" (see nsIWidget::GetDefaultScale)
  */
 struct LayoutDevicePixel {
   static LayoutDeviceRect FromAppUnits(const nsRect& aRect, nscoord aAppUnitsPerDevPixel) {
     return LayoutDeviceRect(NSAppUnitsToFloatPixels(aRect.x, float(aAppUnitsPerDevPixel)),
                             NSAppUnitsToFloatPixels(aRect.y, float(aAppUnitsPerDevPixel)),
-                            NSAppUnitsToFloatPixels(aRect.width, float(aAppUnitsPerDevPixel)),
-                            NSAppUnitsToFloatPixels(aRect.height, float(aAppUnitsPerDevPixel)));
+                            NSAppUnitsToFloatPixels(aRect.Width(), float(aAppUnitsPerDevPixel)),
+                            NSAppUnitsToFloatPixels(aRect.Height(), float(aAppUnitsPerDevPixel)));
   }
 
   static LayoutDeviceSize FromAppUnits(const nsSize& aSize, nscoord aAppUnitsPerDevPixel) {
     return LayoutDeviceSize(
       NSAppUnitsToFloatPixels(aSize.width, aAppUnitsPerDevPixel),
       NSAppUnitsToFloatPixels(aSize.height, aAppUnitsPerDevPixel));
   }
 
@@ -359,25 +359,25 @@ struct LayoutDevicePixel {
   static nsSize ToAppUnits(const LayoutDeviceSize& aSize, nscoord aAppUnitsPerDevPixel) {
     return nsSize(NSFloatPixelsToAppUnits(aSize.width, aAppUnitsPerDevPixel),
                   NSFloatPixelsToAppUnits(aSize.height, aAppUnitsPerDevPixel));
   }
 
   static nsRect ToAppUnits(const LayoutDeviceIntRect& aRect, nscoord aAppUnitsPerDevPixel) {
     return nsRect(aRect.x * aAppUnitsPerDevPixel,
                   aRect.y * aAppUnitsPerDevPixel,
-                  aRect.width * aAppUnitsPerDevPixel,
-                  aRect.height * aAppUnitsPerDevPixel);
+                  aRect.Width() * aAppUnitsPerDevPixel,
+                  aRect.Height() * aAppUnitsPerDevPixel);
   }
 
   static nsRect ToAppUnits(const LayoutDeviceRect& aRect, nscoord aAppUnitsPerDevPixel) {
     return nsRect(NSFloatPixelsToAppUnits(aRect.x, aAppUnitsPerDevPixel),
                   NSFloatPixelsToAppUnits(aRect.y, aAppUnitsPerDevPixel),
-                  NSFloatPixelsToAppUnits(aRect.width, aAppUnitsPerDevPixel),
-                  NSFloatPixelsToAppUnits(aRect.height, aAppUnitsPerDevPixel));
+                  NSFloatPixelsToAppUnits(aRect.Width(), aAppUnitsPerDevPixel),
+                  NSFloatPixelsToAppUnits(aRect.Height(), aAppUnitsPerDevPixel));
   }
 };
 
 /*
  * The pixels that layout rasterizes and delivers to the graphics code.
  * These also are generally referred to as "device pixels" in layout code.
  * Conversion between CSS pixels and LayerPixels is affected by:
  * 1) the "display resolution" (see nsIPresShell::SetResolution)
@@ -511,74 +511,74 @@ gfx::PointTyped<dst> operator/(const gfx
   return gfx::PointTyped<dst>(float(aPoint.x) / aScale.xScale,
                               float(aPoint.y) / aScale.yScale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator*(const gfx::RectTyped<src>& aRect, const gfx::ScaleFactor<src, dst>& aScale) {
   return gfx::RectTyped<dst>(aRect.x * aScale.scale,
                              aRect.y * aScale.scale,
-                             aRect.width * aScale.scale,
-                             aRect.height * aScale.scale);
+                             aRect.Width() * aScale.scale,
+                             aRect.Height() * aScale.scale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator/(const gfx::RectTyped<src>& aRect, const gfx::ScaleFactor<dst, src>& aScale) {
   return gfx::RectTyped<dst>(aRect.x / aScale.scale,
                              aRect.y / aScale.scale,
-                             aRect.width / aScale.scale,
-                             aRect.height / aScale.scale);
+                             aRect.Width() / aScale.scale,
+                             aRect.Height() / aScale.scale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator*(const gfx::RectTyped<src>& aRect, const gfx::ScaleFactors2D<src, dst>& aScale) {
   return gfx::RectTyped<dst>(aRect.x * aScale.xScale,
                              aRect.y * aScale.yScale,
-                             aRect.width * aScale.xScale,
-                             aRect.height * aScale.yScale);
+                             aRect.Width() * aScale.xScale,
+                             aRect.Height() * aScale.yScale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator/(const gfx::RectTyped<src>& aRect, const gfx::ScaleFactors2D<dst, src>& aScale) {
   return gfx::RectTyped<dst>(aRect.x / aScale.xScale,
                              aRect.y / aScale.yScale,
-                             aRect.width / aScale.xScale,
-                             aRect.height / aScale.yScale);
+                             aRect.Width() / aScale.xScale,
+                             aRect.Height() / aScale.yScale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator*(const gfx::IntRectTyped<src>& aRect, const gfx::ScaleFactor<src, dst>& aScale) {
   return gfx::RectTyped<dst>(float(aRect.x) * aScale.scale,
                              float(aRect.y) * aScale.scale,
-                             float(aRect.width) * aScale.scale,
-                             float(aRect.height) * aScale.scale);
+                             float(aRect.Width()) * aScale.scale,
+                             float(aRect.Height()) * aScale.scale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator/(const gfx::IntRectTyped<src>& aRect, const gfx::ScaleFactor<dst, src>& aScale) {
   return gfx::RectTyped<dst>(float(aRect.x) / aScale.scale,
                              float(aRect.y) / aScale.scale,
-                             float(aRect.width) / aScale.scale,
-                             float(aRect.height) / aScale.scale);
+                             float(aRect.Width()) / aScale.scale,
+                             float(aRect.Height()) / aScale.scale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator*(const gfx::IntRectTyped<src>& aRect, const gfx::ScaleFactors2D<src, dst>& aScale) {
   return gfx::RectTyped<dst>(float(aRect.x) * aScale.xScale,
                              float(aRect.y) * aScale.yScale,
-                             float(aRect.width) * aScale.xScale,
-                             float(aRect.height) * aScale.yScale);
+                             float(aRect.Width()) * aScale.xScale,
+                             float(aRect.Height()) * aScale.yScale);
 }
 
 template<class src, class dst>
 gfx::RectTyped<dst> operator/(const gfx::IntRectTyped<src>& aRect, const gfx::ScaleFactors2D<dst, src>& aScale) {
   return gfx::RectTyped<dst>(float(aRect.x) / aScale.xScale,
                              float(aRect.y) / aScale.yScale,
-                             float(aRect.width) / aScale.xScale,
-                             float(aRect.height) / aScale.yScale);
+                             float(aRect.Width()) / aScale.xScale,
+                             float(aRect.Height()) / aScale.yScale);
 }
 
 template<class src, class dst>
 gfx::SizeTyped<dst> operator*(const gfx::SizeTyped<src>& aSize, const gfx::ScaleFactor<src, dst>& aScale) {
   return gfx::SizeTyped<dst>(aSize.width * aScale.scale,
                              aSize.height * aScale.scale);
 }
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -697,18 +697,18 @@ public:
   // If there is a remainder, it is rounded to nearest app units.
   nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const;
 
   gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const;
 
   gfxRect AppUnitsToGfxUnits(const nsRect& aAppRect) const
   { return gfxRect(AppUnitsToGfxUnits(aAppRect.x),
                    AppUnitsToGfxUnits(aAppRect.y),
-                   AppUnitsToGfxUnits(aAppRect.width),
-                   AppUnitsToGfxUnits(aAppRect.height)); }
+                   AppUnitsToGfxUnits(aAppRect.Width()),
+                   AppUnitsToGfxUnits(aAppRect.Height())); }
 
   static nscoord CSSTwipsToAppUnits(float aTwips)
   { return NSToCoordRoundWithClamp(
       mozilla::AppUnitsPerCSSInch() * NS_TWIPS_TO_INCHES(aTwips)); }
 
   // Margin-specific version, since they often need TwipsToAppUnits
   static nsMargin CSSTwipsToAppUnits(const nsIntMargin &marginInTwips)
   { return nsMargin(CSSTwipsToAppUnits(float(marginInTwips.top)),
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -1043,19 +1043,19 @@ public:
    * This leaves the frame's logical position in the given mode unchanged,
    * which means its physical position may change (for right-to-left modes).
    */
   void SetSize(mozilla::WritingMode aWritingMode,
                const mozilla::LogicalSize& aSize)
   {
     if ((!aWritingMode.IsVertical() && !aWritingMode.IsBidiLTR()) ||
         aWritingMode.IsVerticalRL()) {
-      nscoord oldWidth = mRect.width;
+      nscoord oldWidth = mRect.Width();
       SetSize(aSize.GetPhysicalSize(aWritingMode));
-      mRect.x -= mRect.width - oldWidth;
+      mRect.x -= mRect.Width() - oldWidth;
     } else {
       SetSize(aSize.GetPhysicalSize(aWritingMode));
     }
   }
 
   /**
    * Set this frame's physical size. This leaves the frame's physical position
    * (topLeft) unchanged.
@@ -1319,17 +1319,17 @@ public:
   nsRect GetContentRectRelativeToSelf() const;
   nsRect GetMarginRectRelativeToSelf() const;
 
   /**
    * The area to paint box-shadows around.  The default is the border rect.
    * (nsFieldSetFrame overrides this).
    */
   virtual nsRect VisualBorderRectRelativeToSelf() const {
-    return nsRect(0, 0, mRect.width, mRect.height);
+    return nsRect(0, 0, mRect.Width(), mRect.Height());
   }
 
   /**
    * Get the size, in app units, of the border radii. It returns FALSE iff all
    * returned radii == 0 (so no border radii), TRUE otherwise.
    * For the aRadii indexes, use the enum HalfCorner constants in gfx/2d/Types.h
    * If a side is skipped via aSkipSides, its corners are forced to 0.
    *
@@ -4283,20 +4283,20 @@ private:
     MOZ_ASSERT(mOverflow.mType != NS_FRAME_OVERFLOW_LARGE,
                "should not be called when overflow is in a property");
     // Calculate the rect using deltas from the frame's border rect.
     // Note that the mOverflow.mDeltas fields are unsigned, but we will often
     // need to return negative values for the left and top, so take care
     // to cast away the unsigned-ness.
     return nsRect(-(int32_t)mOverflow.mVisualDeltas.mLeft,
                   -(int32_t)mOverflow.mVisualDeltas.mTop,
-                  mRect.width + mOverflow.mVisualDeltas.mRight +
-                                mOverflow.mVisualDeltas.mLeft,
-                  mRect.height + mOverflow.mVisualDeltas.mBottom +
-                                 mOverflow.mVisualDeltas.mTop);
+                  mRect.Width() + mOverflow.mVisualDeltas.mRight +
+                                  mOverflow.mVisualDeltas.mLeft,
+                  mRect.Height() + mOverflow.mVisualDeltas.mBottom +
+                                   mOverflow.mVisualDeltas.mTop);
   }
   /**
    * Returns true if any overflow changed.
    */
   bool SetOverflowAreas(const nsOverflowAreas& aOverflowAreas);
 
   // Helper-functions for SortFrameList():
   template<bool IsLessThanOrEqual(nsIFrame*, nsIFrame*)>