Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/web_ui/lib/src/engine/recording_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ class RecordingCanvas {
// Ensure inner is fully contained within outer, by comparing its
// defining points (including its border radius)
ui.Rect innerRect = inner.outerRect;
if (outer.outerRect.intersect(innerRect) != innerRect) {
ui.Rect outerRect = outer.outerRect;
if (outerRect == innerRect || outerRect.intersect(innerRect) != innerRect) {
return; // inner is not fully contained within outer
}

Expand All @@ -252,7 +253,7 @@ class RecordingCanvas {
final double innerBl = _getDistance(scaledInner.blRadiusX, scaledInner.blRadiusY);
final double innerBr = _getDistance(scaledInner.brRadiusX, scaledInner.brRadiusY);

if (innerTl >= outerTl || innerTr >= outerTr || innerBl >= outerBl || innerBr >= outerBr) {
if (innerTl > outerTl || innerTr > outerTr || innerBl > outerBl || innerBr > outerBr) {
return; // Some inner radius is overlapping some outer radius
}

Expand Down
31 changes: 25 additions & 6 deletions lib/web_ui/test/engine/recording_canvas_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ void main() {
test('Happy case', () {
underTest.drawDRRect(rrect, rrect.deflate(1), somePaint);
underTest.apply(mockCanvas);
// Expect drawDRRect to be called
expect(mockCanvas.methodCallLog.length, equals(1));
MockCanvasCall mockCall = mockCanvas.methodCallLog[0];
expect(mockCall.methodName, equals('drawDRRect'));
expect(mockCall.arguments, equals({

_expectDrawCall(mockCanvas, {
'outer': rrect,
'inner': rrect.deflate(1),
'paint': somePaint.webOnlyPaintData,
}));
});
});

test('Inner RRect > Outer RRect', () {
Expand All @@ -56,5 +53,27 @@ void main() {
// Expect nothing to be called
expect(mockCanvas.methodCallLog.length, equals(0));
});

test('preserve old scuba test behavior', () {
final RRect outer = RRect.fromRectAndCorners(const Rect.fromLTRB(10, 20, 30, 40));
final RRect inner = RRect.fromRectAndCorners(const Rect.fromLTRB(12, 22, 28, 38));

underTest.drawDRRect(outer, inner, somePaint);
underTest.apply(mockCanvas);

_expectDrawCall(mockCanvas, {
'outer': outer,
'inner': inner,
'paint': somePaint.webOnlyPaintData,
});
});
});
}

// Expect a drawDRRect call to be registered in the mock call log, with the expectedArguments
void _expectDrawCall(MockEngineCanvas mock, Map<String, dynamic> expectedArguments) {
expect(mock.methodCallLog.length, equals(1));
MockCanvasCall mockCall = mock.methodCallLog[0];
expect(mockCall.methodName, equals('drawDRRect'));
expect(mockCall.arguments, equals(expectedArguments));
}