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
91a72d9f
Commit
91a72d9f
authored
Aug 27, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #879 from Hixie/RenderBlockViewport
Abstract out syncChildren().
parents
e51525cf
e6f34f86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
131 deletions
+135
-131
block.dart
packages/flutter/lib/rendering/block.dart
+2
-1
framework.dart
packages/flutter/lib/widgets/framework.dart
+133
-130
No files found.
packages/flutter/lib/rendering/block.dart
View file @
91a72d9f
...
...
@@ -272,7 +272,8 @@ class RenderBlockViewport extends RenderBlockBase {
result
=
intrinsicCallback
(
constraints
);
if
(
result
==
null
)
result
=
constrainer
(
0.0
);
assert
(
constrainer
(
result
)
==
result
);
else
result
=
constrainer
(
result
);
}
finally
{
_inCallback
=
false
;
}
...
...
packages/flutter/lib/widgets/framework.dart
View file @
91a72d9f
...
...
@@ -979,6 +979,7 @@ abstract class RenderObjectWrapper extends Widget {
}
void
syncRenderObject
(
RenderObjectWrapper
old
)
{
assert
(
old
==
null
||
old
.
renderObject
==
renderObject
);
ParentData
parentData
=
null
;
Widget
ancestor
=
parent
;
while
(
ancestor
!=
null
&&
ancestor
is
!
RenderObjectWrapper
)
{
...
...
@@ -998,134 +999,8 @@ abstract class RenderObjectWrapper extends Widget {
}
}
void
dependenciesChanged
()
{
// called by Inherited.sync()
syncRenderObject
(
this
);
}
void
remove
()
{
assert
(
renderObject
!=
null
);
_nodeMap
.
remove
(
renderObject
);
super
.
remove
();
}
void
detachRenderObject
()
{
assert
(
_ancestor
!=
null
);
assert
(
renderObject
!=
null
);
_ancestor
.
detachChildRenderObject
(
this
);
}
}
abstract
class
LeafRenderObjectWrapper
extends
RenderObjectWrapper
{
LeafRenderObjectWrapper
({
Key
key
})
:
super
(
key:
key
);
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
dynamic
slot
)
{
assert
(
false
);
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
assert
(
false
);
}
}
abstract
class
OneChildRenderObjectWrapper
extends
RenderObjectWrapper
{
OneChildRenderObjectWrapper
({
Key
key
,
Widget
child
})
:
_child
=
child
,
super
(
key:
key
);
Widget
_child
;
Widget
get
child
=>
_child
;
void
walkChildren
(
WidgetTreeWalker
walker
)
{
if
(
child
!=
null
)
walker
(
child
);
}
void
syncRenderObject
(
RenderObjectWrapper
old
)
{
super
.
syncRenderObject
(
old
);
Widget
oldChild
=
old
==
null
?
null
:
(
old
as
OneChildRenderObjectWrapper
).
child
;
Widget
newChild
=
child
;
_child
=
syncChild
(
newChild
,
oldChild
,
null
);
assert
((
newChild
==
null
&&
child
==
null
)
||
(
newChild
!=
null
&&
child
.
parent
==
this
));
assert
(
oldChild
==
null
||
child
==
oldChild
||
oldChild
.
parent
==
null
);
}
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
dynamic
slot
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
RenderObjectWithChildMixin
);
assert
(
slot
==
null
);
renderObject
.
child
=
child
.
renderObject
;
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
RenderObjectWithChildMixin
);
assert
(
renderObject
.
child
==
child
.
renderObject
);
renderObject
.
child
=
null
;
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
}
abstract
class
MultiChildRenderObjectWrapper
extends
RenderObjectWrapper
{
// In MultiChildRenderObjectWrapper subclasses, slots are the Widget
// nodes whose RenderObjects are to be used as the "insert before"
// sibling in ContainerRenderObjectMixin.add() calls
MultiChildRenderObjectWrapper
({
Key
key
,
List
<
Widget
>
children
})
:
this
.
children
=
children
==
null
?
const
[]
:
children
,
super
(
key:
key
)
{
assert
(!
_debugHasDuplicateIds
());
}
final
List
<
Widget
>
children
;
void
walkChildren
(
WidgetTreeWalker
walker
)
{
for
(
Widget
child
in
children
)
walker
(
child
);
}
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
Widget
slot
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
RenderObject
nextSibling
=
slot
!=
null
?
slot
.
renderObject
:
null
;
assert
(
nextSibling
==
null
||
nextSibling
is
RenderObject
);
assert
(
renderObject
is
ContainerRenderObjectMixin
);
renderObject
.
add
(
child
.
renderObject
,
before:
nextSibling
);
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
ContainerRenderObjectMixin
);
assert
(
child
.
renderObject
.
parent
==
renderObject
);
renderObject
.
remove
(
child
.
renderObject
);
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
bool
_debugHasDuplicateIds
()
{
var
idSet
=
new
HashSet
<
Key
>();
for
(
var
child
in
children
)
{
assert
(
child
!=
null
);
if
(
child
.
key
==
null
)
continue
;
// when these nodes are reordered, we just reassign the data
if
(!
idSet
.
add
(
child
.
key
))
{
throw
'''If multiple keyed nodes exist as children of another node, they must have unique keys.
$this
has duplicate child key "
${child.key}
".'''
;
}
}
return
false
;
}
void
syncRenderObject
(
MultiChildRenderObjectWrapper
old
)
{
super
.
syncRenderObject
(
old
);
final
ContainerRenderObjectMixin
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
ContainerRenderObjectMixin
);
assert
(
old
==
null
||
old
.
renderObject
==
renderObject
);
// for use by subclasses that manage their children using lists
void
syncChildren
(
List
<
Widget
>
newChildren
,
List
<
Widget
>
oldChildren
)
{
// This attempts to diff the new child list (this.children) with
// the old child list (old.children), and update our renderObject
...
...
@@ -1158,8 +1033,9 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
// 6. Sync null with any items in the list of keys that are still
// mounted.
final
List
<
Widget
>
newChildren
=
children
;
final
List
<
Widget
>
oldChildren
=
old
==
null
?
const
<
Widget
>[]
:
old
.
children
;
final
ContainerRenderObjectMixin
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
ContainerRenderObjectMixin
);
int
childrenTop
=
0
;
int
newChildrenBottom
=
newChildren
.
length
-
1
;
int
oldChildrenBottom
=
oldChildren
.
length
-
1
;
...
...
@@ -1260,6 +1136,133 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
void
dependenciesChanged
()
{
// called by Inherited.sync()
syncRenderObject
(
this
);
}
void
remove
()
{
assert
(
renderObject
!=
null
);
_nodeMap
.
remove
(
renderObject
);
super
.
remove
();
}
void
detachRenderObject
()
{
assert
(
_ancestor
!=
null
);
assert
(
renderObject
!=
null
);
_ancestor
.
detachChildRenderObject
(
this
);
}
}
abstract
class
LeafRenderObjectWrapper
extends
RenderObjectWrapper
{
LeafRenderObjectWrapper
({
Key
key
})
:
super
(
key:
key
);
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
dynamic
slot
)
{
assert
(
false
);
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
assert
(
false
);
}
}
abstract
class
OneChildRenderObjectWrapper
extends
RenderObjectWrapper
{
OneChildRenderObjectWrapper
({
Key
key
,
Widget
child
})
:
_child
=
child
,
super
(
key:
key
);
Widget
_child
;
Widget
get
child
=>
_child
;
void
walkChildren
(
WidgetTreeWalker
walker
)
{
if
(
child
!=
null
)
walker
(
child
);
}
void
syncRenderObject
(
RenderObjectWrapper
old
)
{
super
.
syncRenderObject
(
old
);
Widget
oldChild
=
old
==
null
?
null
:
(
old
as
OneChildRenderObjectWrapper
).
child
;
Widget
newChild
=
child
;
_child
=
syncChild
(
newChild
,
oldChild
,
null
);
assert
((
newChild
==
null
&&
child
==
null
)
||
(
newChild
!=
null
&&
child
.
parent
==
this
));
assert
(
oldChild
==
null
||
child
==
oldChild
||
oldChild
.
parent
==
null
);
}
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
dynamic
slot
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
RenderObjectWithChildMixin
);
assert
(
slot
==
null
);
renderObject
.
child
=
child
.
renderObject
;
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
RenderObjectWithChildMixin
);
assert
(
renderObject
.
child
==
child
.
renderObject
);
renderObject
.
child
=
null
;
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
}
abstract
class
MultiChildRenderObjectWrapper
extends
RenderObjectWrapper
{
// In MultiChildRenderObjectWrapper subclasses, slots are the Widget
// nodes whose RenderObjects are to be used as the "insert before"
// sibling in ContainerRenderObjectMixin.add() calls
MultiChildRenderObjectWrapper
({
Key
key
,
List
<
Widget
>
children
})
:
this
.
children
=
children
==
null
?
const
[]
:
children
,
super
(
key:
key
)
{
assert
(!
_debugHasDuplicateIds
());
}
final
List
<
Widget
>
children
;
void
walkChildren
(
WidgetTreeWalker
walker
)
{
for
(
Widget
child
in
children
)
walker
(
child
);
}
void
insertChildRenderObject
(
RenderObjectWrapper
child
,
Widget
slot
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
RenderObject
nextSibling
=
slot
!=
null
?
slot
.
renderObject
:
null
;
assert
(
nextSibling
==
null
||
nextSibling
is
RenderObject
);
assert
(
renderObject
is
ContainerRenderObjectMixin
);
renderObject
.
add
(
child
.
renderObject
,
before:
nextSibling
);
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
void
detachChildRenderObject
(
RenderObjectWrapper
child
)
{
final
renderObject
=
this
.
renderObject
;
// TODO(ianh): Remove this once the analyzer is cleverer
assert
(
renderObject
is
ContainerRenderObjectMixin
);
assert
(
child
.
renderObject
.
parent
==
renderObject
);
renderObject
.
remove
(
child
.
renderObject
);
assert
(
renderObject
==
this
.
renderObject
);
// TODO(ianh): Remove this once the analyzer is cleverer
}
bool
_debugHasDuplicateIds
()
{
var
idSet
=
new
HashSet
<
Key
>();
for
(
var
child
in
children
)
{
assert
(
child
!=
null
);
if
(
child
.
key
==
null
)
continue
;
// when these nodes are reordered, we just reassign the data
if
(!
idSet
.
add
(
child
.
key
))
{
throw
'''If multiple keyed nodes exist as children of another node, they must have unique keys.
$this
has duplicate child key "
${child.key}
".'''
;
}
}
return
false
;
}
void
syncRenderObject
(
MultiChildRenderObjectWrapper
old
)
{
super
.
syncRenderObject
(
old
);
syncChildren
(
children
,
old
==
null
?
const
<
Widget
>[]
:
old
.
children
);
}
}
class
WidgetSkyBinding
extends
SkyBinding
{
...
...
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