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

Side by Side Diff: sky/sdk/lib/widgets/block_viewport.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/widgets/basic.dart ('k') | sky/sdk/lib/widgets/button_base.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 '../rendering/block.dart'; 5 import '../rendering/block.dart';
6 import '../rendering/box.dart'; 6 import '../rendering/box.dart';
7 import '../rendering/object.dart'; 7 import '../rendering/object.dart';
8 import 'widget.dart'; 8 import 'widget.dart';
9 9
10 // return null if index is greater than index of last entry 10 // return null if index is greater than index of last entry
11 typedef Widget IndexedBuilder(int index); 11 typedef Widget IndexedBuilder(int index);
12 12
13 class _Key { 13 class _Key {
14 const _Key(this.type, this.key); 14 const _Key(this.type, this.key);
15 factory _Key.fromWidget(Widget widget) => new _Key(widget.runtimeType, widget. key); 15 factory _Key.fromWidget(Widget widget) => new _Key(widget.runtimeType, widget. key);
16 final Type type; 16 final Type type;
17 final String key; 17 final String key;
18
19 @override
18 bool operator ==(other) => other is _Key && other.type == type && other.key == key; 20 bool operator ==(other) => other is _Key && other.type == type && other.key == key;
21
22 @override
19 int get hashCode => 373 * 37 * type.hashCode + key.hashCode; 23 int get hashCode => 373 * 37 * type.hashCode + key.hashCode;
20 } 24 }
21 25
22 class BlockViewport extends RenderObjectWrapper { 26 class BlockViewport extends RenderObjectWrapper {
23 BlockViewport({ this.builder, this.startOffset, this.token, String key }) 27 BlockViewport({ this.builder, this.startOffset, this.token, String key })
24 : super(key: key); 28 : super(key: key);
25 29
26 IndexedBuilder builder; 30 IndexedBuilder builder;
27 double startOffset; 31 double startOffset;
28 Object token; 32 Object token;
29 33
34 @override
30 RenderBlockViewport get root => super.root; 35 RenderBlockViewport get root => super.root;
36
37 @override
31 RenderBlockViewport createNode() => new RenderBlockViewport(); 38 RenderBlockViewport createNode() => new RenderBlockViewport();
32 39
33 Map<_Key, Widget> _childrenByKey = new Map<_Key, Widget>(); 40 Map<_Key, Widget> _childrenByKey = new Map<_Key, Widget>();
34 41
35 void walkChildren(WidgetTreeWalker walker) { 42 void walkChildren(WidgetTreeWalker walker) {
36 for (Widget child in _childrenByKey.values) 43 for (Widget child in _childrenByKey.values)
37 walker(child); 44 walker(child);
38 } 45 }
39 46
40 static const _omit = const Object(); // used as a slot when it's not yet time to attach the child 47 static const _omit = const Object(); // used as a slot when it's not yet time to attach the child
41 48
49 @override
42 void insertChildRoot(RenderObjectWrapper child, dynamic slot) { 50 void insertChildRoot(RenderObjectWrapper child, dynamic slot) {
43 if (slot == _omit) 51 if (slot == _omit)
44 return; 52 return;
45 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 53 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
46 assert(slot == null || slot is RenderObject); 54 assert(slot == null || slot is RenderObject);
47 assert(root is ContainerRenderObjectMixin); 55 assert(root is ContainerRenderObjectMixin);
48 root.add(child.root, before: slot); 56 root.add(child.root, before: slot);
49 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer 57 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer
50 } 58 }
51 59
52 void detachChildRoot(RenderObjectWrapper child) { 60 void detachChildRoot(RenderObjectWrapper child) {
53 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 61 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
54 assert(root is ContainerRenderObjectMixin); 62 assert(root is ContainerRenderObjectMixin);
55 if (child.root.parent != root) 63 if (child.root.parent != root)
56 return; // probably had slot == _omit when inserted 64 return; // probably had slot == _omit when inserted
57 root.remove(child.root); 65 root.remove(child.root);
58 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer 66 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer
59 } 67 }
60 68
69 @override
61 void remove() { 70 void remove() {
62 for (Widget child in _childrenByKey.values) { 71 for (Widget child in _childrenByKey.values) {
63 assert(child != null); 72 assert(child != null);
64 removeChild(child); 73 removeChild(child);
65 } 74 }
66 super.remove(); 75 super.remove();
67 } 76 }
68 77
78 @override
69 void didMount() { 79 void didMount() {
70 root.callback = layout; 80 root.callback = layout;
71 super.didMount(); 81 super.didMount();
72 } 82 }
73 83
84 @override
74 void didUnmount() { 85 void didUnmount() {
75 root.callback = null; 86 root.callback = null;
76 super.didUnmount(); 87 super.didUnmount();
77 } 88 }
78 89
79 // _offsets contains the offsets of each child from the top of the 90 // _offsets contains the offsets of each child from the top of the
80 // list up to the last one we've ever created, and the offset of the 91 // list up to the last one we've ever created, and the offset of the
81 // end of the last one. If there's no children, then the only offset 92 // end of the last one. If there's no children, then the only offset
82 // is 0.0. 93 // is 0.0.
83 List<double> _offsets = <double>[0.0]; 94 List<double> _offsets = <double>[0.0];
84 95
85 int _findIndexForOffsetBeforeOrAt(double offset) { 96 int _findIndexForOffsetBeforeOrAt(double offset) {
86 int left = 0; 97 int left = 0;
87 int right = _offsets.length - 1; 98 int right = _offsets.length - 1;
88 while (right >= left) { 99 while (right >= left) {
89 int middle = left + ((right - left) ~/ 2); 100 int middle = left + ((right - left) ~/ 2);
90 if (_offsets[middle] < offset) { 101 if (_offsets[middle] < offset) {
91 left = middle + 1; 102 left = middle + 1;
92 } else if (_offsets[middle] > offset) { 103 } else if (_offsets[middle] > offset) {
93 right = middle - 1; 104 right = middle - 1;
94 } else { 105 } else {
95 return middle; 106 return middle;
96 } 107 }
97 } 108 }
98 return right; 109 return right;
99 } 110 }
100 111
101 bool _dirty = false; 112 bool _dirty = false;
102 113
114 @override
103 bool retainStatefulNodeIfPossible(BlockViewport newNode) { 115 bool retainStatefulNodeIfPossible(BlockViewport newNode) {
104 retainStatefulRenderObjectWrapper(newNode); 116 retainStatefulRenderObjectWrapper(newNode);
105 if (startOffset != newNode.startOffset) { 117 if (startOffset != newNode.startOffset) {
106 _dirty = true; 118 _dirty = true;
107 startOffset = newNode.startOffset; 119 startOffset = newNode.startOffset;
108 } 120 }
109 if (token != newNode.token || builder != newNode.builder) { 121 if (token != newNode.token || builder != newNode.builder) {
110 _dirty = true; 122 _dirty = true;
111 builder = newNode.builder; 123 builder = newNode.builder;
112 token = newNode.token; 124 token = newNode.token;
113 _offsets = <double>[0.0]; 125 _offsets = <double>[0.0];
114 } 126 }
115 return true; 127 return true;
116 } 128 }
117 129
130 @override
118 void syncRenderObject(BlockViewport old) { 131 void syncRenderObject(BlockViewport old) {
119 super.syncRenderObject(old); 132 super.syncRenderObject(old);
120 if (_dirty) 133 if (_dirty)
121 root.markNeedsLayout(); 134 root.markNeedsLayout();
122 } 135 }
123 136
124 Widget _getWidget(int index, BoxConstraints innerConstraints) { 137 Widget _getWidget(int index, BoxConstraints innerConstraints) {
125 LayoutCallbackBuilderHandle handle = enterLayoutCallbackBuilder(); 138 LayoutCallbackBuilderHandle handle = enterLayoutCallbackBuilder();
126 try { 139 try {
127 assert(index >= 0); 140 assert(index >= 0);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 index -= 1; 263 index -= 1;
251 Widget widget = builtChildren[index]; 264 Widget widget = builtChildren[index];
252 if (widget.root.parent == root) { 265 if (widget.root.parent == root) {
253 root.move(widget.root, before: nextSibling); 266 root.move(widget.root, before: nextSibling);
254 } else { 267 } else {
255 assert(widget.root.parent == null); 268 assert(widget.root.parent == null);
256 root.add(widget.root, before: nextSibling); 269 root.add(widget.root, before: nextSibling);
257 } 270 }
258 widget.updateSlot(nextSibling); 271 widget.updateSlot(nextSibling);
259 nextSibling = widget.root; 272 nextSibling = widget.root;
260 } 273 }
261 } 274 }
262 275
263 _childrenByKey = newChildren; 276 _childrenByKey = newChildren;
264 } 277 }
265 278
266 } 279 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/basic.dart ('k') | sky/sdk/lib/widgets/button_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698