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
7a236aed
Unverified
Commit
7a236aed
authored
Aug 08, 2019
by
chunhtai
Committed by
GitHub
Aug 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix debug paint crash when axis direction inverted (#37033)
parent
771c843f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
2 deletions
+96
-2
sliver.dart
packages/flutter/lib/src/rendering/sliver.dart
+28
-0
sliver_padding.dart
packages/flutter/lib/src/rendering/sliver_padding.dart
+2
-2
debug_test.dart
packages/flutter/test/rendering/debug_test.dart
+66
-0
No files found.
packages/flutter/lib/src/rendering/sliver.dart
View file @
7a236aed
...
@@ -1425,6 +1425,10 @@ abstract class RenderSliver extends RenderObject {
...
@@ -1425,6 +1425,10 @@ abstract class RenderSliver extends RenderObject {
/// This means that the dimensions may be negative.
/// This means that the dimensions may be negative.
///
///
/// This is only valid after [layout] has completed.
/// This is only valid after [layout] has completed.
///
/// See also:
///
/// * [getAbsoluteSize], which returns absolute size.
@protected
@protected
Size
getAbsoluteSizeRelativeToOrigin
()
{
Size
getAbsoluteSizeRelativeToOrigin
()
{
assert
(
geometry
!=
null
);
assert
(
geometry
!=
null
);
...
@@ -1442,6 +1446,30 @@ abstract class RenderSliver extends RenderObject {
...
@@ -1442,6 +1446,30 @@ abstract class RenderSliver extends RenderObject {
return
null
;
return
null
;
}
}
/// This returns the absolute [Size] of the sliver.
///
/// The dimensions are always positive and calling this is only valid after
/// [layout] has completed.
///
/// See also:
///
/// * [getAbsoluteSizeRelativeToOrigin], which returns the size relative to
/// the leading edge of the sliver.
@protected
Size
getAbsoluteSize
()
{
assert
(
geometry
!=
null
);
assert
(!
debugNeedsLayout
);
switch
(
constraints
.
axisDirection
)
{
case
AxisDirection
.
up
:
case
AxisDirection
.
down
:
return
Size
(
constraints
.
crossAxisExtent
,
geometry
.
paintExtent
);
case
AxisDirection
.
right
:
case
AxisDirection
.
left
:
return
Size
(
geometry
.
paintExtent
,
constraints
.
crossAxisExtent
);
}
return
null
;
}
void
_debugDrawArrow
(
Canvas
canvas
,
Paint
paint
,
Offset
p0
,
Offset
p1
,
GrowthDirection
direction
)
{
void
_debugDrawArrow
(
Canvas
canvas
,
Paint
paint
,
Offset
p0
,
Offset
p1
,
GrowthDirection
direction
)
{
assert
(()
{
assert
(()
{
if
(
p0
==
p1
)
if
(
p0
==
p1
)
...
...
packages/flutter/lib/src/rendering/sliver_padding.dart
View file @
7a236aed
...
@@ -328,12 +328,12 @@ class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin<R
...
@@ -328,12 +328,12 @@ class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin<R
super
.
debugPaint
(
context
,
offset
);
super
.
debugPaint
(
context
,
offset
);
assert
(()
{
assert
(()
{
if
(
debugPaintSizeEnabled
)
{
if
(
debugPaintSizeEnabled
)
{
final
Size
parentSize
=
getAbsoluteSize
RelativeToOrigin
();
final
Size
parentSize
=
getAbsoluteSize
();
final
Rect
outerRect
=
offset
&
parentSize
;
final
Rect
outerRect
=
offset
&
parentSize
;
Size
childSize
;
Size
childSize
;
Rect
innerRect
;
Rect
innerRect
;
if
(
child
!=
null
)
{
if
(
child
!=
null
)
{
childSize
=
child
.
getAbsoluteSize
RelativeToOrigin
();
childSize
=
child
.
getAbsoluteSize
();
final
SliverPhysicalParentData
childParentData
=
child
.
parentData
;
final
SliverPhysicalParentData
childParentData
=
child
.
parentData
;
innerRect
=
(
offset
+
childParentData
.
paintOffset
)
&
childSize
;
innerRect
=
(
offset
+
childParentData
.
paintOffset
)
&
childSize
;
assert
(
innerRect
.
top
>=
outerRect
.
top
);
assert
(
innerRect
.
top
>=
outerRect
.
top
);
...
...
packages/flutter/test/rendering/debug_test.dart
View file @
7a236aed
...
@@ -124,4 +124,70 @@ void main() {
...
@@ -124,4 +124,70 @@ void main() {
expect
(
b
.
debugPaint
,
isNot
(
paints
..
rect
(
color:
const
Color
(
0x90909090
))));
expect
(
b
.
debugPaint
,
isNot
(
paints
..
rect
(
color:
const
Color
(
0x90909090
))));
debugPaintSizeEnabled
=
false
;
debugPaintSizeEnabled
=
false
;
});
});
test
(
'debugPaintPadding from render objects with inverted direction vertical'
,
()
{
debugPaintSizeEnabled
=
true
;
RenderSliver
s
;
final
RenderViewport
root
=
RenderViewport
(
axisDirection:
AxisDirection
.
up
,
crossAxisDirection:
AxisDirection
.
right
,
offset:
ViewportOffset
.
zero
(),
children:
<
RenderSliver
>[
s
=
RenderSliverPadding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
RenderSliverToBoxAdapter
(
child:
RenderPadding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
),
),
),
],
);
layout
(
root
);
dynamic
error
;
try
{
s
.
debugPaint
(
PaintingContext
(
ContainerLayer
(),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.0
,
600.0
)),
const
Offset
(
0.0
,
500
)
);
}
catch
(
e
)
{
error
=
e
;
}
expect
(
error
,
isNull
);
debugPaintSizeEnabled
=
false
;
});
test
(
'debugPaintPadding from render objects with inverted direction horizontal'
,
()
{
debugPaintSizeEnabled
=
true
;
RenderSliver
s
;
final
RenderViewport
root
=
RenderViewport
(
axisDirection:
AxisDirection
.
left
,
crossAxisDirection:
AxisDirection
.
down
,
offset:
ViewportOffset
.
zero
(),
children:
<
RenderSliver
>[
s
=
RenderSliverPadding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
RenderSliverToBoxAdapter
(
child:
RenderPadding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
),
),
),
],
);
layout
(
root
);
dynamic
error
;
try
{
s
.
debugPaint
(
PaintingContext
(
ContainerLayer
(),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.0
,
600.0
)),
const
Offset
(
0.0
,
500
)
);
}
catch
(
e
)
{
error
=
e
;
}
expect
(
error
,
isNull
);
debugPaintSizeEnabled
=
false
;
});
}
}
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