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
877cfd1c
Commit
877cfd1c
authored
Feb 10, 2016
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1760 from Hixie/asserts
Improve asserts around BoxConstraints
parents
96405fb4
3bd8bc33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
sector_layout.dart
examples/rendering/lib/sector_layout.dart
+4
-0
box.dart
packages/flutter/lib/src/rendering/box.dart
+12
-3
object.dart
packages/flutter/lib/src/rendering/object.dart
+5
-1
No files found.
examples/rendering/lib/sector_layout.dart
View file @
877cfd1c
...
...
@@ -39,6 +39,10 @@ class SectorConstraints extends Constraints {
bool
get
isTight
=>
minDeltaTheta
>=
maxDeltaTheta
&&
minDeltaTheta
>=
maxDeltaTheta
;
bool
get
isNormalized
=>
minDeltaRadius
<=
maxDeltaRadius
&&
minDeltaTheta
<=
maxDeltaTheta
;
bool
get
debugAssertIsNormalized
{
assert
(
isNormalized
);
return
isNormalized
;
}
}
class
SectorDimensions
{
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
877cfd1c
...
...
@@ -272,12 +272,21 @@ class BoxConstraints extends Constraints {
/// normalized and have undefined behavior when they are not. In
/// checked mode, many of these APIs will assert if the constraints
/// are not normalized.
bool
get
isNormalized
=>
minWidth
<=
maxWidth
&&
minHeight
<=
maxHeight
;
bool
get
isNormalized
{
return
minWidth
>=
0.0
&&
minWidth
<=
maxWidth
&&
minHeight
>=
0.0
&&
minHeight
<=
maxHeight
;
}
/// Same as [isNormalized] but, in checked mode, throws an exception
/// if isNormalized is false.
bool
get
debugAssertIsNormalized
{
assert
(()
{
if
(
minWidth
<
0.0
&&
minHeight
<
0.0
)
throw
new
RenderingError
(
'BoxConstraints has both a negative minimum width and a negative minimum height.
\n
$this
'
);
if
(
minWidth
<
0.0
)
throw
new
RenderingError
(
'BoxConstraints has a negative minimum width.
\n
$this
'
);
if
(
minHeight
<
0.0
)
throw
new
RenderingError
(
'BoxConstraints has a negative minimum height.
\n
$this
'
);
if
(
maxWidth
<
minWidth
&&
maxHeight
<
minHeight
)
throw
new
RenderingError
(
'BoxConstraints has both width and height constraints non-normalized.
\n
$this
'
);
if
(
maxWidth
<
minWidth
)
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
877cfd1c
...
...
@@ -353,6 +353,10 @@ abstract class Constraints {
/// Whether the constraint is expressed in a consistent manner.
bool
get
isNormalized
;
/// Same as [isNormalized] but, in checked mode, throws an exception
/// if isNormalized is false.
bool
get
debugAssertIsNormalized
;
}
typedef
void
RenderObjectVisitor
(
RenderObject
child
);
...
...
@@ -975,7 +979,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// implemented here) to return early if the child does not need to do any
/// work to update its layout information.
void
layout
(
Constraints
constraints
,
{
bool
parentUsesSize:
false
})
{
assert
(
constraints
.
i
sNormalized
);
assert
(
constraints
.
debugAssertI
sNormalized
);
assert
(!
_debugDoingThisResize
);
assert
(!
_debugDoingThisLayout
);
final
RenderObject
parent
=
this
.
parent
;
...
...
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