diff --git a/widget/CompositorWidget.cpp b/widget/CompositorWidget.cpp index 5c8909a27e258..7d729c1b8b939 100644 --- a/widget/CompositorWidget.cpp +++ b/widget/CompositorWidget.cpp @@ -53,7 +53,7 @@ CompositorWidget::GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget, target->SetTransform(gfx::Matrix()); if (!aClearRect.IsEmpty()) { gfx::IntRect clearRect = aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft(); - target->ClearRect(gfx::Rect(clearRect.x, clearRect.y, clearRect.width, clearRect.height)); + target->ClearRect(gfx::Rect(clearRect.X(), clearRect.Y(), clearRect.Width(), clearRect.Height())); } } else { target = aScreenTarget->CreateSimilarDrawTarget(size, format); diff --git a/widget/ContentCache.cpp b/widget/ContentCache.cpp index 41fbfebdbe6ed..349b4ed1298a4 100644 --- a/widget/ContentCache.cpp +++ b/widget/ContentCache.cpp @@ -44,13 +44,13 @@ class GetRectText : public nsAutoCString explicit GetRectText(const LayoutDeviceIntRect& aRect) { AssignLiteral("{ x="); - AppendInt(aRect.x); + AppendInt(aRect.X()); AppendLiteral(", y="); - AppendInt(aRect.y); + AppendInt(aRect.Y()); AppendLiteral(", width="); - AppendInt(aRect.width); + AppendInt(aRect.Width()); AppendLiteral(", height="); - AppendInt(aRect.height); + AppendInt(aRect.Height()); AppendLiteral(" }"); } virtual ~GetRectText() {} @@ -293,11 +293,11 @@ ContentCacheInChild::QueryCharRect(nsIWidget* aWidget, aCharRect = textRect.mReply.mRect; // Guarantee the rect is not empty. - if (NS_WARN_IF(!aCharRect.height)) { - aCharRect.height = 1; + if (NS_WARN_IF(!aCharRect.Height())) { + aCharRect.SetHeight(1); } - if (NS_WARN_IF(!aCharRect.width)) { - aCharRect.width = 1; + if (NS_WARN_IF(!aCharRect.Width())) { + aCharRect.SetWidth(1); } return true; } @@ -1081,10 +1081,10 @@ ContentCacheInParent::GetCaretRect(uint32_t aOffset, } if (mSelection.mWritingMode.IsVertical()) { - aCaretRect.y = aCaretRect.YMost(); + aCaretRect.MoveToY(aCaretRect.YMost()); } else { // XXX bidi-unaware. - aCaretRect.x = aCaretRect.XMost(); + aCaretRect.MoveToX(aCaretRect.XMost()); } } @@ -1092,9 +1092,9 @@ ContentCacheInParent::GetCaretRect(uint32_t aOffset, // direction. However, this is usually used by IME, so, assuming the // character is in LRT context must not cause any problem. if (mSelection.mWritingMode.IsVertical()) { - aCaretRect.height = mCaret.IsValid() ? mCaret.mRect.height : 1; + aCaretRect.SetHeight(mCaret.IsValid() ? mCaret.mRect.Height() : 1); } else { - aCaretRect.width = mCaret.IsValid() ? mCaret.mRect.width : 1; + aCaretRect.SetWidth(mCaret.IsValid() ? mCaret.mRect.Width() : 1); } return true; } diff --git a/widget/IMEData.h b/widget/IMEData.h index 30ed1896e1dfc..377d44805376f 100644 --- a/widget/IMEData.h +++ b/widget/IMEData.h @@ -660,10 +660,7 @@ struct IMENotification final void Set(const nsIntRect& aRect) { - mX = aRect.x; - mY = aRect.y; - mWidth = aRect.Width(); - mHeight = aRect.Height(); + aRect.GetRect(&mX, &mY, &mWidth, &mHeight); } nsIntRect AsIntRect() const { diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 24e94e995fff7..3615eb0cbdd54 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -134,7 +134,7 @@ PuppetWidget::InfallibleCreate(nsIWidget* aParent, mLayerManager = parent->GetLayerManager(); } else { - Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, false); + Resize(mBounds.X(), mBounds.Y(), mBounds.Width(), mBounds.Height(), false); } nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { @@ -224,7 +224,7 @@ PuppetWidget::Show(bool aState) // of no use anymore (and is actually actively harmful - see // bug 1323586). mPreviouslyAttachedWidgetListener = nullptr; - Resize(mBounds.width, mBounds.height, false); + Resize(mBounds.Width(), mBounds.Height(), false); Invalidate(mBounds); } } @@ -257,9 +257,9 @@ PuppetWidget::Resize(double aWidth, if (!oldBounds.IsEqualEdges(mBounds) && mAttachedWidgetListener) { if (GetCurrentWidgetListener() && GetCurrentWidgetListener() != mAttachedWidgetListener) { - GetCurrentWidgetListener()->WindowResized(this, mBounds.width, mBounds.height); + GetCurrentWidgetListener()->WindowResized(this, mBounds.Width(), mBounds.Height()); } - mAttachedWidgetListener->WindowResized(this, mBounds.width, mBounds.height); + mAttachedWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height()); } } @@ -274,11 +274,11 @@ PuppetWidget::ConfigureChildren(const nsTArray& aConfigurations) w->SetWindowClipRegion(configuration.mClipRegion, true); LayoutDeviceIntRect bounds = w->GetBounds(); if (bounds.Size() != configuration.mBounds.Size()) { - w->Resize(configuration.mBounds.x, configuration.mBounds.y, - configuration.mBounds.width, configuration.mBounds.height, + w->Resize(configuration.mBounds.X(), configuration.mBounds.Y(), + configuration.mBounds.Width(), configuration.mBounds.Height(), true); } else if (bounds.TopLeft() != configuration.mBounds.TopLeft()) { - w->Move(configuration.mBounds.x, configuration.mBounds.y); + w->Move(configuration.mBounds.X(), configuration.mBounds.Y()); } w->SetWindowClipRegion(configuration.mClipRegion, false); } @@ -1314,7 +1314,7 @@ nsIntSize PuppetWidget::GetScreenDimensions() { nsIntRect r = ScreenConfig().rect(); - return nsIntSize(r.width, r.height); + return nsIntSize(r.Width(), r.Height()); } NS_IMETHODIMP @@ -1322,10 +1322,7 @@ PuppetScreen::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) { nsIntRect r = ScreenConfig().rect(); - *outLeft = r.x; - *outTop = r.y; - *outWidth = r.width; - *outHeight = r.height; + r.GetRect(outLeft, outTop, outWidth, outHeight); return NS_OK; } diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index cc279b6b4111d..30e1e94e70bb3 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -108,11 +108,10 @@ class PuppetWidget : public nsBaseWidget double aHeight, bool aRepaint) override { - if (mBounds.x != aX || mBounds.y != aY) { + if (!mBounds.IsEqualXY(aX, aY)) { NotifyWindowMoved(aX, aY); } - mBounds.x = aX; - mBounds.y = aY; + mBounds.MoveTo(aX, aY); return Resize(aWidth, aHeight, aRepaint); } diff --git a/widget/Screen.cpp b/widget/Screen.cpp index 9f0e7d2bddf47..054bf38d29188 100644 --- a/widget/Screen.cpp +++ b/widget/Screen.cpp @@ -70,10 +70,7 @@ Screen::GetRect(int32_t* aOutLeft, int32_t* aOutWidth, int32_t* aOutHeight) { - *aOutLeft = mRect.x; - *aOutTop = mRect.y; - *aOutWidth = mRect.width; - *aOutHeight = mRect.height; + mRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight); return NS_OK; } @@ -83,10 +80,7 @@ Screen::GetRectDisplayPix(int32_t* aOutLeft, int32_t* aOutWidth, int32_t* aOutHeight) { - *aOutLeft = mRectDisplayPix.x; - *aOutTop = mRectDisplayPix.y; - *aOutWidth = mRectDisplayPix.width; - *aOutHeight = mRectDisplayPix.height; + mRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight); return NS_OK; } @@ -96,10 +90,7 @@ Screen::GetAvailRect(int32_t* aOutLeft, int32_t* aOutWidth, int32_t* aOutHeight) { - *aOutLeft = mAvailRect.x; - *aOutTop = mAvailRect.y; - *aOutWidth = mAvailRect.width; - *aOutHeight = mAvailRect.height; + mAvailRect.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight); return NS_OK; } @@ -109,10 +100,7 @@ Screen::GetAvailRectDisplayPix(int32_t* aOutLeft, int32_t* aOutWidth, int32_t* aOutHeight) { - *aOutLeft = mAvailRectDisplayPix.x; - *aOutTop = mAvailRectDisplayPix.y; - *aOutWidth = mAvailRectDisplayPix.width; - *aOutHeight = mAvailRectDisplayPix.height; + mAvailRectDisplayPix.GetRect(aOutLeft, aOutTop, aOutWidth, aOutHeight); return NS_OK; } diff --git a/widget/ScreenManager.cpp b/widget/ScreenManager.cpp index 694f0e5d58477..24d88561635f1 100644 --- a/widget/ScreenManager.cpp +++ b/widget/ScreenManager.cpp @@ -156,7 +156,7 @@ ScreenManager::ScreenForRect(int32_t aX, int32_t aY, // calculate the surface area DesktopIntRect screenRect(x, y, width, height); screenRect.IntersectRect(screenRect, windowRect); - uint32_t tempArea = screenRect.width * screenRect.height; + uint32_t tempArea = screenRect.Area(); if (tempArea > area) { which = screen.get(); area = tempArea; diff --git a/widget/WidgetUtils.cpp b/widget/WidgetUtils.cpp index 345c0772ad628..b4519689558b3 100644 --- a/widget/WidgetUtils.cpp +++ b/widget/WidgetUtils.cpp @@ -33,15 +33,15 @@ ComputeTransformForRotation(const nsIntRect& aBounds, case ROTATION_0: break; case ROTATION_90: - transform.PreTranslate(aBounds.width, 0); + transform.PreTranslate(aBounds.Width(), 0); transform.PreRotate(floatPi / 2); break; case ROTATION_180: - transform.PreTranslate(aBounds.width, aBounds.height); + transform.PreTranslate(aBounds.Width(), aBounds.Height()); transform.PreRotate(floatPi); break; case ROTATION_270: - transform.PreTranslate(0, aBounds.height); + transform.PreTranslate(0, aBounds.Height()); transform.PreRotate(floatPi * 3 / 2); break; default: @@ -61,15 +61,15 @@ ComputeTransformForUnRotation(const nsIntRect& aBounds, case ROTATION_0: break; case ROTATION_90: - transform.PreTranslate(0, aBounds.height); + transform.PreTranslate(0, aBounds.Height()); transform.PreRotate(floatPi * 3 / 2); break; case ROTATION_180: - transform.PreTranslate(aBounds.width, aBounds.height); + transform.PreTranslate(aBounds.Width(), aBounds.Height()); transform.PreRotate(floatPi); break; case ROTATION_270: - transform.PreTranslate(aBounds.width, 0); + transform.PreTranslate(aBounds.Width(), 0); transform.PreRotate(floatPi / 2); break; default: @@ -86,17 +86,17 @@ nsIntRect RotateRect(nsIntRect aRect, case ROTATION_0: return aRect; case ROTATION_90: - return nsIntRect(aRect.y, - aBounds.width - aRect.x - aRect.width, - aRect.height, aRect.width); + return nsIntRect(aRect.Y(), + aBounds.Width() - aRect.XMost(), + aRect.Height(), aRect.Width()); case ROTATION_180: - return nsIntRect(aBounds.width - aRect.x - aRect.width, - aBounds.height - aRect.y - aRect.height, - aRect.width, aRect.height); + return nsIntRect(aBounds.Width() - aRect.XMost(), + aBounds.Height() - aRect.YMost(), + aRect.Width(), aRect.Height()); case ROTATION_270: - return nsIntRect(aBounds.height - aRect.y - aRect.height, - aRect.x, - aRect.height, aRect.width); + return nsIntRect(aBounds.Height() - aRect.YMost(), + aRect.X(), + aRect.Height(), aRect.Width()); default: MOZ_CRASH("Unknown rotation"); } diff --git a/widget/cocoa/nsCocoaUtils.h b/widget/cocoa/nsCocoaUtils.h index 8f1b3655572bf..9a6c7cfb840a5 100644 --- a/widget/cocoa/nsCocoaUtils.h +++ b/widget/cocoa/nsCocoaUtils.h @@ -192,10 +192,10 @@ class nsCocoaUtils DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect, CGFloat aBackingScale) { - return NSMakeRect((CGFloat)aRect.x / aBackingScale, - (CGFloat)aRect.y / aBackingScale, - (CGFloat)aRect.width / aBackingScale, - (CGFloat)aRect.height / aBackingScale); + return NSMakeRect((CGFloat)aRect.X() / aBackingScale, + (CGFloat)aRect.Y() / aBackingScale, + (CGFloat)aRect.Width() / aBackingScale, + (CGFloat)aRect.Height() / aBackingScale); } // Returns the given y coordinate, which must be in screen coordinates, diff --git a/widget/headless/HeadlessWidget.cpp b/widget/headless/HeadlessWidget.cpp index 1312864725bf1..ea8b0d1258215 100644 --- a/widget/headless/HeadlessWidget.cpp +++ b/widget/headless/HeadlessWidget.cpp @@ -278,13 +278,12 @@ HeadlessWidget::Move(double aX, double aY) // Since a popup window's x/y coordinates are in relation to // the parent, the parent might have moved so we always move a // popup window. - if (x == mBounds.x && y == mBounds.y && + if (mBounds.IsEqualXY(x, y) && mWindowType != eWindowType_popup) { return; } - mBounds.x = x; - mBounds.y = y; + mBounds.MoveTo(x, y); NotifyRollupGeometryChange(); } @@ -325,13 +324,13 @@ HeadlessWidget::Resize(double aWidth, mBounds.SizeTo(LayoutDeviceIntSize(width, height)); if (mCompositorWidget) { - mCompositorWidget->NotifyClientSizeChanged(LayoutDeviceIntSize(mBounds.width, mBounds.height)); + mCompositorWidget->NotifyClientSizeChanged(LayoutDeviceIntSize(mBounds.Width(), mBounds.Height())); } if (mWidgetListener) { - mWidgetListener->WindowResized(this, mBounds.width, mBounds.height); + mWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height()); } if (mAttachedWidgetListener) { - mAttachedWidgetListener->WindowResized(this, mBounds.width, mBounds.height); + mAttachedWidgetListener->WindowResized(this, mBounds.Width(), mBounds.Height()); } } @@ -342,7 +341,7 @@ HeadlessWidget::Resize(double aX, double aHeight, bool aRepaint) { - if (mBounds.x != aX || mBounds.y != aY) { + if (!mBounds.IsEqualXY(aX, aY)) { NotifyWindowMoved(aX, aY); } return Resize(aWidth, aHeight, aRepaint); @@ -380,7 +379,7 @@ HeadlessWidget::ApplySizeModeSideEffects() switch(mSizeMode) { case nsSizeMode_Normal: { - Resize(mRestoreBounds.x, mRestoreBounds.y, mRestoreBounds.width, mRestoreBounds.height, false); + Resize(mRestoreBounds.X(), mRestoreBounds.Y(), mRestoreBounds.Width(), mRestoreBounds.Height(), false); break; } case nsSizeMode_Minimized: diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 3920833e7742c..2d2beca7e00d3 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -543,9 +543,9 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, *aPresContext = nullptr; // use a default size, in case of an error. - aScreenDragRect->MoveTo(aScreenPosition.x - mImageOffset.x, - aScreenPosition.y - mImageOffset.y); - aScreenDragRect->SizeTo(1, 1); + aScreenDragRect->SetRect(aScreenPosition.x - mImageOffset.x, + aScreenPosition.y - mImageOffset.y, + 1, 1); // if a drag image was specified, use that, otherwise, use the source node nsCOMPtr dragNode = mImage ? mImage.get() : aDOMNode; @@ -581,8 +581,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, screenPosition.x -= mImageOffset.x; screenPosition.y -= mImageOffset.y; LayoutDeviceIntPoint screenPoint = ConvertToUnscaledDevPixels(*aPresContext, screenPosition); - aScreenDragRect->x = screenPoint.x; - aScreenDragRect->y = screenPoint.y; + aScreenDragRect->MoveTo(screenPoint.x, screenPoint.y); // check if drag images are disabled bool enableDragImages = Preferences::GetBool(DRAGIMAGES_PREF, true); @@ -594,7 +593,9 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, CSSIntRect dragRect; if (aRegion) { // the region's coordinates are relative to the root frame - aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height); + int32_t dragRectX, dragRectY, dragRectW, dragRectH; + aRegion->GetBoundingBox(&dragRectX, &dragRectY, &dragRectW, &dragRectH); + dragRect.SetRect(dragRectX, dragRectY, dragRectW, dragRectH); nsIFrame* rootFrame = presShell->GetRootFrame(); CSSIntRect screenRect = rootFrame->GetScreenRect(); @@ -613,7 +614,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, nsIntRect dragRectDev = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()). ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel()); - aScreenDragRect->SizeTo(dragRectDev.width, dragRectDev.height); + aScreenDragRect->SizeTo(dragRectDev.Width(), dragRectDev.Height()); return NS_OK; } @@ -698,8 +699,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, // If an image was specified, reset the position from the offset that was supplied. if (mImage) { - aScreenDragRect->x = screenPoint.x; - aScreenDragRect->y = screenPoint.y; + aScreenDragRect->MoveTo(screenPoint.x, screenPoint.y); } return NS_OK; @@ -734,20 +734,19 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, rv = imgContainer->GetHeight(&imageHeight); NS_ENSURE_SUCCESS(rv, rv); - aScreenDragRect->width = aPresContext->CSSPixelsToDevPixels(imageWidth); - aScreenDragRect->height = aPresContext->CSSPixelsToDevPixels(imageHeight); + aScreenDragRect->SizeTo(aPresContext->CSSPixelsToDevPixels(imageWidth), + aPresContext->CSSPixelsToDevPixels(imageHeight)); } else { // XXX The canvas size should be converted to dev pixels. NS_ASSERTION(aCanvas, "both image and canvas are null"); nsIntSize sz = aCanvas->GetSize(); - aScreenDragRect->width = sz.width; - aScreenDragRect->height = sz.height; + aScreenDragRect->SizeTo(sz.width, sz.height); } nsIntSize destSize; - destSize.width = aScreenDragRect->width; - destSize.height = aScreenDragRect->height; + destSize.width = aScreenDragRect->Width(); + destSize.height = aScreenDragRect->Height(); if (destSize.width == 0 || destSize.height == 0) return NS_ERROR_FAILURE; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index da7b7b259d8da..5b9a1990a2178 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -748,7 +748,7 @@ nsBaseWidget::GetWindowClipRegion(nsTArray* aRects) if (mClipRects) { aRects->AppendElements(mClipRects.get(), mClipRectCount); } else { - aRects->AppendElement(LayoutDeviceIntRect(0, 0, mBounds.width, mBounds.height)); + aRects->AppendElement(LayoutDeviceIntRect(0, 0, mBounds.Width(), mBounds.Height())); } } @@ -837,10 +837,11 @@ nsBaseWidget::InfallibleMakeFullScreen(bool aFullScreen, nsIScreen* aScreen) } else if (mOriginalBounds) { if (BoundsUseDesktopPixels()) { DesktopRect deskRect = *mOriginalBounds / GetDesktopToDeviceScale(); - Resize(deskRect.x, deskRect.y, deskRect.width, deskRect.height, true); + Resize(deskRect.X(), deskRect.Y(), + deskRect.Width(), deskRect.Height(), true); } else { - Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width, - mOriginalBounds->height, true); + Resize(mOriginalBounds->X(), mOriginalBounds->Y(), + mOriginalBounds->Width(), mOriginalBounds->Height(), true); } } } @@ -902,7 +903,7 @@ nsBaseWidget::UseAPZ() void nsBaseWidget::CreateCompositor() { LayoutDeviceIntRect rect = GetBounds(); - CreateCompositor(rect.width, rect.height); + CreateCompositor(rect.Width(), rect.Height()); } already_AddRefed @@ -1534,13 +1535,13 @@ nsBaseWidget::ResizeClient(double aWidth, double aHeight, bool aRepaint) // if that's what this widget uses for the Move/Resize APIs if (BoundsUseDesktopPixels()) { DesktopSize desktopDelta = - (LayoutDeviceIntSize(mBounds.width, mBounds.height) - + (LayoutDeviceIntSize(mBounds.Width(), mBounds.Height()) - clientBounds.Size()) / GetDesktopToDeviceScale(); Resize(aWidth + desktopDelta.width, aHeight + desktopDelta.height, aRepaint); } else { - Resize(mBounds.width + (aWidth - clientBounds.width), - mBounds.height + (aHeight - clientBounds.height), aRepaint); + Resize(mBounds.Width() + (aWidth - clientBounds.Width()), + mBounds.Height() + (aHeight - clientBounds.Height()), aRepaint); } } @@ -1561,15 +1562,15 @@ nsBaseWidget::ResizeClient(double aX, DesktopToLayoutDeviceScale scale = GetDesktopToDeviceScale(); DesktopPoint desktopOffset = clientOffset / scale; DesktopSize desktopDelta = - (LayoutDeviceIntSize(mBounds.width, mBounds.height) - + (LayoutDeviceIntSize(mBounds.Width(), mBounds.Height()) - clientBounds.Size()) / scale; Resize(aX - desktopOffset.x, aY - desktopOffset.y, aWidth + desktopDelta.width, aHeight + desktopDelta.height, aRepaint); } else { Resize(aX - clientOffset.x, aY - clientOffset.y, - aWidth + mBounds.width - clientBounds.width, - aHeight + mBounds.height - clientBounds.height, + aWidth + mBounds.Width() - clientBounds.Width(), + aHeight + mBounds.Height() - clientBounds.Height(), aRepaint); } } @@ -1974,8 +1975,8 @@ nsBaseWidget::GetWidgetScreen() LayoutDeviceIntRect bounds = GetScreenBounds(); DesktopIntRect deskBounds = RoundedToInt(bounds / GetDesktopToDeviceScale()); nsCOMPtr screen; - screenManager->ScreenForRect(deskBounds.x, deskBounds.y, - deskBounds.width, deskBounds.height, + screenManager->ScreenForRect(deskBounds.X(), deskBounds.Y(), + deskBounds.Width(), deskBounds.Height(), getter_AddRefs(screen)); return screen.forget(); } @@ -2322,7 +2323,7 @@ void nsBaseWidget::UpdateScrollCapture() { // Don't capture if no container or no size. - if (!mScrollCaptureContainer || mBounds.width <= 0 || mBounds.height <= 0) { + if (!mScrollCaptureContainer || mBounds.IsEmpty()) { return; } @@ -3379,7 +3380,7 @@ nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut, (void *) aWidget, aWidgetName, aWindowID, - rect.x, rect.y, rect.width, rect.height + rect.X(), rect.Y(), rect.Width(), rect.Height() ); fprintf(aFileOut,"\n"); @@ -3408,7 +3409,7 @@ nsBaseWidget::debug_DumpInvalidate(FILE* aFileOut, if (aRect) { fprintf(aFileOut, " rect=%3d,%-3d %3d,%-3d", - aRect->x, aRect->y, aRect->width, aRect->height); + aRect->X(), aRect->Y(), aRect->Width(), aRect->Height()); } else { fprintf(aFileOut, " rect=%-15s", diff --git a/widget/nsNativeTheme.cpp b/widget/nsNativeTheme.cpp index e27feb7e4388f..65c4bafe739e8 100644 --- a/widget/nsNativeTheme.cpp +++ b/widget/nsNativeTheme.cpp @@ -482,7 +482,7 @@ nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame) return false; while ((aFrame = aFrame->GetNextSibling())) { - if (aFrame->GetRect().width > 0) + if (aFrame->GetRect().Width() > 0) return false; } return true; @@ -512,7 +512,7 @@ nsNativeTheme::IsFirstTab(nsIFrame* aFrame) return false; for (nsIFrame* first : aFrame->GetParent()->PrincipalChildList()) { - if (first->GetRect().width > 0 && + if (first->GetRect().Width() > 0 && first->GetContent()->IsXULElement(nsGkAtoms::tab)) return (first == aFrame); } @@ -547,7 +547,7 @@ nsNativeTheme::IsNextToSelectedTab(nsIFrame* aFrame, int32_t aOffset) nsIFrame* currentTab = aFrame->GetParent()->PrincipalChildList().FirstChild(); for (int32_t i = 0; currentTab; currentTab = currentTab->GetNextSibling()) { - if (currentTab->GetRect().width == 0) + if (currentTab->GetRect().Width() == 0) continue; if (aFrame == currentTab) thisTabIndex = i; @@ -625,7 +625,7 @@ nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent) LayoutDeviceIntRect selfBounds, parentBounds; selfBounds = aFrame->GetNearestWidget()->GetScreenBounds(); parentBounds = parent->GetNearestWidget()->GetScreenBounds(); - *aLeftOfParent = selfBounds.x < parentBounds.x; + *aLeftOfParent = selfBounds.X() < parentBounds.X(); } return true; } @@ -733,13 +733,13 @@ nsNativeTheme::GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame, nsIFrame* sibling = aFrame; do { sibling = aNextSibling ? sibling->GetNextSibling() : sibling->GetPrevSibling(); - } while (sibling && sibling->GetRect().width == 0); + } while (sibling && sibling->GetRect().Width() == 0); // Check same appearance and adjacency. if (!sibling || sibling->StyleDisplay()->mAppearance != aFrame->StyleDisplay()->mAppearance || - (sibling->GetRect().XMost() != aFrame->GetRect().x && - aFrame->GetRect().XMost() != sibling->GetRect().x)) + (sibling->GetRect().XMost() != aFrame->GetRect().X() && + aFrame->GetRect().XMost() != sibling->GetRect().X())) return nullptr; return sibling; } diff --git a/widget/windows/IMMHandler.cpp b/widget/windows/IMMHandler.cpp index 597d58dd122e1..b293efc39ad89 100644 --- a/widget/windows/IMMHandler.cpp +++ b/widget/windows/IMMHandler.cpp @@ -1736,10 +1736,10 @@ IMMHandler::HandleQueryCharPosition(nsWindow* aWindow, // documented) and its horizontal width. So, it might be better to set // top-right corner of the character and horizontal width, but we're not // sure if it doesn't cause any problems with a lot of IMEs... - pCharPosition->pt.x = screenRect.x; - pCharPosition->pt.y = screenRect.y; + pCharPosition->pt.x = screenRect.X(); + pCharPosition->pt.y = screenRect.Y(); - pCharPosition->cLineHeight = r.height; + pCharPosition->cLineHeight = r.Height(); WidgetQueryContentEvent editorRect(true, eQueryEditorRect, aWindow); aWindow->InitEvent(editorRect); @@ -1755,7 +1755,7 @@ IMMHandler::HandleQueryCharPosition(nsWindow* aWindow, LayoutDeviceIntRect editorRectInScreen; ResolveIMECaretPos(window, editorRectInWindow, nullptr, editorRectInScreen); ::SetRect(&pCharPosition->rcDocument, - editorRectInScreen.x, editorRectInScreen.y, + editorRectInScreen.X(), editorRectInScreen.Y(), editorRectInScreen.XMost(), editorRectInScreen.YMost()); } @@ -2264,7 +2264,7 @@ IMMHandler::GetCharacterRectOfSelectedTextAt(nsWindow* aWindow, ("GetCharacterRectOfSelectedTextAt, Succeeded, aOffset=%u, " "aCharRect={ x: %ld, y: %ld, width: %ld, height: %ld }, " "charRect.GetWritingMode()=%s", - aOffset, aCharRect.x, aCharRect.y, aCharRect.width, aCharRect.height, + aOffset, aCharRect.X(), aCharRect.Y(), aCharRect.Width(), aCharRect.Height(), GetWritingModeName(charRect.GetWritingMode()).get())); return true; } @@ -2299,7 +2299,7 @@ IMMHandler::GetCaretRect(nsWindow* aWindow, ("GetCaretRect, SUCCEEDED, " "aCaretRect={ x: %ld, y: %ld, width: %ld, height: %ld }, " "caretRect.GetWritingMode()=%s", - aCaretRect.x, aCaretRect.y, aCaretRect.width, aCaretRect.height, + aCaretRect.X(), aCaretRect.Y(), aCaretRect.Width(), aCaretRect.Height(), GetWritingModeName(caretRect.GetWritingMode()).get())); return true; } @@ -2326,17 +2326,17 @@ IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow, ResolveIMECaretPos(toplevelWindow, r, aWindow, caretRect); } else { NS_WARNING("failed to get caret rect"); - caretRect.width = 1; + caretRect.SetWidth(1); } if (!mNativeCaretIsCreated) { mNativeCaretIsCreated = ::CreateCaret(aWindow->GetWindowHandle(), nullptr, - caretRect.width, caretRect.height); + caretRect.Width(), caretRect.Height()); MOZ_LOG(gIMMLog, LogLevel::Info, ("SetIMERelatedWindowsPos, mNativeCaretIsCreated=%s, " "width=%ld, height=%ld", - GetBoolName(mNativeCaretIsCreated), caretRect.width, caretRect.height)); + GetBoolName(mNativeCaretIsCreated), caretRect.Width(), caretRect.Height())); } - ::SetCaretPos(caretRect.x, caretRect.y); + ::SetCaretPos(caretRect.X(), caretRect.Y()); if (ShouldDrawCompositionStringOurselves()) { MOZ_LOG(gIMMLog, LogLevel::Info, @@ -2388,22 +2388,22 @@ IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow, candForm.dwStyle = CFS_EXCLUDE; // Candidate window shouldn't overlap the target clause in any writing // mode. - candForm.rcArea.left = targetClauseRect.x; + candForm.rcArea.left = targetClauseRect.X(); candForm.rcArea.right = targetClauseRect.XMost(); - candForm.rcArea.top = targetClauseRect.y; + candForm.rcArea.top = targetClauseRect.Y(); candForm.rcArea.bottom = targetClauseRect.YMost(); if (!writingMode.IsVertical()) { // In horizontal layout, current point of interest should be top-left // of the first character. - candForm.ptCurrentPos.x = firstTargetCharRect.x; - candForm.ptCurrentPos.y = firstTargetCharRect.y; + candForm.ptCurrentPos.x = firstTargetCharRect.X(); + candForm.ptCurrentPos.y = firstTargetCharRect.Y(); } else if (writingMode.IsVerticalRL()) { // In vertical layout (RL), candidate window should be positioned right // side of target clause. However, we don't set vertical writing font // to the IME. Therefore, the candidate window may be positioned // bottom-left of target clause rect with these information. - candForm.ptCurrentPos.x = targetClauseRect.x; - candForm.ptCurrentPos.y = targetClauseRect.y; + candForm.ptCurrentPos.x = targetClauseRect.X(); + candForm.ptCurrentPos.y = targetClauseRect.Y(); } else { MOZ_ASSERT(writingMode.IsVerticalLR(), "Did we miss some causes?"); // In vertical layout (LR), candidate window should be poisitioned left @@ -2411,7 +2411,7 @@ IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow, // to the IME, the candidate window may be positioned bottom-right of // the target clause rect with these information. candForm.ptCurrentPos.x = targetClauseRect.XMost(); - candForm.ptCurrentPos.y = targetClauseRect.y; + candForm.ptCurrentPos.y = targetClauseRect.Y(); } } else { // If vertical writing is not supported by IME, let's set candidate @@ -2419,7 +2419,7 @@ IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow, // the position must be the safest position to prevent the candidate // window to overlap with the target clause. candForm.dwStyle = CFS_CANDIDATEPOS; - candForm.ptCurrentPos.x = targetClauseRect.x; + candForm.ptCurrentPos.x = targetClauseRect.X(); candForm.ptCurrentPos.y = targetClauseRect.YMost(); } MOZ_LOG(gIMMLog, LogLevel::Info, @@ -2443,9 +2443,9 @@ IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow, COMPOSITIONFORM compForm; compForm.dwStyle = CFS_POINT; compForm.ptCurrentPos.x = - !writingMode.IsVerticalLR() ? firstSelectedCharRect.x : + !writingMode.IsVerticalLR() ? firstSelectedCharRect.X() : firstSelectedCharRect.XMost(); - compForm.ptCurrentPos.y = firstSelectedCharRect.y; + compForm.ptCurrentPos.y = firstSelectedCharRect.Y(); ::ImmSetCompositionWindow(aContext.get(), &compForm); } @@ -2473,19 +2473,18 @@ IMMHandler::SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow, editorRectEvent.mReply.mRect + toplevelWindow->WidgetToScreenOffset(); LayoutDeviceIntRect winRectInScreen = aWindow->GetClientBounds(); // composition window cannot be positioned on the edge of client area. - winRectInScreen.width--; - winRectInScreen.height--; + winRectInScreen.SizeTo(winRectInScreen.Width() - 1, + winRectInScreen.Height() - 1); LayoutDeviceIntRect clippedPluginRect; - clippedPluginRect.x = - std::min(std::max(pluginRectInScreen.x, winRectInScreen.x), - winRectInScreen.XMost()); - clippedPluginRect.y = - std::min(std::max(pluginRectInScreen.y, winRectInScreen.y), - winRectInScreen.YMost()); + clippedPluginRect.MoveTo( + std::min(std::max(pluginRectInScreen.X(), winRectInScreen.X()), + winRectInScreen.XMost()), + std::min(std::max(pluginRectInScreen.Y(), winRectInScreen.Y()), + winRectInScreen.YMost())); int32_t xMost = std::min(pluginRectInScreen.XMost(), winRectInScreen.XMost()); int32_t yMost = std::min(pluginRectInScreen.YMost(), winRectInScreen.YMost()); - clippedPluginRect.width = std::max(0, xMost - clippedPluginRect.x); - clippedPluginRect.height = std::max(0, yMost - clippedPluginRect.y); + clippedPluginRect.SizeTo(std::max(0, xMost - clippedPluginRect.X()), + std::max(0, yMost - clippedPluginRect.Y())); clippedPluginRect -= aWindow->WidgetToScreenOffset(); // Cover the plugin with native caret. This prevents IME's window and plugin @@ -2495,8 +2494,8 @@ IMMHandler::SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow, } mNativeCaretIsCreated = ::CreateCaret(aWindow->GetWindowHandle(), nullptr, - clippedPluginRect.width, clippedPluginRect.height); - ::SetCaretPos(clippedPluginRect.x, clippedPluginRect.y); + clippedPluginRect.Width(), clippedPluginRect.Height()); + ::SetCaretPos(clippedPluginRect.X(), clippedPluginRect.Y()); // Set the composition window to bottom-left of the clipped plugin. // As far as we know, there is no IME for RTL language. Therefore, this code @@ -2721,7 +2720,7 @@ IMMHandler::OnMouseButtonEvent(nsWindow* aWindow, aIMENotification.mMouseButtonEventData.mCursorPos.AsIntPoint(); nsIntRect charRect = aIMENotification.mMouseButtonEventData.mCharRect.AsIntRect(); - int32_t cursorXInChar = cursorPos.x - charRect.x; + int32_t cursorXInChar = cursorPos.x - charRect.X(); // The event might hit to zero-width character, see bug 694913. // The reason might be: // * There are some zero-width characters are actually. @@ -2730,8 +2729,8 @@ IMMHandler::OnMouseButtonEvent(nsWindow* aWindow, // We should assume that user clicked on right most of the zero-width // character in such case. int positioning = 1; - if (charRect.width > 0) { - positioning = cursorXInChar * 4 / charRect.width; + if (charRect.Width() > 0) { + positioning = cursorXInChar * 4 / charRect.Width(); positioning = (positioning + 2) % 4; } diff --git a/widget/windows/ScreenHelperWin.cpp b/widget/windows/ScreenHelperWin.cpp index accfec2c4a520..23ec5ccde1ec8 100644 --- a/widget/windows/ScreenHelperWin.cpp +++ b/widget/windows/ScreenHelperWin.cpp @@ -51,8 +51,8 @@ CollectMonitors(HMONITOR aMon, HDC hDCScreen, LPRECT, LPARAM ioParam) float dpi = WinUtils::MonitorDPI(aMon); MOZ_LOG(sScreenLog, LogLevel::Debug, ("New screen [%d %d %d %d (%d %d %d %d) %d %f %f %f]", - rect.x, rect.y, rect.width, rect.height, - availRect.x, availRect.y, availRect.width, availRect.height, + rect.X(), rect.Y(), rect.Width(), rect.Height(), + availRect.X(), availRect.Y(), availRect.Width(), availRect.Height(), pixelDepth, contentsScaleFactor.scale, defaultCssScaleFactor.scale, dpi)); auto screen = new Screen(rect, availRect, diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp index 9e8b54e9213d3..5338ac0f2149f 100644 --- a/widget/windows/TSFTextStore.cpp +++ b/widget/windows/TSFTextStore.cpp @@ -4480,10 +4480,10 @@ TSFTextStore::GetTextExt(TsViewCookie vcView, } // IMEs don't like empty rects, fix here - if (event.mReply.mRect.width <= 0) - event.mReply.mRect.width = 1; - if (event.mReply.mRect.height <= 0) - event.mReply.mRect.height = 1; + if (event.mReply.mRect.Width() <= 0) + event.mReply.mRect.SetWidth(1); + if (event.mReply.mRect.Height() <= 0) + event.mReply.mRect.SetHeight(1); // convert to unclipped screen rect nsWindow* refWindow = static_cast( @@ -4509,7 +4509,7 @@ TSFTextStore::GetTextExt(TsViewCookie vcView, // clip text rect to bounding rect RECT textRect; - ::SetRect(&textRect, event.mReply.mRect.x, event.mReply.mRect.y, + ::SetRect(&textRect, event.mReply.mRect.X(), event.mReply.mRect.Y(), event.mReply.mRect.XMost(), event.mReply.mRect.YMost()); if (!::IntersectRect(prc, prc, &textRect)) // Text is not visible @@ -4621,7 +4621,7 @@ TSFTextStore::GetScreenExtInternal(RECT& aScreenExt) boundRect.IntersectRect(event.mReply.mRect, boundRect); if (!boundRect.IsEmpty()) { boundRect.MoveBy(refWindow->WidgetToScreenOffset()); - ::SetRect(&aScreenExt, boundRect.x, boundRect.y, + ::SetRect(&aScreenExt, boundRect.X(), boundRect.Y(), boundRect.XMost(), boundRect.YMost()); } else { ::SetRectEmpty(&aScreenExt); @@ -5941,9 +5941,9 @@ TSFTextStore::OnMouseButtonEventInternal( nsIntPoint cursorPos = aIMENotification.mMouseButtonEventData.mCursorPos.AsIntPoint(); ULONG quadrant = 1; - if (charRect.width > 0) { - int32_t cursorXInChar = cursorPos.x - charRect.x; - quadrant = cursorXInChar * 4 / charRect.width; + if (charRect.Width() > 0) { + int32_t cursorXInChar = cursorPos.x - charRect.X(); + quadrant = cursorXInChar * 4 / charRect.Width(); quadrant = (quadrant + 2) % 4; } ULONG edge = quadrant < 2 ? offset + 1 : offset; @@ -6038,7 +6038,7 @@ TSFTextStore::CreateNativeCaret() LayoutDeviceIntRect& caretRect = queryCaretRect.mReply.mRect; mNativeCaretIsCreated = ::CreateCaret(mWidget->GetWindowHandle(), nullptr, - caretRect.width, caretRect.height); + caretRect.Width(), caretRect.Height()); if (!mNativeCaretIsCreated) { MOZ_LOG(sTextStoreLog, LogLevel::Error, ("0x%p TSFTextStore::CreateNativeCaret() FAILED due to " @@ -6060,7 +6060,7 @@ TSFTextStore::CreateNativeCaret() caretRect.MoveBy(-window->WidgetToScreenOffset()); } - ::SetCaretPos(caretRect.x, caretRect.y); + ::SetCaretPos(caretRect.X(), caretRect.Y()); } void diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 95d9b039287bc..fad5954942032 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -673,10 +673,10 @@ WinUtils::MonitorFromRect(const gfx::Rect& rect) IsPerMonitorDPIAware() ? 1.0 : LogToPhysFactor(GetPrimaryMonitor()); RECT globalWindowBounds = { - NSToIntRound(dpiScale * rect.x), - NSToIntRound(dpiScale * rect.y), - NSToIntRound(dpiScale * (rect.x + rect.width)), - NSToIntRound(dpiScale * (rect.y + rect.height)) + NSToIntRound(dpiScale * rect.X()), + NSToIntRound(dpiScale * rect.Y()), + NSToIntRound(dpiScale * (rect.XMost())), + NSToIntRound(dpiScale * (rect.YMost())) }; return ::MonitorFromRect(&globalWindowBounds, MONITOR_DEFAULTTONEAREST); @@ -1174,8 +1174,8 @@ WinUtils::InvalidatePluginAsWorkaround(nsIWidget* aWidget, if (windowRect.top == 0 && windowRect.left == 0) { RECT rect; - rect.left = aRect.x; - rect.top = aRect.y; + rect.left = aRect.X(); + rect.top = aRect.Y(); rect.right = aRect.XMost(); rect.bottom = aRect.YMost(); diff --git a/widget/windows/nsDragService.cpp b/widget/windows/nsDragService.cpp index bc7cabdfd21c9..a6c4a749183b2 100644 --- a/widget/windows/nsDragService.cpp +++ b/widget/windows/nsDragService.cpp @@ -87,7 +87,7 @@ nsDragService::CreateDragImage(nsIDOMNode *aDOMNode, if (!surface) return false; - uint32_t bmWidth = dragRect.width, bmHeight = dragRect.height; + uint32_t bmWidth = dragRect.Width(), bmHeight = dragRect.Height(); if (bmWidth == 0 || bmHeight == 0) return false; @@ -152,8 +152,8 @@ nsDragService::CreateDragImage(nsIDOMNode *aDOMNode, LayoutDeviceIntPoint screenPoint = ConvertToUnscaledDevPixels(pc, mScreenPosition); - psdi->ptOffset.x = screenPoint.x - dragRect.x; - psdi->ptOffset.y = screenPoint.y - dragRect.y; + psdi->ptOffset.x = screenPoint.x - dragRect.X(); + psdi->ptOffset.y = screenPoint.y - dragRect.Y(); DeleteDC(hdcSrc); } diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index bd6f76ca3e52e..4f3071d86c553 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -1584,8 +1584,8 @@ nsNativeThemeWin::DrawWidgetBackground(gfxContext* aContext, gfxFloat p2a = gfxFloat(aFrame->PresContext()->AppUnitsPerDevPixel()); RECT widgetRect; RECT clipRect; - gfxRect tr(aRect.x, aRect.y, aRect.width, aRect.height), - dr(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); + gfxRect tr(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()), + dr(aDirtyRect.X(), aDirtyRect.Y(), aDirtyRect.Width(), aDirtyRect.Height()); tr.Scale(1.0 / (p2a * themeScale)); dr.Scale(1.0 / (p2a * themeScale)); @@ -3551,8 +3551,8 @@ nsresult nsNativeThemeWin::ClassicDrawWidgetBackground(gfxContext* aContext, gfxFloat p2a = gfxFloat(aFrame->PresContext()->AppUnitsPerDevPixel()); RECT widgetRect; - gfxRect tr(aRect.x, aRect.y, aRect.width, aRect.height), - dr(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); + gfxRect tr(aRect.X(), aRect.Y(), aRect.Width(), aRect.Height()), + dr(aDirtyRect.X(), aDirtyRect.Y(), aDirtyRect.Width(), aDirtyRect.Height()); tr.Scale(1.0 / p2a); dr.Scale(1.0 / p2a); diff --git a/widget/windows/nsPrintDialogUtil.cpp b/widget/windows/nsPrintDialogUtil.cpp index 14ea99d7d2791..d25a0bc8d8de1 100644 --- a/widget/windows/nsPrintDialogUtil.cpp +++ b/widget/windows/nsPrintDialogUtil.cpp @@ -230,10 +230,10 @@ CreateControl(LPCWSTR aType, HWND hWnd = ::CreateWindowW(aType, aStr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | aStyle, - aRect.x, - aRect.y, - aRect.width, - aRect.height, + aRect.X(), + aRect.Y(), + aRect.Width(), + aRect.Height(), (HWND)aHdlg, (HMENU)(intptr_t)aId, aHInst, diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index cb9ee3fdb5986..f7258e56da31a 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -834,10 +834,10 @@ nsWindow::Create(nsIWidget* aParent, className, L"", style, - aRect.x, - aRect.y, - aRect.width, - GetHeight(aRect.height), + aRect.X(), + aRect.Y(), + aRect.Width(), + GetHeight(aRect.Height()), parent, nullptr, nsToolkit::mDllInstance, @@ -1435,14 +1435,14 @@ nsWindow::CreateScrollSnapshot() // We failed to get the clip assume that we need a full fallback. clip.left = 0; clip.top = 0; - clip.right = mBounds.width; - clip.bottom = mBounds.height; + clip.right = mBounds.Width(); + clip.bottom = mBounds.Height(); return GetFallbackScrollSnapshot(clip); } // Check that the window is in a position to snapshot. We don't check for // clipped width as that doesn't currently matter for APZ scrolling. - if (clip.top || clip.bottom != mBounds.height) { + if (clip.top || clip.bottom != mBounds.Height()) { return GetFallbackScrollSnapshot(clip); } @@ -1454,9 +1454,9 @@ nsWindow::CreateScrollSnapshot() ::ReleaseDC(mWnd, windowDC); }); - gfx::IntSize snapshotSize(mBounds.width, mBounds.height); + gfx::IntSize snapshotSize(mBounds.Width(), mBounds.Height()); ScrollSnapshot* snapshot; - if (clip.left || clip.right != mBounds.width) { + if (clip.left || clip.right != mBounds.Width()) { // Can't do a full snapshot, so use the partial snapshot. snapshot = EnsureSnapshotSurface(mPartialSnapshot, snapshotSize); } else { @@ -1480,7 +1480,7 @@ nsWindow::CreateScrollSnapshot() already_AddRefed nsWindow::GetFallbackScrollSnapshot(const RECT& aRequiredClip) { - gfx::IntSize snapshotSize(mBounds.width, mBounds.height); + gfx::IntSize snapshotSize(mBounds.Width(), mBounds.Height()); // If the current snapshot is the correct size and covers the required clip, // just keep that by returning null. @@ -1693,7 +1693,7 @@ void nsWindow::SetThemeRegion() (mWindowType == eWindowType_popup && !IsPopupWithTitleBar() && (mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) { HRGN hRgn = nullptr; - RECT rect = {0,0,mBounds.width,mBounds.height}; + RECT rect = {0,0,mBounds.Width(),mBounds.Height()}; HDC dc = ::GetDC(mWnd); GetThemeBackgroundRegion(nsUXThemeData::GetTheme(eUXTooltip), dc, TTP_STANDARD, TS_NORMAL, &rect, &hRgn); @@ -1804,14 +1804,13 @@ nsWindow::Move(double aX, double aY) // Only perform this check for non-popup windows, since the positioning can // in fact change even when the x/y do not. We always need to perform the // check. See bug #97805 for details. - if (mWindowType != eWindowType_popup && (mBounds.x == x) && (mBounds.y == y)) + if (mWindowType != eWindowType_popup && mBounds.IsEqualXY(x, y)) { // Nothing to do, since it is already positioned correctly. return; } - mBounds.x = x; - mBounds.y = y; + mBounds.MoveTo(x, y); if (mWnd) { #ifdef DEBUG @@ -1843,7 +1842,7 @@ nsWindow::Move(double aX, double aY) if (IsPlugin() && !mLayerManager && mClipRects && - (mClipRectCount != 1 || !mClipRects[0].IsEqualInterior(LayoutDeviceIntRect(0, 0, mBounds.width, mBounds.height)))) { + (mClipRectCount != 1 || !mClipRects[0].IsEqualInterior(LayoutDeviceIntRect(0, 0, mBounds.Width(), mBounds.Height())))) { flags |= SWP_NOCOPYBITS; } double oldScale = mDefaultScale; @@ -1875,7 +1874,7 @@ nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) ConstrainSize(&width, &height); // Avoid unnecessary resizing calls - if (mBounds.width == width && mBounds.height == height) { + if (mBounds.IsEqualSize(width, height)) { if (aRepaint) { Invalidate(); } @@ -1883,8 +1882,7 @@ nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) } // Set cached value for lightweight and printing - mBounds.width = width; - mBounds.height = height; + mBounds.SizeTo(width, height); if (mWnd) { UINT flags = SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE; @@ -1928,8 +1926,7 @@ nsWindow::Resize(double aX, double aY, double aWidth, ConstrainSize(&width, &height); // Avoid unnecessary resizing calls - if (mBounds.x == x && mBounds.y == y && - mBounds.width == width && mBounds.height == height) { + if (mBounds.IsEqualRect(x, y, width, height)) { if (aRepaint) { Invalidate(); } @@ -1937,10 +1934,7 @@ nsWindow::Resize(double aX, double aY, double aWidth, } // Set cached value for lightweight and printing - mBounds.x = x; - mBounds.y = y; - mBounds.width = width; - mBounds.height = height; + mBounds.SetRect(x, y, width, height); if (mWnd) { UINT flags = SWP_NOZORDER | SWP_NOACTIVATE; @@ -2147,8 +2141,8 @@ nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) // We need to use the window size in the kind of pixels used for window- // manipulation APIs. - int32_t logWidth = std::max(NSToIntRound(mBounds.width / dpiScale), 1); - int32_t logHeight = std::max(NSToIntRound(mBounds.height / dpiScale), 1); + int32_t logWidth = std::max(NSToIntRound(mBounds.Width() / dpiScale), 1); + int32_t logHeight = std::max(NSToIntRound(mBounds.Height() / dpiScale), 1); /* get our playing field. use the current screen, or failing that for any reason, use device caps for the default screen. */ @@ -2292,14 +2286,12 @@ nsWindow::GetBounds() LayoutDeviceIntRect rect; // assign size - rect.width = r.right - r.left; - rect.height = r.bottom - r.top; + rect.SizeTo(r.right - r.left, r.bottom - r.top); // popup window bounds' are in screen coordinates, not relative to parent // window if (mWindowType == eWindowType_popup) { - rect.x = r.left; - rect.y = r.top; + rect.MoveTo(r.left, r.top); return rect; } @@ -2344,8 +2336,7 @@ nsWindow::GetBounds() r.top -= clientOffset.y; } } - rect.x = r.left; - rect.y = r.top; + rect.MoveTo(r.left, r.top); return rect; } @@ -2363,8 +2354,7 @@ nsWindow::GetClientBounds() LayoutDeviceIntRect bounds = GetBounds(); LayoutDeviceIntRect rect; rect.MoveTo(bounds.TopLeft() + GetClientOffset()); - rect.width = r.right - r.left; - rect.height = r.bottom - r.top; + rect.SizeTo(r.right - r.left, r.bottom - r.top); return rect; } @@ -2379,12 +2369,7 @@ nsWindow::GetScreenBounds() RECT r; VERIFY(::GetWindowRect(mWnd, &r)); - LayoutDeviceIntRect rect; - rect.x = r.left; - rect.y = r.top; - rect.width = r.right - r.left; - rect.height = r.bottom - r.top; - return rect; + return LayoutDeviceIntRect(r.left, r.top, r.right - r.left, r.bottom - r.top); } nsresult @@ -3094,16 +3079,16 @@ void nsWindow::UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) // priority is to include the bounds of all plugins. LayoutDeviceIntRect largest = aOpaqueRegion.GetLargestRectangle(pluginBounds); - margins.cxLeftWidth = largest.x; - margins.cxRightWidth = clientBounds.width - largest.XMost(); - margins.cyBottomHeight = clientBounds.height - largest.YMost(); + margins.cxLeftWidth = largest.X(); + margins.cxRightWidth = clientBounds.Width() - largest.XMost(); + margins.cyBottomHeight = clientBounds.Height() - largest.YMost(); if (mCustomNonClient) { // The minimum glass height must be the caption buttons height, // otherwise the buttons are drawn incorrectly. - largest.y = std::max(largest.y, - nsUXThemeData::GetCommandButtonBoxMetrics().cy); + largest.MoveToY(std::max(largest.Y(), + nsUXThemeData::GetCommandButtonBoxMetrics().cy)); } - margins.cyTopHeight = largest.y; + margins.cyTopHeight = largest.Y(); } // Only update glass area if there are changes @@ -3276,10 +3261,10 @@ nsWindow::Invalidate(const LayoutDeviceIntRect& aRect) RECT rect; - rect.left = aRect.x; - rect.top = aRect.y; - rect.right = aRect.x + aRect.width; - rect.bottom = aRect.y + aRect.height; + rect.left = aRect.X(); + rect.top = aRect.Y(); + rect.right = aRect.XMost(); + rect.bottom = aRect.YMost(); VERIFY(::InvalidateRect(mWnd, &rect, FALSE)); } @@ -3366,8 +3351,8 @@ FullscreenTransitionThreadProc(LPVOID lpParam) ::SetWindowLongW(wnd, GWL_STYLE, 0); ::SetWindowLongW(wnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE); - ::SetWindowPos(wnd, HWND_TOPMOST, data->mBounds.x, data->mBounds.y, - data->mBounds.width, data->mBounds.height, 0); + ::SetWindowPos(wnd, HWND_TOPMOST, data->mBounds.X(), data->mBounds.Y(), + data->mBounds.Width(), data->mBounds.Height(), 0); data->mWnd = wnd; ::ReleaseSemaphore(data->mSemaphore, 1, nullptr); // The initialization data may no longer be valid @@ -3426,10 +3411,10 @@ nsWindow::PrepareForFullscreenTransition(nsISupports** aData) MOZ_ASSERT(BoundsUseDesktopPixels(), "Should only be called on top-level window"); double scale = GetDesktopToDeviceScale().scale; // XXX or GetDefaultScale() ? - initData.mBounds.x = NSToIntRound(x * scale); - initData.mBounds.y = NSToIntRound(y * scale); - initData.mBounds.width = NSToIntRound(width * scale); - initData.mBounds.height = NSToIntRound(height * scale); + initData.mBounds.SetRect(NSToIntRound(x * scale), + NSToIntRound(y * scale), + NSToIntRound(width * scale), + NSToIntRound(height * scale)); // Create a semaphore for synchronizing the window handle which will // be created by the transition thread and used by the main thread for @@ -4024,8 +4009,8 @@ nsWindow::OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) LayoutDeviceIntRect widgetRect = GetScreenBounds(); LayoutDeviceIntRect buttonRect(aButtonRect + widgetRect.TopLeft()); - LayoutDeviceIntPoint centerOfButton(buttonRect.x + buttonRect.width / 2, - buttonRect.y + buttonRect.height / 2); + LayoutDeviceIntPoint centerOfButton(buttonRect.X() + buttonRect.Width() / 2, + buttonRect.Y() + buttonRect.Height() / 2); // The center of the button can be outside of the widget. // E.g., it could be hidden by scrolling. if (!widgetRect.Contains(centerOfButton)) { @@ -4074,7 +4059,7 @@ nsWindow::UpdateThemeGeometries(const nsTArray& aThemeGeometries) // Extend the bounds by one pixel to the right, because that's how much // the actual window button shape extends past the client area of the // window (and overlaps the right window frame). - bounds.width += 1; + bounds.SetWidth(bounds.Width() + 1); if (!mWindowButtonsRect) { mWindowButtonsRect = Some(bounds); } @@ -4640,8 +4625,7 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, if (mWidgetListener) { if (aEventMessage == eMouseMove) { LayoutDeviceIntRect rect = GetBounds(); - rect.x = 0; - rect.y = 0; + rect.MoveTo(0, 0); if (rect.Contains(event.mRefPoint)) { if (sCurrentWindow == nullptr || sCurrentWindow != this) { @@ -6728,9 +6712,7 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) // Handle window position changes if (!(wp->flags & SWP_NOMOVE)) { - mBounds.x = wp->x; - mBounds.y = wp->y; - + mBounds.MoveTo(wp->x, wp->y); NotifyWindowMoved(wp->x, wp->y); } @@ -6780,8 +6762,7 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) RDW_ALLCHILDREN); } - mBounds.width = newWidth; - mBounds.height = newHeight; + mBounds.SizeTo(newWidth, newHeight); mLastSize.width = newWidth; mLastSize.height = newHeight; @@ -6801,8 +6782,7 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) // Recalculate the width and height based on the client area for gecko events. if (::GetClientRect(mWnd, &r)) { - rect.width = r.right - r.left; - rect.height = r.bottom - r.top; + rect.SizeTo(r.right - r.left, r.bottom - r.top); } // Send a gecko resize event @@ -7090,11 +7070,11 @@ nsWindow::ConfigureChildren(const nsTArray& aConfigurations) NS_ENSURE_SUCCESS(rv, rv); LayoutDeviceIntRect bounds = w->GetBounds(); if (bounds.Size() != configuration.mBounds.Size()) { - w->Resize(configuration.mBounds.x, configuration.mBounds.y, - configuration.mBounds.width, configuration.mBounds.height, + w->Resize(configuration.mBounds.X(), configuration.mBounds.Y(), + configuration.mBounds.Width(), configuration.mBounds.Height(), true); } else if (bounds.TopLeft() != configuration.mBounds.TopLeft()) { - w->Move(configuration.mBounds.x, configuration.mBounds.y); + w->Move(configuration.mBounds.X(), configuration.mBounds.Y()); if (gfxWindowsPlatform::GetPlatform()->IsDirect2DBackend() || @@ -7104,8 +7084,8 @@ nsWindow::ConfigureChildren(const nsTArray& aConfigurations) // underlying problem should be found and fixed! LayoutDeviceIntRegion r; r.Sub(bounds, configuration.mBounds); - r.MoveBy(-bounds.x, - -bounds.y); + r.MoveBy(-bounds.X(), + -bounds.Y()); LayoutDeviceIntRect toInvalidate = r.GetBounds(); WinUtils::InvalidatePluginAsWorkaround(w, toInvalidate); @@ -7132,9 +7112,9 @@ CreateHRGNFromArray(const nsTArray& aRects) for (uint32_t i = 0; i < aRects.Length(); ++i) { const LayoutDeviceIntRect& r = aRects[i]; bounds.UnionRect(bounds, r); - ::SetRect(&rects[i], r.x, r.y, r.XMost(), r.YMost()); + ::SetRect(&rects[i], r.X(), r.Y(), r.XMost(), r.YMost()); } - ::SetRect(&data->rdh.rcBound, bounds.x, bounds.y, bounds.XMost(), bounds.YMost()); + ::SetRect(&data->rdh.rcBound, bounds.X(), bounds.Y(), bounds.XMost(), bounds.YMost()); return ::ExtCreateRegion(nullptr, buf.Length(), data); } @@ -7266,11 +7246,11 @@ void nsWindow::OnDestroy() bool nsWindow::OnResize(nsIntRect &aWindowRect) { bool result = mWidgetListener ? - mWidgetListener->WindowResized(this, aWindowRect.width, aWindowRect.height) : false; + mWidgetListener->WindowResized(this, aWindowRect.Width(), aWindowRect.Height()) : false; // If there is an attached view, inform it as well as the normal widget listener. if (mAttachedWidgetListener) { - return mAttachedWidgetListener->WindowResized(this, aWindowRect.width, aWindowRect.height); + return mAttachedWidgetListener->WindowResized(this, aWindowRect.Width(), aWindowRect.Height()); } return result; @@ -8291,10 +8271,10 @@ nsWindow::SetCandidateWindowForPlugin(const CandidateWindowPosition& aPosition) form.dwIndex = 0; if (aPosition.mExcludeRect) { form.dwStyle = CFS_EXCLUDE; - form.rcArea.left = aPosition.mRect.x; - form.rcArea.top = aPosition.mRect.y; - form.rcArea.right = aPosition.mRect.x + aPosition.mRect.width; - form.rcArea.bottom = aPosition.mRect.y + aPosition.mRect.height; + form.rcArea.left = aPosition.mRect.X(); + form.rcArea.top = aPosition.mRect.Y(); + form.rcArea.right = aPosition.mRect.XMost(); + form.rcArea.bottom = aPosition.mRect.YMost(); } else { form.dwStyle = CFS_CANDIDATEPOS; }