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 'node.dart'; | 5 import 'node.dart'; |
6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
7 | 7 |
8 // ABSTRACT LAYOUT | 8 // ABSTRACT LAYOUT |
9 | 9 |
10 class ParentData { | 10 class ParentData { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 return true; | 94 return true; |
95 } | 95 } |
96 void markNeedsLayout() { | 96 void markNeedsLayout() { |
97 assert(!_debugDoingLayout); | 97 assert(!_debugDoingLayout); |
98 assert(!_debugDoingPaint); | 98 assert(!_debugDoingPaint); |
99 if (_needsLayout) { | 99 if (_needsLayout) { |
100 assert(debugAncestorsAlreadyMarkedNeedsLayout()); | 100 assert(debugAncestorsAlreadyMarkedNeedsLayout()); |
101 return; | 101 return; |
102 } | 102 } |
103 _needsLayout = true; | 103 _needsLayout = true; |
104 assert(parent is RenderNode); | 104 if (_relayoutSubtreeRoot != null) { |
105 if (_relayoutSubtreeRoot != null) | 105 assert(parent is RenderNode); |
106 parent.markNeedsLayout(); | 106 parent.markNeedsLayout(); |
107 else | 107 } else { |
108 _nodesNeedingLayout.add(this); | 108 _nodesNeedingLayout.add(this); |
| 109 } |
109 } | 110 } |
110 static void flushLayout() { | 111 static void flushLayout() { |
111 _debugDoingLayout = true; | 112 _debugDoingLayout = true; |
112 List<RenderNode> dirtyNodes = _nodesNeedingLayout; | 113 List<RenderNode> dirtyNodes = _nodesNeedingLayout; |
113 _nodesNeedingLayout = new List<RenderNode>(); | 114 _nodesNeedingLayout = new List<RenderNode>(); |
114 dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) { | 115 dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) { |
115 if (node._needsLayout && node.attached) | 116 if (node._needsLayout && node.attached) |
116 node._doLayout(); | 117 node._doLayout(); |
117 }); | 118 }); |
118 _debugDoingLayout = false; | 119 _debugDoingLayout = false; |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 }) { | 575 }) { |
575 if (newOrientation != orientation) { | 576 if (newOrientation != orientation) { |
576 if (orientation != null && root != null) | 577 if (orientation != null && root != null) |
577 root.rotate(oldAngle: orientation, newAngle: newOrientation, time: timeF
orRotation); | 578 root.rotate(oldAngle: orientation, newAngle: newOrientation, time: timeF
orRotation); |
578 _orientation = newOrientation; | 579 _orientation = newOrientation; |
579 } | 580 } |
580 if ((newWidth != width) || (newHeight != height)) { | 581 if ((newWidth != width) || (newHeight != height)) { |
581 _width = newWidth; | 582 _width = newWidth; |
582 _height = newHeight; | 583 _height = newHeight; |
583 relayout(); | 584 relayout(); |
| 585 } else { |
| 586 layoutDone(); |
584 } | 587 } |
585 } | 588 } |
586 | 589 |
587 void relayout() { | 590 void relayout() { |
588 if (root != null) { | 591 if (root != null) { |
589 root.layout(new BoxConstraints( | 592 root.layout(new BoxConstraints( |
590 minWidth: width, | 593 minWidth: width, |
591 maxWidth: width, | 594 maxWidth: width, |
592 minHeight: height, | 595 minHeight: height, |
593 maxHeight: height | 596 maxHeight: height |
594 )); | 597 )); |
595 assert(root.width == width); | 598 assert(root.width == width); |
596 assert(root.height == height); | 599 assert(root.height == height); |
597 } | 600 } |
| 601 layoutDone(); |
598 } | 602 } |
599 | 603 |
600 void rotate({ int oldAngle, int newAngle, Duration time }) { | 604 void rotate({ int oldAngle, int newAngle, Duration time }) { |
601 assert(false); // nobody tells the screen to rotate, the whole rotate() danc
e is started from our layout() | 605 assert(false); // nobody tells the screen to rotate, the whole rotate() danc
e is started from our layout() |
602 } | 606 } |
603 | 607 |
604 bool hitTest(HitTestResult result, { double x, double y }) { | 608 bool hitTest(HitTestResult result, { double x, double y }) { |
605 if (x < 0.0 || x >= width || y < 0.0 || y >= height) | 609 if (x < 0.0 || x >= width || y < 0.0 || y >= height) |
606 return false; | 610 return false; |
607 if (root != null) { | 611 if (root != null) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 893 |
890 void hitTestChildren(HitTestResult result, { double x, double y }) { | 894 void hitTestChildren(HitTestResult result, { double x, double y }) { |
891 defaultHitTestChildren(result, x: x, y: y); | 895 defaultHitTestChildren(result, x: x, y: y); |
892 } | 896 } |
893 | 897 |
894 void paint(RenderNodeDisplayList canvas) { | 898 void paint(RenderNodeDisplayList canvas) { |
895 super.paint(canvas); | 899 super.paint(canvas); |
896 defaultPaint(canvas); | 900 defaultPaint(canvas); |
897 } | 901 } |
898 } | 902 } |
OLD | NEW |