Bug 1423551: Use BaseRect access methods instead of member variables in view/. r?jet
MozReview-Commit-ID: 1VlWJWAqRB3
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -189,18 +189,17 @@ void nsView::Destroy()
{
this->~nsView();
mozWritePoison(this, sizeof(*this));
nsView::operator delete(this);
}
void nsView::SetPosition(nscoord aX, nscoord aY)
{
- mDimBounds.x += aX - mPosX;
- mDimBounds.y += aY - mPosY;
+ mDimBounds.MoveBy(aX - mPosX, aY - mPosY);
mPosX = aX;
mPosY = aY;
NS_ASSERTION(GetParent() || (aX == 0 && aY == 0),
"Don't try to move the root widget to something non-zero");
ResetWidgetBounds(true, false);
}
@@ -286,18 +285,18 @@ LayoutDeviceIntRect nsView::CalcWidgetBo
if (newBounds.height > pixelRoundedSize.height) {
newBounds.height -= round;
}
}
#endif
// Compute where the top-left of our widget ended up relative to the parent
// widget, in appunits.
- nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.x, p2a),
- NSIntPixelsToAppUnits(newBounds.y, p2a));
+ nsPoint roundedOffset(NSIntPixelsToAppUnits(newBounds.X(), p2a),
+ NSIntPixelsToAppUnits(newBounds.Y(), p2a));
// mViewToWidgetOffset is added to coordinates relative to the view origin
// to get coordinates relative to the widget.
// The view origin, relative to the parent widget, is at
// (mPosX,mPosY) - mDimBounds.TopLeft() + viewBounds.TopLeft().
// Our widget, relative to the parent widget, is roundedOffset.
mViewToWidgetOffset = nsPoint(mPosX, mPosY)
- mDimBounds.TopLeft() + viewBounds.TopLeft() - roundedOffset;
@@ -360,25 +359,25 @@ void nsView::DoResetWidgetBounds(bool aM
// because of the potential for device-pixel coordinate spaces for mixed
// hidpi/lodpi screens to overlap each other and result in bad placement
// (bug 814434).
DesktopToLayoutDeviceScale scale = dx->GetDesktopToDeviceScale();
DesktopRect deskRect = newBounds / scale;
if (changedPos) {
if (changedSize && !aMoveOnly) {
- widget->ResizeClient(deskRect.x, deskRect.y,
- deskRect.width, deskRect.height,
+ widget->ResizeClient(deskRect.X(), deskRect.Y(),
+ deskRect.Width(), deskRect.Height(),
aInvalidateChangedSize);
} else {
- widget->MoveClient(deskRect.x, deskRect.y);
+ widget->MoveClient(deskRect.X(), deskRect.Y());
}
} else {
if (changedSize && !aMoveOnly) {
- widget->ResizeClient(deskRect.width, deskRect.height,
+ widget->ResizeClient(deskRect.Width(), deskRect.Height(),
aInvalidateChangedSize);
} // else do nothing!
}
if (!curVisibility && newVisibility) {
widget->Show(true);
}
}
@@ -807,22 +806,22 @@ void nsView::List(FILE* out, int32_t aIn
nsRect windowBounds = LayoutDeviceIntRect::ToAppUnits(rect, p2a);
rect = mWindow->GetBounds();
nsRect nonclientBounds = LayoutDeviceIntRect::ToAppUnits(rect, p2a);
nsrefcnt widgetRefCnt = mWindow.get()->AddRef() - 1;
mWindow.get()->Release();
int32_t Z = mWindow->GetZIndex();
fprintf(out, "(widget=%p[%" PRIuPTR "] z=%d pos={%d,%d,%d,%d}) ",
(void*)mWindow, widgetRefCnt, Z,
- nonclientBounds.x, nonclientBounds.y,
- windowBounds.width, windowBounds.height);
+ nonclientBounds.X(), nonclientBounds.Y(),
+ windowBounds.Width(), windowBounds.Height());
}
nsRect brect = GetBounds();
fprintf(out, "{%d,%d,%d,%d}",
- brect.x, brect.y, brect.width, brect.height);
+ brect.X(), brect.Y(), brect.Width(), brect.Height());
fprintf(out, " z=%d vis=%d frame=%p <\n",
mZIndex, mVis, static_cast<void*>(mFrame));
for (nsView* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
NS_ASSERTION(kid->GetParent() == this, "incorrect parent");
kid->List(out, aIndent + 1);
}
for (i = aIndent; --i >= 0; ) fputs(" ", out);
fputs(">\n", out);
--- a/view/nsViewManager.cpp
+++ b/view/nsViewManager.cpp
@@ -123,18 +123,18 @@ nsViewManager::Init(nsDeviceContext* aCo
nsView*
nsViewManager::CreateView(const nsRect& aBounds,
nsView* aParent,
nsViewVisibility aVisibilityFlag)
{
auto *v = new nsView(this, aVisibilityFlag);
v->SetParent(aParent);
- v->SetPosition(aBounds.x, aBounds.y);
- nsRect dim(0, 0, aBounds.width, aBounds.height);
+ v->SetPosition(aBounds.X(), aBounds.Y());
+ nsRect dim(0, 0, aBounds.Width(), aBounds.Height());
v->SetDimensions(dim, false);
return v;
}
void
nsViewManager::SetRootView(nsView *aView)
{
NS_PRECONDITION(!aView || aView->GetViewManager() == this,
@@ -160,18 +160,18 @@ nsViewManager::SetRootView(nsView *aView
}
void
nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
{
if (nullptr != mRootView) {
if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
nsRect dim = mRootView->GetDimensions();
- *aWidth = dim.width;
- *aHeight = dim.height;
+ *aWidth = dim.Width();
+ *aHeight = dim.Height();
} else {
*aWidth = mDelayedResize.width;
*aHeight = mDelayedResize.height;
}
}
else
{
*aWidth = 0;
@@ -183,17 +183,17 @@ void nsViewManager::DoSetWindowDimension
{
nsRect oldDim = mRootView->GetDimensions();
nsRect newDim(0, 0, aWidth, aHeight);
// We care about resizes even when one dimension is already zero.
if (!oldDim.IsEqualEdges(newDim)) {
// Don't resize the widget. It is already being set elsewhere.
mRootView->SetDimensions(newDim, true, false);
if (mPresShell)
- mPresShell->ResizeReflow(aWidth, aHeight, oldDim.width, oldDim.height);
+ mPresShell->ResizeReflow(aWidth, aHeight, oldDim.Width(), oldDim.Height());
}
}
bool
nsViewManager::ShouldDelayResize() const
{
MOZ_ASSERT(mRootView);
if (!mRootView->IsEffectivelyVisible() ||