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

Side by Side Diff: sky/sdk/lib/rendering/paragraph.dart

Issue 1226113007: Add @override annotation to known overriden methods (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 | « sky/sdk/lib/rendering/object.dart ('k') | sky/sdk/lib/rendering/sky_binding.dart » ('j') | 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:sky' as sky; 5 import 'dart:sky' as sky;
6 6
7 import 'box.dart'; 7 import 'box.dart';
8 import 'object.dart'; 8 import 'object.dart';
9 import '../painting/text_style.dart'; 9 import '../painting/text_style.dart';
10 10
11 abstract class InlineBase { 11 abstract class InlineBase {
12 sky.Node _toDOM(sky.Document owner); 12 sky.Node _toDOM(sky.Document owner);
13 @override
13 String toString([String prefix = '']); 14 String toString([String prefix = '']);
14 } 15 }
15 16
16 class InlineText extends InlineBase { 17 class InlineText extends InlineBase {
17 InlineText(this.text) { 18 InlineText(this.text) {
18 assert(text != null); 19 assert(text != null);
19 } 20 }
20 21
21 final String text; 22 final String text;
22 23
24 @override
23 sky.Node _toDOM(sky.Document owner) { 25 sky.Node _toDOM(sky.Document owner) {
24 return owner.createText(text); 26 return owner.createText(text);
25 } 27 }
26 28
29 @override
27 bool operator ==(other) => other is InlineText && text == other.text; 30 bool operator ==(other) => other is InlineText && text == other.text;
31
32 @override
28 int get hashCode => text.hashCode; 33 int get hashCode => text.hashCode;
29 34
35 @override
30 String toString([String prefix = '']) => '${prefix}InlineText: "${text}"'; 36 String toString([String prefix = '']) => '${prefix}InlineText: "${text}"';
31 } 37 }
32 38
33 class InlineStyle extends InlineBase { 39 class InlineStyle extends InlineBase {
34 InlineStyle(this.style, this.children) { 40 InlineStyle(this.style, this.children) {
35 assert(style != null); 41 assert(style != null);
36 assert(children != null); 42 assert(children != null);
37 } 43 }
38 44
39 final TextStyle style; 45 final TextStyle style;
40 final List<InlineBase> children; 46 final List<InlineBase> children;
41 47
48 @override
42 sky.Node _toDOM(sky.Document owner) { 49 sky.Node _toDOM(sky.Document owner) {
43 sky.Element parent = owner.createElement('t'); 50 sky.Element parent = owner.createElement('t');
44 style.applyToCSSStyle(parent.style); 51 style.applyToCSSStyle(parent.style);
45 for (InlineBase child in children) { 52 for (InlineBase child in children) {
46 parent.appendChild(child._toDOM(owner)); 53 parent.appendChild(child._toDOM(owner));
47 } 54 }
48 return parent; 55 return parent;
49 } 56 }
50 57
58 @override
51 bool operator ==(other) { 59 bool operator ==(other) {
52 if (identical(this, other)) 60 if (identical(this, other))
53 return true; 61 return true;
54 if (other is! InlineStyle 62 if (other is! InlineStyle
55 || style != other.style 63 || style != other.style
56 || children.length != other.children.length) 64 || children.length != other.children.length)
57 return false; 65 return false;
58 for (int i = 0; i < children.length; ++i) { 66 for (int i = 0; i < children.length; ++i) {
59 if (children[i] != other.children[i]) 67 if (children[i] != other.children[i])
60 return false; 68 return false;
61 } 69 }
62 return true; 70 return true;
63 } 71 }
64 72
73 @override
65 int get hashCode { 74 int get hashCode {
66 int value = 373; 75 int value = 373;
67 value = 37 * value + style.hashCode; 76 value = 37 * value + style.hashCode;
68 for (InlineBase child in children) 77 for (InlineBase child in children)
69 value = 37 * value + child.hashCode; 78 value = 37 * value + child.hashCode;
70 return value; 79 return value;
71 } 80 }
72 81
82 @override
73 String toString([String prefix = '']) { 83 String toString([String prefix = '']) {
74 List<String> result = []; 84 List<String> result = [];
75 result.add('${prefix}InlineStyle:'); 85 result.add('${prefix}InlineStyle:');
76 var indent = '${prefix} '; 86 var indent = '${prefix} ';
77 result.add('${style.toString(indent)}'); 87 result.add('${style.toString(indent)}');
78 for (InlineBase child in children) { 88 for (InlineBase child in children) {
79 result.add(child.toString(indent)); 89 result.add(child.toString(indent));
80 } 90 }
81 return result.join('\n'); 91 return result.join('\n');
82 } 92 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (_constraintsForCurrentLayout == constraints) 131 if (_constraintsForCurrentLayout == constraints)
122 return; // already cached this layout 132 return; // already cached this layout
123 _layoutRoot.maxWidth = constraints.maxWidth; 133 _layoutRoot.maxWidth = constraints.maxWidth;
124 _layoutRoot.minWidth = constraints.minWidth; 134 _layoutRoot.minWidth = constraints.minWidth;
125 _layoutRoot.minHeight = constraints.minHeight; 135 _layoutRoot.minHeight = constraints.minHeight;
126 _layoutRoot.maxHeight = constraints.maxHeight; 136 _layoutRoot.maxHeight = constraints.maxHeight;
127 _layoutRoot.layout(); 137 _layoutRoot.layout();
128 _constraintsForCurrentLayout = constraints; 138 _constraintsForCurrentLayout = constraints;
129 } 139 }
130 140
141 @override
131 double getMinIntrinsicWidth(BoxConstraints constraints) { 142 double getMinIntrinsicWidth(BoxConstraints constraints) {
132 _layout(constraints); 143 _layout(constraints);
133 return constraints.constrainWidth( 144 return constraints.constrainWidth(
134 _applyFloatingPointHack(_layoutRoot.rootElement.minContentWidth)); 145 _applyFloatingPointHack(_layoutRoot.rootElement.minContentWidth));
135 } 146 }
136 147
148 @override
137 double getMaxIntrinsicWidth(BoxConstraints constraints) { 149 double getMaxIntrinsicWidth(BoxConstraints constraints) {
138 _layout(constraints); 150 _layout(constraints);
139 return constraints.constrainWidth( 151 return constraints.constrainWidth(
140 _applyFloatingPointHack(_layoutRoot.rootElement.maxContentWidth)); 152 _applyFloatingPointHack(_layoutRoot.rootElement.maxContentWidth));
141 } 153 }
142 154
143 double _getIntrinsicHeight(BoxConstraints constraints) { 155 double _getIntrinsicHeight(BoxConstraints constraints) {
144 _layout(constraints); 156 _layout(constraints);
145 return constraints.constrainHeight( 157 return constraints.constrainHeight(
146 _applyFloatingPointHack(_layoutRoot.rootElement.height)); 158 _applyFloatingPointHack(_layoutRoot.rootElement.height));
147 } 159 }
148 160
161 @override
149 double getMinIntrinsicHeight(BoxConstraints constraints) { 162 double getMinIntrinsicHeight(BoxConstraints constraints) {
150 return _getIntrinsicHeight(constraints); 163 return _getIntrinsicHeight(constraints);
151 } 164 }
152 165
166 @override
153 double getMaxIntrinsicHeight(BoxConstraints constraints) { 167 double getMaxIntrinsicHeight(BoxConstraints constraints) {
154 return _getIntrinsicHeight(constraints); 168 return _getIntrinsicHeight(constraints);
155 } 169 }
156 170
171 @override
157 double computeDistanceToActualBaseline(TextBaseline baseline) { 172 double computeDistanceToActualBaseline(TextBaseline baseline) {
158 assert(!needsLayout); 173 assert(!needsLayout);
159 _layout(constraints); 174 _layout(constraints);
160 sky.Element root = _layoutRoot.rootElement; 175 sky.Element root = _layoutRoot.rootElement;
161 switch (baseline) { 176 switch (baseline) {
162 case TextBaseline.alphabetic: return root.alphabeticBaseline; 177 case TextBaseline.alphabetic: return root.alphabeticBaseline;
163 case TextBaseline.ideographic: return root.ideographicBaseline; 178 case TextBaseline.ideographic: return root.ideographicBaseline;
164 } 179 }
165 } 180 }
166 181
182 @override
167 void performLayout() { 183 void performLayout() {
168 _layout(constraints); 184 _layout(constraints);
169 sky.Element root = _layoutRoot.rootElement; 185 sky.Element root = _layoutRoot.rootElement;
170 // rootElement.width always expands to fill, use maxContentWidth instead. 186 // rootElement.width always expands to fill, use maxContentWidth instead.
171 size = constraints.constrain(new Size(_applyFloatingPointHack(root.maxConten tWidth), 187 size = constraints.constrain(new Size(_applyFloatingPointHack(root.maxConten tWidth),
172 _applyFloatingPointHack(root.height))) ; 188 _applyFloatingPointHack(root.height))) ;
173 } 189 }
174 190
191 @override
175 void paint(PaintingCanvas canvas, Offset offset) { 192 void paint(PaintingCanvas canvas, Offset offset) {
176 // Ideally we could compute the min/max intrinsic width/height with a 193 // Ideally we could compute the min/max intrinsic width/height with a
177 // non-destructive operation. However, currently, computing these values 194 // non-destructive operation. However, currently, computing these values
178 // will destroy state inside the layout root. If that happens, we need to 195 // will destroy state inside the layout root. If that happens, we need to
179 // get back the correct state by calling _layout again. 196 // get back the correct state by calling _layout again.
180 // 197 //
181 // TODO(abarth): Make computing the min/max intrinsic width/height 198 // TODO(abarth): Make computing the min/max intrinsic width/height
182 // a non-destructive operation. 199 // a non-destructive operation.
183 // TODO(ianh): Make LayoutRoot support a paint offset so we don't 200 // TODO(ianh): Make LayoutRoot support a paint offset so we don't
184 // need to translate for each span of text. 201 // need to translate for each span of text.
185 _layout(constraints); 202 _layout(constraints);
186 canvas.translate(offset.dx, offset.dy); 203 canvas.translate(offset.dx, offset.dy);
187 _layoutRoot.paint(canvas); 204 _layoutRoot.paint(canvas);
188 canvas.translate(-offset.dx, -offset.dy); 205 canvas.translate(-offset.dx, -offset.dy);
189 } 206 }
190 207
191 // we should probably expose a way to do precise (inter-glpyh) hit testing 208 // we should probably expose a way to do precise (inter-glpyh) hit testing
192 209 @override
193 String debugDescribeSettings(String prefix) { 210 String debugDescribeSettings(String prefix) {
194 String result = '${super.debugDescribeSettings(prefix)}'; 211 String result = '${super.debugDescribeSettings(prefix)}';
195 result += '${prefix}inline:\n${inline.toString("$prefix ")}\n'; 212 result += '${prefix}inline:\n${inline.toString("$prefix ")}\n';
196 return result; 213 return result;
197 } 214 }
198 } 215 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/rendering/object.dart ('k') | sky/sdk/lib/rendering/sky_binding.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698