| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; | 7 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; |
| 8 | 8 |
| 9 import '../base/hit_test.dart'; | 9 import '../base/hit_test.dart'; |
| 10 import '../base/node.dart'; | 10 import '../base/node.dart'; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 assert(child != null); | 62 assert(child != null); |
| 63 setupParentData(child); | 63 setupParentData(child); |
| 64 super.adoptChild(child); | 64 super.adoptChild(child); |
| 65 markNeedsLayout(); | 65 markNeedsLayout(); |
| 66 } | 66 } |
| 67 void dropChild(RenderObject child) { // only for use by subclasses | 67 void dropChild(RenderObject child) { // only for use by subclasses |
| 68 assert(!debugDoingLayout); | 68 assert(!debugDoingLayout); |
| 69 assert(!debugDoingPaint); | 69 assert(!debugDoingPaint); |
| 70 assert(child != null); | 70 assert(child != null); |
| 71 assert(child.parentData != null); | 71 assert(child.parentData != null); |
| 72 child._cleanRelayoutSubtreeRoot(); |
| 72 child.parentData.detach(); | 73 child.parentData.detach(); |
| 73 child._cleanRelayoutSubtreeRoot(); | |
| 74 super.dropChild(child); | 74 super.dropChild(child); |
| 75 markNeedsLayout(); | 75 markNeedsLayout(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 static List<RenderObject> _nodesNeedingLayout = new List<RenderObject>(); | 78 static List<RenderObject> _nodesNeedingLayout = new List<RenderObject>(); |
| 79 static bool _debugDoingLayout = false; | 79 static bool _debugDoingLayout = false; |
| 80 static bool get debugDoingLayout => _debugDoingLayout; | 80 static bool get debugDoingLayout => _debugDoingLayout; |
| 81 bool _debugDoingThisResize = false; | 81 bool _debugDoingThisResize = false; |
| 82 bool get debugDoingThisResize => _debugDoingThisResize; | 82 bool get debugDoingThisResize => _debugDoingThisResize; |
| 83 bool _debugDoingThisLayout = false; | 83 bool _debugDoingThisLayout = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 _needsLayout = true; | 116 _needsLayout = true; |
| 117 assert(_relayoutSubtreeRoot != null); | 117 assert(_relayoutSubtreeRoot != null); |
| 118 if (_relayoutSubtreeRoot != this) { | 118 if (_relayoutSubtreeRoot != this) { |
| 119 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i
s cleverer | 119 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i
s cleverer |
| 120 assert(parent is RenderObject); | 120 assert(parent is RenderObject); |
| 121 parent.markNeedsLayout(); | 121 parent.markNeedsLayout(); |
| 122 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze
r is cleverer | 122 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze
r is cleverer |
| 123 } else { | 123 } else { |
| 124 _nodesNeedingLayout.add(this); | 124 _nodesNeedingLayout.add(this); |
| 125 scheduler.ensureVisualUpdate(); | |
| 126 } | 125 } |
| 127 } | 126 } |
| 128 void _cleanRelayoutSubtreeRoot() { | 127 void _cleanRelayoutSubtreeRoot() { |
| 129 if (_relayoutSubtreeRoot != this) { | 128 if (_relayoutSubtreeRoot != this) { |
| 130 _relayoutSubtreeRoot = null; | 129 _relayoutSubtreeRoot = null; |
| 131 _needsLayout = true; | 130 _needsLayout = true; |
| 132 _cleanRelayoutSubtreeRootChildren(); | 131 _cleanRelayoutSubtreeRootChildren(); |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 void _cleanRelayoutSubtreeRootChildren() { } // workaround for lack of inter-c
lass mixins in Dart | 134 void _cleanRelayoutSubtreeRootChildren() { } // workaround for lack of inter-c
lass mixins in Dart |
| (...skipping 25 matching lines...) Expand all Loading... |
| 161 assert(_relayoutSubtreeRoot == this); | 160 assert(_relayoutSubtreeRoot == this); |
| 162 _debugCanParentUseSize = false; | 161 _debugCanParentUseSize = false; |
| 163 _debugDoingThisLayout = true; | 162 _debugDoingThisLayout = true; |
| 164 RenderObject debugPreviousActiveLayout = _debugActiveLayout; | 163 RenderObject debugPreviousActiveLayout = _debugActiveLayout; |
| 165 _debugActiveLayout = this; | 164 _debugActiveLayout = this; |
| 166 performLayout(); | 165 performLayout(); |
| 167 _debugActiveLayout = debugPreviousActiveLayout; | 166 _debugActiveLayout = debugPreviousActiveLayout; |
| 168 _debugDoingThisLayout = false; | 167 _debugDoingThisLayout = false; |
| 169 _debugCanParentUseSize = null; | 168 _debugCanParentUseSize = null; |
| 170 } catch (e, stack) { | 169 } catch (e, stack) { |
| 171 print('Exception raised during layout of ${this}: ${e}'); | 170 print('Exception raised during layout:\n${e}\nContext:\n${this}'); |
| 172 print(stack); | 171 print(stack); |
| 173 return; | 172 return; |
| 174 } | 173 } |
| 175 _needsLayout = false; | 174 _needsLayout = false; |
| 175 markNeedsPaint(); |
| 176 } | 176 } |
| 177 void layout(Constraints constraints, { bool parentUsesSize: false }) { | 177 void layout(Constraints constraints, { bool parentUsesSize: false }) { |
| 178 final parent = this.parent; // TODO(ianh): Remove this once the analyzer is
cleverer | 178 final parent = this.parent; // TODO(ianh): Remove this once the analyzer is
cleverer |
| 179 RenderObject relayoutSubtreeRoot; | 179 RenderObject relayoutSubtreeRoot; |
| 180 if (!parentUsesSize || sizedByParent || constraints.isTight || parent is! Re
nderObject) | 180 if (!parentUsesSize || sizedByParent || constraints.isTight || parent is! Re
nderObject) |
| 181 relayoutSubtreeRoot = this; | 181 relayoutSubtreeRoot = this; |
| 182 else | 182 else |
| 183 relayoutSubtreeRoot = parent._relayoutSubtreeRoot; | 183 relayoutSubtreeRoot = parent._relayoutSubtreeRoot; |
| 184 assert(parent == this.parent); // TODO(ianh): Remove this once the analyzer
is cleverer | 184 assert(parent == this.parent); // TODO(ianh): Remove this once the analyzer
is cleverer |
| 185 if (!needsLayout && constraints == _constraints && relayoutSubtreeRoot == _r
elayoutSubtreeRoot) | 185 if (!needsLayout && constraints == _constraints && relayoutSubtreeRoot == _r
elayoutSubtreeRoot) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 210 // Override this to perform relayout without your parent's | 210 // Override this to perform relayout without your parent's |
| 211 // involvement. | 211 // involvement. |
| 212 // | 212 // |
| 213 // This is called during layout. If sizedByParent is true, then | 213 // This is called during layout. If sizedByParent is true, then |
| 214 // performLayout() should not change your dimensions, only do that | 214 // performLayout() should not change your dimensions, only do that |
| 215 // in performResize(). If sizedByParent is false, then set both | 215 // in performResize(). If sizedByParent is false, then set both |
| 216 // your dimensions and do your children's layout here. | 216 // your dimensions and do your children's layout here. |
| 217 // | 217 // |
| 218 // When calling layout() on your children, pass in | 218 // When calling layout() on your children, pass in |
| 219 // "parentUsesSize: true" if your size or layout is dependent on | 219 // "parentUsesSize: true" if your size or layout is dependent on |
| 220 // your child's size. | 220 // your child's size or intrinsic dimensions. |
| 221 | 221 |
| 222 // when the parent has rotated (e.g. when the screen has been turned | 222 // when the parent has rotated (e.g. when the screen has been turned |
| 223 // 90 degrees), immediately prior to layout() being called for the | 223 // 90 degrees), immediately prior to layout() being called for the |
| 224 // new dimensions, rotate() is called with the old and new angles. | 224 // new dimensions, rotate() is called with the old and new angles. |
| 225 // The next time paint() is called, the coordinate space will have | 225 // The next time paint() is called, the coordinate space will have |
| 226 // been rotated N quarter-turns clockwise, where: | 226 // been rotated N quarter-turns clockwise, where: |
| 227 // N = newAngle-oldAngle | 227 // N = newAngle-oldAngle |
| 228 // ...but the rendering is expected to remain the same, pixel for | 228 // ...but the rendering is expected to remain the same, pixel for |
| 229 // pixel, on the output device. Then, the layout() method or | 229 // pixel, on the output device. Then, the layout() method or |
| 230 // equivalent will be invoked. | 230 // equivalent will be invoked. |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 int count = 1; | 529 int count = 1; |
| 530 ChildType child = _firstChild; | 530 ChildType child = _firstChild; |
| 531 while (child != null) { | 531 while (child != null) { |
| 532 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 532 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
| 533 count += 1; | 533 count += 1; |
| 534 child = child.parentData.nextSibling; | 534 child = child.parentData.nextSibling; |
| 535 } | 535 } |
| 536 return result; | 536 return result; |
| 537 } | 537 } |
| 538 } | 538 } |
| OLD | NEW |