tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 7ec0d3439bf147f52e92fa9bdc5aca36cca796b8
parent 961bc8802f08ee81e213f3e3e786b97cfa8597c9
Author: Alexandru Marc <amarc@mozilla.com>
Date:   Wed,  3 Dec 2025 10:24:53 +0200

Revert "Bug 1998555 - Make sure that nsIBaseWindow scale agrees with nsDeviceContext. r=jwatt" for causing bc failures @ browser_print_page_range.js

This reverts commit d45de9c0f73a5fe192041547d6b0f64135a62b78.

Diffstat:
Mgfx/src/nsDeviceContext.cpp | 31++++++++++++-------------------
Mgfx/src/nsDeviceContext.h | 4----
Mwidget/nsIBaseWindow.cpp | 9++-------
3 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp @@ -44,19 +44,6 @@ nsDeviceContext::nsDeviceContext() nsDeviceContext::~nsDeviceContext() = default; -int32_t nsDeviceContext::ComputeAppUnitsPerDevPixelForWidgetScale( - CSSToLayoutDeviceScale aScale) { - return std::max(1, NS_lround(AppUnitsPerCSSPixel() / aScale.scale)); -} - -int32_t nsDeviceContext::ApplyFullZoomToAPD(int32_t aUnzoomedAppUnits, - float aFullZoom) { - if (aFullZoom == 1.0f) { - return aUnzoomedAppUnits; - } - return std::max(1, NSToIntRound(float(aUnzoomedAppUnits) / aFullZoom)); -} - void nsDeviceContext::SetDPI() { float dpi; @@ -66,8 +53,7 @@ void nsDeviceContext::SetDPI() { mPrintingScale = mDeviceContextSpec->GetPrintingScale(); mPrintingTranslate = mDeviceContextSpec->GetPrintingTranslate(); mAppUnitsPerDevPixelAtUnitFullZoom = - ComputeAppUnitsPerDevPixelForWidgetScale( - CSSToLayoutDeviceScale(96.0f / dpi)); + NS_lround((AppUnitsPerCSSPixel() * 96) / dpi); } else { // A value of -1 means use the maximum of 96 and the system DPI. // A value of 0 means use the system DPI. A positive value is used as the @@ -90,7 +76,7 @@ void nsDeviceContext::SetDPI() { mWidget ? mWidget->GetDefaultScale() : CSSToLayoutDeviceScale(1.0); MOZ_ASSERT(scale.scale > 0.0); mAppUnitsPerDevPixelAtUnitFullZoom = - ComputeAppUnitsPerDevPixelForWidgetScale(scale); + std::max(1, NS_lround(AppUnitsPerCSSPixel() / scale.scale)); } NS_ASSERTION(dpi != -1.0, "no dpi set"); @@ -379,15 +365,22 @@ bool nsDeviceContext::SetFullZoom(float aScale) { return oldAppUnitsPerDevPixel != mAppUnitsPerDevPixel; } +static int32_t ApplyFullZoom(int32_t aUnzoomedAppUnits, float aFullZoom) { + if (aFullZoom == 1.0f) { + return aUnzoomedAppUnits; + } + return std::max(1, NSToIntRound(float(aUnzoomedAppUnits) / aFullZoom)); +} + int32_t nsDeviceContext::AppUnitsPerDevPixelInTopLevelChromePage() const { // The only zoom that applies to chrome pages is the system zoom, if any. - return ApplyFullZoomToAPD(mAppUnitsPerDevPixelAtUnitFullZoom, - LookAndFeel::SystemZoomSettings().mFullZoom); + return ApplyFullZoom(mAppUnitsPerDevPixelAtUnitFullZoom, + LookAndFeel::SystemZoomSettings().mFullZoom); } void nsDeviceContext::UpdateAppUnitsForFullZoom() { mAppUnitsPerDevPixel = - ApplyFullZoomToAPD(mAppUnitsPerDevPixelAtUnitFullZoom, mFullZoom); + ApplyFullZoom(mAppUnitsPerDevPixelAtUnitFullZoom, mFullZoom); // adjust mFullZoom to reflect appunit rounding mFullZoom = float(mAppUnitsPerDevPixelAtUnitFullZoom) / mAppUnitsPerDevPixel; } diff --git a/gfx/src/nsDeviceContext.h b/gfx/src/nsDeviceContext.h @@ -91,10 +91,6 @@ class nsDeviceContext final { */ int32_t AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; } - static int32_t ComputeAppUnitsPerDevPixelForWidgetScale( - mozilla::CSSToLayoutDeviceScale); - static int32_t ApplyFullZoomToAPD(int32_t aAppUnitsPerPixel, float aFullZoom); - /** * Convert device pixels which is used for gfx/thebes to nearest * (rounded) app units diff --git a/widget/nsIBaseWindow.cpp b/widget/nsIBaseWindow.cpp @@ -4,16 +4,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsIBaseWindow.h" -#include "nsDeviceContext.h" #include "mozilla/LookAndFeel.h" using namespace mozilla; CSSToLayoutDeviceScale nsIBaseWindow::UnscaledDevicePixelsPerCSSPixel() { - CSSToLayoutDeviceScale widgetScale(GetWidgetCSSToDeviceScale()); - int32_t apd = - nsDeviceContext::ComputeAppUnitsPerDevPixelForWidgetScale(widgetScale); - apd = nsDeviceContext::ApplyFullZoomToAPD( - apd, LookAndFeel::SystemZoomSettings().mFullZoom); - return CSSToLayoutDeviceScale(double(AppUnitsPerCSSPixel()) / double(apd)); + return CSSToLayoutDeviceScale(GetWidgetCSSToDeviceScale() * + LookAndFeel::SystemZoomSettings().mFullZoom); }