Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1662a14b
Unverified
Commit
1662a14b
authored
May 17, 2022
by
Dan Field
Committed by
GitHub
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More missing clipBehavior respects (#103931)
parent
a633f3df
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
183 additions
and
16 deletions
+183
-16
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+10
-1
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+11
-1
object.dart
packages/flutter/lib/src/rendering/object.dart
+5
-0
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+8
-1
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+10
-1
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+10
-1
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+10
-1
single_child_scroll_view.dart
...ges/flutter/lib/src/widgets/single_child_scroll_view.dart
+12
-5
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+22
-0
viewport_test.dart
packages/flutter/test/rendering/viewport_test.dart
+37
-0
overlay_test.dart
packages/flutter/test/widgets/overlay_test.dart
+23
-5
semantics_clipping_test.dart
packages/flutter/test/widgets/semantics_clipping_test.dart
+2
-0
stack_test.dart
packages/flutter/test/widgets/stack_test.dart
+23
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
1662a14b
...
...
@@ -2526,7 +2526,16 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
final
LayerHandle
<
ClipRectLayer
>
_clipRectLayer
=
LayerHandle
<
ClipRectLayer
>();
@override
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
=>
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
}
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
packages/flutter/lib/src/rendering/flex.dart
View file @
1662a14b
...
...
@@ -1144,7 +1144,17 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}
@override
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
=>
_hasOverflow
?
Offset
.
zero
&
size
:
null
;
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
_hasOverflow
?
Offset
.
zero
&
size
:
null
;
}
}
@override
String
toStringShort
()
{
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
1662a14b
...
...
@@ -2788,6 +2788,11 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
///
/// This is used in the semantics phase to avoid including children
/// that are not physically visible.
///
/// RenderObjects that respect a [Clip] behavior when painting _must_ respect
/// that same behavior when describing this value. For example, if passing
/// [Clip.none] to [PaintingContext.pushClipRect] as the `clipBehavior`, then
/// the implementation of this method must return null.
Rect
?
describeApproximatePaintClip
(
covariant
RenderObject
child
)
=>
null
;
/// Returns a rect in this object's coordinate system that describes
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
1662a14b
...
...
@@ -826,8 +826,15 @@ class RenderConstraintsTransformBox extends RenderAligningShiftedBox with DebugO
@override
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
_isOverflowing
?
Offset
.
zero
&
size
:
null
;
}
}
@override
String
toStringShort
()
{
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
1662a14b
...
...
@@ -636,7 +636,16 @@ class RenderStack extends RenderBox
}
@override
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
=>
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
}
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
packages/flutter/lib/src/rendering/viewport.dart
View file @
1662a14b
...
...
@@ -562,7 +562,16 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
}
@override
Rect
describeApproximatePaintClip
(
RenderSliver
child
)
{
Rect
?
describeApproximatePaintClip
(
RenderSliver
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
break
;
}
final
Rect
viewportClip
=
Offset
.
zero
&
size
;
// The child's viewportMainAxisExtent can be infinite when a
// RenderShrinkWrappingViewport is given infinite constraints, such as when
...
...
packages/flutter/lib/src/widgets/overlay.dart
View file @
1662a14b
...
...
@@ -866,7 +866,16 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin<RenderBox
}
@override
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
=>
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
Rect
?
describeApproximatePaintClip
(
RenderObject
child
)
{
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
null
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
_hasVisualOverflow
?
Offset
.
zero
&
size
:
null
;
}
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
packages/flutter/lib/src/widgets/single_child_scroll_view.dart
View file @
1662a14b
...
...
@@ -533,11 +533,18 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
bool
_shouldClipAtPaintOffset
(
Offset
paintOffset
)
{
assert
(
child
!=
null
);
switch
(
clipBehavior
)
{
case
Clip
.
none
:
return
false
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
return
paintOffset
.
dx
<
0
||
paintOffset
.
dy
<
0
||
paintOffset
.
dx
+
child
!.
size
.
width
>
size
.
width
||
paintOffset
.
dy
+
child
!.
size
.
height
>
size
.
height
;
}
}
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
...
...
@@ -548,7 +555,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix
context
.
paintChild
(
child
!,
offset
+
paintOffset
);
}
if
(
_shouldClipAtPaintOffset
(
paintOffset
)
&&
clipBehavior
!=
Clip
.
none
)
{
if
(
_shouldClipAtPaintOffset
(
paintOffset
))
{
_clipRectLayer
.
layer
=
context
.
pushClipRect
(
needsCompositing
,
offset
,
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
1662a14b
...
...
@@ -128,6 +128,28 @@ void main() {
}
});
test
(
'Editable respect clipBehavior in describeApproximatePaintClip'
,
()
{
final
String
longString
=
'a'
*
10000
;
final
RenderEditable
editable
=
RenderEditable
(
text:
TextSpan
(
text:
longString
),
textDirection:
TextDirection
.
ltr
,
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
offset:
ViewportOffset
.
zero
(),
textSelectionDelegate:
_FakeEditableTextState
(),
selection:
const
TextSelection
(
baseOffset:
0
,
extentOffset:
0
),
clipBehavior:
Clip
.
none
,
);
layout
(
editable
);
bool
visited
=
false
;
editable
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
expect
(
editable
.
describeApproximatePaintClip
(
child
),
null
);
});
expect
(
visited
,
true
);
});
test
(
'editable intrinsics'
,
()
{
final
TextSelectionDelegate
delegate
=
_FakeEditableTextState
();
final
RenderEditable
editable
=
RenderEditable
(
...
...
packages/flutter/test/rendering/viewport_test.dart
View file @
1662a14b
...
...
@@ -2158,4 +2158,41 @@ void main() {
await
tester
.
drag
(
find
.
text
(
'b'
),
const
Offset
(
0
,
200
));
await
tester
.
pumpAndSettle
();
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'Viewport describeApproximateClip respects clipBehavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
CustomScrollView
(
clipBehavior:
Clip
.
none
,
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
SizedBox
(
width:
20
,
height:
20
)),
]
),
));
RenderViewport
viewport
=
tester
.
allRenderObjects
.
whereType
<
RenderViewport
>().
first
;
expect
(
viewport
.
clipBehavior
,
Clip
.
none
);
bool
visited
=
false
;
viewport
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
expect
(
viewport
.
describeApproximatePaintClip
(
child
as
RenderSliver
),
null
);
});
expect
(
visited
,
true
);
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
CustomScrollView
(
slivers:
<
Widget
>[
SliverToBoxAdapter
(
child:
SizedBox
(
width:
20
,
height:
20
)),
]
),
));
viewport
=
tester
.
allRenderObjects
.
whereType
<
RenderViewport
>().
first
;
expect
(
viewport
.
clipBehavior
,
Clip
.
hardEdge
);
visited
=
false
;
viewport
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
expect
(
viewport
.
describeApproximatePaintClip
(
child
as
RenderSliver
),
Offset
.
zero
&
viewport
.
size
);
});
expect
(
visited
,
true
);
});
}
packages/flutter/test/widgets/overlay_test.dart
View file @
1662a14b
...
...
@@ -1020,14 +1020,13 @@ void main() {
});
testWidgets
(
'Overlay can set and update clipBehavior'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
Container
(
),
builder:
(
BuildContext
context
)
=>
Positioned
(
left:
2000
,
right:
2500
,
child:
Container
()
),
),
],
),
...
...
@@ -1035,9 +1034,9 @@ void main() {
);
// By default, clipBehavior should be Clip.hardEdge
final
dynamic
renderObject
=
tester
.
renderObject
(
find
.
byType
(
Overlay
));
final
RenderObject
renderObject
=
tester
.
renderObject
(
find
.
byType
(
Overlay
));
// ignore: avoid_dynamic_calls
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
expect
(
(
renderObject
as
dynamic
)
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
for
(
final
Clip
clip
in
Clip
.
values
)
{
await
tester
.
pumpWidget
(
...
...
@@ -1053,8 +1052,27 @@ void main() {
),
),
);
// ignore: avoid_dynamic_calls
expect
(
renderObject
.
clipBehavior
,
clip
);
expect
((
renderObject
as
dynamic
).
clipBehavior
,
clip
);
bool
visited
=
false
;
renderObject
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
switch
(
clip
)
{
case
Clip
.
none
:
expect
(
renderObject
.
describeApproximatePaintClip
(
child
),
null
);
break
;
case
Clip
.
hardEdge
:
case
Clip
.
antiAlias
:
case
Clip
.
antiAliasWithSaveLayer
:
expect
(
renderObject
.
describeApproximatePaintClip
(
child
),
const
Rect
.
fromLTRB
(
0
,
0
,
800
,
600
),
);
break
;
}
});
expect
(
visited
,
true
);
}
});
...
...
packages/flutter/test/widgets/semantics_clipping_test.dart
View file @
1662a14b
...
...
@@ -18,6 +18,7 @@ void main() {
child:
SizedBox
(
width:
100.0
,
child:
Flex
(
clipBehavior:
Clip
.
hardEdge
,
direction:
Axis
.
horizontal
,
children:
const
<
Widget
>[
SizedBox
(
...
...
@@ -75,6 +76,7 @@ void main() {
child:
SizedBox
(
width:
100.0
,
child:
Flex
(
clipBehavior:
Clip
.
hardEdge
,
direction:
Axis
.
horizontal
,
children:
<
Widget
>[
const
SizedBox
(
...
...
packages/flutter/test/widgets/stack_test.dart
View file @
1662a14b
...
...
@@ -385,6 +385,29 @@ void main() {
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
});
testWidgets
(
'Clip.none is respected by describeApproximateClip'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Stack
(
textDirection:
TextDirection
.
ltr
,
children:
const
<
Widget
>[
Positioned
(
left:
1000
,
right:
2000
,
child:
SizedBox
(
width:
2000
,
height:
2000
))],
));
final
RenderStack
renderObject
=
tester
.
allRenderObjects
.
whereType
<
RenderStack
>().
first
;
expect
(
renderObject
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
bool
visited
=
false
;
renderObject
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
expect
(
renderObject
.
describeApproximatePaintClip
(
child
),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.0
,
600.0
));
});
expect
(
visited
,
true
);
visited
=
false
;
renderObject
.
clipBehavior
=
Clip
.
none
;
renderObject
.
visitChildren
((
RenderObject
child
)
{
visited
=
true
;
expect
(
renderObject
.
describeApproximatePaintClip
(
child
),
null
);
});
expect
(
visited
,
true
);
});
testWidgets
(
'IndexedStack with null index'
,
(
WidgetTester
tester
)
async
{
bool
?
tapped
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment