зеркало из https://github.com/mozilla/gecko-dev.git
Bug 804062. Move device-pixels-per-CSS-pixel preference logic into nsIWidget::GetDefaultScale. r=jfkthame
The only behavior change caused by this patch should be that nsDeviceContexts with no widget (mainly printing, I think), default to a devpixel-per-CSS-pixel ratio of 1.0, ignoring any prefs set.
This commit is contained in:
Родитель
58fb7809df
Коммит
344c63740a
|
@ -337,23 +337,7 @@ nsDeviceContext::SetDPI()
|
|||
dpi = 96.0f;
|
||||
}
|
||||
|
||||
// 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".
|
||||
float devPixelsPerCSSPixel = -1.0;
|
||||
|
||||
nsAdoptingCString prefString = Preferences::GetCString("layout.css.devPixelsPerPx");
|
||||
if (!prefString.IsEmpty()) {
|
||||
devPixelsPerCSSPixel = static_cast<float>(atof(prefString));
|
||||
}
|
||||
|
||||
if (devPixelsPerCSSPixel <= 0) {
|
||||
if (mWidget) {
|
||||
devPixelsPerCSSPixel = mWidget->GetDefaultScale();
|
||||
} else {
|
||||
devPixelsPerCSSPixel = 1.0;
|
||||
}
|
||||
}
|
||||
double devPixelsPerCSSPixel = mWidget ? mWidget->GetDefaultScale() : 1.0;
|
||||
|
||||
mAppUnitsPerDevNotScaledPixel =
|
||||
NS_MAX(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel));
|
||||
|
|
|
@ -408,7 +408,7 @@ public:
|
|||
// between HiDPI and non-HiDPI screens
|
||||
void BackingScaleFactorChanged();
|
||||
|
||||
virtual double GetDefaultScale();
|
||||
virtual double GetDefaultScaleInternal();
|
||||
|
||||
NS_IMETHOD Invalidate(const nsIntRect &aRect);
|
||||
|
||||
|
|
|
@ -742,7 +742,7 @@ NS_IMETHODIMP nsChildView::GetBounds(nsIntRect &aRect)
|
|||
}
|
||||
|
||||
double
|
||||
nsChildView::GetDefaultScale()
|
||||
nsChildView::GetDefaultScaleInternal()
|
||||
{
|
||||
return BackingScaleFactor();
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ public:
|
|||
|
||||
CGFloat BackingScaleFactor();
|
||||
void BackingScaleFactorChanged();
|
||||
virtual double GetDefaultScale();
|
||||
virtual double GetDefaultScaleInternal();
|
||||
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
||||
|
||||
|
|
|
@ -1399,7 +1399,7 @@ NS_IMETHODIMP nsCocoaWindow::GetScreenBounds(nsIntRect &aRect)
|
|||
}
|
||||
|
||||
double
|
||||
nsCocoaWindow::GetDefaultScale()
|
||||
nsCocoaWindow::GetDefaultScaleInternal()
|
||||
{
|
||||
return BackingScaleFactor();
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
|
|||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0x8181a08f, 0xaa37, 0x4fd0, \
|
||||
{ 0x94, 0x32, 0x27, 0x74, 0xe2, 0xce, 0x02, 0xc8 } }
|
||||
{ 0xb7c60bda, 0xe16c, 0x4e89, \
|
||||
{ 0x86, 0x8c, 0xc3, 0x2e, 0x62, 0x40, 0x05, 0xb2 } }
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
|
@ -574,9 +574,10 @@ class nsIWidget : public nsISupports {
|
|||
* Return the default scale factor for the window. This is the
|
||||
* default number of device pixels per CSS pixel to use. This should
|
||||
* depend on OS/platform settings such as the Mac's "UI scale factor"
|
||||
* or Windows' "font DPI".
|
||||
* or Windows' "font DPI". This will take into account Gecko preferences
|
||||
* overriding the system setting.
|
||||
*/
|
||||
virtual double GetDefaultScale() = 0;
|
||||
double GetDefaultScale();
|
||||
|
||||
/**
|
||||
* Return the first child of this widget. Will return null if
|
||||
|
@ -1652,6 +1653,11 @@ class nsIWidget : public nsISupports {
|
|||
{ return nullptr; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Like GetDefaultScale, but taking into account only the system settings
|
||||
* and ignoring Gecko preferences.
|
||||
*/
|
||||
virtual double GetDefaultScaleInternal() { return 1.0; }
|
||||
|
||||
// keep the list of children. We also keep track of our siblings.
|
||||
// The ownership model is as follows: parent holds a strong ref to
|
||||
|
|
|
@ -164,7 +164,7 @@
|
|||
|
||||
#include "nsIContent.h"
|
||||
|
||||
#include "mozilla/HangMonitor.h"
|
||||
#include "mozilla/HangMonitor.h"
|
||||
#include "nsIMM32Handler.h"
|
||||
|
||||
using namespace mozilla::widget;
|
||||
|
@ -975,7 +975,7 @@ float nsWindow::GetDPI()
|
|||
return float(heightPx/heightInches);
|
||||
}
|
||||
|
||||
double nsWindow::GetDefaultScale()
|
||||
double nsWindow::GetDefaultScaleInternal()
|
||||
{
|
||||
HDC dc = ::GetDC(mWnd);
|
||||
if (!dc)
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
NS_IMETHOD SetParent(nsIWidget *aNewParent);
|
||||
virtual nsIWidget* GetParent(void);
|
||||
virtual float GetDPI();
|
||||
virtual double GetDefaultScale();
|
||||
virtual double GetDefaultScaleInternal();
|
||||
NS_IMETHOD Show(bool bState);
|
||||
virtual bool IsVisible() const;
|
||||
NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY);
|
||||
|
|
|
@ -377,9 +377,23 @@ float nsBaseWidget::GetDPI()
|
|||
return 96.0f;
|
||||
}
|
||||
|
||||
double nsBaseWidget::GetDefaultScale()
|
||||
double nsIWidget::GetDefaultScale()
|
||||
{
|
||||
return 1.0;
|
||||
// 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".
|
||||
float devPixelsPerCSSPixel = -1.0;
|
||||
|
||||
nsAdoptingCString prefString = Preferences::GetCString("layout.css.devPixelsPerPx");
|
||||
if (!prefString.IsEmpty()) {
|
||||
devPixelsPerCSSPixel = static_cast<float>(atof(prefString));
|
||||
}
|
||||
|
||||
if (devPixelsPerCSSPixel <= 0) {
|
||||
devPixelsPerCSSPixel = GetDefaultScaleInternal();
|
||||
}
|
||||
|
||||
return devPixelsPerCSSPixel;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -72,7 +72,6 @@ public:
|
|||
virtual nsIWidget* GetTopLevelWidget();
|
||||
virtual nsIWidget* GetSheetWindowParent(void);
|
||||
virtual float GetDPI();
|
||||
virtual double GetDefaultScale();
|
||||
virtual void AddChild(nsIWidget* aChild);
|
||||
virtual void RemoveChild(nsIWidget* aChild);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче