From 1c5f34a179a33fd6be267963fc2895cf7138853c Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Wed, 23 Mar 2022 15:24:38 +0000 Subject: [PATCH] Bug 1751217 Part 2: Change nsDeviceContext::GetDepth to eliminate the outparam. r=emilio This function always succeeds so there's no reason to maintain an nsresult. Differential Revision: https://phabricator.services.mozilla.com/D141407 --- dom/base/nsScreen.cpp | 4 +--- gfx/src/nsDeviceContext.cpp | 8 ++++---- gfx/src/nsDeviceContext.h | 2 +- layout/style/nsMediaFeatures.cpp | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/dom/base/nsScreen.cpp b/dom/base/nsScreen.cpp index 6f53f405a4c8..245b06f7c519 100644 --- a/dom/base/nsScreen.cpp +++ b/dom/base/nsScreen.cpp @@ -63,9 +63,7 @@ int32_t nsScreen::GetPixelDepth(ErrorResult& aRv) { return -1; } - uint32_t depth; - context->GetDepth(depth); - return depth; + return context->GetDepth(); } nsPIDOMWindowOuter* nsScreen::GetOuter() const { diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 2676320cf66c..1d1085e03964 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -211,7 +211,7 @@ already_AddRefed nsDeviceContext::CreateRenderingContextCommon( return pContext.forget(); } -nsresult nsDeviceContext::GetDepth(uint32_t& aDepth) { +uint32_t nsDeviceContext::GetDepth() { nsCOMPtr screen; FindScreen(getter_AddRefs(screen)); if (!screen) { @@ -219,9 +219,9 @@ nsresult nsDeviceContext::GetDepth(uint32_t& aDepth) { screenManager.GetPrimaryScreen(getter_AddRefs(screen)); MOZ_ASSERT(screen); } - screen->GetColorDepth(reinterpret_cast(&aDepth)); - - return NS_OK; + int32_t depth = 0; + screen->GetColorDepth(&depth); + return uint32_t(depth); } nsresult nsDeviceContext::GetDeviceSurfaceDimensions(nscoord& aWidth, diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h index f64512a8983e..9fc795b5bf49 100644 --- a/gfx/src/nsDeviceContext.h +++ b/gfx/src/nsDeviceContext.h @@ -110,7 +110,7 @@ class nsDeviceContext final { /** * Return the bit depth of the device. */ - nsresult GetDepth(uint32_t& aDepth); + uint32_t GetDepth(); /** * Get the size of the displayable area of the output device diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index 25a6d8034311..dbb576754725 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -157,7 +157,7 @@ uint32_t Gecko_MediaFeatures_GetColorDepth(const Document* aDocument) { if (!nsContentUtils::ShouldResistFingerprinting(aDocument)) { if (nsDeviceContext* dx = GetDeviceContextFor(aDocument)) { - dx->GetDepth(depth); + depth = dx->GetDepth(); } }