diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c809874b258b..8c2522400036 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6884,9 +6884,9 @@ nsresult nsDocShell::CaptureState() { // Capture the current content viewer bounds. if (mDocumentViewer) { - nsIntRect bounds; + LayoutDeviceIntRect bounds; mDocumentViewer->GetBounds(bounds); - mOSHE->SetViewerBounds(bounds); + mOSHE->SetViewerBounds(bounds.ToUnknownRect()); } // Capture the docshell hierarchy. @@ -7234,7 +7234,7 @@ nsresult nsDocShell::RestoreFromHistory() { nsView* rootViewSibling = nullptr; nsView* rootViewParent = nullptr; - nsIntRect newBounds(0, 0, 0, 0); + LayoutDeviceIntRect newBounds(0, 0, 0, 0); PresShell* oldPresShell = GetPresShell(); if (oldPresShell) { @@ -7541,7 +7541,8 @@ nsresult nsDocShell::RestoreFromHistory() { // cached viewer size (skipping the resize if they are equal). if (newRootView) { - if (!newBounds.IsEmpty() && !newBounds.IsEqualEdges(oldBounds)) { + if (!newBounds.IsEmpty() && + !newBounds.ToUnknownRect().IsEqualEdges(oldBounds)) { MOZ_LOG(gPageCacheLog, LogLevel::Debug, ("resize widget(%d, %d, %d, %d)", newBounds.x, newBounds.y, newBounds.width, newBounds.height)); @@ -7938,7 +7939,7 @@ nsresult nsDocShell::SetupNewViewer(nsIDocumentViewer* aNewViewer, nsCOMPtr widget; NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE); - nsIntRect bounds(x, y, cx, cy); + LayoutDeviceIntRect bounds(x, y, cx, cy); mDocumentViewer->SetNavigationTiming(mTiming); diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 0cf72f8fffb4..26772871c39d 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -1163,7 +1163,7 @@ class nsDocShell final : public nsDocLoader, nsWeakPtr mBrowserChild; // Dimensions of the docshell - nsIntRect mBounds; + mozilla::LayoutDeviceIntRect mBounds; /** * Content-Type Hint of the most-recently initiated load. Used for diff --git a/docshell/base/nsIDocumentViewer.idl b/docshell/base/nsIDocumentViewer.idl index 27510dc87905..ec6c864c18b1 100644 --- a/docshell/base/nsIDocumentViewer.idl +++ b/docshell/base/nsIDocumentViewer.idl @@ -33,7 +33,7 @@ class RemotePrintJobChild; %} [ptr] native nsIWidgetPtr(nsIWidget); -[ref] native nsIntRectRef(nsIntRect); +[ref] native LayoutDeviceIntRectRef(mozilla::LayoutDeviceIntRect); [ptr] native nsPresContextPtr(nsPresContext); [ptr] native nsViewPtr(nsView); [ptr] native nsDOMNavigationTimingPtr(nsDOMNavigationTiming); @@ -46,7 +46,7 @@ class RemotePrintJobChild; interface nsIDocumentViewer : nsISupports { [noscript] void init(in nsIWidgetPtr aParentWidget, - [const] in nsIntRectRef aBounds, + [const] in LayoutDeviceIntRectRef aBounds, in WindowGlobalChildPtr aWindowActor); attribute nsIDocShell container; @@ -163,13 +163,13 @@ interface nsIDocumentViewer : nsISupports */ [noscript,nostdcall] void setDocument(in Document aDocument); - [noscript] void getBounds(in nsIntRectRef aBounds); - [noscript] void setBounds([const] in nsIntRectRef aBounds); + [noscript] void getBounds(in LayoutDeviceIntRectRef aBounds); + [noscript] void setBounds([const] in LayoutDeviceIntRectRef aBounds); /** * The 'aFlags' argument to setBoundsWithFlags is a set of these bits. */ const unsigned long eDelayResize = 1; - [noscript] void setBoundsWithFlags([const] in nsIntRectRef aBounds, + [noscript] void setBoundsWithFlags([const] in LayoutDeviceIntRectRef aBounds, in unsigned long aFlags); /** diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index f9daaecc3591..c233c00f8608 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -993,7 +993,7 @@ nsresult ExternalResourceMap::AddExternalResource(nsIURI* aURI, // Make sure that hiding our viewer will tear down its presentation. aViewer->SetSticky(false); - rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr); + rv = aViewer->Init(nullptr, LayoutDeviceIntRect(), nullptr); if (NS_SUCCEEDED(rv)) { rv = aViewer->Open(nullptr, nullptr); } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 848b7d717711..6266290dd9f6 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3654,17 +3654,14 @@ static void PrepareForFullscreenChange(nsIDocShell* aDocShell, nsCOMPtr viewer; aDocShell->GetDocViewer(getter_AddRefs(viewer)); if (viewer) { - nsIntRect viewerBounds; + LayoutDeviceIntRect viewerBounds; viewer->GetBounds(viewerBounds); nscoord auPerDev = presShell->GetPresContext()->AppUnitsPerDevPixel(); if (aOldSize) { - *aOldSize = LayoutDeviceIntSize::ToAppUnits( - LayoutDeviceIntSize::FromUnknownSize(viewerBounds.Size()), - auPerDev); + *aOldSize = + LayoutDeviceIntSize::ToAppUnits(viewerBounds.Size(), auPerDev); } - LayoutDeviceIntSize newSize = - LayoutDeviceIntSize::FromAppUnitsRounded(aSize, auPerDev); - + auto newSize = LayoutDeviceIntSize::FromAppUnitsRounded(aSize, auPerDev); viewerBounds.SizeTo(newSize.width, newSize.height); viewer->SetBounds(viewerBounds); } diff --git a/gfx/thebes/gfxSVGGlyphs.cpp b/gfx/thebes/gfxSVGGlyphs.cpp index 4afeace2c409..a668f9070337 100644 --- a/gfx/thebes/gfxSVGGlyphs.cpp +++ b/gfx/thebes/gfxSVGGlyphs.cpp @@ -138,7 +138,7 @@ nsresult gfxSVGGlyphsDocument::SetupPresentation() { NS_ENSURE_SUCCESS(rv, rv); auto upem = mOwner->FontEntry()->UnitsPerEm(); - rv = viewer->Init(nullptr, gfx::IntRect(0, 0, upem, upem), nullptr); + rv = viewer->Init(nullptr, LayoutDeviceIntRect(0, 0, upem, upem), nullptr); if (NS_SUCCEEDED(rv)) { rv = viewer->Open(nullptr, nullptr); NS_ENSURE_SUCCESS(rv, rv); diff --git a/image/SVGDocumentWrapper.cpp b/image/SVGDocumentWrapper.cpp index bf29d8d64dd7..b2f9f6c26b98 100644 --- a/image/SVGDocumentWrapper.cpp +++ b/image/SVGDocumentWrapper.cpp @@ -72,12 +72,14 @@ void SVGDocumentWrapper::UpdateViewportBounds(const nsIntSize& aViewportSize) { MOZ_ASSERT(!mIgnoreInvalidation, "shouldn't be reentrant"); mIgnoreInvalidation = true; - nsIntRect currentBounds; + LayoutDeviceIntRect currentBounds; mViewer->GetBounds(currentBounds); // If the bounds have changed, we need to do a layout flush. - if (currentBounds.Size() != aViewportSize) { - mViewer->SetBounds(IntRect(IntPoint(0, 0), aViewportSize)); + if (currentBounds.Size().ToUnknownSize() != aViewportSize) { + mViewer->SetBounds(LayoutDeviceIntRect( + LayoutDeviceIntPoint(), + LayoutDeviceIntSize::FromUnknownSize(aViewportSize))); FlushLayout(); } @@ -207,7 +209,7 @@ SVGDocumentWrapper::OnStartRequest(nsIRequest* aRequest) { mViewer->GetDocument()->SetIsBeingUsedAsImage(); StopAnimation(); // otherwise animations start automatically in helper doc - rv = mViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr); + rv = mViewer->Init(nullptr, LayoutDeviceIntRect(), nullptr); if (NS_SUCCEEDED(rv)) { rv = mViewer->Open(nullptr, nullptr); } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f948cedba1b5..2e14057cd2e5 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -364,7 +364,7 @@ class nsDocumentViewer final : public nsIDocumentViewer, */ nsresult InitInternal(nsIWidget* aParentWidget, nsISupports* aState, mozilla::dom::WindowGlobalChild* aActor, - const nsIntRect& aBounds, bool aDoCreation, + const LayoutDeviceIntRect& aBounds, bool aDoCreation, bool aNeedMakeCX = true, bool aForceSetNewDocument = true); /** @@ -434,7 +434,7 @@ class nsDocumentViewer final : public nsIDocumentViewer, nsIWidget* mParentWidget; // purposely won't be ref counted. May be null bool mAttachedToParent; // view is attached to the parent widget - nsIntRect mBounds; + LayoutDeviceIntRect mBounds; int16_t mNumURLStarts; int16_t mDestroyBlockedCount; @@ -673,7 +673,8 @@ nsDocumentViewer::GetContainer(nsIDocShell** aResult) { } NS_IMETHODIMP -nsDocumentViewer::Init(nsIWidget* aParentWidget, const nsIntRect& aBounds, +nsDocumentViewer::Init(nsIWidget* aParentWidget, + const LayoutDeviceIntRect& aBounds, WindowGlobalChild* aActor) { return InitInternal(aParentWidget, nullptr, aActor, aBounds, true); } @@ -729,11 +730,10 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) { p2a == mPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom()); - nscoord width = p2a * mBounds.width; - nscoord height = p2a * mBounds.height; + const nsSize size = LayoutDevicePixel::ToAppUnits(mBounds.Size(), p2a); - mViewManager->SetWindowDimensions(width, height); - mPresContext->SetInitialVisibleArea(nsRect(0, 0, width, height)); + mViewManager->SetWindowDimensions(size.width, size.height); + mPresContext->SetInitialVisibleArea(nsRect(nsPoint(), size)); // We rely on the default zoom not being initialized until here. mPresContext->RecomputeBrowsingContextDependentData(); } @@ -796,8 +796,8 @@ static already_AddRefed CreatePresContext( // all the new objects or just initialize the existing ones nsresult nsDocumentViewer::InitInternal( nsIWidget* aParentWidget, nsISupports* aState, WindowGlobalChild* aActor, - const nsIntRect& aBounds, bool aDoCreation, bool aNeedMakeCX /*= true*/, - bool aForceSetNewDocument /* = true*/) { + const LayoutDeviceIntRect& aBounds, bool aDoCreation, + bool aNeedMakeCX /*= true*/, bool aForceSetNewDocument /* = true*/) { // We don't want any scripts to run here. That can cause flushing, // which can cause reentry into initialization of this document viewer, // which would be disastrous. @@ -1883,7 +1883,7 @@ nsPresContext* nsDocumentViewer::GetPresContext() { return mPresContext; } nsViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; } NS_IMETHODIMP -nsDocumentViewer::GetBounds(nsIntRect& aResult) { +nsDocumentViewer::GetBounds(LayoutDeviceIntRect& aResult) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); aResult = mBounds; return NS_OK; @@ -1926,7 +1926,7 @@ void nsDocumentViewer::SetPreviousViewer(nsIDocumentViewer* aViewer) { } NS_IMETHODIMP -nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds, +nsDocumentViewer::SetBoundsWithFlags(const LayoutDeviceIntRect& aBounds, uint32_t aFlags) { NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE); @@ -1963,13 +1963,12 @@ nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds, // need to invalidate because what we want to draw to the screen has // changed. if (viewDims.width == width && viewDims.height == height) { - nsIFrame* f = rootView->GetFrame(); - if (f) { + if (nsIFrame* f = rootView->GetFrame()) { f->InvalidateFrame(); // Forcibly refresh the viewport sizes even if the view size is not // changed since it is possible that the |mBounds| change means that - // the software keyboard appeared/disappered, in such cases we might + // the software keyboard appeared/disappeared. In such cases we might // need to fire visual viewport events. mPresShell->RefreshViewportSize(); } @@ -1996,7 +1995,7 @@ nsDocumentViewer::SetBoundsWithFlags(const nsIntRect& aBounds, } NS_IMETHODIMP -nsDocumentViewer::SetBounds(const nsIntRect& aBounds) { +nsDocumentViewer::SetBounds(const LayoutDeviceIntRect& aBounds) { return SetBoundsWithFlags(aBounds, 0); } @@ -2639,8 +2638,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsDocumentViewer::GetContentSize( // Leave our viewport in a consistent state. { auto newBounds = LayoutDeviceIntRect::FromAppUnitsToOutside( - shellArea, presContext->AppUnitsPerDevPixel()) - .ToUnknownRect(); + shellArea, presContext->AppUnitsPerDevPixel()); newBounds.MoveTo(mBounds.TopLeft()); SetBounds(newBounds); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 78e84d998477..6928a7e688fe 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -8022,7 +8022,7 @@ bool nsLayoutUtils::GetDocumentViewerSize( return false; } - nsIntRect bounds; + LayoutDeviceIntRect bounds; viewer->GetBounds(bounds); if (aPresContext->IsRootContentDocumentCrossProcess() && @@ -8038,7 +8038,7 @@ bool nsLayoutUtils::GetDocumentViewerSize( } } - aOutSize = LayoutDeviceIntRect::FromUnknownRect(bounds).Size(); + aOutSize = bounds.Size(); return true; } diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 328a18ad5ec2..f4e528b4c1a0 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -1322,7 +1322,7 @@ nsresult nsPrintJob::ReflowPrintObject(const UniquePtr& aPO) { do_QueryInterface(mDocViewerPrint)) { // If we're print-previewing and the top level document, use the bounds // from our doc viewer. Page bounds is not what we want. - nsIntRect bounds; + LayoutDeviceIntRect bounds; viewer->GetBounds(bounds); adjSize = nsSize(bounds.width * p2a, bounds.height * p2a); }