Bug 1501665 Part 6: Fix an edge case in Document::GetViewportInfo to return css scaled sizes. r=botond

This fixes a problem in an edge case that we are evidently not testing.
If width is 0 and height is auto, we are currently setting height to
the unscaled (not CSS units) display height value.

In addition to this fix, this patch does two drive-by cleanups of code
that uses "defaultScale":

    The redundantly-defined defaultPixelScale is removed.
    The masking block-level definition of defaultScale is renamed to bestFitScale.

Differential Revision: https://phabricator.services.mozilla.com/D16774

--HG--
extra : source : 9eebe767ef20b9ec635d90fc9844cf7dbe3403de
This commit is contained in:
Brad Werth 2019-03-18 14:57:47 +00:00
Родитель c2c75edc72
Коммит 8a637ac0e3
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -6772,10 +6772,9 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
CSSCoord maxHeight = mMaxHeight;
// aDisplaySize is in screen pixels; convert them to CSS pixels for the
// viewport size.
CSSToScreenScale defaultPixelScale =
layoutDeviceScale * LayoutDeviceToScreenScale(1.0f);
CSSSize displaySize = ScreenSize(aDisplaySize) / defaultPixelScale;
// viewport size. We need to use this scaled size for any clamping of
// width or height.
CSSSize displaySize = ScreenSize(aDisplaySize) / defaultScale;
// Resolve device-width and device-height first.
if (maxWidth == nsViewportInfo::DeviceSize) {
@ -6852,7 +6851,7 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
// https://drafts.csswg.org/css-device-adapt/#resolve-height
if (height == nsViewportInfo::Auto) {
if (aDisplaySize.width == 0) {
height = aDisplaySize.height;
height = displaySize.height;
} else {
height = width * aDisplaySize.height / aDisplaySize.width;
}
@ -6895,8 +6894,8 @@ nsViewportInfo Document::GetViewportInfo(const ScreenIntSize& aDisplaySize) {
// Also recalculate the default zoom, if it wasn't specified in the
// metadata, and the width is specified.
if (mScaleStrEmpty && !mWidthStrEmpty) {
CSSToScreenScale defaultScale(float(aDisplaySize.width) / size.width);
scaleFloat = (scaleFloat > defaultScale) ? scaleFloat : defaultScale;
CSSToScreenScale bestFitScale(float(aDisplaySize.width) / size.width);
scaleFloat = (scaleFloat > bestFitScale) ? scaleFloat : bestFitScale;
}
size.height = clamped(size.height, effectiveMinSize.height,