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

Side by Side Diff: sky/sdk/lib/framework/rendering/box.dart

Issue 1166523006: Make EdgeDims and BoxConstraints printable (for debugging) (Closed) Base URL: https://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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:typed_data'; 7 import 'dart:typed_data';
8 import 'node.dart'; 8 import 'node.dart';
9 import 'package:vector_math/vector_math.dart'; 9 import 'package:vector_math/vector_math.dart';
10 import 'package:sky/framework/net/image_cache.dart' as image_cache; 10 import 'package:sky/framework/net/image_cache.dart' as image_cache;
(...skipping 18 matching lines...) Expand all
29 29
30 final double top; 30 final double top;
31 final double right; 31 final double right;
32 final double bottom; 32 final double bottom;
33 final double left; 33 final double left;
34 34
35 operator ==(EdgeDims other) => (top == other.top) || 35 operator ==(EdgeDims other) => (top == other.top) ||
36 (right == other.right) || 36 (right == other.right) ||
37 (bottom == other.bottom) || 37 (bottom == other.bottom) ||
38 (left == other.left); 38 (left == other.left);
39
40 int get hashCode {
41 value = 373;
42 value = 37 * value + top.hashCode;
eseidel 2015/06/03 23:23:16 Why the magic number? And doesn't dart have a *=?
43 value = 37 * value + left.hashCode;
44 value = 37 * value + bottom.hashCode;
45 value = 37 * value + right.hashCode;
46 return value;
47 }
48 String toString() => "EdgeDims($top, $right, $bottom, $left)";
39 } 49 }
40 50
41 class BoxConstraints { 51 class BoxConstraints {
42 const BoxConstraints({ 52 const BoxConstraints({
43 this.minWidth: 0.0, 53 this.minWidth: 0.0,
44 this.maxWidth: double.INFINITY, 54 this.maxWidth: double.INFINITY,
45 this.minHeight: 0.0, 55 this.minHeight: 0.0,
46 this.maxHeight: double.INFINITY}); 56 this.maxHeight: double.INFINITY});
47 57
48 BoxConstraints.tight(sky.Size size) 58 BoxConstraints.tight(sky.Size size)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 90
81 double constrainHeight(double height) { 91 double constrainHeight(double height) {
82 return clamp(min: minHeight, max: maxHeight, value: height); 92 return clamp(min: minHeight, max: maxHeight, value: height);
83 } 93 }
84 94
85 sky.Size constrain(sky.Size size) { 95 sky.Size constrain(sky.Size size) {
86 return new sky.Size(constrainWidth(size.width), constrainHeight(size.height) ); 96 return new sky.Size(constrainWidth(size.width), constrainHeight(size.height) );
87 } 97 }
88 98
89 bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI NITY; 99 bool get isInfinite => maxWidth >= double.INFINITY || maxHeight >= double.INFI NITY;
100
101 int get hashCode {
102 value = 373;
103 value = 37 * value + minWidth.hashCode;
eseidel 2015/06/03 23:23:16 Maybe we want a hash() helper which can take N num
104 value = 37 * value + maxWidth.hashCode;
105 value = 37 * value + minHeight.hashCode;
106 value = 37 * value + maxHeight.hashCode;
107 return value;
108 }
109 String toString() => "BoxConstraints($minWidth<=w<$maxWidth, $minHeight<=h<$ma xHeight)";
90 } 110 }
91 111
92 class BoxParentData extends ParentData { 112 class BoxParentData extends ParentData {
93 sky.Point position = new sky.Point(0.0, 0.0); 113 sky.Point position = new sky.Point(0.0, 0.0);
94 } 114 }
95 115
96 abstract class RenderBox extends RenderNode { 116 abstract class RenderBox extends RenderNode {
97 117
98 void setParentData(RenderNode child) { 118 void setParentData(RenderNode child) {
99 if (child.parentData is! BoxParentData) 119 if (child.parentData is! BoxParentData)
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 558
539 void defaultPaint(RenderNodeDisplayList canvas) { 559 void defaultPaint(RenderNodeDisplayList canvas) {
540 RenderBox child = firstChild; 560 RenderBox child = firstChild;
541 while (child != null) { 561 while (child != null) {
542 assert(child.parentData is ParentDataType); 562 assert(child.parentData is ParentDataType);
543 canvas.paintChild(child, child.parentData.position); 563 canvas.paintChild(child, child.parentData.position);
544 child = child.parentData.nextSibling; 564 child = child.parentData.nextSibling;
545 } 565 }
546 } 566 }
547 } 567 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698