Fix HTML renderer does not render non zeroed width borders (flutter/engine#36249)
This commit is contained in:
@@ -247,7 +247,9 @@ class PathRef {
|
||||
if ((x2 - x3) != width || (y3 - y0) != height) {
|
||||
return null;
|
||||
}
|
||||
return ui.Rect.fromLTWH(x0, y0, width, height);
|
||||
final double x = math.min(x0, x1);
|
||||
final double y = math.min(y0, y2);
|
||||
return ui.Rect.fromLTWH(x, y, width.abs(), height.abs());
|
||||
}
|
||||
|
||||
/// Returns horizontal/vertical line bounds or null if not a line.
|
||||
|
||||
@@ -65,6 +65,30 @@ void testMain() {
|
||||
expect(path.toRect(), rrect.outerRect);
|
||||
});
|
||||
|
||||
test('PathRef.getRect returns a Rect from a valid Path and null otherwise', () {
|
||||
final SurfacePath path = SurfacePath();
|
||||
// Draw a line
|
||||
path.moveTo(0,0);
|
||||
path.lineTo(10,0);
|
||||
expect(path.pathRef.getRect(), isNull);
|
||||
// Draw two other lines to get a valid rectangle
|
||||
path.lineTo(10,10);
|
||||
path.lineTo(0,10);
|
||||
expect(path.pathRef.getRect(), const Rect.fromLTWH(0, 0, 10, 10));
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/111750
|
||||
test('PathRef.getRect returns Rect with positive width and height', () {
|
||||
final SurfacePath path = SurfacePath();
|
||||
// Draw a rectangle starting from bottom right corner
|
||||
path.moveTo(10,10);
|
||||
path.lineTo(0,10);
|
||||
path.lineTo(0,0);
|
||||
path.lineTo(10,0);
|
||||
// pathRef.getRect() should return a rectangle with positive height and width
|
||||
expect(path.pathRef.getRect(), const Rect.fromLTWH(0, 0, 10, 10));
|
||||
});
|
||||
|
||||
// This test demonstrates the issue with attempting to reconstruct an RRect
|
||||
// with imprecision introduced by comparing double values. We should fix this
|
||||
// by removing the need to reconstruct rrects:
|
||||
|
||||
Reference in New Issue
Block a user