mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1208023 - Ensure the minimum scale is a sane value greater than zero and add a separate flag to track if the default zoom is valid. r=botond
This commit is contained in:
parent
ecb4c526c5
commit
87fbc89c7d
@ -17,6 +17,12 @@ nsViewportInfo::ConstrainViewportValues()
|
||||
// dev.w3.org/csswg/css-device-adapt section 6.2
|
||||
mMaxZoom = std::max(mMinZoom, mMaxZoom);
|
||||
|
||||
mDefaultZoom = mDefaultZoom < mMaxZoom ? mDefaultZoom : mMaxZoom;
|
||||
mDefaultZoom = mDefaultZoom > mMinZoom ? mDefaultZoom : mMinZoom;
|
||||
if (mDefaultZoom > mMaxZoom) {
|
||||
mDefaultZoomValid = false;
|
||||
mDefaultZoom = mMaxZoom;
|
||||
}
|
||||
if (mDefaultZoom < mMinZoom) {
|
||||
mDefaultZoomValid = false;
|
||||
mDefaultZoom = mMinZoom;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
/**
|
||||
* Default values for the nsViewportInfo class.
|
||||
*/
|
||||
static const mozilla::LayoutDeviceToScreenScale kViewportMinScale(0.0f);
|
||||
static const mozilla::LayoutDeviceToScreenScale kViewportMinScale(0.1f);
|
||||
static const mozilla::LayoutDeviceToScreenScale kViewportMaxScale(10.0f);
|
||||
static const mozilla::CSSIntSize kViewportMinSize(200, 40);
|
||||
static const mozilla::CSSIntSize kViewportMaxSize(10000, 10000);
|
||||
@ -27,6 +27,7 @@ class MOZ_STACK_CLASS nsViewportInfo
|
||||
nsViewportInfo(const mozilla::ScreenIntSize& aDisplaySize,
|
||||
const mozilla::CSSToScreenScale& aDefaultZoom,
|
||||
bool aAllowZoom) :
|
||||
mDefaultZoomValid(true),
|
||||
mDefaultZoom(aDefaultZoom),
|
||||
mAutoSize(true),
|
||||
mAllowZoom(aAllowZoom)
|
||||
@ -44,6 +45,7 @@ class MOZ_STACK_CLASS nsViewportInfo
|
||||
const mozilla::CSSSize& aSize,
|
||||
bool aAutoSize,
|
||||
bool aAllowZoom) :
|
||||
mDefaultZoomValid(true),
|
||||
mDefaultZoom(aDefaultZoom),
|
||||
mMinZoom(aMinZoom),
|
||||
mMaxZoom(aMaxZoom),
|
||||
@ -54,6 +56,7 @@ class MOZ_STACK_CLASS nsViewportInfo
|
||||
ConstrainViewportValues();
|
||||
}
|
||||
|
||||
bool IsDefaultZoomValid() const { return mDefaultZoomValid; }
|
||||
mozilla::CSSToScreenScale GetDefaultZoom() const { return mDefaultZoom; }
|
||||
mozilla::CSSToScreenScale GetMinZoom() const { return mMinZoom; }
|
||||
mozilla::CSSToScreenScale GetMaxZoom() const { return mMaxZoom; }
|
||||
@ -72,6 +75,10 @@ class MOZ_STACK_CLASS nsViewportInfo
|
||||
*/
|
||||
void ConstrainViewportValues();
|
||||
|
||||
// If the default zoom was specified and was between the min and max
|
||||
// zoom values.
|
||||
bool mDefaultZoomValid;
|
||||
|
||||
// Default zoom indicates the level at which the display is 'zoomed in'
|
||||
// initially for the user, upon loading of the page.
|
||||
mozilla::CSSToScreenScale mDefaultZoom;
|
||||
|
@ -16,12 +16,16 @@
|
||||
|
||||
let tests = [];
|
||||
|
||||
function fuzzeq(a, b, msg) {
|
||||
ok(Math.abs(a - b) < 1e-6, msg);
|
||||
}
|
||||
|
||||
tests.push(function test1() {
|
||||
SpecialPowers.pushPrefEnv(scaleRatio(1.0),
|
||||
function() {
|
||||
let info = getViewportInfo(800, 480);
|
||||
is(info.defaultZoom, 0, "initial scale is unspecified");
|
||||
is(info.minZoom, 0, "minumum scale defaults to the absolute minumum");
|
||||
fuzzeq(info.defaultZoom, 0.1, "initial scale is unspecified");
|
||||
fuzzeq(info.minZoom, 0.1, "minimum scale defaults to the absolute minimum");
|
||||
is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum");
|
||||
is(info.width, 980, "width is the default width");
|
||||
is(info.height, 588, "height is proportional to displayHeight");
|
||||
|
@ -125,12 +125,17 @@ MobileViewportManager::UpdateResolution(const nsViewportInfo& aViewportInfo,
|
||||
if (mIsFirstPaint) {
|
||||
CSSToScreenScale defaultZoom = aViewportInfo.GetDefaultZoom();
|
||||
MVM_LOG("%p: default zoom from viewport is %f\n", this, defaultZoom.scale);
|
||||
// FIXME/bug 799585(?): GetViewportInfo() returns a default zoom of
|
||||
// 0.0 to mean "did not calculate a zoom". In that case, we default
|
||||
// it to the intrinsic scale.
|
||||
if (defaultZoom.scale < 0.01f) {
|
||||
if (!aViewportInfo.IsDefaultZoomValid()) {
|
||||
defaultZoom = MaxScaleRatio(ScreenSize(aDisplaySize), aViewport);
|
||||
MVM_LOG("%p: Intrinsic computed zoom is %f\n", this, defaultZoom.scale);
|
||||
if (defaultZoom < aViewportInfo.GetMinZoom()) {
|
||||
defaultZoom = aViewportInfo.GetMinZoom();
|
||||
MVM_LOG("%p: Clamped to %f\n", this, defaultZoom.scale);
|
||||
}
|
||||
if (defaultZoom > aViewportInfo.GetMaxZoom()) {
|
||||
defaultZoom = aViewportInfo.GetMaxZoom();
|
||||
MVM_LOG("%p: Clamped to %f\n", this, defaultZoom.scale);
|
||||
}
|
||||
}
|
||||
MOZ_ASSERT(aViewportInfo.GetMinZoom() <= defaultZoom &&
|
||||
defaultZoom <= aViewportInfo.GetMaxZoom());
|
||||
|
Loading…
Reference in New Issue
Block a user