Commit 269b63fb authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Simplify logic for shouldSwapLogicalResolutionText

The former logic was susceptible to rounding errors when the aspect
ratio of the current display mode did not perfectly match the aspect
ratio of the display's native mode. The former logic was unnecessarily
strict because all we need to determine the order of the dimensions
must be flipped is to check whether the longer edge of the current mode
and native mode are the same edge or not.

Bug: 1085064
Change-Id: I86d4f4fb77098f1a034e0bc62671a7aa1cd62e14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210008
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Auto-Submit: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770749}
parent 8c56e1c9
......@@ -1055,17 +1055,17 @@ cr.define('settings.display', function() {
/**
* 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.
* Logical Resolution Text. Returns true if the longer edge of the
* display's native pixels is different than the longer edge of the
* display's current bounds.
* @private
*/
shouldSwapLogicalResolutionText_() {
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);
return bounds.width > bounds.height !=
mode.widthInNativePixels > mode.heightInNativePixels;
},
......
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