Color picker can have NaN values for HSL and Hex formats at zoom 150%
This change fixes a bug where the HSL and Hex values for the selected color could be NaN if the color well's selection ring was the bottom of the color well and the page zoom was set to 150%. At certain zoom levels like 150%, the height of the color well is not a round number. However, the getImageData API, which is used to retrieve the underlying pixel color data for the color well, only works with integer values and will truncate decimal values. As such, if the color well's selection ring is placed at the bottom of the color well, a valid pixel data point for the ring's position cannot be found in the image data array for the color well. When such a situation occurs, the fix is to use the last color in the color well's image data array. This color will be the same as the color seen at the bottom of the color well (black), so the user will see what they expect. Bug: 1015238 Change-Id: I1b74a4870fa455d197c525dca39dc88e7c6f75f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866060Reviewed-by:Kent Tamura <tkent@chromium.org> Commit-Queue: Sanket Joshi <sajos@microsoft.com> Cr-Commit-Position: refs/heads/master@{#706758}
Showing
Please register or sign in to comment