diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index c868ad04b74f..7bd456fd2f70 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -11295,8 +11295,8 @@ bool nsContentUtils::IsURIInList(nsIURI* aURI, const nsCString& aList) { } /* static */ -ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets( - nsIScreen* aScreen, const ScreenIntMargin& aSafeAreaInsets, +LayoutDeviceIntMargin nsContentUtils::GetWindowSafeAreaInsets( + nsIScreen* aScreen, const LayoutDeviceIntMargin& aSafeAreaInsets, const LayoutDeviceIntRect& aWindowRect) { // This calculates safe area insets of window from screen rectangle, window // rectangle and safe area insets of screen. @@ -11312,36 +11312,23 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets( // | +-------------------------------+ | // +----------------------------------------+ // - ScreenIntMargin windowSafeAreaInsets; - + LayoutDeviceIntMargin windowSafeAreaInsets; if (windowSafeAreaInsets == aSafeAreaInsets) { // no safe area insets. return windowSafeAreaInsets; } - int32_t screenLeft, screenTop, screenWidth, screenHeight; - nsresult rv = - aScreen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight); - if (NS_WARN_IF(NS_FAILED(rv))) { - return windowSafeAreaInsets; - } - - const ScreenIntRect screenRect(screenLeft, screenTop, screenWidth, - screenHeight); - - ScreenIntRect safeAreaRect = screenRect; + const LayoutDeviceIntRect screenRect = aScreen->GetRect(); + LayoutDeviceIntRect safeAreaRect = screenRect; safeAreaRect.Deflate(aSafeAreaInsets); - ScreenIntRect windowRect = ViewAs( - aWindowRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims); - // FIXME(bug 1754323): This can trigger because the screen rect is not // orientation-aware. // MOZ_ASSERT(screenRect.Contains(windowRect), // "Screen doesn't contain window rect? Something seems off"); // window's rect of safe area - safeAreaRect = safeAreaRect.Intersect(windowRect); + safeAreaRect = safeAreaRect.Intersect(aWindowRect); windowSafeAreaInsets.top = safeAreaRect.y - aWindowRect.y; windowSafeAreaInsets.left = safeAreaRect.x - aWindowRect.x; @@ -11350,7 +11337,7 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets( windowSafeAreaInsets.bottom = aWindowRect.y + aWindowRect.height - (safeAreaRect.y + safeAreaRect.height); - windowSafeAreaInsets.EnsureAtLeast(ScreenIntMargin()); + windowSafeAreaInsets.EnsureAtLeast(LayoutDeviceIntMargin()); // This shouldn't be needed, but it wallpapers orientation issues, see bug // 1754323. windowSafeAreaInsets.EnsureAtMost(aSafeAreaInsets); diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index f52475f524a5..f7a858d5349c 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3423,8 +3423,8 @@ class nsContentUtils { * Return safe area insets of window that defines as * https://drafts.csswg.org/css-env-1/#safe-area-insets. */ - static mozilla::ScreenIntMargin GetWindowSafeAreaInsets( - nsIScreen* aScreen, const mozilla::ScreenIntMargin& aSafeareaInsets, + static mozilla::LayoutDeviceIntMargin GetWindowSafeAreaInsets( + nsIScreen* aScreen, const mozilla::LayoutDeviceIntMargin& aSafeareaInsets, const mozilla::LayoutDeviceIntRect& aWindowRect); struct SubresourceCacheValidationInfo { diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index d86d469134d7..c333b1dce957 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -956,7 +956,7 @@ bool nsFrameLoader::Show(nsSubDocumentFrame* aFrame) { if (IsRemoteFrame()) { return ShowRemoteFrame(aFrame); } - const ScreenIntSize size = aFrame->GetSubdocumentSize(); + const LayoutDeviceIntSize size = aFrame->GetSubdocumentSize(); nsresult rv = MaybeCreateDocShell(); if (NS_FAILED(rv)) { return false; @@ -1123,7 +1123,8 @@ bool nsFrameLoader::ShowRemoteFrame(nsSubDocumentFrame* aFrame) { baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); nsSizeMode sizeMode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal; - const auto size = hasSize ? aFrame->GetSubdocumentSize() : ScreenIntSize(); + const auto size = + hasSize ? aFrame->GetSubdocumentSize() : LayoutDeviceIntSize(); OwnerShowInfo info(size, GetScrollbarPreference(mOwnerContent), sizeMode); if (!mRemoteBrowser->Show(info)) { return false; @@ -2364,7 +2365,7 @@ nsresult nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI) { return NS_OK; } -nsresult nsFrameLoader::GetWindowDimensions(nsIntRect& aRect) { +nsresult nsFrameLoader::GetWindowDimensions(LayoutDeviceIntRect& aRect) { if (!mOwnerContent) { return NS_ERROR_FAILURE; } @@ -2394,8 +2395,8 @@ nsresult nsFrameLoader::GetWindowDimensions(nsIntRect& aRect) { } nsCOMPtr treeOwnerAsWin(do_GetInterface(parentOwner)); - treeOwnerAsWin->GetPosition(&aRect.x, &aRect.y); - treeOwnerAsWin->GetSize(&aRect.width, &aRect.height); + aRect.MoveTo(treeOwnerAsWin->GetPosition()); + aRect.SizeTo(treeOwnerAsWin->GetSize()); return NS_OK; } @@ -2410,8 +2411,8 @@ nsresult nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame* aFrame) { if (!mRemoteBrowserShown) { ShowRemoteFrame(aFrame); } - nsIntRect dimensions; - NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE); + LayoutDeviceIntRect dimensions; + MOZ_TRY(GetWindowDimensions(dimensions)); mRemoteBrowser->UpdateDimensions(dimensions, size); mRemoteBrowserSized = true; } diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index dfaca9eaaa6d..fe0d16be377e 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -390,7 +390,7 @@ class nsFrameLoader final : public nsStubMutationObserver, nsIContentSecurityPolicy** aCsp); // Properly retrieves documentSize of any subdocument type. - nsresult GetWindowDimensions(nsIntRect& aRect); + nsresult GetWindowDimensions(mozilla::LayoutDeviceIntRect& aRect); virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager() const override; @@ -523,7 +523,7 @@ class nsFrameLoader final : public nsStubMutationObserver, RefPtr mDocShell; // Holds the last known size of the frame. - mozilla::ScreenIntSize mLazySize; + mozilla::LayoutDeviceIntSize mLazySize; // Actor for collecting session store data from content children. This will be // cleared and set to null eagerly when taking down the frameloader to break diff --git a/dom/ipc/BrowserBridgeHost.cpp b/dom/ipc/BrowserBridgeHost.cpp index 2cb8decd58b8..91b23f695111 100644 --- a/dom/ipc/BrowserBridgeHost.cpp +++ b/dom/ipc/BrowserBridgeHost.cpp @@ -66,8 +66,8 @@ bool BrowserBridgeHost::Show(const OwnerShowInfo& aShowInfo) { return true; } -void BrowserBridgeHost::UpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize) { +void BrowserBridgeHost::UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize) { Unused << mBridge->SendUpdateDimensions(aRect, aSize); } diff --git a/dom/ipc/BrowserBridgeHost.h b/dom/ipc/BrowserBridgeHost.h index 09f2f4dfdd06..6d2a6a801b8f 100644 --- a/dom/ipc/BrowserBridgeHost.h +++ b/dom/ipc/BrowserBridgeHost.h @@ -21,7 +21,7 @@ namespace mozilla::dom { * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC * actors. */ -class BrowserBridgeHost : public RemoteBrowser { +class BrowserBridgeHost final : public RemoteBrowser { public: typedef mozilla::layers::LayersId LayersId; @@ -48,8 +48,8 @@ class BrowserBridgeHost : public RemoteBrowser { void DestroyComplete() override; bool Show(const OwnerShowInfo&) override; - void UpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize) override; + void UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize) override; void UpdateEffects(EffectsInfo aInfo) override; diff --git a/dom/ipc/BrowserBridgeParent.cpp b/dom/ipc/BrowserBridgeParent.cpp index 2bf4d4e5d455..736ea9e9e28f 100644 --- a/dom/ipc/BrowserBridgeParent.cpp +++ b/dom/ipc/BrowserBridgeParent.cpp @@ -180,7 +180,7 @@ IPCResult BrowserBridgeParent::RecvResumeLoad(uint64_t aPendingSwitchID) { } IPCResult BrowserBridgeParent::RecvUpdateDimensions( - const nsIntRect& aRect, const ScreenIntSize& aSize) { + const LayoutDeviceIntRect& aRect, const LayoutDeviceIntSize& aSize) { mBrowserParent->UpdateDimensions(aRect, aSize); return IPC_OK(); } diff --git a/dom/ipc/BrowserBridgeParent.h b/dom/ipc/BrowserBridgeParent.h index 35dfd7636fe5..f36f9ec330ec 100644 --- a/dom/ipc/BrowserBridgeParent.h +++ b/dom/ipc/BrowserBridgeParent.h @@ -76,8 +76,8 @@ class BrowserBridgeParent : public PBrowserBridgeParent { mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference); mozilla::ipc::IPCResult RecvLoadURL(nsDocShellLoadState* aLoadState); mozilla::ipc::IPCResult RecvResumeLoad(uint64_t aPendingSwitchID); - mozilla::ipc::IPCResult RecvUpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize); + mozilla::ipc::IPCResult RecvUpdateDimensions( + const LayoutDeviceIntRect& aRect, const LayoutDeviceIntSize& aSize); mozilla::ipc::IPCResult RecvUpdateEffects(const EffectsInfo& aEffects); mozilla::ipc::IPCResult RecvUpdateRemotePrintSettings( const embedding::PrintData&); diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 786113675800..db70b19a2fa3 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -28,6 +28,7 @@ #include "mozilla/IMEStateManager.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" +#include "mozilla/widget/ScreenManager.h" #include "mozilla/NativeKeyBindingsType.h" #include "mozilla/NullPrincipal.h" #include "mozilla/PointerLockManager.h" @@ -604,7 +605,7 @@ BrowserChild::SetDimensions(DimensionRequest&& aRequest) { NS_IMETHODIMP BrowserChild::GetDimensions(DimensionKind aDimensionKind, int32_t* aX, int32_t* aY, int32_t* aCx, int32_t* aCy) { - ScreenIntRect rect = GetOuterRect(); + LayoutDeviceIntRect rect = GetOuterRect(); if (aDimensionKind == DimensionKind::Inner) { if (aX || aY) { return NS_ERROR_NOT_IMPLEMENTED; @@ -1007,7 +1008,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateRemotePrintSettings( } void BrowserChild::DoFakeShow(const ParentShowInfo& aParentShowInfo) { - OwnerShowInfo ownerInfo{ScreenIntSize(), ScrollbarPreference::Auto, + OwnerShowInfo ownerInfo{LayoutDeviceIntSize(), ScrollbarPreference::Auto, nsSizeMode_Normal}; RecvShow(aParentShowInfo, ownerInfo); mDidFakeShow = true; @@ -1125,20 +1126,20 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions( mHasValidInnerSize = true; } - ScreenIntSize screenSize = GetInnerSize(); - ScreenIntRect screenRect = GetOuterRect(); - + const LayoutDeviceIntSize innerSize = GetInnerSize(); // Make sure to set the size on the document viewer first. The // MobileViewportManager needs the content viewer size to be updated before // the reflow, otherwise it gets a stale size when it computes a new CSS // viewport. nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); - baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, + baseWin->SetPositionAndSize(0, 0, innerSize.width, innerSize.height, nsIBaseWindow::eRepaint); - mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x, - screenRect.y + mClientOffset.y + mChromeOffset.y, - screenSize.width, screenSize.height, true); + const LayoutDeviceIntRect outerRect = + GetOuterRect() + mClientOffset + mChromeOffset; + + mPuppetWidget->Resize(outerRect.x, outerRect.y, innerSize.width, + innerSize.height, true); RecvSafeAreaInsetsChanged(mPuppetWidget->GetSafeAreaInsets()); @@ -3345,23 +3346,22 @@ void BrowserChild::NotifyJankedAnimations( mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged( const float& aDpi, const int32_t& aRounding, const double& aScale) { - ScreenIntSize oldScreenSize = GetInnerSize(); + const LayoutDeviceIntSize oldInnerSize = GetInnerSize(); if (aDpi > 0) { mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale); } - ScreenIntSize screenSize = GetInnerSize(); - if (mHasValidInnerSize && oldScreenSize != screenSize) { - ScreenIntRect screenRect = GetOuterRect(); - + const LayoutDeviceIntSize innerSize = GetInnerSize(); + if (mHasValidInnerSize && oldInnerSize != innerSize) { // See RecvUpdateDimensions for the order of these operations. nsCOMPtr baseWin = do_QueryInterface(WebNavigation()); - baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, + baseWin->SetPositionAndSize(0, 0, innerSize.width, innerSize.height, nsIBaseWindow::eRepaint); - mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x, - screenRect.y + mClientOffset.y + mChromeOffset.y, - screenSize.width, screenSize.height, true); + const LayoutDeviceIntRect outerRect = + GetOuterRect() + mClientOffset + mChromeOffset; + mPuppetWidget->Resize(outerRect.x, outerRect.y, innerSize.width, + innerSize.height, true); } nsCOMPtr document(GetTopLevelDocument()); @@ -3375,32 +3375,23 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged( } mozilla::ipc::IPCResult BrowserChild::RecvSafeAreaInsetsChanged( - const mozilla::ScreenIntMargin& aSafeAreaInsets) { + const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets) { mPuppetWidget->UpdateSafeAreaInsets(aSafeAreaInsets); - nsCOMPtr screenMgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - ScreenIntMargin currentSafeAreaInsets; - if (screenMgr) { - // aSafeAreaInsets is for current screen. But we have to calculate - // safe insets for content window. - int32_t x, y, cx, cy; - GetDimensions(DimensionKind::Outer, &x, &y, &cx, &cy); - nsCOMPtr screen; - screenMgr->ScreenForRect(x, y, cx, cy, getter_AddRefs(screen)); - - if (screen) { - LayoutDeviceIntRect windowRect(x + mClientOffset.x + mChromeOffset.x, - y + mClientOffset.y + mChromeOffset.y, cx, - cy); - currentSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( - screen, aSafeAreaInsets, windowRect); - } + LayoutDeviceIntMargin currentSafeAreaInsets; + // aSafeAreaInsets is for current screen. But we have to calculate safe insets + // for content window. + LayoutDeviceIntRect outerRect = GetOuterRect(); + RefPtr screen = widget::ScreenManager::GetSingleton().ScreenForRect( + RoundedToInt(outerRect / mPuppetWidget->GetDesktopToDeviceScale())); + if (screen) { + LayoutDeviceIntRect windowRect = outerRect + mClientOffset + mChromeOffset; + currentSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( + screen, aSafeAreaInsets, windowRect); } if (nsCOMPtr document = GetTopLevelDocument()) { - nsPresContext* presContext = document->GetPresContext(); - if (presContext) { + if (nsPresContext* presContext = document->GetPresContext()) { presContext->SetSafeAreaInsets(currentSafeAreaInsets); } } @@ -3441,11 +3432,8 @@ bool BrowserChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) { return true; } -ScreenIntSize BrowserChild::GetInnerSize() { - LayoutDeviceIntSize innerSize = - RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale()); - return ViewAs( - innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims); +LayoutDeviceIntSize BrowserChild::GetInnerSize() { + return RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale()); }; Maybe BrowserChild::GetVisibleRect() const { @@ -3489,11 +3477,8 @@ BrowserChild::GetTopLevelViewportVisibleRectInSelfCoords() const { return rect; } -ScreenIntRect BrowserChild::GetOuterRect() { - LayoutDeviceIntRect outerRect = - RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale()); - return ViewAs( - outerRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims); +LayoutDeviceIntRect BrowserChild::GetOuterRect() { + return RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale()); } void BrowserChild::PaintWhileInterruptingJS() { diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index 94d7987fbbb7..27767514c1d8 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -436,7 +436,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, const IPCTabContext& aContext); mozilla::ipc::IPCResult RecvSafeAreaInsetsChanged( - const mozilla::ScreenIntMargin& aSafeAreaInsets); + const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets); #ifdef ACCESSIBILITY PDocAccessibleChild* AllocPDocAccessibleChild( @@ -568,7 +568,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, const mozilla::layers::CompositorOptions& GetCompositorOptions() const; bool AsyncPanZoomEnabled() const; - ScreenIntSize GetInnerSize(); + LayoutDeviceIntSize GetInnerSize(); CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; } Maybe GetVisibleRect() const; @@ -758,7 +758,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor, bool HasValidInnerSize(); - ScreenIntRect GetOuterRect(); + LayoutDeviceIntRect GetOuterRect(); void SetUnscaledInnerSize(const CSSSize& aSize) { mUnscaledInnerSize = aSize; diff --git a/dom/ipc/BrowserHost.cpp b/dom/ipc/BrowserHost.cpp index 489f07a612e5..123c9de9def3 100644 --- a/dom/ipc/BrowserHost.cpp +++ b/dom/ipc/BrowserHost.cpp @@ -90,8 +90,8 @@ bool BrowserHost::Show(const OwnerShowInfo& aShowInfo) { return mRoot->Show(aShowInfo); } -void BrowserHost::UpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize) { +void BrowserHost::UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize) { mRoot->UpdateDimensions(aRect, aSize); } diff --git a/dom/ipc/BrowserHost.h b/dom/ipc/BrowserHost.h index 5b651a1df041..84357d626ba2 100644 --- a/dom/ipc/BrowserHost.h +++ b/dom/ipc/BrowserHost.h @@ -87,8 +87,8 @@ class BrowserHost : public RemoteBrowser, void DestroyComplete() override; bool Show(const OwnerShowInfo&) override; - void UpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize) override; + void UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize) override; void UpdateEffects(EffectsInfo aInfo) override; diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index eb65fe4730e1..8461e290d9c7 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -1027,8 +1027,7 @@ void BrowserParent::InitRendering() { RefPtr widget = GetTopLevelWidget(); if (widget) { - ScreenIntMargin safeAreaInsets = widget->GetSafeAreaInsets(); - Unused << SendSafeAreaInsetsChanged(safeAreaInsets); + Unused << SendSafeAreaInsetsChanged(widget->GetSafeAreaInsets()); } #if defined(MOZ_WIDGET_ANDROID) @@ -1116,7 +1115,7 @@ nsresult BrowserParent::UpdatePosition() { if (!frameLoader) { return NS_OK; } - nsIntRect windowDims; + LayoutDeviceIntRect windowDims; NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ERROR_FAILURE); // Avoid updating sizes here. @@ -1139,8 +1138,8 @@ void BrowserParent::NotifyPositionUpdatedForContentsInPopup() { } } -void BrowserParent::UpdateDimensions(const nsIntRect& rect, - const ScreenIntSize& size) { +void BrowserParent::UpdateDimensions(const LayoutDeviceIntRect& rect, + const LayoutDeviceIntSize& size) { if (mIsDestroyed) { return; } @@ -1169,26 +1168,18 @@ void BrowserParent::UpdateDimensions(const nsIntRect& rect, } DimensionInfo BrowserParent::GetDimensionInfo() { - LayoutDeviceIntRect devicePixelRect = ViewAs( - mRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims); - LayoutDeviceIntSize devicePixelSize = ViewAs( - mDimensions, PixelCastJustification::LayoutDeviceIsScreenForTabDims); - - CSSRect unscaledRect = devicePixelRect / mDefaultScale; - CSSSize unscaledSize = devicePixelSize / mDefaultScale; - DimensionInfo di(unscaledRect, unscaledSize, mClientOffset, mChromeOffset); - return di; + CSSRect unscaledRect = mRect / mDefaultScale; + CSSSize unscaledSize = mDimensions / mDefaultScale; + return DimensionInfo(unscaledRect, unscaledSize, mClientOffset, + mChromeOffset); } void BrowserParent::UpdateNativePointerLockCenter(nsIWidget* aWidget) { if (!mLockedNativePointer) { return; } - LayoutDeviceIntRect dims( - {0, 0}, - ViewAs( - mDimensions, PixelCastJustification::LayoutDeviceIsScreenForTabDims)); - aWidget->SetNativePointerLockCenter((dims + mChromeOffset).Center()); + aWidget->SetNativePointerLockCenter( + LayoutDeviceIntRect(mChromeOffset, mDimensions).Center()); } void BrowserParent::SizeModeChanged(const nsSizeMode& aSizeMode) { diff --git a/dom/ipc/BrowserParent.h b/dom/ipc/BrowserParent.h index 58dee684f464..52cbf24e5883 100644 --- a/dom/ipc/BrowserParent.h +++ b/dom/ipc/BrowserParent.h @@ -468,7 +468,8 @@ class BrowserParent final : public PBrowserParent, bool Show(const OwnerShowInfo&); - void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize); + void UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize); DimensionInfo GetDimensionInfo(); @@ -922,8 +923,8 @@ class BrowserParent final : public PBrowserParent, }; nsTArray mWaitingReplyKeyboardEvents; - nsIntRect mRect; - ScreenIntSize mDimensions; + LayoutDeviceIntRect mRect; + LayoutDeviceIntSize mDimensions; float mDPI; int32_t mRounding; CSSToLayoutDeviceScale mDefaultScale; diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index ed72af20dd23..8abdce68b21d 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -39,7 +39,7 @@ using mozilla::DesktopToLayoutDeviceScale from "Units.h"; using mozilla::CSSToLayoutDeviceScale from "Units.h"; using mozilla::CSSRect from "Units.h"; using mozilla::CSSSize from "Units.h"; -using mozilla::ScreenIntSize from "Units.h"; +using mozilla::LayoutDeviceIntSize from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; using mozilla::ImageIntSize from "Units.h"; using nsSizeMode from "nsIWidgetListener.h"; @@ -315,7 +315,7 @@ struct ParentShowInfo struct OwnerShowInfo { // This can be an IntSize rather than a Rect because content processes always // render to a virtual <0, 0> top-left point. - ScreenIntSize size; + LayoutDeviceIntSize size; // TODO(emilio): Margin preferences go here. ScrollbarPreference scrollbarPreference; diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 14406ad0a6cc..83cf929bb349 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -48,9 +48,8 @@ using mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; using mozilla::LayoutDevicePoint from "Units.h"; +using mozilla::LayoutDeviceIntMargin from "Units.h"; using mozilla::ScreenIntCoord from "Units.h"; -using mozilla::ScreenIntMargin from "Units.h"; -using mozilla::ScreenIntPoint from "Units.h"; using mozilla::ScreenRect from "Units.h"; using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using struct mozilla::layers::ZoomConstraints from "mozilla/layers/ZoomConstraints.h"; @@ -936,7 +935,7 @@ child: * Tell the child that the safe area of widget has changed. * */ - async SafeAreaInsetsChanged(ScreenIntMargin aSafeAreaInsets); + async SafeAreaInsetsChanged(LayoutDeviceIntMargin aSafeAreaInsets); /** * Tell the browser that its frame loader has been swapped diff --git a/dom/ipc/PBrowserBridge.ipdl b/dom/ipc/PBrowserBridge.ipdl index c2af10d2a49b..a95951393e46 100644 --- a/dom/ipc/PBrowserBridge.ipdl +++ b/dom/ipc/PBrowserBridge.ipdl @@ -23,7 +23,6 @@ using mozilla::ScrollAxis from "mozilla/PresShellForwards.h"; using mozilla::ScrollFlags from "mozilla/PresShellForwards.h"; using struct nsRect from "nsRect.h"; using mozilla::dom::CallerType from "mozilla/dom/BindingDeclarations.h"; -using nsIntRect from "nsRect.h"; using mozilla::dom::EmbedderElementEventType from "mozilla/dom/TabMessageTypes.h"; [RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h"; using mozilla::IntrinsicSize from "nsIFrame.h"; @@ -92,7 +91,7 @@ parent: // Out of process rendering. async Show(OwnerShowInfo info); async ScrollbarPreferenceChanged(ScrollbarPreference pref); - [Compress=all] async UpdateDimensions(nsIntRect rect, ScreenIntSize size); + [Compress=all] async UpdateDimensions(LayoutDeviceIntRect rect, LayoutDeviceIntSize size); async RenderLayers(bool aEnabled); async UpdateEffects(EffectsInfo aEffects); diff --git a/dom/ipc/RemoteBrowser.h b/dom/ipc/RemoteBrowser.h index 7ea0b669fdb9..f490086e891a 100644 --- a/dom/ipc/RemoteBrowser.h +++ b/dom/ipc/RemoteBrowser.h @@ -61,8 +61,8 @@ class RemoteBrowser : public nsISupports { virtual void DestroyComplete() = 0; virtual bool Show(const OwnerShowInfo&) = 0; - virtual void UpdateDimensions(const nsIntRect& aRect, - const ScreenIntSize& aSize) = 0; + virtual void UpdateDimensions(const LayoutDeviceIntRect& aRect, + const LayoutDeviceIntSize& aSize) = 0; virtual void UpdateEffects(EffectsInfo aInfo) = 0; }; diff --git a/layout/base/UnitTransforms.h b/layout/base/UnitTransforms.h index 7bbd0f088f73..78d79eb9fe57 100644 --- a/layout/base/UnitTransforms.h +++ b/layout/base/UnitTransforms.h @@ -44,9 +44,6 @@ enum class PixelCastJustification : uint8_t { // reference point as a screen point. The reverse is useful when synthetically // created WidgetEvents need to be converted back to InputData. LayoutDeviceIsScreenForUntransformedEvent, - // Similar to LayoutDeviceIsScreenForUntransformedEvent, PBrowser handles - // some widget/tab dimension information as the OS does -- in screen units. - LayoutDeviceIsScreenForTabDims, // A combination of LayoutDeviceIsScreenForBounds and // ScreenIsParentLayerForRoot, which is how we're using it. LayoutDeviceIsParentLayerForRCDRSF, diff --git a/layout/base/Units.h b/layout/base/Units.h index 2285d8c1ba1b..480558fccde9 100644 --- a/layout/base/Units.h +++ b/layout/base/Units.h @@ -890,8 +890,8 @@ template gfx::MarginTyped operator/(const gfx::MarginTyped& aMargin, const gfx::ScaleFactor& aScale) { return gfx::MarginTyped( - aMargin.top / aScale.scale, aMargin.right / aScale.scale, - aMargin.bottom / aScale.scale, aMargin.left / aScale.scale); + aMargin.top.value / aScale.scale, aMargin.right.value / aScale.scale, + aMargin.bottom.value / aScale.scale, aMargin.left.value / aScale.scale); } template diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 2e14057cd2e5..9fdbb3065fc4 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -740,14 +740,12 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) { if (mWindow && mDocument->IsTopLevelContentDocument()) { // Set initial safe area insets - ScreenIntMargin windowSafeAreaInsets; + LayoutDeviceIntMargin windowSafeAreaInsets; LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); - nsCOMPtr screen = mWindow->GetWidgetScreen(); - if (screen) { + if (nsCOMPtr screen = mWindow->GetWidgetScreen()) { windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( screen, mWindow->GetSafeAreaInsets(), windowRect); } - mPresContext->SetSafeAreaInsets(windowSafeAreaInsets); } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 1c24a15088fa..19ffab5db39b 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -3204,7 +3204,8 @@ nscoord nsPresContext::GetBimodalDynamicToolbarHeightInAppUnits() const { : 0; } -void nsPresContext::SetSafeAreaInsets(const ScreenIntMargin& aSafeAreaInsets) { +void nsPresContext::SetSafeAreaInsets( + const LayoutDeviceIntMargin& aSafeAreaInsets) { if (mSafeAreaInsets == aSafeAreaInsets) { return; } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index b24336dde554..5c8337bd7d16 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -544,9 +544,11 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { /** * Notify the pres context that the safe area insets have changed. */ - void SetSafeAreaInsets(const mozilla::ScreenIntMargin& aInsets); + void SetSafeAreaInsets(const mozilla::LayoutDeviceIntMargin& aInsets); - mozilla::ScreenIntMargin GetSafeAreaInsets() const { return mSafeAreaInsets; } + const mozilla::LayoutDeviceIntMargin& GetSafeAreaInsets() const { + return mSafeAreaInsets; + } void RegisterManagedPostRefreshObserver(mozilla::ManagedPostRefreshObserver*); void UnregisterManagedPostRefreshObserver( @@ -1245,7 +1247,7 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { // The software keyboard height. mozilla::ScreenIntCoord mKeyboardHeight; // Safe area insets support - mozilla::ScreenIntMargin mSafeAreaInsets; + mozilla::LayoutDeviceIntMargin mSafeAreaInsets; nsSize mPageSize; // The computed page margins from the print settings. diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 1b80b04aa727..9c62a8a1f5c6 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -283,26 +283,27 @@ nsRect nsSubDocumentFrame::GetDestRect(const nsRect& aConstraintRect) { GetIntrinsicRatio(), StylePosition()); } -ScreenIntSize nsSubDocumentFrame::GetSubdocumentSize() { +LayoutDeviceIntSize nsSubDocumentFrame::GetSubdocumentSize() { if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { if (RefPtr frameloader = FrameLoader()) { nsIFrame* detachedFrame = frameloader->GetDetachedSubdocFrame(); if (nsView* view = detachedFrame ? detachedFrame->GetView() : nullptr) { nsSize size = view->GetBounds().Size(); nsPresContext* presContext = detachedFrame->PresContext(); - return ScreenIntSize(presContext->AppUnitsToDevPixels(size.width), - presContext->AppUnitsToDevPixels(size.height)); + return LayoutDeviceIntSize( + presContext->AppUnitsToDevPixels(size.width), + presContext->AppUnitsToDevPixels(size.height)); } } // Pick some default size for now. Using 10x10 because that's what the // code used to do. - return ScreenIntSize(10, 10); + return LayoutDeviceIntSize(10, 10); } nsSize docSizeAppUnits = GetDestRect().Size(); nsPresContext* pc = PresContext(); - return ScreenIntSize(pc->AppUnitsToDevPixels(docSizeAppUnits.width), - pc->AppUnitsToDevPixels(docSizeAppUnits.height)); + return LayoutDeviceIntSize(pc->AppUnitsToDevPixels(docSizeAppUnits.width), + pc->AppUnitsToDevPixels(docSizeAppUnits.height)); } static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder, diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index ffadebaba2df..088ae1e775dd 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -103,7 +103,7 @@ class nsSubDocumentFrame final : public nsAtomicContainerFrame, mozilla::PresShell* GetSubdocumentPresShellForPainting(uint32_t aFlags); nsRect GetDestRect(); nsRect GetDestRect(const nsRect& aConstraintRect); - mozilla::ScreenIntSize GetSubdocumentSize(); + mozilla::LayoutDeviceIntSize GetSubdocumentSize(); bool ContentReactsToPointerEvents() const; diff --git a/layout/style/GeckoBindings.cpp b/layout/style/GeckoBindings.cpp index b05727bd1adf..c0f47bfa8b46 100644 --- a/layout/style/GeckoBindings.cpp +++ b/layout/style/GeckoBindings.cpp @@ -1664,11 +1664,13 @@ bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue* aValue) { void Gecko_GetSafeAreaInsets(const nsPresContext* aPresContext, float* aTop, float* aRight, float* aBottom, float* aLeft) { MOZ_ASSERT(aPresContext); - ScreenIntMargin safeAreaInsets = aPresContext->GetSafeAreaInsets(); - *aTop = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.top); - *aRight = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.right); - *aBottom = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.bottom); - *aLeft = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.left); + const CSSMargin insets = + LayoutDeviceMargin(aPresContext->GetSafeAreaInsets()) / + aPresContext->CSSToDevPixelScale(); + *aTop = insets.top; + *aRight = insets.right; + *aBottom = insets.bottom; + *aLeft = insets.left; } void Gecko_PrintfStderr(const nsCString* aStr) { diff --git a/view/nsView.cpp b/view/nsView.cpp index 8506cce03fda..42f6a78fb016 100644 --- a/view/nsView.cpp +++ b/view/nsView.cpp @@ -1013,7 +1013,8 @@ nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent, return result; } -void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) { +void nsView::SafeAreaInsetsChanged( + const LayoutDeviceIntMargin& aSafeAreaInsets) { if (!IsRoot()) { return; } @@ -1023,10 +1024,9 @@ void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) { return; } - ScreenIntMargin windowSafeAreaInsets; - LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); - nsCOMPtr screen = mWindow->GetWidgetScreen(); - if (screen) { + LayoutDeviceIntMargin windowSafeAreaInsets; + const LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); + if (nsCOMPtr screen = mWindow->GetWidgetScreen()) { windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( screen, aSafeAreaInsets, windowRect); } diff --git a/view/nsView.h b/view/nsView.h index 73acb9273119..37ccb83b2d36 100644 --- a/view/nsView.h +++ b/view/nsView.h @@ -408,37 +408,33 @@ class nsView final : public nsIWidgetListener { } // nsIWidgetListener - virtual mozilla::PresShell* GetPresShell() override; - virtual nsView* GetView() override { return this; } - virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y, - ByMoveToRect) override; - virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, - int32_t aHeight) override; + mozilla::PresShell* GetPresShell() override; + nsView* GetView() override { return this; } + bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y, + ByMoveToRect) override; + bool WindowResized(nsIWidget* aWidget, int32_t aWidth, + int32_t aHeight) override; #if defined(MOZ_WIDGET_ANDROID) - virtual void DynamicToolbarMaxHeightChanged( - mozilla::ScreenIntCoord aHeight) override; - virtual void DynamicToolbarOffsetChanged( - mozilla::ScreenIntCoord aOffset) override; - virtual void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override; + void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight) override; + void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset) override; + void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override; #endif - virtual bool RequestWindowClose(nsIWidget* aWidget) override; + bool RequestWindowClose(nsIWidget* aWidget) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void WillPaintWindow(nsIWidget* aWidget) override; + void WillPaintWindow(nsIWidget* aWidget) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual bool PaintWindow(nsIWidget* aWidget, - LayoutDeviceIntRegion aRegion) override; + bool PaintWindow(nsIWidget* aWidget, LayoutDeviceIntRegion aRegion) override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void DidPaintWindow() override; - virtual void DidCompositeWindow( - mozilla::layers::TransactionId aTransactionId, - const mozilla::TimeStamp& aCompositeStart, - const mozilla::TimeStamp& aCompositeEnd) override; - virtual void RequestRepaint() override; - virtual bool ShouldNotBeVisible() override; + void DidPaintWindow() override; + void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, + const mozilla::TimeStamp& aCompositeStart, + const mozilla::TimeStamp& aCompositeEnd) override; + void RequestRepaint() override; + bool ShouldNotBeVisible() override; MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, - bool aUseAttachedEvents) override; - virtual void SafeAreaInsetsChanged(const mozilla::ScreenIntMargin&) override; + nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, + bool aUseAttachedEvents) override; + void SafeAreaInsetsChanged(const mozilla::LayoutDeviceIntMargin&) override; virtual ~nsView(); diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 80657a2d8ee7..059cdbb03be8 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -988,12 +988,12 @@ void PuppetWidget::StartAsyncScrollbarDrag( mBrowserChild->StartScrollbarDrag(aDragMetrics); } -ScreenIntMargin PuppetWidget::GetSafeAreaInsets() const { +LayoutDeviceIntMargin PuppetWidget::GetSafeAreaInsets() const { return mSafeAreaInsets; } void PuppetWidget::UpdateSafeAreaInsets( - const ScreenIntMargin& aSafeAreaInsets) { + const LayoutDeviceIntMargin& aSafeAreaInsets) { mSafeAreaInsets = aSafeAreaInsets; } diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index f352c329739a..24f093b6341f 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -204,8 +204,8 @@ class PuppetWidget final : public nsBaseWidget, } // safe area insets support - ScreenIntMargin GetSafeAreaInsets() const override; - void UpdateSafeAreaInsets(const ScreenIntMargin& aSafeAreaInsets); + LayoutDeviceIntMargin GetSafeAreaInsets() const override; + void UpdateSafeAreaInsets(const LayoutDeviceIntMargin& aSafeAreaInsets); // Get the offset to the chrome of the window that this tab belongs to. // @@ -363,8 +363,7 @@ class PuppetWidget final : public nsBaseWidget, int32_t mRounding = 1; double mDefaultScale = GetFallbackDefaultScale().scale; - ScreenIntMargin mSafeAreaInsets; - + LayoutDeviceIntMargin mSafeAreaInsets; RefPtr mNativeTextEventDispatcherListener; protected: diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 66f03e1bf337..2f0a9d41dfe7 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1747,7 +1747,7 @@ class LayerViewSupport final return; } - ScreenIntMargin safeAreaInsets(aTop, aRight, aBottom, aLeft); + LayoutDeviceIntMargin safeAreaInsets(aTop, aRight, aBottom, aLeft); gkWindow->UpdateSafeAreaInsets(safeAreaInsets); } }; @@ -3275,9 +3275,12 @@ void nsWindow::KeyboardHeightChanged(ScreenIntCoord aHeight) { } } -ScreenIntMargin nsWindow::GetSafeAreaInsets() const { return mSafeAreaInsets; } +LayoutDeviceIntMargin nsWindow::GetSafeAreaInsets() const { + return mSafeAreaInsets; +} -void nsWindow::UpdateSafeAreaInsets(const ScreenIntMargin& aSafeAreaInsets) { +void nsWindow::UpdateSafeAreaInsets( + const LayoutDeviceIntMargin& aSafeAreaInsets) { mSafeAreaInsets = aSafeAreaInsets; if (mWidgetListener) { diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index 28bc574cfb7f..0a8b7c8dba4e 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -73,7 +73,7 @@ class nsWindow final : public nsBaseWidget { private: nsCOMPtr mIdleService; mozilla::ScreenIntCoord mDynamicToolbarMaxHeight{0}; - mozilla::ScreenIntMargin mSafeAreaInsets; + mozilla::LayoutDeviceIntMargin mSafeAreaInsets; mozilla::widget::PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate = nullptr; mozilla::Mutex mDestroyMutex{"nsWindow::mDestroyMutex"}; @@ -251,8 +251,8 @@ class nsWindow final : public nsBaseWidget { void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset); - mozilla::ScreenIntMargin GetSafeAreaInsets() const override; - void UpdateSafeAreaInsets(const mozilla::ScreenIntMargin& aSafeAreaInsets); + mozilla::LayoutDeviceIntMargin GetSafeAreaInsets() const override; + void UpdateSafeAreaInsets(const mozilla::LayoutDeviceIntMargin&); void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight); diff --git a/widget/nsIBaseWindow.idl b/widget/nsIBaseWindow.idl index 664facd40eac..b51990e21c2c 100644 --- a/widget/nsIBaseWindow.idl +++ b/widget/nsIBaseWindow.idl @@ -173,6 +173,14 @@ interface nsIBaseWindow : nsISupports */ [noscript] void getDimensions(in DimensionKind aDimensionKind, out long aX, out long aY, out long aCX, out long aCY); +%{C++ + mozilla::LayoutDeviceIntRect GetDimensions(mozilla::DimensionKind aDimensionKind) { + int32_t x = 0, y = 0, w = 0, h = 0; + GetDimensions(aDimensionKind, &x, &y, &w, &h); + return mozilla::LayoutDeviceIntRect(x, y, w, h); + } +%} + /** * Tell the window to repaint itself * @param aForce - if true, repaint immediately diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index bbadacd8e839..06fd73d819b4 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1667,8 +1667,8 @@ class nsIWidget : public nsISupports { * Get safe area insets except to cutout. * See https://drafts.csswg.org/css-env-1/#safe-area-insets. */ - virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const { - return mozilla::ScreenIntMargin(); + virtual mozilla::LayoutDeviceIntMargin GetSafeAreaInsets() const { + return mozilla::LayoutDeviceIntMargin(); } private: diff --git a/widget/nsIWidgetListener.cpp b/widget/nsIWidgetListener.cpp index b0e2c438e5ee..ed4609b6d873 100644 --- a/widget/nsIWidgetListener.cpp +++ b/widget/nsIWidgetListener.cpp @@ -33,8 +33,8 @@ bool nsIWidgetListener::WindowResized(nsIWidget* aWidget, int32_t aWidth, void nsIWidgetListener::SizeModeChanged(nsSizeMode aSizeMode) {} -void nsIWidgetListener::SafeAreaInsetsChanged(const mozilla::ScreenIntMargin&) { -} +void nsIWidgetListener::SafeAreaInsetsChanged( + const mozilla::LayoutDeviceIntMargin&) {} #if defined(MOZ_WIDGET_ANDROID) void nsIWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) { diff --git a/widget/nsIWidgetListener.h b/widget/nsIWidgetListener.h index d0d2e334704a..637e4e51640d 100644 --- a/widget/nsIWidgetListener.h +++ b/widget/nsIWidgetListener.h @@ -176,7 +176,7 @@ class nsIWidgetListener { * Called when safe area insets are changed. */ virtual void SafeAreaInsetsChanged( - const mozilla::ScreenIntMargin& aSafeAreaInsets); + const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets); }; #endif