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
5f9ad01e
Unverified
Commit
5f9ad01e
authored
Sep 14, 2022
by
Greg Spencer
Committed by
GitHub
Sep 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare the framework for having RRect assert on negative radii (#111515)
parent
fb90be4a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
17 deletions
+62
-17
border_radius.dart
packages/flutter/lib/src/painting/border_radius.dart
+10
-4
box_border.dart
packages/flutter/lib/src/painting/box_border.dart
+12
-1
rounded_rectangle_border.dart
...es/flutter/lib/src/painting/rounded_rectangle_border.dart
+12
-1
table_border.dart
packages/flutter/lib/src/rendering/table_border.dart
+12
-1
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+11
-0
checkbox_test.dart
packages/flutter/test/material/checkbox_test.dart
+4
-4
box_decoration_test.dart
packages/flutter/test/widgets/box_decoration_test.dart
+1
-6
No files found.
packages/flutter/lib/src/painting/border_radius.dart
View file @
5f9ad01e
...
@@ -392,13 +392,19 @@ class BorderRadius extends BorderRadiusGeometry {
...
@@ -392,13 +392,19 @@ class BorderRadius extends BorderRadiusGeometry {
Radius
get
_bottomEnd
=>
Radius
.
zero
;
Radius
get
_bottomEnd
=>
Radius
.
zero
;
/// Creates an [RRect] from the current border radius and a [Rect].
/// Creates an [RRect] from the current border radius and a [Rect].
///
/// If any of the radii have negative values in x or y, those values will be
/// clamped to zero in order to produce a valid [RRect].
RRect
toRRect
(
Rect
rect
)
{
RRect
toRRect
(
Rect
rect
)
{
// Because the current radii could be negative, we must clamp them before
// converting them to an RRect to be rendered, since negative radii on
// RRects don't make sense.
return
RRect
.
fromRectAndCorners
(
return
RRect
.
fromRectAndCorners
(
rect
,
rect
,
topLeft:
topLeft
,
topLeft:
topLeft
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
topRight:
topRight
,
topRight:
topRight
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomLeft:
bottomLeft
,
bottomLeft:
bottomLeft
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomRight:
bottomRight
,
bottomRight:
bottomRight
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
);
);
}
}
...
...
packages/flutter/lib/src/painting/box_border.dart
View file @
5f9ad01e
...
@@ -232,7 +232,18 @@ abstract class BoxBorder extends ShapeBorder {
...
@@ -232,7 +232,18 @@ abstract class BoxBorder extends ShapeBorder {
canvas
.
drawRRect
(
borderRadius
.
toRRect
(
rect
),
paint
);
canvas
.
drawRRect
(
borderRadius
.
toRRect
(
rect
),
paint
);
}
else
{
}
else
{
final
RRect
borderRect
=
borderRadius
.
toRRect
(
rect
);
final
RRect
borderRect
=
borderRadius
.
toRRect
(
rect
);
final
RRect
inner
=
borderRect
.
deflate
(
side
.
strokeInset
);
RRect
inner
=
borderRect
.
deflate
(
side
.
strokeInset
);
// Clamp the inner border's radii to zero, until deflate does this
// automatically, so that we can start asserting non-negative values
// in the engine without breaking the framework.
// TODO(gspencergoog): Remove this once https://github.com/flutter/engine/pull/36062 rolls into the framework.
inner
=
RRect
.
fromLTRBAndCorners
(
inner
.
left
,
inner
.
top
,
inner
.
right
,
inner
.
bottom
,
topLeft:
inner
.
tlRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
topRight:
inner
.
trRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomLeft:
inner
.
blRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomRight:
inner
.
brRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
);
final
RRect
outer
=
borderRect
.
inflate
(
side
.
strokeOutset
);
final
RRect
outer
=
borderRect
.
inflate
(
side
.
strokeOutset
);
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
}
}
...
...
packages/flutter/lib/src/painting/rounded_rectangle_border.dart
View file @
5f9ad01e
...
@@ -132,7 +132,18 @@ class RoundedRectangleBorder extends OutlinedBorder {
...
@@ -132,7 +132,18 @@ class RoundedRectangleBorder extends OutlinedBorder {
final
Paint
paint
=
Paint
()
final
Paint
paint
=
Paint
()
..
color
=
side
.
color
;
..
color
=
side
.
color
;
final
RRect
borderRect
=
borderRadius
.
resolve
(
textDirection
).
toRRect
(
rect
);
final
RRect
borderRect
=
borderRadius
.
resolve
(
textDirection
).
toRRect
(
rect
);
final
RRect
inner
=
borderRect
.
deflate
(
side
.
strokeInset
);
RRect
inner
=
borderRect
.
deflate
(
side
.
strokeInset
);
// Clamp the inner border's radii to zero, until deflate does this
// automatically, so that we can start asserting non-negative values
// in the engine without breaking the framework.
// TODO(gspencergoog): Remove this once https://github.com/flutter/engine/pull/36062 rolls into the framework.
inner
=
RRect
.
fromLTRBAndCorners
(
inner
.
left
,
inner
.
top
,
inner
.
right
,
inner
.
bottom
,
topLeft:
inner
.
tlRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
topRight:
inner
.
trRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomLeft:
inner
.
blRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomRight:
inner
.
brRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
);
final
RRect
outer
=
borderRect
.
inflate
(
side
.
strokeOutset
);
final
RRect
outer
=
borderRect
.
inflate
(
side
.
strokeOutset
);
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
}
}
...
...
packages/flutter/lib/src/rendering/table_border.dart
View file @
5f9ad01e
...
@@ -271,7 +271,18 @@ class TableBorder {
...
@@ -271,7 +271,18 @@ class TableBorder {
paintBorder
(
canvas
,
rect
,
top:
top
,
right:
right
,
bottom:
bottom
,
left:
left
);
paintBorder
(
canvas
,
rect
,
top:
top
,
right:
right
,
bottom:
bottom
,
left:
left
);
}
else
{
}
else
{
final
RRect
outer
=
borderRadius
.
toRRect
(
rect
);
final
RRect
outer
=
borderRadius
.
toRRect
(
rect
);
final
RRect
inner
=
outer
.
deflate
(
top
.
width
);
RRect
inner
=
outer
.
deflate
(
top
.
width
);
// Clamp the inner border's radii to zero, until deflate does this
// automatically, so that we can start asserting non-negative values
// in the engine without breaking the framework.
// TODO(gspencergoog): Remove this once https://github.com/flutter/engine/pull/36062 rolls into the framework.
inner
=
RRect
.
fromLTRBAndCorners
(
inner
.
left
,
inner
.
top
,
inner
.
right
,
inner
.
bottom
,
topLeft:
inner
.
tlRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
topRight:
inner
.
trRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomLeft:
inner
.
blRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomRight:
inner
.
brRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
);
final
Paint
paint
=
Paint
()..
color
=
top
.
color
;
final
Paint
paint
=
Paint
()..
color
=
top
.
color
;
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
canvas
.
drawDRRect
(
outer
,
inner
,
paint
);
}
}
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
5f9ad01e
...
@@ -129,6 +129,17 @@ class _MulticastCanvas implements Canvas {
...
@@ -129,6 +129,17 @@ class _MulticastCanvas implements Canvas {
@override
@override
void
drawDRRect
(
RRect
outer
,
RRect
inner
,
Paint
paint
)
{
void
drawDRRect
(
RRect
outer
,
RRect
inner
,
Paint
paint
)
{
// Clamp the inner border's radii to zero, until deflate does this
// automatically, so that we can start asserting non-negative values
// in the engine without breaking the framework.
// TODO(gspencergoog): Remove this once https://github.com/flutter/engine/pull/36062 rolls into the framework.
inner
=
RRect
.
fromLTRBAndCorners
(
inner
.
left
,
inner
.
top
,
inner
.
right
,
inner
.
bottom
,
topLeft:
inner
.
tlRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
topRight:
inner
.
trRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomLeft:
inner
.
blRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
bottomRight:
inner
.
brRadius
.
clamp
(
minimum:
Radius
.
zero
),
// ignore_clamp_double_lint
);
_main
.
drawDRRect
(
outer
,
inner
,
paint
);
_main
.
drawDRRect
(
outer
,
inner
,
paint
);
_screenshot
.
drawDRRect
(
outer
,
inner
,
paint
);
_screenshot
.
drawDRRect
(
outer
,
inner
,
paint
);
}
}
...
...
packages/flutter/test/material/checkbox_test.dart
View file @
5f9ad01e
...
@@ -553,7 +553,7 @@ void main() {
...
@@ -553,7 +553,7 @@ void main() {
..
drrect
(
..
drrect
(
color:
material3
?
theme
.
colorScheme
.
onSurface
:
const
Color
(
0x8a000000
),
color:
material3
?
theme
.
colorScheme
.
onSurface
:
const
Color
(
0x8a000000
),
outer:
RRect
.
fromLTRBR
(
15.0
,
15.0
,
33.0
,
33.0
,
const
Radius
.
circular
(
1.0
)),
outer:
RRect
.
fromLTRBR
(
15.0
,
15.0
,
33.0
,
33.0
,
const
Radius
.
circular
(
1.0
)),
inner:
RRect
.
fromLTRBR
(
17.0
,
17.0
,
31.0
,
31.0
,
const
Radius
.
circular
(-
1.0
)
),
inner:
RRect
.
fromLTRBR
(
17.0
,
17.0
,
31.0
,
31.0
,
Radius
.
zero
),
),
),
);
);
...
@@ -568,7 +568,7 @@ void main() {
...
@@ -568,7 +568,7 @@ void main() {
..
drrect
(
..
drrect
(
color:
material3
?
theme
.
colorScheme
.
onSurface
.
withOpacity
(
0.38
)
:
const
Color
(
0x61000000
),
color:
material3
?
theme
.
colorScheme
.
onSurface
.
withOpacity
(
0.38
)
:
const
Color
(
0x61000000
),
outer:
RRect
.
fromLTRBR
(
15.0
,
15.0
,
33.0
,
33.0
,
const
Radius
.
circular
(
1.0
)),
outer:
RRect
.
fromLTRBR
(
15.0
,
15.0
,
33.0
,
33.0
,
const
Radius
.
circular
(
1.0
)),
inner:
RRect
.
fromLTRBR
(
17.0
,
17.0
,
31.0
,
31.0
,
const
Radius
.
circular
(-
1.0
)
),
inner:
RRect
.
fromLTRBR
(
17.0
,
17.0
,
31.0
,
31.0
,
Radius
.
zero
),
),
),
);
);
});
});
...
@@ -1420,7 +1420,7 @@ void main() {
...
@@ -1420,7 +1420,7 @@ void main() {
..
drrect
(
..
drrect
(
color:
borderColor
,
color:
borderColor
,
outer:
RRect
.
fromLTRBR
(
15
,
15
,
33
,
33
,
const
Radius
.
circular
(
1
)),
outer:
RRect
.
fromLTRBR
(
15
,
15
,
33
,
33
,
const
Radius
.
circular
(
1
)),
inner:
RRect
.
fromLTRBR
(
19
,
19
,
29
,
29
,
const
Radius
.
circular
(-
3
)
),
inner:
RRect
.
fromLTRBR
(
19
,
19
,
29
,
29
,
Radius
.
zero
),
),
),
);
);
}
}
...
@@ -1479,7 +1479,7 @@ void main() {
...
@@ -1479,7 +1479,7 @@ void main() {
..
drrect
(
..
drrect
(
color:
borderColor
,
color:
borderColor
,
outer:
RRect
.
fromLTRBR
(
15
,
15
,
33
,
33
,
const
Radius
.
circular
(
1
)),
outer:
RRect
.
fromLTRBR
(
15
,
15
,
33
,
33
,
const
Radius
.
circular
(
1
)),
inner:
RRect
.
fromLTRBR
(
19
,
19
,
29
,
29
,
const
Radius
.
circular
(-
3
)
),
inner:
RRect
.
fromLTRBR
(
19
,
19
,
29
,
29
,
Radius
.
zero
),
),
),
);
);
}
}
...
...
packages/flutter/test/widgets/box_decoration_test.dart
View file @
5f9ad01e
...
@@ -249,12 +249,7 @@ Future<void> main() async {
...
@@ -249,12 +249,7 @@ Future<void> main() async {
350.0
,
200.0
,
450.0
,
300.0
,
350.0
,
200.0
,
450.0
,
300.0
,
topRight:
const
Radius
.
circular
(
10.0
),
topRight:
const
Radius
.
circular
(
10.0
),
),
),
inner:
RRect
.
fromLTRBAndCorners
(
inner:
RRect
.
fromLTRBAndCorners
(
360.0
,
210.0
,
440.0
,
290.0
),
360.0
,
210.0
,
440.0
,
290.0
,
topLeft:
const
Radius
.
circular
(-
10.0
),
bottomRight:
const
Radius
.
circular
(-
10.0
),
bottomLeft:
const
Radius
.
circular
(-
10.0
),
),
)
)
..
circle
(
x:
400.0
,
y:
350.0
,
radius:
45.0
),
..
circle
(
x:
400.0
,
y:
350.0
,
radius:
45.0
),
);
);
...
...
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