Commit bbfb6f36 authored by Brad Werth's avatar Brad Werth
Browse files

Bug 1638773: Allow initial-scale clamping when user-scalable=no, add WPT. r=hiro, a=RyanVM

This corrects the handling of user-scalable=no to first clamp scale (whether
specified or default) between min and max scales, then applies the resulting
value to initial-scale, min and max.

Differential Revision: https://phabricator.services.mozilla.com/D76056
parent b4461e4e
......@@ -9817,12 +9817,14 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
size.height = clamped(size.height, effectiveMinSize.height,
float(kViewportMaxSize.height));
 
// In cases of user-scalable=no, if we have a positive scale, use it for
// both min and max. If we don't have a positive scale, assert that we
// are setting the auto scale flag.
// In cases of user-scalable=no, if we have a positive scale, clamp it to
// min and max, and then use the clamped value for the scale, the min, and
// the max. If we don't have a positive scale, assert that we are setting
// the auto scale flag.
if (effectiveZoomFlag == nsViewportInfo::ZoomFlag::DisallowZoom &&
scaleFloat > CSSToScreenScale(0.0f)) {
scaleMinFloat = scaleMaxFloat = scaleFloat;
scaleFloat = scaleMinFloat = scaleMaxFloat =
clamped(scaleFloat, scaleMinFloat, scaleMaxFloat);
}
MOZ_ASSERT(
scaleFloat > CSSToScreenScale(0.0f) || !mValidScaleFloat,
......
implementation-status: not-implementing
prefs: [dom.visualviewport.enabled:true,
dom.meta-viewport.enabled:true,
apz.allow_zooming:true]
[viewport-user-scalable-no-wide-content.tentative.html]
prefs: [dom.visualviewport.enabled:true,
dom.meta-viewport.enabled:true,
apz.allow_zooming:true]
<!doctype html>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=device-width, maximum-scale=1.0">
<link rel="help" href="https://drafts.csswg.org/css-device-adapt/">
<link rel="help" href="https://webcompat.com/issues/52856">
<style>
body {
margin: 0;
}
#content {
width: 100px;
height: 100px;
background: green;
}
</style>
<div id="content">Content</div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
'use strict';
test(() => {
assert_equals(window.visualViewport.scale, 1.0,
'visual viewport scale should be 1.0');
}, 'Page with meta viewport "width=device-width, user-scalable=no, ' +
'initial-scale=device-width, maximum-scale=1.0" ' +
'should scale to 1.0.');
</script>
<!doctype html>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=0.25, minimum-scale=1.0">
<link rel="help" href="https://drafts.csswg.org/css-device-adapt/">
<link rel="help" href="https://webcompat.com/issues/52856">
<style>
body {
margin: 0;
}
#content {
width: 100px;
height: 100px;
background: green;
}
</style>
<div id="content">Content</div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
'use strict';
test(() => {
assert_equals(window.visualViewport.scale, 1.0,
'visual viewport scale should be 1.0');
}, 'Page with meta viewport "width=device-width, user-scalable=no, ' +
'initial-scale=0.25, minimum-scale=1.0" ' +
'should scale to 1.0.');
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment