Bug 1387514: Upgrade BaseRect (derived classes) width and height direct member variable use to instead use Width()/SetWidth() and Height()/SetHeight() in dom/*. r=overholt
authorMilan Sreckovic <milan@mozilla.com>
Mon, 14 Aug 2017 08:30:10 -0400
changeset 374633 39b6c51cebcdb0fa7af7d068f3602f74a737ede2
parent 374632 1a5fb194a79cb848dbb50e0efbda46cd01566d96
child 374634 fdc6247f8fcaf0d5629c816d148df835bba4bf4d
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)
reviewersoverholt
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 dom/*. r=overholt MozReview-Commit-ID: B9YWmM3C1oX
dom/base/DOMIntersectionObserver.cpp
dom/base/Element.cpp
dom/base/Element.h
dom/base/Selection.cpp
dom/base/nsContentSink.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsQueryContentEventResult.cpp
dom/base/nsRange.cpp
dom/base/nsScreen.cpp
dom/base/nsScreen.h
dom/html/nsGenericHTMLElement.h
dom/media/MediaInfo.h
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -307,17 +307,17 @@ DOMIntersectionObserver::Update(nsIDocum
         rootRect = scrollFrame->GetScrollPortRect();
       }
     }
   }
 
   nsMargin rootMargin;
   NS_FOR_CSS_SIDES(side) {
     nscoord basis = side == eSideTop || side == eSideBottom ?
-      rootRect.height : rootRect.width;
+      rootRect.Height() : rootRect.Width();
     nsCSSValue value = mRootMargin.*nsCSSRect::sides[side];
     nsStyleCoord coord;
     if (value.IsPixelLengthUnit()) {
       coord.SetCoordValue(value.GetPixelLength());
     } else if (value.IsPercentLengthUnit()) {
       coord.SetPercentValue(value.GetPercentValue());
     } else {
       MOZ_ASSERT_UNREACHABLE("invalid length unit");
@@ -417,19 +417,19 @@ DOMIntersectionObserver::Update(nsIDocum
         nsIFrame* rootScrollFrame = presContext->PresShell()->GetRootScrollFrame();
         if (rootScrollFrame) {
           nsLayoutUtils::TransformRect(rootFrame, rootScrollFrame, rect);
         }
         intersectionRect = Some(rect);
       }
     }
 
-    double targetArea = targetRect.width * targetRect.height;
+    double targetArea = targetRect.Width() * targetRect.Height();
     double intersectionArea = !intersectionRect ?
-      0 : intersectionRect->width * intersectionRect->height;
+      0 : intersectionRect->Width() * intersectionRect->Height();
 
     double intersectionRatio;
     if (targetArea > 0.0) {
       intersectionRatio = intersectionArea / targetArea;
     } else {
       intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0;
     }
 
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -975,34 +975,34 @@ int32_t
 Element::ScrollHeight()
 {
   if (IsSVGElement())
     return 0;
 
   nsIScrollableFrame* sf = GetScrollFrame();
   nscoord height;
   if (sf) {
-    height = sf->GetScrollRange().height + sf->GetScrollPortRect().height;
+    height = sf->GetScrollRange().Height() + sf->GetScrollPortRect().Height();
   } else {
     height = GetScrollRectSizeForOverflowVisibleFrame(GetStyledFrame()).height;
   }
 
   return nsPresContext::AppUnitsToIntCSSPixels(height);
 }
 
 int32_t
 Element::ScrollWidth()
 {
   if (IsSVGElement())
     return 0;
 
   nsIScrollableFrame* sf = GetScrollFrame();
   nscoord width;
   if (sf) {
-    width = sf->GetScrollRange().width + sf->GetScrollPortRect().width;
+    width = sf->GetScrollRange().Width() + sf->GetScrollPortRect().Width();
   } else {
     width = GetScrollRectSizeForOverflowVisibleFrame(GetStyledFrame()).width;
   }
 
   return nsPresContext::AppUnitsToIntCSSPixels(width);
 }
 
 nsRect
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1057,21 +1057,21 @@ public:
     return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
   }
   int32_t ClientLeft()
   {
     return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().x);
   }
   int32_t ClientWidth()
   {
-    return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().width);
+    return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Width());
   }
   int32_t ClientHeight()
   {
-    return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().height);
+    return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().Height());
   }
   int32_t ScrollTopMin()
   {
     nsIScrollableFrame* sf = GetScrollFrame();
     return sf ?
            nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().y) : 0;
   }
   int32_t ScrollTopMax()
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -3477,19 +3477,19 @@ Selection::GetSelectionEndPointGeometry(
       return nullptr;
   }
 
   // Return the rect relative to the frame, with zero width.
   if (isText) {
     aRect->x = pt.x;
   } else if (mFrameSelection->GetHint() == CARET_ASSOCIATE_BEFORE) {
     // It's the frame's right edge we're interested in.
-    aRect->x = frame->GetRect().width;
-  }
-  aRect->height = frame->GetRect().height;
+    aRect->x = frame->GetRect().Width();
+  }
+  aRect->SetHeight(frame->GetRect().Height());
 
   return frame;
 }
 
 NS_IMETHODIMP
 Selection::ScrollSelectionIntoViewEvent::Run()
 {
   if (!mSelection)
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1254,17 +1254,17 @@ nsContentSink::StartLayout(bool aIgnoreP
   // Make sure we don't call Initialize() for a shell that has
   // already called it. This can happen when the layout frame for
   // an iframe is constructed *between* the Embed() call for the
   // docshell in the iframe, and the content sink's call to OpenBody().
   // (Bug 153815)
   if (shell && !shell->DidInitialize()) {
     nsRect r = shell->GetPresContext()->GetVisibleArea();
     nsCOMPtr<nsIPresShell> shellGrip = shell;
-    nsresult rv = shell->Initialize(r.width, r.height);
+    nsresult rv = shell->Initialize(r.Width(), r.Height());
     if (NS_FAILED(rv)) {
       return;
     }
   }
 
   // If the document we are loading has a reference or it is a
   // frameset document, disable the scroll bars on the views.
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1891,29 +1891,29 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMCl
   NS_ENSURE_STATE(doc);
 
   nsRect bounds(0, 0, 0, 0);
   nsIPresShell* presShell = doc->GetShell();
   if (presShell) {
     nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
     if (sf) {
       bounds = sf->GetScrollRange();
-      bounds.width += sf->GetScrollPortRect().width;
-      bounds.height += sf->GetScrollPortRect().height;
+      bounds.SetWidth(bounds.Width() + sf->GetScrollPortRect().Width());
+      bounds.SetHeight(bounds.Height() + sf->GetScrollPortRect().Height());
     } else if (presShell->GetRootFrame()) {
       bounds = presShell->GetRootFrame()->GetRect();
     }
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   RefPtr<DOMRect> rect = new DOMRect(window);
   rect->SetRect(nsPresContext::AppUnitsToFloatCSSPixels(bounds.x),
                 nsPresContext::AppUnitsToFloatCSSPixels(bounds.y),
-                nsPresContext::AppUnitsToFloatCSSPixels(bounds.width),
-                nsPresContext::AppUnitsToFloatCSSPixels(bounds.height));
+                nsPresContext::AppUnitsToFloatCSSPixels(bounds.Width()),
+                nsPresContext::AppUnitsToFloatCSSPixels(bounds.Height()));
   rect.forget(aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetIMEIsOpen(bool *aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2627,17 +2627,17 @@ nsGlobalWindow::SetInitialPrincipalToSub
   mDoc->SetIsInitialDocument(true);
 
   nsCOMPtr<nsIPresShell> shell = GetDocShell()->GetPresShell();
 
   if (shell && !shell->DidInitialize()) {
     // Ensure that if someone plays with this document they will get
     // layout happening.
     nsRect r = shell->GetPresContext()->GetVisibleArea();
-    shell->Initialize(r.width, r.height);
+    shell->Initialize(r.Width(), r.Height());
   }
 }
 
 PopupControlState
 PushPopupControlState(PopupControlState aState, bool aForce)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -5741,17 +5741,17 @@ nsGlobalWindow::SetInnerWidthOuter(int32
   if (presShell && presShell->GetIsViewportOverridden())
   {
     nscoord height = 0;
 
     RefPtr<nsPresContext> presContext;
     presContext = presShell->GetPresContext();
 
     nsRect shellArea = presContext->GetVisibleArea();
-    height = shellArea.height;
+    height = shellArea.Height();
     SetCSSViewportWidthAndHeight(nsPresContext::CSSPixelsToAppUnits(aInnerWidth),
                                  height);
     return;
   }
 
   int32_t height = 0;
   int32_t unused  = 0;
 
@@ -5835,17 +5835,17 @@ nsGlobalWindow::SetInnerHeightOuter(int3
 
   if (presShell && presShell->GetIsViewportOverridden())
   {
     RefPtr<nsPresContext> presContext;
     presContext = presShell->GetPresContext();
 
     nsRect shellArea = presContext->GetVisibleArea();
     nscoord height = aInnerHeight;
-    nscoord width = shellArea.width;
+    nscoord width = shellArea.Width();
     CheckSecurityWidthAndHeight(nullptr, &height, aCallerType);
     SetCSSViewportWidthAndHeight(width,
                                  nsPresContext::CSSPixelsToAppUnits(height));
     return;
   }
 
   int32_t height = 0;
   int32_t width  = 0;
@@ -6455,18 +6455,18 @@ void
 nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInnerHeight)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
 
   nsRect shellArea = presContext->GetVisibleArea();
-  shellArea.height = aInnerHeight;
-  shellArea.width = aInnerWidth;
+  shellArea.SetHeight(aInnerHeight);
+  shellArea.SetWidth(aInnerWidth);
 
   presContext->SetVisibleArea(shellArea);
 }
 
 // NOTE: Arguments to this function should have values scaled to
 // CSS pixels, not device pixels.
 void
 nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
--- a/dom/base/nsQueryContentEventResult.cpp
+++ b/dom/base/nsQueryContentEventResult.cpp
@@ -128,17 +128,17 @@ nsQueryContentEventResult::GetLeft(int32
 }
 
 NS_IMETHODIMP
 nsQueryContentEventResult::GetWidth(int32_t *aWidth)
 {
   NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
                  NS_ERROR_NOT_AVAILABLE);
-  *aWidth = mRect.width;
+  *aWidth = mRect.Width();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsQueryContentEventResult::GetTop(int32_t *aTop)
 {
   NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
@@ -148,17 +148,17 @@ nsQueryContentEventResult::GetTop(int32_
 }
 
 NS_IMETHODIMP
 nsQueryContentEventResult::GetHeight(int32_t *aHeight)
 {
   NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(IsRectRelatedPropertyAvailable(mEventMessage),
                  NS_ERROR_NOT_AVAILABLE);
-  *aHeight = mRect.height;
+  *aHeight = mRect.Height();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsQueryContentEventResult::GetText(nsAString &aText)
 {
   NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mEventMessage == eQuerySelectedText ||
@@ -211,18 +211,18 @@ nsQueryContentEventResult::GetCharacterR
                  NS_ERROR_NOT_AVAILABLE);
 
   if (NS_WARN_IF(mRectArray.Length() <= static_cast<uint32_t>(aOffset))) {
     return NS_ERROR_FAILURE;
   }
 
   *aLeft = mRectArray[aOffset].x;
   *aTop = mRectArray[aOffset].y;
-  *aWidth = mRectArray[aOffset].width;
-  *aHeight = mRectArray[aOffset].height;
+  *aWidth = mRectArray[aOffset].Width();
+  *aHeight = mRectArray[aOffset].Height();
 
   return NS_OK;
 }
 
 void
 nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
                                           WidgetQueryContentEvent &aEvent)
 {
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -3077,29 +3077,29 @@ nsRange::CreateContextualFragment(const 
 static void ExtractRectFromOffset(nsIFrame* aFrame,
                                   const int32_t aOffset, nsRect* aR, bool aKeepLeft,
                                   bool aClampToEdge)
 {
   nsPoint point;
   aFrame->GetPointFromOffset(aOffset, &point);
 
   if (!aClampToEdge && !aR->Contains(point)) {
-    aR->width = 0;
+    aR->SetWidth(0);
     aR->x = point.x;
     return;
   }
 
   if (aClampToEdge) {
     point = aR->ClampPoint(point);
   }
 
   if (aKeepLeft) {
-    aR->width = point.x - aR->x;
+    aR->SetWidth(point.x - aR->x);
   } else {
-    aR->width = aR->XMost() - point.x;
+    aR->SetWidth(aR->XMost() - point.x);
     aR->x = point.x;
   }
 }
 
 static nsTextFrame*
 GetTextFrameForContent(nsIContent* aContent, bool aFlushLayout)
 {
   nsIPresShell* presShell = aContent->OwnerDoc()->GetShell();
@@ -3219,17 +3219,17 @@ nsRange::CollectClientRectsAndText(nsLay
                      static_cast<int32_t>(aStartOffset), false,
                      &outOffset, &outFrame);
         if (outFrame) {
            nsIFrame* relativeTo =
              nsLayoutUtils::GetContainingBlockForClientRect(outFrame);
            nsRect r = outFrame->GetRectRelativeToSelf();
            ExtractRectFromOffset(outFrame, static_cast<int32_t>(aStartOffset),
                                  &r, false, aClampToEdge);
-           r.width = 0;
+           r.SetWidth(0);
            r = nsLayoutUtils::TransformFrameRectToAncestor(outFrame, r, relativeTo);
            aCollector->AddRect(r);
         }
       }
     }
     return;
   }
 
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -132,18 +132,18 @@ nsScreen::GetRect(nsRect& aRect)
     LayoutDevicePixel::FromAppUnits(aRect.TopLeft(),
                                     context->AppUnitsPerDevPixel());
   DesktopPoint screenTopLeftDesk =
     screenTopLeftDev / context->GetDesktopToDeviceScale();
 
   aRect.x = NSToIntRound(screenTopLeftDesk.x);
   aRect.y = NSToIntRound(screenTopLeftDesk.y);
 
-  aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
-  aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
+  aRect.SetHeight(nsPresContext::AppUnitsToIntCSSPixels(aRect.Height()));
+  aRect.SetWidth(nsPresContext::AppUnitsToIntCSSPixels(aRect.Width()));
 
   return NS_OK;
 }
 
 nsresult
 nsScreen::GetAvailRect(nsRect& aRect)
 {
   // Return window inner rect to prevent fingerprinting.
@@ -167,18 +167,18 @@ nsScreen::GetAvailRect(nsRect& aRect)
 
   context->GetClientRect(aRect);
 
   aRect.x = NSToIntRound(screenTopLeftDesk.x) +
             nsPresContext::AppUnitsToIntCSSPixels(aRect.x - r.x);
   aRect.y = NSToIntRound(screenTopLeftDesk.y) +
             nsPresContext::AppUnitsToIntCSSPixels(aRect.y - r.y);
 
-  aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
-  aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
+  aRect.SetHeight(nsPresContext::AppUnitsToIntCSSPixels(aRect.Height()));
+  aRect.SetWidth(nsPresContext::AppUnitsToIntCSSPixels(aRect.Width()));
 
   return NS_OK;
 }
 
 mozilla::dom::ScreenOrientation*
 nsScreen::Orientation() const
 {
   return mScreenOrientation;
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -57,32 +57,32 @@ public:
       if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
         int32_t innerWidth = 0;
         aRv = owner->GetInnerWidth(&innerWidth);
         return innerWidth;
       }
     }
 
     aRv = GetRect(rect);
-    return rect.width;
+    return rect.Width();
   }
 
   int32_t GetHeight(ErrorResult& aRv)
   {
     nsRect rect;
     if (IsDeviceSizePageSize()) {
       if (nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner()) {
         int32_t innerHeight = 0;
         aRv = owner->GetInnerHeight(&innerHeight);
         return innerHeight;
       }
     }
 
     aRv = GetRect(rect);
-    return rect.height;
+    return rect.Height();
   }
 
   int32_t GetPixelDepth(ErrorResult& aRv);
   int32_t GetColorDepth(ErrorResult& aRv)
   {
     return GetPixelDepth(aRv);
   }
 
@@ -99,24 +99,24 @@ public:
     aRv = GetAvailRect(rect);
     return rect.x;
   }
 
   int32_t GetAvailWidth(ErrorResult& aRv)
   {
     nsRect rect;
     aRv = GetAvailRect(rect);
-    return rect.width;
+    return rect.Width();
   }
 
   int32_t GetAvailHeight(ErrorResult& aRv)
   {
     nsRect rect;
     aRv = GetAvailRect(rect);
-    return rect.height;
+    return rect.Height();
   }
 
   // Deprecated
   void GetMozOrientation(nsString& aOrientation,
                          mozilla::dom::CallerType aCallerType) const;
 
   IMPL_EVENT_HANDLER(mozorientationchange)
 
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -224,24 +224,24 @@ public:
 
     return rcFrame.x;
   }
   int32_t OffsetWidth()
   {
     mozilla::CSSIntRect rcFrame;
     GetOffsetRect(rcFrame);
 
-    return rcFrame.width;
+    return rcFrame.Width();
   }
   int32_t OffsetHeight()
   {
     mozilla::CSSIntRect rcFrame;
     GetOffsetRect(rcFrame);
 
-    return rcFrame.height;
+    return rcFrame.Height();
   }
 
   // These methods are already implemented in nsIContent but we want something
   // faster for HTMLElements ignoring the namespace checking.
   // This is safe because we already know that we are in the HTML namespace.
   inline bool IsHTMLElement() const
   {
     return true;
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -256,17 +256,17 @@ public:
 
   bool HasAlpha() const
   {
     return mAlphaPresent;
   }
 
   nsIntRect ImageRect() const
   {
-    if (mImageRect.width < 0 || mImageRect.height < 0) {
+    if (mImageRect.Width() < 0 || mImageRect.Height() < 0) {
       return nsIntRect(0, 0, mImage.width, mImage.height);
     }
     return mImageRect;
   }
 
   void SetImageRect(const nsIntRect& aRect)
   {
     mImageRect = aRect;
@@ -285,18 +285,18 @@ public:
     if ((aWidth == mImage.width && aHeight == mImage.height)
         || !mImage.width
         || !mImage.height) {
       return ImageRect();
     }
     nsIntRect imageRect = ImageRect();
     imageRect.x = (imageRect.x * aWidth) / mImage.width;
     imageRect.y = (imageRect.y * aHeight) / mImage.height;
-    imageRect.width = (aWidth * imageRect.width) / mImage.width;
-    imageRect.height = (aHeight * imageRect.height) / mImage.height;
+    imageRect.SetWidth((aWidth * imageRect.Width()) / mImage.width);
+    imageRect.SetHeight((aHeight * imageRect.Height()) / mImage.height);
     return imageRect;
   }
 
   Rotation ToSupportedRotation(int32_t aDegree)
   {
     switch (aDegree) {
       case 90:
         return kDegree_90;