Commit c8993fac authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Use selectedDisplay to show logical resolution text

This change uses selectedDisplay's width and height properties,
which correctly reflects the orientation of the display, to set the
logical resolution text so that it correctly reflects the orientation
of the display.

Fixed: 994970
Test: Ran unittests, verified manually on device
Change-Id: I3aa0174edff55fb88a0599e1a2809bcb7001abfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894173Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Auto-Submit: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713964}
parent e4373df3
......@@ -700,8 +700,7 @@ Polymer({
this.logicalResolutionText_ = '';
return;
}
const mode = this.selectedDisplay.modes[
/** @type {number} */ (this.selectedModePref_.value)];
const mode = this.selectedDisplay.modes[this.currentSelectedModeIndex_];
const deviceScaleFactor = mode.deviceScaleFactor;
const inverseZoomFactor = 1.0 / zoomFactor;
let logicalResolutionStrId = 'displayZoomLogicalResolutionText';
......@@ -710,16 +709,37 @@ Polymer({
} else if (Math.abs(inverseZoomFactor - 1.0) < 0.001) {
logicalResolutionStrId = 'displayZoomLogicalResolutionDefaultText';
}
const widthStr =
let widthStr =
Math.round(mode.widthInNativePixels / (deviceScaleFactor * zoomFactor))
.toString();
const heightStr =
let heightStr =
Math.round(mode.heightInNativePixels / (deviceScaleFactor * zoomFactor))
.toString();
if (this.shouldSwapLogicalResolutionText_()) {
const temp = widthStr;
widthStr = heightStr;
heightStr = temp;
}
this.logicalResolutionText_ =
this.i18n(logicalResolutionStrId, widthStr, heightStr);
},
/**
* Determines whether width and height should be swapped in the
* Logical Resolution Text. Returns true if the aspect ratio of the display's
* native pixels is not equal to the aspect ratio of the displays current
* bounds.
* @private
*/
shouldSwapLogicalResolutionText_: function() {
const mode = this.selectedDisplay.modes[this.currentSelectedModeIndex_];
const bounds = this.selectedDisplay.bounds;
return (bounds.width / bounds.height).toPrecision(4) !=
(mode.widthInNativePixels / mode.heightInNativePixels).toPrecision(4);
},
/**
* Handles the event where the display size slider is being dragged, i.e. the
* mouse or tap has not been released.
......
Markdown is supported
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