Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Unified Diff: sky/sdk/lib/rendering/object.dart

Issue 1195113002: Improve stocks2 performance (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/rendering/box.dart ('k') | sky/sdk/lib/rendering/paragraph.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/object.dart
diff --git a/sky/sdk/lib/rendering/object.dart b/sky/sdk/lib/rendering/object.dart
index 1a5a8b46638ebdde00c49d85da3f5cd7784aaed5..75edf32f4e3cf35634087c08f7a112f0563eeeff 100644
--- a/sky/sdk/lib/rendering/object.dart
+++ b/sky/sdk/lib/rendering/object.dart
@@ -131,14 +131,19 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
scheduler.ensureVisualUpdate();
}
static void flushLayout() {
+ sky.tracing.begin('RenderObject.flushLayout');
_debugDoingLayout = true;
- List<RenderObject> dirtyNodes = _nodesNeedingLayout;
- _nodesNeedingLayout = new List<RenderObject>();
- dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) {
- if (node._needsLayout && node.attached)
- node.layoutWithoutResize();
- });
- _debugDoingLayout = false;
+ try {
+ List<RenderObject> dirtyNodes = _nodesNeedingLayout;
+ _nodesNeedingLayout = new List<RenderObject>();
+ dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) {
+ if (node._needsLayout && node.attached)
+ node.layoutWithoutResize();
+ });
+ } finally {
+ _debugDoingLayout = false;
+ sky.tracing.end('RenderObject.flushLayout');
+ }
}
void layoutWithoutResize() {
try {
@@ -350,13 +355,7 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
ChildType _firstChild;
ChildType _lastChild;
- void add(ChildType child, { ChildType before }) {
- assert(child != this);
- assert(before != this);
- assert(child != before);
- assert(child != _firstChild);
- assert(child != _lastChild);
- adoptChild(child);
+ void _addToChildList(ChildType child, { ChildType before }) {
assert(child.parentData is ParentDataType);
assert(child.parentData.nextSibling == null);
assert(child.parentData.previousSibling == null);
@@ -396,7 +395,16 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
}
}
}
- void remove(ChildType child) {
+ void add(ChildType child, { ChildType before }) {
+ assert(child != this);
+ assert(before != this);
+ assert(child != before);
+ assert(child != _firstChild);
+ assert(child != _lastChild);
+ adoptChild(child);
+ _addToChildList(child, before: before);
+ }
+ void _removeFromChildList(ChildType child) {
assert(child.parentData is ParentDataType);
assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
@@ -416,8 +424,22 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
}
child.parentData.previousSibling = null;
child.parentData.nextSibling = null;
+ }
+ void remove(ChildType child) {
+ _removeFromChildList(child);
dropChild(child);
}
+ void move(ChildType child, { ChildType before }) {
+ assert(child != this);
+ assert(before != this);
+ assert(child != before);
+ assert(child.parent == this);
+ assert(child.parentData is ParentDataType);
+ if (child.parentData.nextSibling == before)
+ return;
+ _removeFromChildList(child);
+ _addToChildList(child, before: before);
+ }
void redepthChildren() {
ChildType child = _firstChild;
while (child != null) {
« no previous file with comments | « sky/sdk/lib/rendering/box.dart ('k') | sky/sdk/lib/rendering/paragraph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698