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
9157c164
Commit
9157c164
authored
Mar 29, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The intrinsic size checks were very slow
Now we run them once per render object. Fixes #2487
parent
992fc76e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
37 deletions
+46
-37
box.dart
packages/flutter/lib/src/rendering/box.dart
+43
-37
debug.dart
packages/flutter/lib/src/rendering/debug.dart
+3
-0
No files found.
packages/flutter/lib/src/rendering/box.dart
View file @
9157c164
...
@@ -653,6 +653,9 @@ abstract class RenderBox extends RenderObject {
...
@@ -653,6 +653,9 @@ abstract class RenderBox extends RenderObject {
@override
@override
BoxConstraints
get
constraints
=>
super
.
constraints
;
BoxConstraints
get
constraints
=>
super
.
constraints
;
// We check the intrinsic sizes of each render box once by default.
bool
_debugNeedsIntrinsicSizeCheck
=
true
;
@override
@override
void
debugAssertDoesMeetConstraints
()
{
void
debugAssertDoesMeetConstraints
()
{
assert
(
constraints
!=
null
);
assert
(
constraints
!=
null
);
...
@@ -716,43 +719,46 @@ abstract class RenderBox extends RenderObject {
...
@@ -716,43 +719,46 @@ abstract class RenderBox extends RenderObject {
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
);
}
}
// verify that the intrinsics are also within the constraints
if
(
_debugNeedsIntrinsicSizeCheck
||
debugCheckIntrinsicSizes
)
{
assert
(!
RenderObject
.
debugCheckingIntrinsics
);
// verify that the intrinsics are also within the constraints
RenderObject
.
debugCheckingIntrinsics
=
true
;
assert
(!
RenderObject
.
debugCheckingIntrinsics
);
double
intrinsic
;
RenderObject
.
debugCheckingIntrinsics
=
true
;
StringBuffer
failures
=
new
StringBuffer
();
double
intrinsic
;
int
failureCount
=
0
;
StringBuffer
failures
=
new
StringBuffer
();
intrinsic
=
getMinIntrinsicWidth
(
constraints
);
int
failureCount
=
0
;
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
intrinsic
=
getMinIntrinsicWidth
(
constraints
);
failures
.
writeln
(
' * getMinIntrinsicWidth() -- returned: w=
$intrinsic
'
);
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
failureCount
+=
1
;
failures
.
writeln
(
' * getMinIntrinsicWidth() -- returned: w=
$intrinsic
'
);
}
failureCount
+=
1
;
intrinsic
=
getMaxIntrinsicWidth
(
constraints
);
}
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
intrinsic
=
getMaxIntrinsicWidth
(
constraints
);
failures
.
writeln
(
' * getMaxIntrinsicWidth() -- returned: w=
$intrinsic
'
);
if
(
intrinsic
!=
constraints
.
constrainWidth
(
intrinsic
))
{
failureCount
+=
1
;
failures
.
writeln
(
' * getMaxIntrinsicWidth() -- returned: w=
$intrinsic
'
);
}
failureCount
+=
1
;
intrinsic
=
getMinIntrinsicHeight
(
constraints
);
}
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
intrinsic
=
getMinIntrinsicHeight
(
constraints
);
failures
.
writeln
(
' * getMinIntrinsicHeight() -- returned: h=
$intrinsic
'
);
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
failureCount
+=
1
;
failures
.
writeln
(
' * getMinIntrinsicHeight() -- returned: h=
$intrinsic
'
);
}
failureCount
+=
1
;
intrinsic
=
getMaxIntrinsicHeight
(
constraints
);
}
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
intrinsic
=
getMaxIntrinsicHeight
(
constraints
);
failures
.
writeln
(
' * getMaxIntrinsicHeight() -- returned: h=
$intrinsic
'
);
if
(
intrinsic
!=
constraints
.
constrainHeight
(
intrinsic
))
{
failureCount
+=
1
;
failures
.
writeln
(
' * getMaxIntrinsicHeight() -- returned: h=
$intrinsic
'
);
}
failureCount
+=
1
;
RenderObject
.
debugCheckingIntrinsics
=
false
;
}
if
(
failures
.
isNotEmpty
)
{
RenderObject
.
debugCheckingIntrinsics
=
false
;
assert
(
failureCount
>
0
);
_debugNeedsIntrinsicSizeCheck
=
false
;
throw
new
FlutterError
(
if
(
failures
.
isNotEmpty
)
{
'The intrinsic dimension methods of the
$runtimeType
class returned values that violate the given constraints.
\n
'
assert
(
failureCount
>
0
);
'The constraints were:
$constraints
\n
'
throw
new
FlutterError
(
'The following method
${failureCount > 1 ? "s" : ""}
returned values outside of those constraints:
\n
'
'The intrinsic dimension methods of the
$runtimeType
class returned values that violate the given constraints.
\n
'
'
$failures
'
'The constraints were:
$constraints
\n
'
'If you are not writing your own RenderBox subclass, then this is not
\n
'
'The following method
${failureCount > 1 ? "s" : ""}
returned values outside of those constraints:
\n
'
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
'
$failures
'
);
'If you are not writing your own RenderBox subclass, then this is not
\n
'
'your fault. Contact support: https://github.com/flutter/flutter/issues/new'
);
}
}
}
return
true
;
return
true
;
});
});
...
...
packages/flutter/lib/src/rendering/debug.dart
View file @
9157c164
...
@@ -68,6 +68,9 @@ bool debugPrintMarkNeedsPaintStacks = false;
...
@@ -68,6 +68,9 @@ bool debugPrintMarkNeedsPaintStacks = false;
/// Log the call stacks that mark render objects as needing layout.
/// Log the call stacks that mark render objects as needing layout.
bool
debugPrintMarkNeedsLayoutStacks
=
false
;
bool
debugPrintMarkNeedsLayoutStacks
=
false
;
/// Check the intrinsic sizes of each [RenderBox] during layout.
bool
debugCheckIntrinsicSizes
=
false
;
List
<
String
>
debugDescribeTransform
(
Matrix4
transform
)
{
List
<
String
>
debugDescribeTransform
(
Matrix4
transform
)
{
List
<
String
>
matrix
=
transform
.
toString
().
split
(
'
\n
'
).
map
((
String
s
)
=>
'
$s
'
).
toList
();
List
<
String
>
matrix
=
transform
.
toString
().
split
(
'
\n
'
).
map
((
String
s
)
=>
'
$s
'
).
toList
();
matrix
.
removeLast
();
matrix
.
removeLast
();
...
...
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