( canvasSize: Size | null, deviceNaturalSize: Size | null, marginX: number, marginY: number, chromeProfile: ChromeProfile | null, reservedBottomInset = 0, rotationQuarterTurns = 0, )
| 208 | } |
| 209 | |
| 210 | function computeScale( |
| 211 | canvasSize: Size | null, |
| 212 | deviceNaturalSize: Size | null, |
| 213 | marginX: number, |
| 214 | marginY: number, |
| 215 | chromeProfile: ChromeProfile | null, |
| 216 | reservedBottomInset = 0, |
| 217 | rotationQuarterTurns = 0, |
| 218 | ): number { |
| 219 | if (!canvasSize) { |
| 220 | return 1; |
| 221 | } |
| 222 | const totalSize = shellSize( |
| 223 | deviceNaturalSize, |
| 224 | chromeProfile, |
| 225 | rotationQuarterTurns, |
| 226 | ); |
| 227 | const availableWidth = Math.max(canvasSize.width - marginX * 2, 0); |
| 228 | const availableHeight = Math.max( |
| 229 | canvasSize.height - marginY * 2 - reservedBottomInset, |
| 230 | 0, |
| 231 | ); |
| 232 | return Math.min( |
| 233 | availableWidth / totalSize.width, |
| 234 | availableHeight / totalSize.height, |
| 235 | ); |
| 236 | } |
| 237 | |
| 238 | export function computeFitScale( |
| 239 | canvasSize: Size | null, |
no test coverage detected