Unverified Commit 3fdd6ee4 authored by chunhtai's avatar chunhtai Committed by GitHub

Reland "Overlay always applies clip (#113770)" (#116674)

* Reland "Overlay always applies clip (#113770)"

This reverts commit d0afbd72.

* Root navigator will not clip
parent 1546fa08
......@@ -1623,6 +1623,7 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
debugLabel: 'Navigator Scope',
autofocus: true,
child: Navigator(
clipBehavior: Clip.none,
restorationScopeId: 'nav',
key: _navigator,
initialRoute: _initialRouteName,
......
......@@ -702,8 +702,6 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
addAll(children);
}
bool _hasVisualOverflow = false;
@override
void setupParentData(RenderBox child) {
if (child.parentData is! StackParentData) {
......@@ -827,8 +825,6 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
@override
void performLayout() {
_hasVisualOverflow = false;
if (_onstageChildCount == 0) {
return;
}
......@@ -847,7 +843,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
child.layout(nonPositionedConstraints, parentUsesSize: true);
childParentData.offset = _resolvedAlignment!.alongOffset(size - child.size as Offset);
} else {
_hasVisualOverflow = RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!) || _hasVisualOverflow;
RenderStack.layoutPositionedChild(child, childParentData, size, _resolvedAlignment!);
}
assert(child.parentData == childParentData);
......@@ -889,7 +885,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
@override
void paint(PaintingContext context, Offset offset) {
if (_hasVisualOverflow && clipBehavior != Clip.none) {
if (clipBehavior != Clip.none) {
_clipRectLayer.layer = context.pushClipRect(
needsCompositing,
offset,
......@@ -930,7 +926,7 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
case Clip.hardEdge:
case Clip.antiAlias:
case Clip.antiAliasWithSaveLayer:
return _hasVisualOverflow ? Offset.zero & size : null;
return Offset.zero & size;
}
}
......
......@@ -953,7 +953,7 @@ void main() {
);
await tester.tap(find.text('Go'));
await tester.pump();
await tester.pumpAndSettle();
expect(
semantics,
......
......@@ -6,6 +6,7 @@ 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() {
......@@ -1119,6 +1120,28 @@ 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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment