mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1573992 - Convert layout.css.devPixelsPerPx to static pref. r=njn
Converts layout.css.devPixelsPerPx to a static pref. This one was one of the slightly odd ones; some values were expecting an atomic float, so instead of defining a regular type float it is defined in StaticPrefList.yaml as an AtomicFloat. I am assuming this was the intent of the pref value all along. Differential Revision: https://phabricator.services.mozilla.com/D42396 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
533fc20279
commit
943e049dcc
@ -4353,6 +4353,15 @@
|
||||
mirror: always
|
||||
rust: true
|
||||
|
||||
# Set the number of device pixels per CSS pixel. A value <= 0 means choose
|
||||
# automatically based on user settings for the platform (e.g., "UI scale factor"
|
||||
# on Mac). A positive value is used as-is. This effectively controls the size
|
||||
# of a CSS "px". This is only used for windows on the screen, not for printing.
|
||||
- name: layout.css.devPixelsPerPx
|
||||
type: AtomicFloat
|
||||
value: -1.0f
|
||||
mirror: always
|
||||
|
||||
# text underline offset
|
||||
- name: layout.css.text-underline-offset.enabled
|
||||
type: bool
|
||||
|
@ -2868,12 +2868,6 @@ pref("layout.css.report_errors", true);
|
||||
// interpretation of physical units such as "pt".
|
||||
pref("layout.css.dpi", -1);
|
||||
|
||||
// Set the number of device pixels per CSS pixel. A value <= 0 means choose
|
||||
// automatically based on user settings for the platform (e.g., "UI scale factor"
|
||||
// on Mac). A positive value is used as-is. This effectively controls the size
|
||||
// of a CSS "px". This is only used for windows on the screen, not for printing.
|
||||
pref("layout.css.devPixelsPerPx", "-1.0");
|
||||
|
||||
// Set the threshold distance in CSS pixels below which scrolling will snap to
|
||||
// an edge, when scroll snapping is set to "proximity".
|
||||
pref("layout.css.scroll-snap.proximity-threshold", 200);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "Screen.h"
|
||||
|
||||
#include "mozilla/dom/DOMTypes.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
@ -103,7 +104,7 @@ Screen::GetContentsScaleFactor(double* aOutScale) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
Screen::GetDefaultCSSScaleFactor(double* aOutScale) {
|
||||
double scale = nsIWidget::DefaultScaleOverride();
|
||||
double scale = StaticPrefs::layout_css_devPixelsPerPx();
|
||||
if (scale > 0.0) {
|
||||
*aOutScale = scale;
|
||||
} else {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "gfxPlatformGtk.h"
|
||||
#include "mozilla/FontPropertyTypes.h"
|
||||
#include "mozilla/RelativeLuminanceUtils.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "ScreenHelperGTK.h"
|
||||
|
||||
#include "gtkdrawing.h"
|
||||
@ -812,7 +813,7 @@ bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
|
||||
}
|
||||
|
||||
// Scale the font for the current monitor
|
||||
double scaleFactor = nsIWidget::DefaultScaleOverride();
|
||||
double scaleFactor = StaticPrefs::layout_css_devPixelsPerPx();
|
||||
if (scaleFactor > 0) {
|
||||
aFontStyle.size *=
|
||||
widget::ScreenHelperGTK::GetGTKMonitorScaleFactor() / scaleFactor;
|
||||
|
@ -73,7 +73,7 @@ static int gLastGdkError;
|
||||
static inline gint GetMonitorScaleFactor(nsIFrame* aFrame) {
|
||||
// When the layout.css.devPixelsPerPx is set the scale can be < 1,
|
||||
// the real monitor scale cannot go under 1.
|
||||
double scale = nsIWidget::DefaultScaleOverride();
|
||||
double scale = StaticPrefs::layout_css_devPixelsPerPx();
|
||||
if (scale <= 0) {
|
||||
nsIWidget* rootWidget = aFrame->PresContext()->GetRootWidget();
|
||||
if (rootWidget) {
|
||||
|
@ -72,6 +72,7 @@
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/webrender/WebRenderTypes.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "TouchEvents.h"
|
||||
@ -517,7 +518,7 @@ nsIWidget* nsBaseWidget::GetSheetWindowParent(void) { return nullptr; }
|
||||
float nsBaseWidget::GetDPI() { return 96.0f; }
|
||||
|
||||
CSSToLayoutDeviceScale nsIWidget::GetDefaultScale() {
|
||||
double devPixelsPerCSSPixel = DefaultScaleOverride();
|
||||
double devPixelsPerCSSPixel = StaticPrefs::layout_css_devPixelsPerPx();
|
||||
|
||||
if (devPixelsPerCSSPixel <= 0.0) {
|
||||
devPixelsPerCSSPixel = GetDefaultScaleInternal();
|
||||
@ -526,23 +527,6 @@ CSSToLayoutDeviceScale nsIWidget::GetDefaultScale() {
|
||||
return CSSToLayoutDeviceScale(devPixelsPerCSSPixel);
|
||||
}
|
||||
|
||||
/* static */
|
||||
double nsIWidget::DefaultScaleOverride() {
|
||||
// The number of device pixels per CSS pixel. A value <= 0 means choose
|
||||
// automatically based on the DPI. A positive value is used as-is. This
|
||||
// effectively controls the size of a CSS "px".
|
||||
static float devPixelsPerCSSPixel = -1.0f;
|
||||
|
||||
static bool valueCached = false;
|
||||
if (!valueCached) {
|
||||
Preferences::AddFloatVarCache(&devPixelsPerCSSPixel,
|
||||
"layout.css.devPixelsPerPx", -1.0f);
|
||||
valueCached = true;
|
||||
}
|
||||
|
||||
return devPixelsPerCSSPixel;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Add a child to the list of children
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
|
||||
// Defined in dwmapi in a header that needs a higher numbered _WINNT #define
|
||||
@ -232,7 +233,7 @@ TaskbarPreview::WndProc(UINT nMsg, WPARAM wParam, LPARAM lParam) {
|
||||
rv = mController->GetHeight(&height);
|
||||
if (NS_FAILED(rv)) break;
|
||||
|
||||
double scale = nsIWidget::DefaultScaleOverride();
|
||||
double scale = StaticPrefs::layout_css_devPixelsPerPx();
|
||||
if (scale <= 0.0) {
|
||||
scale = WinUtils::LogToPhysFactor(PreviewWindow());
|
||||
}
|
||||
|
@ -1494,7 +1494,7 @@ static bool AssumeThemePartAndStateAreTransparent(int32_t aPart,
|
||||
// the system default resolution.
|
||||
static inline double GetThemeDpiScaleFactor(nsIFrame* aFrame) {
|
||||
if (WinUtils::IsPerMonitorDPIAware() ||
|
||||
nsIWidget::DefaultScaleOverride() > 0.0) {
|
||||
StaticPrefs::layout_css_devPixelsPerPx() > 0.0) {
|
||||
nsIWidget* rootWidget = aFrame->PresContext()->GetRootWidget();
|
||||
if (rootWidget) {
|
||||
double systemScale = WinUtils::SystemScaleFactor();
|
||||
|
@ -146,6 +146,7 @@
|
||||
#include "InProcessWinCompositorWidget.h"
|
||||
#include "InputDeviceUtils.h"
|
||||
#include "ScreenHelperWin.h"
|
||||
#include "mozilla/StaticPrefs_layout.h"
|
||||
|
||||
#include "nsIGfxInfo.h"
|
||||
#include "nsUXThemeConstants.h"
|
||||
@ -7227,7 +7228,7 @@ void nsWindow::OnDPIChanged(int32_t x, int32_t y, int32_t width,
|
||||
if (mWindowType == eWindowType_popup) {
|
||||
return;
|
||||
}
|
||||
if (DefaultScaleOverride() > 0.0) {
|
||||
if (StaticPrefs::layout_css_devPixelsPerPx() > 0.0) {
|
||||
return;
|
||||
}
|
||||
mDefaultScale = -1.0; // force recomputation of scale factor
|
||||
|
Loading…
Reference in New Issue
Block a user