| 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'; |
| 11 import '../base/scheduler.dart' as scheduler; | 11 import '../base/scheduler.dart' as scheduler; |
| 12 | 12 |
| 13 export 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; | 13 export 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; |
| 14 export '../base/hit_test.dart' show HitTestTarget, HitTestEntry, HitTestResult; | 14 export '../base/hit_test.dart' show HitTestTarget, HitTestEntry, HitTestResult; |
| 15 | 15 |
| 16 | 16 |
| 17 class ParentData { | 17 class ParentData { |
| 18 void detach() { | 18 void detach() { |
| 19 detachSiblings(); | 19 detachSiblings(); |
| 20 } | 20 } |
| 21 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart | 21 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart |
| 22 void merge(ParentData other) { | 22 void merge(ParentData other) { |
| 23 // override this in subclasses to merge in data from other into this | 23 // override this in subclasses to merge in data from other into this |
| 24 assert(other.runtimeType == this.runtimeType); | 24 assert(other.runtimeType == this.runtimeType); |
| 25 } | 25 } |
| 26 @override |
| 26 String toString() => '<none>'; | 27 String toString() => '<none>'; |
| 27 } | 28 } |
| 28 | 29 |
| 29 class PaintingCanvas extends sky.Canvas { | 30 class PaintingCanvas extends sky.Canvas { |
| 30 PaintingCanvas(sky.PictureRecorder recorder, Rect bounds) : super(recorder, bo
unds); | 31 PaintingCanvas(sky.PictureRecorder recorder, Rect bounds) : super(recorder, bo
unds); |
| 31 | 32 |
| 32 List<RenderObject> _descendentsWithPaintingCanvases = new List<RenderObject>()
; // used by RenderObject._updatePaintingCanvas() to find out which RenderObject
s to ask to paint | 33 List<RenderObject> _descendentsWithPaintingCanvases = new List<RenderObject>()
; // used by RenderObject._updatePaintingCanvas() to find out which RenderObject
s to ask to paint |
| 33 void paintChild(RenderObject child, Point point) { | 34 void paintChild(RenderObject child, Point point) { |
| 34 if (child.createNewDisplayList) { | 35 if (child.createNewDisplayList) { |
| 35 assert(!_descendentsWithPaintingCanvases.contains(child)); | 36 assert(!_descendentsWithPaintingCanvases.contains(child)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 // node out, and any other nodes who happen to know exactly what | 57 // node out, and any other nodes who happen to know exactly what |
| 57 // kind of node that is. | 58 // kind of node that is. |
| 58 dynamic parentData; // TODO(ianh): change the type of this back to ParentData
once the analyzer is cleverer | 59 dynamic parentData; // TODO(ianh): change the type of this back to ParentData
once the analyzer is cleverer |
| 59 void setupParentData(RenderObject child) { | 60 void setupParentData(RenderObject child) { |
| 60 // override this to setup .parentData correctly for your class | 61 // override this to setup .parentData correctly for your class |
| 61 assert(debugCanPerformMutations); | 62 assert(debugCanPerformMutations); |
| 62 if (child.parentData is! ParentData) | 63 if (child.parentData is! ParentData) |
| 63 child.parentData = new ParentData(); | 64 child.parentData = new ParentData(); |
| 64 } | 65 } |
| 65 | 66 |
| 67 @override |
| 66 void adoptChild(RenderObject child) { // only for use by subclasses | 68 void adoptChild(RenderObject child) { // only for use by subclasses |
| 67 // call this whenever you decide a node is a child | 69 // call this whenever you decide a node is a child |
| 68 assert(debugCanPerformMutations); | 70 assert(debugCanPerformMutations); |
| 69 assert(child != null); | 71 assert(child != null); |
| 70 setupParentData(child); | 72 setupParentData(child); |
| 71 super.adoptChild(child); | 73 super.adoptChild(child); |
| 72 markNeedsLayout(); | 74 markNeedsLayout(); |
| 73 } | 75 } |
| 76 |
| 77 @override |
| 74 void dropChild(RenderObject child) { // only for use by subclasses | 78 void dropChild(RenderObject child) { // only for use by subclasses |
| 75 assert(debugCanPerformMutations); | 79 assert(debugCanPerformMutations); |
| 76 assert(child != null); | 80 assert(child != null); |
| 77 assert(child.parentData != null); | 81 assert(child.parentData != null); |
| 78 child._cleanRelayoutSubtreeRoot(); | 82 child._cleanRelayoutSubtreeRoot(); |
| 79 child.parentData.detach(); | 83 child.parentData.detach(); |
| 80 super.dropChild(child); | 84 super.dropChild(child); |
| 81 markNeedsLayout(); | 85 markNeedsLayout(); |
| 82 } | 86 } |
| 83 | 87 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // // Otherwise: | 408 // // Otherwise: |
| 405 // // For each child that intersects x,y, in z-order starting from the top, | 409 // // For each child that intersects x,y, in z-order starting from the top, |
| 406 // // call hitTest() for that child, passing it /result/, and the coordinate
s | 410 // // call hitTest() for that child, passing it /result/, and the coordinate
s |
| 407 // // converted to the child's coordinate origin, and stop at the first chil
d | 411 // // converted to the child's coordinate origin, and stop at the first chil
d |
| 408 // // that returns true. | 412 // // that returns true. |
| 409 // // Then, add yourself to /result/, and return true. | 413 // // Then, add yourself to /result/, and return true. |
| 410 // } | 414 // } |
| 411 // You must not add yourself to /result/ if you return false. | 415 // You must not add yourself to /result/ if you return false. |
| 412 | 416 |
| 413 | 417 |
| 418 @override |
| 414 String toString([String prefix = '']) { | 419 String toString([String prefix = '']) { |
| 415 RenderObject debugPreviousActiveLayout = _debugActiveLayout; | 420 RenderObject debugPreviousActiveLayout = _debugActiveLayout; |
| 416 _debugActiveLayout = null; | 421 _debugActiveLayout = null; |
| 417 String header = '${runtimeType}'; | 422 String header = '${runtimeType}'; |
| 418 if (_relayoutSubtreeRoot != null && _relayoutSubtreeRoot != this) { | 423 if (_relayoutSubtreeRoot != null && _relayoutSubtreeRoot != this) { |
| 419 int count = 1; | 424 int count = 1; |
| 420 RenderObject target = parent; | 425 RenderObject target = parent; |
| 421 while (target != null && target != _relayoutSubtreeRoot) { | 426 while (target != null && target != _relayoutSubtreeRoot) { |
| 422 target = target.parent as RenderObject; | 427 target = target.parent as RenderObject; |
| 423 count += 1; | 428 count += 1; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 int count = 1; | 685 int count = 1; |
| 681 ChildType child = _firstChild; | 686 ChildType child = _firstChild; |
| 682 while (child != null) { | 687 while (child != null) { |
| 683 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 688 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
| 684 count += 1; | 689 count += 1; |
| 685 child = child.parentData.nextSibling; | 690 child = child.parentData.nextSibling; |
| 686 } | 691 } |
| 687 return result; | 692 return result; |
| 688 } | 693 } |
| 689 } | 694 } |
| OLD | NEW |