[web] Fix scaledImageSize handling of a target width with no target height (flutter/engine#54122)
This commit is contained in:
@@ -274,7 +274,7 @@ BitmapSize? scaledImageSize(
|
||||
}
|
||||
targetWidth = (width * targetHeight / height).round();
|
||||
} else if (targetHeight == null) {
|
||||
if (targetWidth == targetWidth) {
|
||||
if (targetWidth == width) {
|
||||
// Not scaled.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import 'dart:typed_data';
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine/canvaskit/image.dart';
|
||||
import 'package:ui/src/engine/image_decoder.dart';
|
||||
import 'package:ui/src/engine/util.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'common.dart';
|
||||
@@ -98,6 +100,12 @@ void testMain() {
|
||||
List<int>.generate(100000, (int i) => i & 0xFF),
|
||||
);
|
||||
});
|
||||
|
||||
test('scaledImageSize scales to a target width with no target height', () {
|
||||
final BitmapSize? size = scaledImageSize(200, 100, 600, null);
|
||||
expect(size?.width, 600);
|
||||
expect(size?.height, 300);
|
||||
});
|
||||
}
|
||||
|
||||
Future<ui.Image> _createImage() => _createPicture().toImage(10, 10);
|
||||
|
||||
Reference in New Issue
Block a user