Bug 1423556: Use BaseRect access methods instead of member variables in xpfe/ r?njn
MozReview-Commit-ID: BKiCUwuDIvl
--- a/xpfe/appshell/nsWebShellWindow.cpp
+++ b/xpfe/appshell/nsWebShellWindow.cpp
@@ -121,32 +121,32 @@ nsresult nsWebShellWindow::Initialize(ns
nsresult rv;
nsCOMPtr<nsIWidget> parentWidget;
mIsHiddenWindow = aIsHiddenWindow;
int32_t initialX = 0, initialY = 0;
nsCOMPtr<nsIBaseWindow> base(do_QueryInterface(aOpener));
if (base) {
- rv = base->GetPositionAndSize(&mOpenerScreenRect.x,
- &mOpenerScreenRect.y,
- &mOpenerScreenRect.width,
- &mOpenerScreenRect.height);
+ int32_t x, y, width, height;
+ rv = base->GetPositionAndSize(&x, &y, &width, &height);
if (NS_FAILED(rv)) {
mOpenerScreenRect.SetEmpty();
} else {
double scale;
if (NS_SUCCEEDED(base->GetUnscaledDevicePixelsPerCSSPixel(&scale))) {
- mOpenerScreenRect.x = NSToIntRound(mOpenerScreenRect.x / scale);
- mOpenerScreenRect.y = NSToIntRound(mOpenerScreenRect.y / scale);
- mOpenerScreenRect.width = NSToIntRound(mOpenerScreenRect.width / scale);
- mOpenerScreenRect.height = NSToIntRound(mOpenerScreenRect.height / scale);
+ mOpenerScreenRect.SetRect(NSToIntRound(x / scale),
+ NSToIntRound(y / scale),
+ NSToIntRound(width / scale),
+ NSToIntRound(height / scale));
+ } else {
+ mOpenerScreenRect.SetRect(x, y, width, height);
}
- initialX = mOpenerScreenRect.x;
- initialY = mOpenerScreenRect.y;
+ initialX = mOpenerScreenRect.X();
+ initialY = mOpenerScreenRect.Y();
ConstrainToOpenerScreen(&initialX, &initialY);
}
}
// XXX: need to get the default window size from prefs...
// Doesn't come from prefs... will come from CSS/XUL/RDF
DesktopIntRect deskRect(initialX, initialY, aInitialWidth, aInitialHeight);
@@ -202,20 +202,20 @@ nsresult nsWebShellWindow::Initialize(ns
// Create() so it knows what type it is.
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);
docShellAsItem->SetTreeOwner(mChromeTreeOwner);
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome);
- r.x = r.y = 0;
+ r.MoveTo(0, 0);
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nullptr, mWindow,
- r.x, r.y, r.width, r.height), NS_ERROR_FAILURE);
+ r.X(), r.Y(), r.Width(), r.Height()), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE);
// Attach a WebProgress listener.during initialization...
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv));
if (webProgress) {
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_NETWORK);
}
@@ -742,18 +742,18 @@ void nsWebShellWindow::ConstrainToOpener
return;
}
int32_t left, top, width, height;
// Constrain initial positions to the same screen as opener
nsCOMPtr<nsIScreenManager> screenmgr = do_GetService("@mozilla.org/gfx/screenmanager;1");
if (screenmgr) {
nsCOMPtr<nsIScreen> screen;
- screenmgr->ScreenForRect(mOpenerScreenRect.x, mOpenerScreenRect.y,
- mOpenerScreenRect.width, mOpenerScreenRect.height,
+ screenmgr->ScreenForRect(mOpenerScreenRect.X(), mOpenerScreenRect.Y(),
+ mOpenerScreenRect.Width(), mOpenerScreenRect.Height(),
getter_AddRefs(screen));
if (screen) {
screen->GetAvailRectDisplayPix(&left, &top, &width, &height);
if (*aX < left || *aX > left + width) {
*aX = left;
}
if (*aY < top || *aY > top + height) {
*aY = top;
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -609,17 +609,17 @@ NS_IMETHODIMP nsXULWindow::SetPositionAn
zoom state. this is important when these two states are competing while
the window is being opened. but it should probably just always be so. */
mWindow->SetSizeMode(nsSizeMode_Normal);
mIntrinsicallySized = false;
DesktopToLayoutDeviceScale scale = mWindow->GetDesktopToDeviceScale();
DesktopRect rect = LayoutDeviceIntRect(aX, aY, aCX, aCY) / scale;
- mWindow->Resize(rect.x, rect.y, rect.width, rect.height,
+ mWindow->Resize(rect.X(), rect.Y(), rect.Width(), rect.Height(),
!!(aFlags & nsIBaseWindow::eRepaint));
if (!mChromeLoaded) {
// If we're called before the chrome is loaded someone obviously wants this
// window at this size and position. We don't persist this one-time setting.
mIgnoreXULPosition = true;
mIgnoreXULSize = true;
mIgnoreXULSizeMode = true;
return NS_OK;
@@ -634,23 +634,23 @@ NS_IMETHODIMP nsXULWindow::GetPositionAn
{
if (!mWindow)
return NS_ERROR_FAILURE;
LayoutDeviceIntRect rect = mWindow->GetScreenBounds();
if (x)
- *x = rect.x;
+ *x = rect.X();
if (y)
- *y = rect.y;
+ *y = rect.Y();
if (cx)
- *cx = rect.width;
+ *cx = rect.Width();
if (cy)
- *cy = rect.height;
+ *cy = rect.Height();
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::Center(nsIXULWindow *aRelative, bool aScreen, bool aAlert)
{
int32_t left, top, width, height,
ourWidth, ourHeight;
@@ -697,18 +697,18 @@ NS_IMETHODIMP nsXULWindow::Center(nsIXUL
aRelative = 0;
aScreen = true;
}
}
}
if (!aRelative) {
if (!mOpenerScreenRect.IsEmpty()) {
// FIXME - check if these are device or display pixels
- screenmgr->ScreenForRect(mOpenerScreenRect.x, mOpenerScreenRect.y,
- mOpenerScreenRect.width, mOpenerScreenRect.height,
+ screenmgr->ScreenForRect(mOpenerScreenRect.X(), mOpenerScreenRect.Y(),
+ mOpenerScreenRect.Width(), mOpenerScreenRect.Height(),
getter_AddRefs(screen));
} else {
screenmgr->GetPrimaryScreen(getter_AddRefs(screen));
}
}
if (aScreen && screen) {
screen->GetAvailRectDisplayPix(&left, &top, &width, &height);
@@ -1609,18 +1609,17 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
CSSToLayoutDeviceScale sizeScale = mWindow->GetDefaultScale();
DesktopToLayoutDeviceScale posScale = mWindow->GetDesktopToDeviceScale();
// make our position relative to our parent, if any
nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
if (parent && gotRestoredBounds) {
int32_t parentX, parentY;
if (NS_SUCCEEDED(parent->GetPosition(&parentX, &parentY))) {
- rect.x -= parentX;
- rect.y -= parentY;
+ rect.MoveBy(-parentX, -parentY);
}
}
char sizeBuf[10];
nsAutoString sizeString;
nsAutoString windowElementId;
nsCOMPtr<nsIDOMXULDocument> ownerXULDoc;
@@ -1630,44 +1629,44 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
docShellElement->GetId(windowElementId);
}
bool shouldPersist = !isFullscreen && ownerXULDoc;
ErrorResult rv;
// (only for size elements which are persisted)
if ((mPersistentAttributesDirty & PAD_POSITION) && gotRestoredBounds) {
if (persistString.Find("screenX") >= 0) {
- SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.x / posScale.scale));
+ SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.X() / posScale.scale));
CopyASCIItoUTF16(sizeBuf, sizeString);
docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
if (shouldPersist) {
ownerXULDoc->Persist(windowElementId, SCREENX_ATTRIBUTE);
}
}
if (persistString.Find("screenY") >= 0) {
- SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.y / posScale.scale));
+ SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.Y() / posScale.scale));
CopyASCIItoUTF16(sizeBuf, sizeString);
docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
if (shouldPersist) {
ownerXULDoc->Persist(windowElementId, SCREENY_ATTRIBUTE);
}
}
}
if ((mPersistentAttributesDirty & PAD_SIZE) && gotRestoredBounds) {
if (persistString.Find("width") >= 0) {
- SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.width / sizeScale.scale));
+ SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.Width() / sizeScale.scale));
CopyASCIItoUTF16(sizeBuf, sizeString);
docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
if (shouldPersist) {
ownerXULDoc->Persist(windowElementId, WIDTH_ATTRIBUTE);
}
}
if (persistString.Find("height") >= 0) {
- SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.height / sizeScale.scale));
+ SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.Height() / sizeScale.scale));
CopyASCIItoUTF16(sizeBuf, sizeString);
docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
if (shouldPersist) {
ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
}
}
}