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
11da9b02
Commit
11da9b02
authored
Dec 09, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #830 from Hixie/BoxConstraints
Catch un-normalized BoxConstraints
parents
23ab08ad
1a049c14
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
127 additions
and
13 deletions
+127
-13
sector_layout.dart
examples/rendering/lib/sector_layout.dart
+2
-0
block.dart
packages/flutter/lib/src/rendering/block.dart
+8
-0
box.dart
packages/flutter/lib/src/rendering/box.dart
+36
-7
custom_layout.dart
packages/flutter/lib/src/rendering/custom_layout.dart
+2
-0
editable_paragraph.dart
packages/flutter/lib/src/rendering/editable_paragraph.dart
+1
-0
flex.dart
packages/flutter/lib/src/rendering/flex.dart
+1
-0
grid.dart
packages/flutter/lib/src/rendering/grid.dart
+4
-0
image.dart
packages/flutter/lib/src/rendering/image.dart
+4
-0
object.dart
packages/flutter/lib/src/rendering/object.dart
+4
-0
overflow.dart
packages/flutter/lib/src/rendering/overflow.dart
+8
-0
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+3
-0
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+23
-0
shifted_box.dart
packages/flutter/lib/src/rendering/shifted_box.dart
+18
-5
stack.dart
packages/flutter/lib/src/rendering/stack.dart
+4
-0
statistics_box.dart
packages/flutter/lib/src/rendering/statistics_box.dart
+4
-0
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+4
-0
flex_test.dart
packages/unit/test/rendering/flex_test.dart
+1
-1
No files found.
examples/rendering/lib/sector_layout.dart
View file @
11da9b02
...
...
@@ -37,6 +37,8 @@ class SectorConstraints extends Constraints {
}
bool
get
isTight
=>
minDeltaTheta
>=
maxDeltaTheta
&&
minDeltaTheta
>=
maxDeltaTheta
;
bool
get
isNormalized
=>
minDeltaRadius
<=
maxDeltaRadius
&&
minDeltaTheta
<=
maxDeltaTheta
;
}
class
SectorDimensions
{
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
11da9b02
...
...
@@ -167,6 +167,7 @@ class RenderBlock extends RenderBlockBase {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
{
return
_getIntrinsicCrossAxis
(
constraints
,
...
...
@@ -177,6 +178,7 @@ class RenderBlock extends RenderBlockBase {
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
{
return
_getIntrinsicCrossAxis
(
constraints
,
...
...
@@ -187,6 +189,7 @@ class RenderBlock extends RenderBlockBase {
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
return
_getIntrinsicMainAxis
(
constraints
);
return
_getIntrinsicCrossAxis
(
...
...
@@ -196,6 +199,7 @@ class RenderBlock extends RenderBlockBase {
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
return
_getIntrinsicMainAxis
(
constraints
);
return
_getIntrinsicCrossAxis
(
...
...
@@ -361,24 +365,28 @@ class RenderBlockViewport extends RenderBlockBase {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
return
_getIntrinsicDimension
(
constraints
,
minCrossAxisExtentCallback
,
constraints
.
constrainWidth
);
return
constraints
.
constrainWidth
(
minExtent
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
isVertical
)
return
_getIntrinsicDimension
(
constraints
,
maxCrossAxisExtentCallback
,
constraints
.
constrainWidth
);
return
_getIntrinsicDimension
(
constraints
,
totalExtentCallback
,
new
BoxConstraints
(
minWidth:
minExtent
).
enforce
(
constraints
).
constrainWidth
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(!
isVertical
)
return
_getIntrinsicDimension
(
constraints
,
minCrossAxisExtentCallback
,
constraints
.
constrainHeight
);
return
constraints
.
constrainHeight
(
0.0
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(!
isVertical
)
return
_getIntrinsicDimension
(
constraints
,
maxCrossAxisExtentCallback
,
constraints
.
constrainHeight
);
return
_getIntrinsicDimension
(
constraints
,
totalExtentCallback
,
new
BoxConstraints
(
minHeight:
minExtent
).
enforce
(
constraints
).
constrainHeight
);
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
11da9b02
...
...
@@ -88,6 +88,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that are smaller by the given edge dimensions
BoxConstraints
deflate
(
EdgeDims
edges
)
{
assert
(
edges
!=
null
);
assert
(
isNormalized
);
double
horizontal
=
edges
.
left
+
edges
.
right
;
double
vertical
=
edges
.
top
+
edges
.
bottom
;
double
deflatedMinWidth
=
math
.
max
(
0.0
,
minWidth
-
horizontal
);
...
...
@@ -102,6 +103,7 @@ class BoxConstraints extends Constraints {
/// Returns new box constraints that remove the minimum width and height requirements
BoxConstraints
loosen
()
{
assert
(
isNormalized
);
return
new
BoxConstraints
(
minWidth:
0.0
,
maxWidth:
maxWidth
,
...
...
@@ -144,19 +146,24 @@ class BoxConstraints extends Constraints {
/// Returns the width that both satisfies the constraints and is as close as possible to the given width
double
constrainWidth
([
double
width
=
double
.
INFINITY
])
{
assert
(
isNormalized
);
return
clamp
(
min:
minWidth
,
max:
maxWidth
,
value:
width
);
}
/// Returns the height that both satisfies the constraints and is as close as possible to the given height
double
constrainHeight
([
double
height
=
double
.
INFINITY
])
{
assert
(
isNormalized
);
return
clamp
(
min:
minHeight
,
max:
maxHeight
,
value:
height
);
}
/// Returns the size that both satisfies the constraints and is as close as possible to the given size
Size
constrain
(
Size
size
)
{
Size
result
=
new
Size
(
constrainWidth
(
size
.
width
),
constrainHeight
(
size
.
height
));
if
(
size
is
_DebugSize
)
result
=
new
_DebugSize
(
result
,
size
.
_owner
,
size
.
_canBeUsedByParent
);
assert
(()
{
if
(
size
is
_DebugSize
)
result
=
new
_DebugSize
(
result
,
size
.
_owner
,
size
.
_canBeUsedByParent
);
return
true
;
});
return
result
;
}
...
...
@@ -177,8 +184,9 @@ class BoxConstraints extends Constraints {
/// Whether the given size satisfies the constraints
bool
isSatisfiedBy
(
Size
size
)
{
return
(
minWidth
<=
size
.
width
)
&&
(
size
.
width
<=
math
.
max
(
minWidth
,
maxWidth
))
&&
(
minHeight
<=
size
.
height
)
&&
(
size
.
height
<=
math
.
max
(
minHeight
,
maxHeight
));
assert
(
isNormalized
);
return
(
minWidth
<=
size
.
width
)
&&
(
size
.
width
<=
maxWidth
)
&&
(
minHeight
<=
size
.
height
)
&&
(
size
.
height
<=
maxHeight
);
}
BoxConstraints
operator
*(
double
other
)
{
...
...
@@ -227,6 +235,8 @@ class BoxConstraints extends Constraints {
return
b
*
t
;
if
(
b
==
null
)
return
a
*
(
1.0
-
t
);
assert
(
a
.
isNormalized
);
assert
(
b
.
isNormalized
);
return
new
BoxConstraints
(
minWidth:
ui
.
lerpDouble
(
a
.
minWidth
,
b
.
minWidth
,
t
),
maxWidth:
ui
.
lerpDouble
(
a
.
maxWidth
,
b
.
maxWidth
,
t
),
...
...
@@ -235,12 +245,25 @@ class BoxConstraints extends Constraints {
);
}
bool
get
isNormalized
=>
minWidth
<=
maxWidth
&&
minHeight
<=
maxHeight
;
BoxConstraints
normalize
()
{
return
new
BoxConstraints
(
minWidth:
minWidth
,
maxWidth:
minWidth
>
maxWidth
?
minWidth
:
maxWidth
,
minHeight:
minHeight
,
maxHeight:
minHeight
>
maxHeight
?
minHeight
:
maxHeight
);
}
bool
operator
==(
dynamic
other
)
{
assert
(
isNormalized
);
if
(
identical
(
this
,
other
))
return
true
;
if
(
other
is
!
BoxConstraints
)
return
false
;
final
BoxConstraints
typedOther
=
other
;
assert
(
typedOther
.
isNormalized
);
return
minWidth
==
typedOther
.
minWidth
&&
maxWidth
==
typedOther
.
maxWidth
&&
minHeight
==
typedOther
.
minHeight
&&
...
...
@@ -248,6 +271,7 @@ class BoxConstraints extends Constraints {
}
int
get
hashCode
{
assert
(
isNormalized
);
int
value
=
373
;
value
=
37
*
value
+
minWidth
.
hashCode
;
value
=
37
*
value
+
maxWidth
.
hashCode
;
...
...
@@ -257,11 +281,12 @@ class BoxConstraints extends Constraints {
}
String
toString
()
{
String
annotation
=
isNormalized
?
''
:
'; NOT NORMALIZED'
;
if
(
minWidth
==
double
.
INFINITY
&&
minHeight
==
double
.
INFINITY
)
return
'BoxConstraints(biggest)'
;
return
'BoxConstraints(biggest
$annotation
)'
;
if
(
minWidth
==
0
&&
maxWidth
==
double
.
INFINITY
&&
minHeight
==
0
&&
maxHeight
==
double
.
INFINITY
)
return
'BoxConstraints(unconstrained)'
;
return
'BoxConstraints(unconstrained
$annotation
)'
;
String
describe
(
double
min
,
double
max
,
String
dim
)
{
if
(
min
==
max
)
return
'
$dim
=
${min.toStringAsFixed(1)}
'
;
...
...
@@ -269,7 +294,7 @@ class BoxConstraints extends Constraints {
}
final
String
width
=
describe
(
minWidth
,
maxWidth
,
'w'
);
final
String
height
=
describe
(
minHeight
,
maxHeight
,
'h'
);
return
'BoxConstraints(
$width
,
$height
)'
;
return
'BoxConstraints(
$width
,
$height
$annotation
)'
;
}
}
...
...
@@ -334,6 +359,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
0.0
);
}
...
...
@@ -342,6 +368,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
0.0
);
}
...
...
@@ -350,6 +377,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainHeight
(
0.0
);
}
...
...
@@ -362,6 +390,7 @@ abstract class RenderBox extends RenderObject {
///
/// Override in subclasses that implement [performLayout].
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainHeight
(
0.0
);
}
...
...
packages/flutter/lib/src/rendering/custom_layout.dart
View file @
11da9b02
...
...
@@ -41,6 +41,7 @@ abstract class MultiChildLayoutDelegate {
'A MultiChildLayoutDelegate cannot layout the same child more than once.'
;
return
_debugChildrenNeedingLayout
.
remove
(
child
);
});
assert
(
constraints
.
isNormalized
);
child
.
layout
(
constraints
,
parentUsesSize:
true
);
return
child
.
size
;
}
...
...
@@ -130,6 +131,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
}
Size
_getSize
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrain
(
_delegate
.
getSize
(
constraints
));
}
...
...
packages/flutter/lib/src/rendering/editable_paragraph.dart
View file @
11da9b02
...
...
@@ -60,6 +60,7 @@ class RenderEditableParagraph extends RenderParagraph {
}
BoxConstraints
_getTextContraints
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
new
BoxConstraints
(
minWidth:
0.0
,
maxWidth:
double
.
INFINITY
,
...
...
packages/flutter/lib/src/rendering/flex.dart
View file @
11da9b02
...
...
@@ -148,6 +148,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
double
_getIntrinsicSize
({
BoxConstraints
constraints
,
FlexDirection
sizingDirection
,
_ChildSizingFunction
childSize
})
{
assert
(
constraints
.
isNormalized
);
// http://www.w3.org/TR/2015/WD-css-flexbox-1-20150514/#intrinsic-sizes
if
(
_direction
==
sizingDirection
)
{
// INTRINSIC MAIN SIZE
...
...
packages/flutter/lib/src/rendering/grid.dart
View file @
11da9b02
...
...
@@ -74,21 +74,25 @@ class RenderGrid extends RenderBox with ContainerRenderObjectMixin<RenderBox, Gr
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
// We can render at any width.
return
constraints
.
constrainWidth
(
0.0
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
maxWidth
=
childCount
*
_maxChildExtent
;
return
constraints
.
constrainWidth
(
maxWidth
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
desiredHeight
=
_computeMetrics
().
size
.
height
;
return
constraints
.
constrainHeight
(
desiredHeight
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
getMinIntrinsicHeight
(
constraints
);
}
...
...
packages/flutter/lib/src/rendering/image.dart
View file @
11da9b02
...
...
@@ -172,22 +172,26 @@ class RenderImage extends RenderBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
_width
==
null
&&
_height
==
null
)
return
constraints
.
constrainWidth
(
0.0
);
return
_sizeForConstraints
(
constraints
).
width
;
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_sizeForConstraints
(
constraints
).
width
;
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
_width
==
null
&&
_height
==
null
)
return
constraints
.
constrainHeight
(
0.0
);
return
_sizeForConstraints
(
constraints
).
height
;
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_sizeForConstraints
(
constraints
).
height
;
}
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
11da9b02
...
...
@@ -366,6 +366,9 @@ abstract class Constraints {
/// Whether there is exactly one size possible given these constraints
bool
get
isTight
;
/// Whether the constraint is expressed in a consistent manner.
bool
get
isNormalized
;
}
typedef
void
RenderObjectVisitor
(
RenderObject
child
);
...
...
@@ -657,6 +660,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
.
isNormalized
);
assert
(!
_debugDoingThisResize
);
assert
(!
_debugDoingThisLayout
);
final
RenderObject
parent
=
this
.
parent
;
...
...
packages/flutter/lib/src/rendering/overflow.dart
View file @
11da9b02
...
...
@@ -93,18 +93,22 @@ class RenderOverflowBox extends RenderBox with RenderObjectWithChildMixin<Render
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
();
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
();
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainHeight
();
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainHeight
();
}
...
...
@@ -165,18 +169,22 @@ class RenderSizedOverflowBox extends RenderBox with RenderObjectWithChildMixin<R
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
_requestedSize
.
width
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
_requestedSize
.
width
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
_requestedSize
.
height
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
constrainWidth
(
_requestedSize
.
height
);
}
...
...
packages/flutter/lib/src/rendering/paragraph.dart
View file @
11da9b02
...
...
@@ -49,6 +49,7 @@ class RenderParagraph extends RenderBox {
void
layoutText
(
BoxConstraints
constraints
)
{
assert
(
constraints
!=
null
);
assert
(
constraints
.
isNormalized
);
if
(
_constraintsForCurrentLayout
==
constraints
)
return
;
// already cached this layout
textPainter
.
maxWidth
=
constraints
.
maxWidth
;
...
...
@@ -80,10 +81,12 @@ class RenderParagraph extends RenderBox {
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getIntrinsicHeight
(
constraints
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getIntrinsicHeight
(
constraints
);
}
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
11da9b02
...
...
@@ -38,24 +38,28 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
constraints
);
return
super
.
getMinIntrinsicWidth
(
constraints
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
constraints
);
return
super
.
getMaxIntrinsicWidth
(
constraints
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
constraints
);
return
super
.
getMinIntrinsicHeight
(
constraints
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
constraints
);
return
super
.
getMaxIntrinsicHeight
(
constraints
);
...
...
@@ -102,6 +106,7 @@ class RenderConstrainedBox extends RenderProxyBox {
BoxConstraints
additionalConstraints
})
:
_additionalConstraints
=
additionalConstraints
,
super
(
child
)
{
assert
(
additionalConstraints
!=
null
);
assert
(
additionalConstraints
.
isNormalized
);
}
/// Additional constraints to apply to [child] during layout
...
...
@@ -109,6 +114,7 @@ class RenderConstrainedBox extends RenderProxyBox {
BoxConstraints
_additionalConstraints
;
void
set
additionalConstraints
(
BoxConstraints
newConstraints
)
{
assert
(
newConstraints
!=
null
);
assert
(
newConstraints
.
isNormalized
);
if
(
_additionalConstraints
==
newConstraints
)
return
;
_additionalConstraints
=
newConstraints
;
...
...
@@ -116,24 +122,28 @@ class RenderConstrainedBox extends RenderProxyBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
_additionalConstraints
.
enforce
(
constraints
));
return
_additionalConstraints
.
enforce
(
constraints
).
constrainWidth
(
0.0
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
_additionalConstraints
.
enforce
(
constraints
));
return
_additionalConstraints
.
enforce
(
constraints
).
constrainWidth
(
0.0
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
_additionalConstraints
.
enforce
(
constraints
));
return
_additionalConstraints
.
enforce
(
constraints
).
constrainHeight
(
0.0
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
_additionalConstraints
.
enforce
(
constraints
));
return
_additionalConstraints
.
enforce
(
constraints
).
constrainHeight
(
0.0
);
...
...
@@ -221,24 +231,28 @@ class RenderFractionallySizedBox extends RenderProxyBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainWidth
(
0.0
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
_getInnerConstraints
(
constraints
).
constrainHeight
(
0.0
);
...
...
@@ -307,6 +321,7 @@ class RenderAspectRatio extends RenderProxyBox {
}
Size
_applyAspectRatio
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
width
=
constraints
.
constrainWidth
();
double
height
=
constraints
.
constrainHeight
(
width
/
_aspectRatio
);
return
new
Size
(
width
,
height
);
...
...
@@ -385,10 +400,12 @@ class RenderIntrinsicWidth extends RenderProxyBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
getMaxIntrinsicWidth
(
constraints
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainWidth
(
0.0
);
double
childResult
=
child
.
getMaxIntrinsicWidth
(
constraints
);
...
...
@@ -396,6 +413,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainHeight
(
0.0
);
double
childResult
=
child
.
getMinIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
...
...
@@ -403,6 +421,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainHeight
(
0.0
);
double
childResult
=
child
.
getMaxIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
...
...
@@ -451,22 +470,26 @@ class RenderIntrinsicHeight extends RenderProxyBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainWidth
(
0.0
);
return
child
.
getMinIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainWidth
(
0.0
);
return
child
.
getMaxIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
getMaxIntrinsicHeight
(
constraints
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
==
null
)
return
constraints
.
constrainHeight
(
0.0
);
return
child
.
getMaxIntrinsicHeight
(
constraints
);
...
...
packages/flutter/lib/src/rendering/shifted_box.dart
View file @
11da9b02
...
...
@@ -7,33 +7,36 @@ import 'package:flutter/painting.dart';
import
'box.dart'
;
import
'object.dart'
;
/// Abstract class for one-child-layout render boxes that provide control over
/// the child's position.
abstract
class
RenderShiftedBox
extends
RenderBox
with
RenderObjectWithChildMixin
<
RenderBox
>
{
// Abstract class for one-child-layout render boxes
RenderShiftedBox
(
RenderBox
child
)
{
this
.
child
=
child
;
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
constraints
);
return
super
.
getMinIntrinsicWidth
(
constraints
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
constraints
);
return
super
.
getMaxIntrinsicWidth
(
constraints
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
constraints
);
return
super
.
getMinIntrinsicHeight
(
constraints
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
constraints
);
return
super
.
getMaxIntrinsicHeight
(
constraints
);
...
...
@@ -100,6 +103,7 @@ class RenderPadding extends RenderShiftedBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
totalPadding
=
padding
.
left
+
padding
.
right
;
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
constraints
.
deflate
(
padding
))
+
totalPadding
;
...
...
@@ -107,6 +111,7 @@ class RenderPadding extends RenderShiftedBox {
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
totalPadding
=
padding
.
left
+
padding
.
right
;
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
constraints
.
deflate
(
padding
))
+
totalPadding
;
...
...
@@ -114,6 +119,7 @@ class RenderPadding extends RenderShiftedBox {
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
totalPadding
=
padding
.
top
+
padding
.
bottom
;
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
constraints
.
deflate
(
padding
))
+
totalPadding
;
...
...
@@ -121,6 +127,7 @@ class RenderPadding extends RenderShiftedBox {
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
totalPadding
=
padding
.
top
+
padding
.
bottom
;
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
constraints
.
deflate
(
padding
))
+
totalPadding
;
...
...
@@ -282,18 +289,22 @@ class RenderCustomOneChildLayoutBox extends RenderShiftedBox {
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getSize
(
constraints
).
width
;
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getSize
(
constraints
).
width
;
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getSize
(
constraints
).
height
;
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
_getSize
(
constraints
).
height
;
}
...
...
@@ -305,9 +316,11 @@ class RenderCustomOneChildLayoutBox extends RenderShiftedBox {
void
performLayout
()
{
if
(
child
!=
null
)
{
child
.
layout
(
delegate
.
getConstraintsForChild
(
constraints
),
parentUsesSize:
true
);
BoxConstraints
childConstraints
=
delegate
.
getConstraintsForChild
(
constraints
);
assert
(
childConstraints
.
isNormalized
);
child
.
layout
(
childConstraints
,
parentUsesSize:
!
childConstraints
.
isTight
);
final
BoxParentData
childParentData
=
child
.
parentData
;
childParentData
.
position
=
delegate
.
getPositionForChild
(
size
,
child
.
size
);
childParentData
.
position
=
delegate
.
getPositionForChild
(
size
,
child
Constraints
.
isTight
?
childConstraints
.
smallest
:
child
.
size
);
}
}
}
...
...
packages/flutter/lib/src/rendering/stack.dart
View file @
11da9b02
...
...
@@ -222,6 +222,7 @@ abstract class RenderStackBase extends RenderBox
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
width
=
constraints
.
minWidth
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
...
...
@@ -236,6 +237,7 @@ abstract class RenderStackBase extends RenderBox
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
bool
hasNonPositionedChildren
=
false
;
double
width
=
constraints
.
minWidth
;
RenderBox
child
=
firstChild
;
...
...
@@ -255,6 +257,7 @@ abstract class RenderStackBase extends RenderBox
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
double
height
=
constraints
.
minHeight
;
RenderBox
child
=
firstChild
;
while
(
child
!=
null
)
{
...
...
@@ -269,6 +272,7 @@ abstract class RenderStackBase extends RenderBox
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
bool
hasNonPositionedChildren
=
false
;
double
height
=
constraints
.
minHeight
;
RenderBox
child
=
firstChild
;
...
...
packages/flutter/lib/src/rendering/statistics_box.dart
View file @
11da9b02
...
...
@@ -34,18 +34,22 @@ class RenderStatisticsBox extends RenderBox {
bool
get
sizedByParent
=>
true
;
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
minWidth
;
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
maxWidth
;
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
minHeight
;
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
return
constraints
.
maxHeight
;
}
...
...
packages/flutter/lib/src/rendering/viewport.dart
View file @
11da9b02
...
...
@@ -98,24 +98,28 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
super
.
getMinIntrinsicWidth
(
constraints
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicWidth
(
_getInnerConstraints
(
constraints
));
return
super
.
getMaxIntrinsicWidth
(
constraints
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMinIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
super
.
getMinIntrinsicHeight
(
constraints
);
}
double
getMaxIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
if
(
child
!=
null
)
return
child
.
getMaxIntrinsicHeight
(
_getInnerConstraints
(
constraints
));
return
super
.
getMaxIntrinsicHeight
(
constraints
);
...
...
packages/unit/test/rendering/flex_test.dart
View file @
11da9b02
...
...
@@ -8,7 +8,7 @@ void main() {
RenderDecoratedBox
box
=
new
RenderDecoratedBox
(
decoration:
new
BoxDecoration
());
RenderFlex
flex
=
new
RenderFlex
(
children:
<
RenderBox
>[
box
]);
layout
(
flex
,
constraints:
const
BoxConstraints
(
minWidth:
200.0
,
maxWidth:
100.0
,
minHeight:
200.0
,
maxHeight:
1
00.0
)
minWidth:
200.0
,
maxWidth:
200.0
,
minHeight:
200.0
,
maxHeight:
2
00.0
)
);
expect
(
flex
.
size
.
width
,
equals
(
200.0
),
reason:
"flex width"
);
...
...
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