Bug 1930476 - Improve units in nsFrameLoader and related code. r=geckoview-reviewers,jwatt,ohall

Use LayoutDevice units for most these things, since it's what they are:

  ScreenIntSize(presContext->AppUnitsToDevPixels(size.width), ...

Is clearly a lie :)

Differential Revision: https://phabricator.services.mozilla.com/D228586
This commit is contained in:
Emilio Cobos Álvarez 2024-11-12 15:16:50 +00:00
parent a3b8ffea41
commit b985e29a3f
36 changed files with 168 additions and 198 deletions

View File

@ -11295,8 +11295,8 @@ bool nsContentUtils::IsURIInList(nsIURI* aURI, const nsCString& aList) {
} }
/* static */ /* static */
ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets( LayoutDeviceIntMargin nsContentUtils::GetWindowSafeAreaInsets(
nsIScreen* aScreen, const ScreenIntMargin& aSafeAreaInsets, nsIScreen* aScreen, const LayoutDeviceIntMargin& aSafeAreaInsets,
const LayoutDeviceIntRect& aWindowRect) { const LayoutDeviceIntRect& aWindowRect) {
// This calculates safe area insets of window from screen rectangle, window // This calculates safe area insets of window from screen rectangle, window
// rectangle and safe area insets of screen. // rectangle and safe area insets of screen.
@ -11312,36 +11312,23 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
// | +-------------------------------+ | // | +-------------------------------+ |
// +----------------------------------------+ // +----------------------------------------+
// //
ScreenIntMargin windowSafeAreaInsets; LayoutDeviceIntMargin windowSafeAreaInsets;
if (windowSafeAreaInsets == aSafeAreaInsets) { if (windowSafeAreaInsets == aSafeAreaInsets) {
// no safe area insets. // no safe area insets.
return windowSafeAreaInsets; return windowSafeAreaInsets;
} }
int32_t screenLeft, screenTop, screenWidth, screenHeight; const LayoutDeviceIntRect screenRect = aScreen->GetRect();
nsresult rv = LayoutDeviceIntRect safeAreaRect = screenRect;
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;
safeAreaRect.Deflate(aSafeAreaInsets); safeAreaRect.Deflate(aSafeAreaInsets);
ScreenIntRect windowRect = ViewAs<ScreenPixel>(
aWindowRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
// FIXME(bug 1754323): This can trigger because the screen rect is not // FIXME(bug 1754323): This can trigger because the screen rect is not
// orientation-aware. // orientation-aware.
// MOZ_ASSERT(screenRect.Contains(windowRect), // MOZ_ASSERT(screenRect.Contains(windowRect),
// "Screen doesn't contain window rect? Something seems off"); // "Screen doesn't contain window rect? Something seems off");
// window's rect of safe area // window's rect of safe area
safeAreaRect = safeAreaRect.Intersect(windowRect); safeAreaRect = safeAreaRect.Intersect(aWindowRect);
windowSafeAreaInsets.top = safeAreaRect.y - aWindowRect.y; windowSafeAreaInsets.top = safeAreaRect.y - aWindowRect.y;
windowSafeAreaInsets.left = safeAreaRect.x - aWindowRect.x; windowSafeAreaInsets.left = safeAreaRect.x - aWindowRect.x;
@ -11350,7 +11337,7 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
windowSafeAreaInsets.bottom = aWindowRect.y + aWindowRect.height - windowSafeAreaInsets.bottom = aWindowRect.y + aWindowRect.height -
(safeAreaRect.y + safeAreaRect.height); (safeAreaRect.y + safeAreaRect.height);
windowSafeAreaInsets.EnsureAtLeast(ScreenIntMargin()); windowSafeAreaInsets.EnsureAtLeast(LayoutDeviceIntMargin());
// This shouldn't be needed, but it wallpapers orientation issues, see bug // This shouldn't be needed, but it wallpapers orientation issues, see bug
// 1754323. // 1754323.
windowSafeAreaInsets.EnsureAtMost(aSafeAreaInsets); windowSafeAreaInsets.EnsureAtMost(aSafeAreaInsets);

View File

@ -3423,8 +3423,8 @@ class nsContentUtils {
* Return safe area insets of window that defines as * Return safe area insets of window that defines as
* https://drafts.csswg.org/css-env-1/#safe-area-insets. * https://drafts.csswg.org/css-env-1/#safe-area-insets.
*/ */
static mozilla::ScreenIntMargin GetWindowSafeAreaInsets( static mozilla::LayoutDeviceIntMargin GetWindowSafeAreaInsets(
nsIScreen* aScreen, const mozilla::ScreenIntMargin& aSafeareaInsets, nsIScreen* aScreen, const mozilla::LayoutDeviceIntMargin& aSafeareaInsets,
const mozilla::LayoutDeviceIntRect& aWindowRect); const mozilla::LayoutDeviceIntRect& aWindowRect);
struct SubresourceCacheValidationInfo { struct SubresourceCacheValidationInfo {

View File

@ -956,7 +956,7 @@ bool nsFrameLoader::Show(nsSubDocumentFrame* aFrame) {
if (IsRemoteFrame()) { if (IsRemoteFrame()) {
return ShowRemoteFrame(aFrame); return ShowRemoteFrame(aFrame);
} }
const ScreenIntSize size = aFrame->GetSubdocumentSize(); const LayoutDeviceIntSize size = aFrame->GetSubdocumentSize();
nsresult rv = MaybeCreateDocShell(); nsresult rv = MaybeCreateDocShell();
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
@ -1123,7 +1123,8 @@ bool nsFrameLoader::ShowRemoteFrame(nsSubDocumentFrame* aFrame) {
baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
nsSizeMode sizeMode = nsSizeMode sizeMode =
mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal; 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); OwnerShowInfo info(size, GetScrollbarPreference(mOwnerContent), sizeMode);
if (!mRemoteBrowser->Show(info)) { if (!mRemoteBrowser->Show(info)) {
return false; return false;
@ -2364,7 +2365,7 @@ nsresult nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI) {
return NS_OK; return NS_OK;
} }
nsresult nsFrameLoader::GetWindowDimensions(nsIntRect& aRect) { nsresult nsFrameLoader::GetWindowDimensions(LayoutDeviceIntRect& aRect) {
if (!mOwnerContent) { if (!mOwnerContent) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -2394,8 +2395,8 @@ nsresult nsFrameLoader::GetWindowDimensions(nsIntRect& aRect) {
} }
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_GetInterface(parentOwner)); nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_GetInterface(parentOwner));
treeOwnerAsWin->GetPosition(&aRect.x, &aRect.y); aRect.MoveTo(treeOwnerAsWin->GetPosition());
treeOwnerAsWin->GetSize(&aRect.width, &aRect.height); aRect.SizeTo(treeOwnerAsWin->GetSize());
return NS_OK; return NS_OK;
} }
@ -2410,8 +2411,8 @@ nsresult nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame* aFrame) {
if (!mRemoteBrowserShown) { if (!mRemoteBrowserShown) {
ShowRemoteFrame(aFrame); ShowRemoteFrame(aFrame);
} }
nsIntRect dimensions; LayoutDeviceIntRect dimensions;
NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE); MOZ_TRY(GetWindowDimensions(dimensions));
mRemoteBrowser->UpdateDimensions(dimensions, size); mRemoteBrowser->UpdateDimensions(dimensions, size);
mRemoteBrowserSized = true; mRemoteBrowserSized = true;
} }

View File

@ -390,7 +390,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
nsIContentSecurityPolicy** aCsp); nsIContentSecurityPolicy** aCsp);
// Properly retrieves documentSize of any subdocument type. // Properly retrieves documentSize of any subdocument type.
nsresult GetWindowDimensions(nsIntRect& aRect); nsresult GetWindowDimensions(mozilla::LayoutDeviceIntRect& aRect);
virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager() virtual mozilla::dom::ProcessMessageManager* GetProcessMessageManager()
const override; const override;
@ -523,7 +523,7 @@ class nsFrameLoader final : public nsStubMutationObserver,
RefPtr<nsDocShell> mDocShell; RefPtr<nsDocShell> mDocShell;
// Holds the last known size of the frame. // 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 // 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 // cleared and set to null eagerly when taking down the frameloader to break

View File

@ -66,8 +66,8 @@ bool BrowserBridgeHost::Show(const OwnerShowInfo& aShowInfo) {
return true; return true;
} }
void BrowserBridgeHost::UpdateDimensions(const nsIntRect& aRect, void BrowserBridgeHost::UpdateDimensions(const LayoutDeviceIntRect& aRect,
const ScreenIntSize& aSize) { const LayoutDeviceIntSize& aSize) {
Unused << mBridge->SendUpdateDimensions(aRect, aSize); Unused << mBridge->SendUpdateDimensions(aRect, aSize);
} }

View File

@ -21,7 +21,7 @@ namespace mozilla::dom {
* See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC * See `dom/docs/Fission-IPC-Diagram.svg` for an overview of the DOM IPC
* actors. * actors.
*/ */
class BrowserBridgeHost : public RemoteBrowser { class BrowserBridgeHost final : public RemoteBrowser {
public: public:
typedef mozilla::layers::LayersId LayersId; typedef mozilla::layers::LayersId LayersId;
@ -48,8 +48,8 @@ class BrowserBridgeHost : public RemoteBrowser {
void DestroyComplete() override; void DestroyComplete() override;
bool Show(const OwnerShowInfo&) override; bool Show(const OwnerShowInfo&) override;
void UpdateDimensions(const nsIntRect& aRect, void UpdateDimensions(const LayoutDeviceIntRect& aRect,
const ScreenIntSize& aSize) override; const LayoutDeviceIntSize& aSize) override;
void UpdateEffects(EffectsInfo aInfo) override; void UpdateEffects(EffectsInfo aInfo) override;

View File

@ -180,7 +180,7 @@ IPCResult BrowserBridgeParent::RecvResumeLoad(uint64_t aPendingSwitchID) {
} }
IPCResult BrowserBridgeParent::RecvUpdateDimensions( IPCResult BrowserBridgeParent::RecvUpdateDimensions(
const nsIntRect& aRect, const ScreenIntSize& aSize) { const LayoutDeviceIntRect& aRect, const LayoutDeviceIntSize& aSize) {
mBrowserParent->UpdateDimensions(aRect, aSize); mBrowserParent->UpdateDimensions(aRect, aSize);
return IPC_OK(); return IPC_OK();
} }

View File

@ -76,8 +76,8 @@ class BrowserBridgeParent : public PBrowserBridgeParent {
mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference); mozilla::ipc::IPCResult RecvScrollbarPreferenceChanged(ScrollbarPreference);
mozilla::ipc::IPCResult RecvLoadURL(nsDocShellLoadState* aLoadState); mozilla::ipc::IPCResult RecvLoadURL(nsDocShellLoadState* aLoadState);
mozilla::ipc::IPCResult RecvResumeLoad(uint64_t aPendingSwitchID); mozilla::ipc::IPCResult RecvResumeLoad(uint64_t aPendingSwitchID);
mozilla::ipc::IPCResult RecvUpdateDimensions(const nsIntRect& aRect, mozilla::ipc::IPCResult RecvUpdateDimensions(
const ScreenIntSize& aSize); const LayoutDeviceIntRect& aRect, const LayoutDeviceIntSize& aSize);
mozilla::ipc::IPCResult RecvUpdateEffects(const EffectsInfo& aEffects); mozilla::ipc::IPCResult RecvUpdateEffects(const EffectsInfo& aEffects);
mozilla::ipc::IPCResult RecvUpdateRemotePrintSettings( mozilla::ipc::IPCResult RecvUpdateRemotePrintSettings(
const embedding::PrintData&); const embedding::PrintData&);

View File

@ -28,6 +28,7 @@
#include "mozilla/IMEStateManager.h" #include "mozilla/IMEStateManager.h"
#include "mozilla/LookAndFeel.h" #include "mozilla/LookAndFeel.h"
#include "mozilla/MouseEvents.h" #include "mozilla/MouseEvents.h"
#include "mozilla/widget/ScreenManager.h"
#include "mozilla/NativeKeyBindingsType.h" #include "mozilla/NativeKeyBindingsType.h"
#include "mozilla/NullPrincipal.h" #include "mozilla/NullPrincipal.h"
#include "mozilla/PointerLockManager.h" #include "mozilla/PointerLockManager.h"
@ -604,7 +605,7 @@ BrowserChild::SetDimensions(DimensionRequest&& aRequest) {
NS_IMETHODIMP NS_IMETHODIMP
BrowserChild::GetDimensions(DimensionKind aDimensionKind, int32_t* aX, BrowserChild::GetDimensions(DimensionKind aDimensionKind, int32_t* aX,
int32_t* aY, int32_t* aCx, int32_t* aCy) { int32_t* aY, int32_t* aCx, int32_t* aCy) {
ScreenIntRect rect = GetOuterRect(); LayoutDeviceIntRect rect = GetOuterRect();
if (aDimensionKind == DimensionKind::Inner) { if (aDimensionKind == DimensionKind::Inner) {
if (aX || aY) { if (aX || aY) {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
@ -1007,7 +1008,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateRemotePrintSettings(
} }
void BrowserChild::DoFakeShow(const ParentShowInfo& aParentShowInfo) { void BrowserChild::DoFakeShow(const ParentShowInfo& aParentShowInfo) {
OwnerShowInfo ownerInfo{ScreenIntSize(), ScrollbarPreference::Auto, OwnerShowInfo ownerInfo{LayoutDeviceIntSize(), ScrollbarPreference::Auto,
nsSizeMode_Normal}; nsSizeMode_Normal};
RecvShow(aParentShowInfo, ownerInfo); RecvShow(aParentShowInfo, ownerInfo);
mDidFakeShow = true; mDidFakeShow = true;
@ -1125,20 +1126,20 @@ mozilla::ipc::IPCResult BrowserChild::RecvUpdateDimensions(
mHasValidInnerSize = true; mHasValidInnerSize = true;
} }
ScreenIntSize screenSize = GetInnerSize(); const LayoutDeviceIntSize innerSize = GetInnerSize();
ScreenIntRect screenRect = GetOuterRect();
// Make sure to set the size on the document viewer first. The // Make sure to set the size on the document viewer first. The
// MobileViewportManager needs the content viewer size to be updated before // MobileViewportManager needs the content viewer size to be updated before
// the reflow, otherwise it gets a stale size when it computes a new CSS // the reflow, otherwise it gets a stale size when it computes a new CSS
// viewport. // viewport.
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation()); nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, baseWin->SetPositionAndSize(0, 0, innerSize.width, innerSize.height,
nsIBaseWindow::eRepaint); nsIBaseWindow::eRepaint);
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x, const LayoutDeviceIntRect outerRect =
screenRect.y + mClientOffset.y + mChromeOffset.y, GetOuterRect() + mClientOffset + mChromeOffset;
screenSize.width, screenSize.height, true);
mPuppetWidget->Resize(outerRect.x, outerRect.y, innerSize.width,
innerSize.height, true);
RecvSafeAreaInsetsChanged(mPuppetWidget->GetSafeAreaInsets()); RecvSafeAreaInsetsChanged(mPuppetWidget->GetSafeAreaInsets());
@ -3345,23 +3346,22 @@ void BrowserChild::NotifyJankedAnimations(
mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged( mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
const float& aDpi, const int32_t& aRounding, const double& aScale) { const float& aDpi, const int32_t& aRounding, const double& aScale) {
ScreenIntSize oldScreenSize = GetInnerSize(); const LayoutDeviceIntSize oldInnerSize = GetInnerSize();
if (aDpi > 0) { if (aDpi > 0) {
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale); mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
} }
ScreenIntSize screenSize = GetInnerSize(); const LayoutDeviceIntSize innerSize = GetInnerSize();
if (mHasValidInnerSize && oldScreenSize != screenSize) { if (mHasValidInnerSize && oldInnerSize != innerSize) {
ScreenIntRect screenRect = GetOuterRect();
// See RecvUpdateDimensions for the order of these operations. // See RecvUpdateDimensions for the order of these operations.
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation()); nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(WebNavigation());
baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, baseWin->SetPositionAndSize(0, 0, innerSize.width, innerSize.height,
nsIBaseWindow::eRepaint); nsIBaseWindow::eRepaint);
mPuppetWidget->Resize(screenRect.x + mClientOffset.x + mChromeOffset.x, const LayoutDeviceIntRect outerRect =
screenRect.y + mClientOffset.y + mChromeOffset.y, GetOuterRect() + mClientOffset + mChromeOffset;
screenSize.width, screenSize.height, true); mPuppetWidget->Resize(outerRect.x, outerRect.y, innerSize.width,
innerSize.height, true);
} }
nsCOMPtr<Document> document(GetTopLevelDocument()); nsCOMPtr<Document> document(GetTopLevelDocument());
@ -3375,32 +3375,23 @@ mozilla::ipc::IPCResult BrowserChild::RecvUIResolutionChanged(
} }
mozilla::ipc::IPCResult BrowserChild::RecvSafeAreaInsetsChanged( mozilla::ipc::IPCResult BrowserChild::RecvSafeAreaInsetsChanged(
const mozilla::ScreenIntMargin& aSafeAreaInsets) { const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets) {
mPuppetWidget->UpdateSafeAreaInsets(aSafeAreaInsets); mPuppetWidget->UpdateSafeAreaInsets(aSafeAreaInsets);
nsCOMPtr<nsIScreenManager> screenMgr = LayoutDeviceIntMargin currentSafeAreaInsets;
do_GetService("@mozilla.org/gfx/screenmanager;1"); // aSafeAreaInsets is for current screen. But we have to calculate safe insets
ScreenIntMargin currentSafeAreaInsets; // for content window.
if (screenMgr) { LayoutDeviceIntRect outerRect = GetOuterRect();
// aSafeAreaInsets is for current screen. But we have to calculate RefPtr<Screen> screen = widget::ScreenManager::GetSingleton().ScreenForRect(
// safe insets for content window. RoundedToInt(outerRect / mPuppetWidget->GetDesktopToDeviceScale()));
int32_t x, y, cx, cy; if (screen) {
GetDimensions(DimensionKind::Outer, &x, &y, &cx, &cy); LayoutDeviceIntRect windowRect = outerRect + mClientOffset + mChromeOffset;
nsCOMPtr<nsIScreen> screen; currentSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets(
screenMgr->ScreenForRect(x, y, cx, cy, getter_AddRefs(screen)); screen, aSafeAreaInsets, windowRect);
if (screen) {
LayoutDeviceIntRect windowRect(x + mClientOffset.x + mChromeOffset.x,
y + mClientOffset.y + mChromeOffset.y, cx,
cy);
currentSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets(
screen, aSafeAreaInsets, windowRect);
}
} }
if (nsCOMPtr<Document> document = GetTopLevelDocument()) { if (nsCOMPtr<Document> document = GetTopLevelDocument()) {
nsPresContext* presContext = document->GetPresContext(); if (nsPresContext* presContext = document->GetPresContext()) {
if (presContext) {
presContext->SetSafeAreaInsets(currentSafeAreaInsets); presContext->SetSafeAreaInsets(currentSafeAreaInsets);
} }
} }
@ -3441,11 +3432,8 @@ bool BrowserChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) {
return true; return true;
} }
ScreenIntSize BrowserChild::GetInnerSize() { LayoutDeviceIntSize BrowserChild::GetInnerSize() {
LayoutDeviceIntSize innerSize = return RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());
RoundedToInt(mUnscaledInnerSize * mPuppetWidget->GetDefaultScale());
return ViewAs<ScreenPixel>(
innerSize, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
}; };
Maybe<nsRect> BrowserChild::GetVisibleRect() const { Maybe<nsRect> BrowserChild::GetVisibleRect() const {
@ -3489,11 +3477,8 @@ BrowserChild::GetTopLevelViewportVisibleRectInSelfCoords() const {
return rect; return rect;
} }
ScreenIntRect BrowserChild::GetOuterRect() { LayoutDeviceIntRect BrowserChild::GetOuterRect() {
LayoutDeviceIntRect outerRect = return RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale());
RoundedToInt(mUnscaledOuterRect * mPuppetWidget->GetDefaultScale());
return ViewAs<ScreenPixel>(
outerRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims);
} }
void BrowserChild::PaintWhileInterruptingJS() { void BrowserChild::PaintWhileInterruptingJS() {

View File

@ -436,7 +436,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
const IPCTabContext& aContext); const IPCTabContext& aContext);
mozilla::ipc::IPCResult RecvSafeAreaInsetsChanged( mozilla::ipc::IPCResult RecvSafeAreaInsetsChanged(
const mozilla::ScreenIntMargin& aSafeAreaInsets); const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets);
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY
PDocAccessibleChild* AllocPDocAccessibleChild( PDocAccessibleChild* AllocPDocAccessibleChild(
@ -568,7 +568,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
const mozilla::layers::CompositorOptions& GetCompositorOptions() const; const mozilla::layers::CompositorOptions& GetCompositorOptions() const;
bool AsyncPanZoomEnabled() const; bool AsyncPanZoomEnabled() const;
ScreenIntSize GetInnerSize(); LayoutDeviceIntSize GetInnerSize();
CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; } CSSSize GetUnscaledInnerSize() { return mUnscaledInnerSize; }
Maybe<nsRect> GetVisibleRect() const; Maybe<nsRect> GetVisibleRect() const;
@ -758,7 +758,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
bool HasValidInnerSize(); bool HasValidInnerSize();
ScreenIntRect GetOuterRect(); LayoutDeviceIntRect GetOuterRect();
void SetUnscaledInnerSize(const CSSSize& aSize) { void SetUnscaledInnerSize(const CSSSize& aSize) {
mUnscaledInnerSize = aSize; mUnscaledInnerSize = aSize;

View File

@ -90,8 +90,8 @@ bool BrowserHost::Show(const OwnerShowInfo& aShowInfo) {
return mRoot->Show(aShowInfo); return mRoot->Show(aShowInfo);
} }
void BrowserHost::UpdateDimensions(const nsIntRect& aRect, void BrowserHost::UpdateDimensions(const LayoutDeviceIntRect& aRect,
const ScreenIntSize& aSize) { const LayoutDeviceIntSize& aSize) {
mRoot->UpdateDimensions(aRect, aSize); mRoot->UpdateDimensions(aRect, aSize);
} }

View File

@ -87,8 +87,8 @@ class BrowserHost : public RemoteBrowser,
void DestroyComplete() override; void DestroyComplete() override;
bool Show(const OwnerShowInfo&) override; bool Show(const OwnerShowInfo&) override;
void UpdateDimensions(const nsIntRect& aRect, void UpdateDimensions(const LayoutDeviceIntRect& aRect,
const ScreenIntSize& aSize) override; const LayoutDeviceIntSize& aSize) override;
void UpdateEffects(EffectsInfo aInfo) override; void UpdateEffects(EffectsInfo aInfo) override;

View File

@ -1027,8 +1027,7 @@ void BrowserParent::InitRendering() {
RefPtr<nsIWidget> widget = GetTopLevelWidget(); RefPtr<nsIWidget> widget = GetTopLevelWidget();
if (widget) { if (widget) {
ScreenIntMargin safeAreaInsets = widget->GetSafeAreaInsets(); Unused << SendSafeAreaInsetsChanged(widget->GetSafeAreaInsets());
Unused << SendSafeAreaInsetsChanged(safeAreaInsets);
} }
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
@ -1116,7 +1115,7 @@ nsresult BrowserParent::UpdatePosition() {
if (!frameLoader) { if (!frameLoader) {
return NS_OK; return NS_OK;
} }
nsIntRect windowDims; LayoutDeviceIntRect windowDims;
NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims), NS_ENSURE_SUCCESS(frameLoader->GetWindowDimensions(windowDims),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
// Avoid updating sizes here. // Avoid updating sizes here.
@ -1139,8 +1138,8 @@ void BrowserParent::NotifyPositionUpdatedForContentsInPopup() {
} }
} }
void BrowserParent::UpdateDimensions(const nsIntRect& rect, void BrowserParent::UpdateDimensions(const LayoutDeviceIntRect& rect,
const ScreenIntSize& size) { const LayoutDeviceIntSize& size) {
if (mIsDestroyed) { if (mIsDestroyed) {
return; return;
} }
@ -1169,26 +1168,18 @@ void BrowserParent::UpdateDimensions(const nsIntRect& rect,
} }
DimensionInfo BrowserParent::GetDimensionInfo() { DimensionInfo BrowserParent::GetDimensionInfo() {
LayoutDeviceIntRect devicePixelRect = ViewAs<LayoutDevicePixel>( CSSRect unscaledRect = mRect / mDefaultScale;
mRect, PixelCastJustification::LayoutDeviceIsScreenForTabDims); CSSSize unscaledSize = mDimensions / mDefaultScale;
LayoutDeviceIntSize devicePixelSize = ViewAs<LayoutDevicePixel>( return DimensionInfo(unscaledRect, unscaledSize, mClientOffset,
mDimensions, PixelCastJustification::LayoutDeviceIsScreenForTabDims); mChromeOffset);
CSSRect unscaledRect = devicePixelRect / mDefaultScale;
CSSSize unscaledSize = devicePixelSize / mDefaultScale;
DimensionInfo di(unscaledRect, unscaledSize, mClientOffset, mChromeOffset);
return di;
} }
void BrowserParent::UpdateNativePointerLockCenter(nsIWidget* aWidget) { void BrowserParent::UpdateNativePointerLockCenter(nsIWidget* aWidget) {
if (!mLockedNativePointer) { if (!mLockedNativePointer) {
return; return;
} }
LayoutDeviceIntRect dims( aWidget->SetNativePointerLockCenter(
{0, 0}, LayoutDeviceIntRect(mChromeOffset, mDimensions).Center());
ViewAs<LayoutDevicePixel>(
mDimensions, PixelCastJustification::LayoutDeviceIsScreenForTabDims));
aWidget->SetNativePointerLockCenter((dims + mChromeOffset).Center());
} }
void BrowserParent::SizeModeChanged(const nsSizeMode& aSizeMode) { void BrowserParent::SizeModeChanged(const nsSizeMode& aSizeMode) {

View File

@ -468,7 +468,8 @@ class BrowserParent final : public PBrowserParent,
bool Show(const OwnerShowInfo&); bool Show(const OwnerShowInfo&);
void UpdateDimensions(const nsIntRect& aRect, const ScreenIntSize& aSize); void UpdateDimensions(const LayoutDeviceIntRect& aRect,
const LayoutDeviceIntSize& aSize);
DimensionInfo GetDimensionInfo(); DimensionInfo GetDimensionInfo();
@ -922,8 +923,8 @@ class BrowserParent final : public PBrowserParent,
}; };
nsTArray<SentKeyEventData> mWaitingReplyKeyboardEvents; nsTArray<SentKeyEventData> mWaitingReplyKeyboardEvents;
nsIntRect mRect; LayoutDeviceIntRect mRect;
ScreenIntSize mDimensions; LayoutDeviceIntSize mDimensions;
float mDPI; float mDPI;
int32_t mRounding; int32_t mRounding;
CSSToLayoutDeviceScale mDefaultScale; CSSToLayoutDeviceScale mDefaultScale;

View File

@ -39,7 +39,7 @@ using mozilla::DesktopToLayoutDeviceScale from "Units.h";
using mozilla::CSSToLayoutDeviceScale from "Units.h"; using mozilla::CSSToLayoutDeviceScale from "Units.h";
using mozilla::CSSRect from "Units.h"; using mozilla::CSSRect from "Units.h";
using mozilla::CSSSize 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::LayoutDeviceIntPoint from "Units.h";
using mozilla::ImageIntSize from "Units.h"; using mozilla::ImageIntSize from "Units.h";
using nsSizeMode from "nsIWidgetListener.h"; using nsSizeMode from "nsIWidgetListener.h";
@ -315,7 +315,7 @@ struct ParentShowInfo
struct OwnerShowInfo { struct OwnerShowInfo {
// This can be an IntSize rather than a Rect because content processes always // This can be an IntSize rather than a Rect because content processes always
// render to a virtual <0, 0> top-left point. // render to a virtual <0, 0> top-left point.
ScreenIntSize size; LayoutDeviceIntSize size;
// TODO(emilio): Margin preferences go here. // TODO(emilio): Margin preferences go here.
ScrollbarPreference scrollbarPreference; ScrollbarPreference scrollbarPreference;

View File

@ -48,9 +48,8 @@ using mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using mozilla::LayoutDeviceIntPoint from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h";
using mozilla::LayoutDevicePoint from "Units.h"; using mozilla::LayoutDevicePoint from "Units.h";
using mozilla::LayoutDeviceIntMargin from "Units.h";
using mozilla::ScreenIntCoord 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 mozilla::ScreenRect from "Units.h";
using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h";
using struct mozilla::layers::ZoomConstraints from "mozilla/layers/ZoomConstraints.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. * 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 * Tell the browser that its frame loader has been swapped

View File

@ -23,7 +23,6 @@ using mozilla::ScrollAxis from "mozilla/PresShellForwards.h";
using mozilla::ScrollFlags from "mozilla/PresShellForwards.h"; using mozilla::ScrollFlags from "mozilla/PresShellForwards.h";
using struct nsRect from "nsRect.h"; using struct nsRect from "nsRect.h";
using mozilla::dom::CallerType from "mozilla/dom/BindingDeclarations.h"; using mozilla::dom::CallerType from "mozilla/dom/BindingDeclarations.h";
using nsIntRect from "nsRect.h";
using mozilla::dom::EmbedderElementEventType from "mozilla/dom/TabMessageTypes.h"; using mozilla::dom::EmbedderElementEventType from "mozilla/dom/TabMessageTypes.h";
[RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h"; [RefCounted] using class nsDocShellLoadState from "nsDocShellLoadState.h";
using mozilla::IntrinsicSize from "nsIFrame.h"; using mozilla::IntrinsicSize from "nsIFrame.h";
@ -92,7 +91,7 @@ parent:
// Out of process rendering. // Out of process rendering.
async Show(OwnerShowInfo info); async Show(OwnerShowInfo info);
async ScrollbarPreferenceChanged(ScrollbarPreference pref); 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 RenderLayers(bool aEnabled);
async UpdateEffects(EffectsInfo aEffects); async UpdateEffects(EffectsInfo aEffects);

View File

@ -61,8 +61,8 @@ class RemoteBrowser : public nsISupports {
virtual void DestroyComplete() = 0; virtual void DestroyComplete() = 0;
virtual bool Show(const OwnerShowInfo&) = 0; virtual bool Show(const OwnerShowInfo&) = 0;
virtual void UpdateDimensions(const nsIntRect& aRect, virtual void UpdateDimensions(const LayoutDeviceIntRect& aRect,
const ScreenIntSize& aSize) = 0; const LayoutDeviceIntSize& aSize) = 0;
virtual void UpdateEffects(EffectsInfo aInfo) = 0; virtual void UpdateEffects(EffectsInfo aInfo) = 0;
}; };

View File

@ -44,9 +44,6 @@ enum class PixelCastJustification : uint8_t {
// reference point as a screen point. The reverse is useful when synthetically // reference point as a screen point. The reverse is useful when synthetically
// created WidgetEvents need to be converted back to InputData. // created WidgetEvents need to be converted back to InputData.
LayoutDeviceIsScreenForUntransformedEvent, LayoutDeviceIsScreenForUntransformedEvent,
// Similar to LayoutDeviceIsScreenForUntransformedEvent, PBrowser handles
// some widget/tab dimension information as the OS does -- in screen units.
LayoutDeviceIsScreenForTabDims,
// A combination of LayoutDeviceIsScreenForBounds and // A combination of LayoutDeviceIsScreenForBounds and
// ScreenIsParentLayerForRoot, which is how we're using it. // ScreenIsParentLayerForRoot, which is how we're using it.
LayoutDeviceIsParentLayerForRCDRSF, LayoutDeviceIsParentLayerForRCDRSF,

View File

@ -890,8 +890,8 @@ template <class Src, class Dst>
gfx::MarginTyped<Dst> operator/(const gfx::MarginTyped<Src>& aMargin, gfx::MarginTyped<Dst> operator/(const gfx::MarginTyped<Src>& aMargin,
const gfx::ScaleFactor<Dst, Src>& aScale) { const gfx::ScaleFactor<Dst, Src>& aScale) {
return gfx::MarginTyped<Dst>( return gfx::MarginTyped<Dst>(
aMargin.top / aScale.scale, aMargin.right / aScale.scale, aMargin.top.value / aScale.scale, aMargin.right.value / aScale.scale,
aMargin.bottom / aScale.scale, aMargin.left / aScale.scale); aMargin.bottom.value / aScale.scale, aMargin.left.value / aScale.scale);
} }
template <class Src, class Dst, class F> template <class Src, class Dst, class F>

View File

@ -740,14 +740,12 @@ nsresult nsDocumentViewer::InitPresentationStuff(bool aDoInitialReflow) {
if (mWindow && mDocument->IsTopLevelContentDocument()) { if (mWindow && mDocument->IsTopLevelContentDocument()) {
// Set initial safe area insets // Set initial safe area insets
ScreenIntMargin windowSafeAreaInsets; LayoutDeviceIntMargin windowSafeAreaInsets;
LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds();
nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen(); if (nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen()) {
if (screen) {
windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets(
screen, mWindow->GetSafeAreaInsets(), windowRect); screen, mWindow->GetSafeAreaInsets(), windowRect);
} }
mPresContext->SetSafeAreaInsets(windowSafeAreaInsets); mPresContext->SetSafeAreaInsets(windowSafeAreaInsets);
} }

View File

@ -3204,7 +3204,8 @@ nscoord nsPresContext::GetBimodalDynamicToolbarHeightInAppUnits() const {
: 0; : 0;
} }
void nsPresContext::SetSafeAreaInsets(const ScreenIntMargin& aSafeAreaInsets) { void nsPresContext::SetSafeAreaInsets(
const LayoutDeviceIntMargin& aSafeAreaInsets) {
if (mSafeAreaInsets == aSafeAreaInsets) { if (mSafeAreaInsets == aSafeAreaInsets) {
return; return;
} }

View File

@ -544,9 +544,11 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
/** /**
* Notify the pres context that the safe area insets have changed. * 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 RegisterManagedPostRefreshObserver(mozilla::ManagedPostRefreshObserver*);
void UnregisterManagedPostRefreshObserver( void UnregisterManagedPostRefreshObserver(
@ -1245,7 +1247,7 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
// The software keyboard height. // The software keyboard height.
mozilla::ScreenIntCoord mKeyboardHeight; mozilla::ScreenIntCoord mKeyboardHeight;
// Safe area insets support // Safe area insets support
mozilla::ScreenIntMargin mSafeAreaInsets; mozilla::LayoutDeviceIntMargin mSafeAreaInsets;
nsSize mPageSize; nsSize mPageSize;
// The computed page margins from the print settings. // The computed page margins from the print settings.

View File

@ -283,26 +283,27 @@ nsRect nsSubDocumentFrame::GetDestRect(const nsRect& aConstraintRect) {
GetIntrinsicRatio(), StylePosition()); GetIntrinsicRatio(), StylePosition());
} }
ScreenIntSize nsSubDocumentFrame::GetSubdocumentSize() { LayoutDeviceIntSize nsSubDocumentFrame::GetSubdocumentSize() {
if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
if (RefPtr<nsFrameLoader> frameloader = FrameLoader()) { if (RefPtr<nsFrameLoader> frameloader = FrameLoader()) {
nsIFrame* detachedFrame = frameloader->GetDetachedSubdocFrame(); nsIFrame* detachedFrame = frameloader->GetDetachedSubdocFrame();
if (nsView* view = detachedFrame ? detachedFrame->GetView() : nullptr) { if (nsView* view = detachedFrame ? detachedFrame->GetView() : nullptr) {
nsSize size = view->GetBounds().Size(); nsSize size = view->GetBounds().Size();
nsPresContext* presContext = detachedFrame->PresContext(); nsPresContext* presContext = detachedFrame->PresContext();
return ScreenIntSize(presContext->AppUnitsToDevPixels(size.width), return LayoutDeviceIntSize(
presContext->AppUnitsToDevPixels(size.height)); presContext->AppUnitsToDevPixels(size.width),
presContext->AppUnitsToDevPixels(size.height));
} }
} }
// Pick some default size for now. Using 10x10 because that's what the // Pick some default size for now. Using 10x10 because that's what the
// code used to do. // code used to do.
return ScreenIntSize(10, 10); return LayoutDeviceIntSize(10, 10);
} }
nsSize docSizeAppUnits = GetDestRect().Size(); nsSize docSizeAppUnits = GetDestRect().Size();
nsPresContext* pc = PresContext(); nsPresContext* pc = PresContext();
return ScreenIntSize(pc->AppUnitsToDevPixels(docSizeAppUnits.width), return LayoutDeviceIntSize(pc->AppUnitsToDevPixels(docSizeAppUnits.width),
pc->AppUnitsToDevPixels(docSizeAppUnits.height)); pc->AppUnitsToDevPixels(docSizeAppUnits.height));
} }
static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder, static void WrapBackgroundColorInOwnLayer(nsDisplayListBuilder* aBuilder,

View File

@ -103,7 +103,7 @@ class nsSubDocumentFrame final : public nsAtomicContainerFrame,
mozilla::PresShell* GetSubdocumentPresShellForPainting(uint32_t aFlags); mozilla::PresShell* GetSubdocumentPresShellForPainting(uint32_t aFlags);
nsRect GetDestRect(); nsRect GetDestRect();
nsRect GetDestRect(const nsRect& aConstraintRect); nsRect GetDestRect(const nsRect& aConstraintRect);
mozilla::ScreenIntSize GetSubdocumentSize(); mozilla::LayoutDeviceIntSize GetSubdocumentSize();
bool ContentReactsToPointerEvents() const; bool ContentReactsToPointerEvents() const;

View File

@ -1664,11 +1664,13 @@ bool Gecko_AssertClassAttrValueIsSane(const nsAttrValue* aValue) {
void Gecko_GetSafeAreaInsets(const nsPresContext* aPresContext, float* aTop, void Gecko_GetSafeAreaInsets(const nsPresContext* aPresContext, float* aTop,
float* aRight, float* aBottom, float* aLeft) { float* aRight, float* aBottom, float* aLeft) {
MOZ_ASSERT(aPresContext); MOZ_ASSERT(aPresContext);
ScreenIntMargin safeAreaInsets = aPresContext->GetSafeAreaInsets(); const CSSMargin insets =
*aTop = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.top); LayoutDeviceMargin(aPresContext->GetSafeAreaInsets()) /
*aRight = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.right); aPresContext->CSSToDevPixelScale();
*aBottom = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.bottom); *aTop = insets.top;
*aLeft = aPresContext->DevPixelsToFloatCSSPixels(safeAreaInsets.left); *aRight = insets.right;
*aBottom = insets.bottom;
*aLeft = insets.left;
} }
void Gecko_PrintfStderr(const nsCString* aStr) { void Gecko_PrintfStderr(const nsCString* aStr) {

View File

@ -1013,7 +1013,8 @@ nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent,
return result; return result;
} }
void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) { void nsView::SafeAreaInsetsChanged(
const LayoutDeviceIntMargin& aSafeAreaInsets) {
if (!IsRoot()) { if (!IsRoot()) {
return; return;
} }
@ -1023,10 +1024,9 @@ void nsView::SafeAreaInsetsChanged(const ScreenIntMargin& aSafeAreaInsets) {
return; return;
} }
ScreenIntMargin windowSafeAreaInsets; LayoutDeviceIntMargin windowSafeAreaInsets;
LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds(); const LayoutDeviceIntRect windowRect = mWindow->GetScreenBounds();
nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen(); if (nsCOMPtr<nsIScreen> screen = mWindow->GetWidgetScreen()) {
if (screen) {
windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets( windowSafeAreaInsets = nsContentUtils::GetWindowSafeAreaInsets(
screen, aSafeAreaInsets, windowRect); screen, aSafeAreaInsets, windowRect);
} }

View File

@ -408,37 +408,33 @@ class nsView final : public nsIWidgetListener {
} }
// nsIWidgetListener // nsIWidgetListener
virtual mozilla::PresShell* GetPresShell() override; mozilla::PresShell* GetPresShell() override;
virtual nsView* GetView() override { return this; } nsView* GetView() override { return this; }
virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y, bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y,
ByMoveToRect) override; ByMoveToRect) override;
virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
int32_t aHeight) override; int32_t aHeight) override;
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
virtual void DynamicToolbarMaxHeightChanged( void DynamicToolbarMaxHeightChanged(mozilla::ScreenIntCoord aHeight) override;
mozilla::ScreenIntCoord aHeight) override; void DynamicToolbarOffsetChanged(mozilla::ScreenIntCoord aOffset) override;
virtual void DynamicToolbarOffsetChanged( void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override;
mozilla::ScreenIntCoord aOffset) override;
virtual void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight) override;
#endif #endif
virtual bool RequestWindowClose(nsIWidget* aWidget) override; bool RequestWindowClose(nsIWidget* aWidget) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual void WillPaintWindow(nsIWidget* aWidget) override; void WillPaintWindow(nsIWidget* aWidget) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual bool PaintWindow(nsIWidget* aWidget, bool PaintWindow(nsIWidget* aWidget, LayoutDeviceIntRegion aRegion) override;
LayoutDeviceIntRegion aRegion) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual void DidPaintWindow() override; void DidPaintWindow() override;
virtual void DidCompositeWindow( void DidCompositeWindow(mozilla::layers::TransactionId aTransactionId,
mozilla::layers::TransactionId aTransactionId, const mozilla::TimeStamp& aCompositeStart,
const mozilla::TimeStamp& aCompositeStart, const mozilla::TimeStamp& aCompositeEnd) override;
const mozilla::TimeStamp& aCompositeEnd) override; void RequestRepaint() override;
virtual void RequestRepaint() override; bool ShouldNotBeVisible() override;
virtual bool ShouldNotBeVisible() override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
bool aUseAttachedEvents) override; bool aUseAttachedEvents) override;
virtual void SafeAreaInsetsChanged(const mozilla::ScreenIntMargin&) override; void SafeAreaInsetsChanged(const mozilla::LayoutDeviceIntMargin&) override;
virtual ~nsView(); virtual ~nsView();

View File

@ -988,12 +988,12 @@ void PuppetWidget::StartAsyncScrollbarDrag(
mBrowserChild->StartScrollbarDrag(aDragMetrics); mBrowserChild->StartScrollbarDrag(aDragMetrics);
} }
ScreenIntMargin PuppetWidget::GetSafeAreaInsets() const { LayoutDeviceIntMargin PuppetWidget::GetSafeAreaInsets() const {
return mSafeAreaInsets; return mSafeAreaInsets;
} }
void PuppetWidget::UpdateSafeAreaInsets( void PuppetWidget::UpdateSafeAreaInsets(
const ScreenIntMargin& aSafeAreaInsets) { const LayoutDeviceIntMargin& aSafeAreaInsets) {
mSafeAreaInsets = aSafeAreaInsets; mSafeAreaInsets = aSafeAreaInsets;
} }

View File

@ -204,8 +204,8 @@ class PuppetWidget final : public nsBaseWidget,
} }
// safe area insets support // safe area insets support
ScreenIntMargin GetSafeAreaInsets() const override; LayoutDeviceIntMargin GetSafeAreaInsets() const override;
void UpdateSafeAreaInsets(const ScreenIntMargin& aSafeAreaInsets); void UpdateSafeAreaInsets(const LayoutDeviceIntMargin& aSafeAreaInsets);
// Get the offset to the chrome of the window that this tab belongs to. // 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; int32_t mRounding = 1;
double mDefaultScale = GetFallbackDefaultScale().scale; double mDefaultScale = GetFallbackDefaultScale().scale;
ScreenIntMargin mSafeAreaInsets; LayoutDeviceIntMargin mSafeAreaInsets;
RefPtr<TextEventDispatcherListener> mNativeTextEventDispatcherListener; RefPtr<TextEventDispatcherListener> mNativeTextEventDispatcherListener;
protected: protected:

View File

@ -1747,7 +1747,7 @@ class LayerViewSupport final
return; return;
} }
ScreenIntMargin safeAreaInsets(aTop, aRight, aBottom, aLeft); LayoutDeviceIntMargin safeAreaInsets(aTop, aRight, aBottom, aLeft);
gkWindow->UpdateSafeAreaInsets(safeAreaInsets); 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; mSafeAreaInsets = aSafeAreaInsets;
if (mWidgetListener) { if (mWidgetListener) {

View File

@ -73,7 +73,7 @@ class nsWindow final : public nsBaseWidget {
private: private:
nsCOMPtr<nsIUserIdleServiceInternal> mIdleService; nsCOMPtr<nsIUserIdleServiceInternal> mIdleService;
mozilla::ScreenIntCoord mDynamicToolbarMaxHeight{0}; mozilla::ScreenIntCoord mDynamicToolbarMaxHeight{0};
mozilla::ScreenIntMargin mSafeAreaInsets; mozilla::LayoutDeviceIntMargin mSafeAreaInsets;
mozilla::widget::PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate = mozilla::widget::PlatformCompositorWidgetDelegate* mCompositorWidgetDelegate =
nullptr; nullptr;
mozilla::Mutex mDestroyMutex{"nsWindow::mDestroyMutex"}; mozilla::Mutex mDestroyMutex{"nsWindow::mDestroyMutex"};
@ -251,8 +251,8 @@ class nsWindow final : public nsBaseWidget {
void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset); void UpdateDynamicToolbarOffset(mozilla::ScreenIntCoord aOffset);
mozilla::ScreenIntMargin GetSafeAreaInsets() const override; mozilla::LayoutDeviceIntMargin GetSafeAreaInsets() const override;
void UpdateSafeAreaInsets(const mozilla::ScreenIntMargin& aSafeAreaInsets); void UpdateSafeAreaInsets(const mozilla::LayoutDeviceIntMargin&);
void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight); void KeyboardHeightChanged(mozilla::ScreenIntCoord aHeight);

View File

@ -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); [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 * Tell the window to repaint itself
* @param aForce - if true, repaint immediately * @param aForce - if true, repaint immediately

View File

@ -1667,8 +1667,8 @@ class nsIWidget : public nsISupports {
* Get safe area insets except to cutout. * Get safe area insets except to cutout.
* See https://drafts.csswg.org/css-env-1/#safe-area-insets. * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
*/ */
virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const { virtual mozilla::LayoutDeviceIntMargin GetSafeAreaInsets() const {
return mozilla::ScreenIntMargin(); return mozilla::LayoutDeviceIntMargin();
} }
private: private:

View File

@ -33,8 +33,8 @@ bool nsIWidgetListener::WindowResized(nsIWidget* aWidget, int32_t aWidth,
void nsIWidgetListener::SizeModeChanged(nsSizeMode aSizeMode) {} void nsIWidgetListener::SizeModeChanged(nsSizeMode aSizeMode) {}
void nsIWidgetListener::SafeAreaInsetsChanged(const mozilla::ScreenIntMargin&) { void nsIWidgetListener::SafeAreaInsetsChanged(
} const mozilla::LayoutDeviceIntMargin&) {}
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
void nsIWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) { void nsIWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {

View File

@ -176,7 +176,7 @@ class nsIWidgetListener {
* Called when safe area insets are changed. * Called when safe area insets are changed.
*/ */
virtual void SafeAreaInsetsChanged( virtual void SafeAreaInsetsChanged(
const mozilla::ScreenIntMargin& aSafeAreaInsets); const mozilla::LayoutDeviceIntMargin& aSafeAreaInsets);
}; };
#endif #endif