Skip to content

Commit

Permalink
Revert "Overlay always applies clip (flutter#113770)" (flutter#114442)
Browse files Browse the repository at this point in the history
This reverts commit 103a5c9.
  • Loading branch information
chunhtai committed Nov 1, 2022
1 parent e6b4296 commit d0afbd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
10 changes: 7 additions & 3 deletions packages/flutter/lib/src/widgets/overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
addAll(children);
}

bool _hasVisualOverflow = false;

@override
void setupParentData(RenderBox child) {
if (child.parentData is! StackParentData) {
Expand Down Expand Up @@ -834,6 +836,8 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox

@override
void performLayout() {
_hasVisualOverflow = false;

if (_onstageChildCount == 0) {
return;
}
Expand All @@ -852,7 +856,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
child.layout(nonPositionedConstraints, parentUsesSize: true);
childParentData.offset = _resolvedAlignment!.alongOffset(size - child.size as Offset);
} else {
RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!);
_hasVisualOverflow = RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!) || _hasVisualOverflow;
}

assert(child.parentData == childParentData);
Expand Down Expand Up @@ -894,7 +898,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox

@override
void paint(PaintingContext context, Offset offset) {
if (clipBehavior != Clip.none) {
if (_hasVisualOverflow && clipBehavior != Clip.none) {
_clipRectLayer.layer = context.pushClipRect(
needsCompositing,
offset,
Expand Down Expand Up @@ -935,7 +939,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
case Clip.hardEdge:
case Clip.antiAlias:
case Clip.antiAliasWithSaveLayer:
return Offset.zero & size;
return _hasVisualOverflow ? Offset.zero & size : null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void main() {
);

await tester.tap(find.text('Go'));
await tester.pumpAndSettle();
await tester.pump();

expect(
semantics,
Expand Down
23 changes: 0 additions & 23 deletions packages/flutter/test/widgets/overlay_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

import '../rendering/mock_canvas.dart';
import 'semantics_tester.dart';

void main() {
Expand Down Expand Up @@ -1120,28 +1119,6 @@ void main() {
}
});

testWidgets('Overlay always applies clip', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
builder: (BuildContext context) => Positioned(left: 10, right: 10, child: Container()),
),
],
),
),
);
final RenderObject renderObject = tester.renderObject(find.byType(Overlay));
// ignore: avoid_dynamic_calls
expect((renderObject as dynamic).paint, paints
..save()
..clipRect(rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0))
..restore(),
);
});

group('OverlayEntry listenable', () {
final GlobalKey overlayKey = GlobalKey();
final Widget emptyOverlay = Directionality(
Expand Down

0 comments on commit d0afbd7

Please sign in to comment.