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
13f106b0
Unverified
Commit
13f106b0
authored
Feb 02, 2022
by
Kate Lovett
Committed by
GitHub
Feb 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Clip.none as a valid clipBehavior (#95593)
parent
f82c0200
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
66 deletions
+112
-66
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+67
-45
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+29
-21
clip_test.dart
packages/flutter/test/widgets/clip_test.dart
+16
-0
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
13f106b0
...
...
@@ -1429,13 +1429,13 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
/// If [clipper] is null, the clip will match the layout size and position of
/// the child.
///
/// The [clipBehavior] must not be null or [Clip.none].
/// The [clipBehavior] must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
RenderClipRect
({
RenderBox
?
child
,
CustomClipper
<
Rect
>?
clipper
,
Clip
clipBehavior
=
Clip
.
antiAlias
,
})
:
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
Clip
.
none
),
super
(
child:
child
,
clipper:
clipper
,
clipBehavior:
clipBehavior
);
@override
...
...
@@ -1455,15 +1455,20 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
_updateClip
();
layer
=
context
.
pushClipRect
(
needsCompositing
,
offset
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipRectLayer
?,
);
if
(
clipBehavior
!=
Clip
.
none
)
{
_updateClip
();
layer
=
context
.
pushClipRect
(
needsCompositing
,
offset
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipRectLayer
?,
);
}
else
{
context
.
paintChild
(
child
!,
offset
);
layer
=
null
;
}
}
else
{
layer
=
null
;
}
...
...
@@ -1495,14 +1500,14 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
///
/// If [clipper] is non-null, then [borderRadius] is ignored.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
RenderClipRRect
({
RenderBox
?
child
,
BorderRadius
borderRadius
=
BorderRadius
.
zero
,
CustomClipper
<
RRect
>?
clipper
,
Clip
clipBehavior
=
Clip
.
antiAlias
,
})
:
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
Clip
.
none
),
_borderRadius
=
borderRadius
,
super
(
child:
child
,
clipper:
clipper
,
clipBehavior:
clipBehavior
)
{
assert
(
_borderRadius
!=
null
||
clipper
!=
null
);
...
...
@@ -1541,14 +1546,21 @@ class RenderClipRRect extends _RenderCustomClip<RRect> {
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
_updateClip
();
layer
=
context
.
pushClipRRect
(
needsCompositing
,
offset
,
_clip
!.
outerRect
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipRRectLayer
?,
);
if
(
clipBehavior
!=
Clip
.
none
)
{
_updateClip
();
layer
=
context
.
pushClipRRect
(
needsCompositing
,
offset
,
_clip
!.
outerRect
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipRRectLayer
?,
);
}
else
{
context
.
paintChild
(
child
!,
offset
);
layer
=
null
;
}
}
else
{
layer
=
null
;
}
...
...
@@ -1578,13 +1590,13 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
/// If [clipper] is null, the oval will be inscribed into the layout size and
/// position of the child.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
RenderClipOval
({
RenderBox
?
child
,
CustomClipper
<
Rect
>?
clipper
,
Clip
clipBehavior
=
Clip
.
antiAlias
,
})
:
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
Clip
.
none
),
super
(
child:
child
,
clipper:
clipper
,
clipBehavior:
clipBehavior
);
Rect
?
_cachedRect
;
...
...
@@ -1620,16 +1632,21 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
_updateClip
();
layer
=
context
.
pushClipPath
(
needsCompositing
,
offset
,
_clip
!,
_getClipPath
(
_clip
!),
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipPathLayer
?,
);
if
(
clipBehavior
!=
Clip
.
none
)
{
_updateClip
();
layer
=
context
.
pushClipPath
(
needsCompositing
,
offset
,
_clip
!,
_getClipPath
(
_clip
!),
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipPathLayer
?,
);
}
else
{
context
.
paintChild
(
child
!,
offset
);
layer
=
null
;
}
}
else
{
layer
=
null
;
}
...
...
@@ -1667,13 +1684,13 @@ class RenderClipPath extends _RenderCustomClip<Path> {
/// consider using a [RenderClipRect], which can achieve the same effect more
/// efficiently.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
RenderClipPath
({
RenderBox
?
child
,
CustomClipper
<
Path
>?
clipper
,
Clip
clipBehavior
=
Clip
.
antiAlias
,
})
:
assert
(
clipBehavior
!=
null
),
assert
(
clipBehavior
!=
Clip
.
none
),
super
(
child:
child
,
clipper:
clipper
,
clipBehavior:
clipBehavior
);
@override
...
...
@@ -1693,16 +1710,21 @@ class RenderClipPath extends _RenderCustomClip<Path> {
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
child
!=
null
)
{
_updateClip
();
layer
=
context
.
pushClipPath
(
needsCompositing
,
offset
,
Offset
.
zero
&
size
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipPathLayer
?,
);
if
(
clipBehavior
!=
Clip
.
none
)
{
_updateClip
();
layer
=
context
.
pushClipPath
(
needsCompositing
,
offset
,
Offset
.
zero
&
size
,
_clip
!,
super
.
paint
,
clipBehavior:
clipBehavior
,
oldLayer:
layer
as
ClipPathLayer
?,
);
}
else
{
context
.
paintChild
(
child
!,
offset
);
layer
=
null
;
}
}
else
{
layer
=
null
;
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
13f106b0
...
...
@@ -662,10 +662,15 @@ class ClipRect extends SingleChildRenderObjectWidget {
/// If [clipper] is null, the clip will match the layout size and position of
/// the child.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
const
ClipRect
({
Key
?
key
,
this
.
clipper
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
Widget
?
child
})
:
assert
(
clipBehavior
!=
null
),
super
(
key:
key
,
child:
child
);
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
const
ClipRect
({
Key
?
key
,
this
.
clipper
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
Widget
?
child
,
})
:
assert
(
clipBehavior
!=
null
),
super
(
key:
key
,
child:
child
);
/// If non-null, determines which clip to use.
final
CustomClipper
<
Rect
>?
clipper
;
...
...
@@ -677,13 +682,11 @@ class ClipRect extends SingleChildRenderObjectWidget {
@override
RenderClipRect
createRenderObject
(
BuildContext
context
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
return
RenderClipRect
(
clipper:
clipper
,
clipBehavior:
clipBehavior
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderClipRect
renderObject
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
renderObject
..
clipper
=
clipper
..
clipBehavior
=
clipBehavior
;
...
...
@@ -723,7 +726,8 @@ class ClipRRect extends SingleChildRenderObjectWidget {
///
/// If [clipper] is non-null, then [borderRadius] is ignored.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
const
ClipRRect
({
Key
?
key
,
this
.
borderRadius
=
BorderRadius
.
zero
,
...
...
@@ -752,13 +756,15 @@ class ClipRRect extends SingleChildRenderObjectWidget {
@override
RenderClipRRect
createRenderObject
(
BuildContext
context
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
return
RenderClipRRect
(
borderRadius:
borderRadius
!,
clipper:
clipper
,
clipBehavior:
clipBehavior
);
return
RenderClipRRect
(
borderRadius:
borderRadius
!,
clipper:
clipper
,
clipBehavior:
clipBehavior
,
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderClipRRect
renderObject
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
renderObject
..
borderRadius
=
borderRadius
!
..
clipBehavior
=
clipBehavior
...
...
@@ -793,10 +799,15 @@ class ClipOval extends SingleChildRenderObjectWidget {
/// If [clipper] is null, the oval will be inscribed into the layout size and
/// position of the child.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
const
ClipOval
({
Key
?
key
,
this
.
clipper
,
this
.
clipBehavior
=
Clip
.
antiAlias
,
Widget
?
child
})
:
assert
(
clipBehavior
!=
null
),
super
(
key:
key
,
child:
child
);
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
const
ClipOval
({
Key
?
key
,
this
.
clipper
,
this
.
clipBehavior
=
Clip
.
antiAlias
,
Widget
?
child
,
})
:
assert
(
clipBehavior
!=
null
),
super
(
key:
key
,
child:
child
);
/// If non-null, determines which clip to use.
///
...
...
@@ -816,13 +827,11 @@ class ClipOval extends SingleChildRenderObjectWidget {
@override
RenderClipOval
createRenderObject
(
BuildContext
context
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
return
RenderClipOval
(
clipper:
clipper
,
clipBehavior:
clipBehavior
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderClipOval
renderObject
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
renderObject
..
clipper
=
clipper
..
clipBehavior
=
clipBehavior
;
...
...
@@ -866,7 +875,8 @@ class ClipPath extends SingleChildRenderObjectWidget {
/// consider using a [ClipRect], which can achieve the same effect more
/// efficiently.
///
/// The [clipBehavior] argument must not be null or [Clip.none].
/// The [clipBehavior] argument must not be null. If [clipBehavior] is
/// [Clip.none], no clipping will be applied.
const
ClipPath
({
Key
?
key
,
this
.
clipper
,
...
...
@@ -886,7 +896,6 @@ class ClipPath extends SingleChildRenderObjectWidget {
Widget
?
child
,
})
{
assert
(
clipBehavior
!=
null
);
assert
(
clipBehavior
!=
Clip
.
none
);
assert
(
shape
!=
null
);
return
Builder
(
key:
key
,
...
...
@@ -917,13 +926,11 @@ class ClipPath extends SingleChildRenderObjectWidget {
@override
RenderClipPath
createRenderObject
(
BuildContext
context
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
return
RenderClipPath
(
clipper:
clipper
,
clipBehavior:
clipBehavior
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
RenderClipPath
renderObject
)
{
assert
(
clipBehavior
!=
Clip
.
none
);
renderObject
..
clipper
=
clipper
..
clipBehavior
=
clipBehavior
;
...
...
@@ -1014,7 +1021,8 @@ class PhysicalModel extends SingleChildRenderObjectWidget {
shape:
shape
,
clipBehavior:
clipBehavior
,
borderRadius:
borderRadius
,
elevation:
elevation
,
color:
color
,
elevation:
elevation
,
color:
color
,
shadowColor:
shadowColor
,
);
}
...
...
packages/flutter/test/widgets/clip_test.dart
View file @
13f106b0
...
...
@@ -87,6 +87,10 @@ void main() {
await
tester
.
pumpWidget
(
const
ClipRect
(
clipBehavior:
Clip
.
antiAlias
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
antiAlias
));
await
tester
.
pumpWidget
(
const
ClipRect
(
clipBehavior:
Clip
.
none
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
none
));
});
test
(
'ClipRRect constructs with the right default values'
,
()
{
...
...
@@ -105,6 +109,10 @@ void main() {
await
tester
.
pumpWidget
(
const
ClipRRect
(
clipBehavior:
Clip
.
hardEdge
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
await
tester
.
pumpWidget
(
const
ClipRRect
(
clipBehavior:
Clip
.
none
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
none
));
});
testWidgets
(
'ClipOval updates clipBehavior in updateRenderObject'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -117,6 +125,10 @@ void main() {
await
tester
.
pumpWidget
(
const
ClipOval
(
clipBehavior:
Clip
.
hardEdge
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
await
tester
.
pumpWidget
(
const
ClipOval
(
clipBehavior:
Clip
.
none
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
none
));
});
testWidgets
(
'ClipPath updates clipBehavior in updateRenderObject'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -129,6 +141,10 @@ void main() {
await
tester
.
pumpWidget
(
const
ClipPath
(
clipBehavior:
Clip
.
hardEdge
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
hardEdge
));
await
tester
.
pumpWidget
(
const
ClipPath
(
clipBehavior:
Clip
.
none
));
expect
(
renderClip
.
clipBehavior
,
equals
(
Clip
.
none
));
});
testWidgets
(
'ClipPath'
,
(
WidgetTester
tester
)
async
{
...
...
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