| 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 library fn; | 5 library fn; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:sky' as sky; | 9 import 'dart:sky' as sky; |
| 10 import 'reflect.dart' as reflect; | 10 import 'reflect.dart' as reflect; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 super._remove(); | 141 super._remove(); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 class StyleNode extends ContentNode { | 145 class StyleNode extends ContentNode { |
| 146 final Style style; | 146 final Style style; |
| 147 | 147 |
| 148 StyleNode(UINode content, this.style): super(content); | 148 StyleNode(UINode content, this.style): super(content); |
| 149 } | 149 } |
| 150 | 150 |
| 151 class ParentDataNode extends ContentNode { |
| 152 final ParentData parentData; |
| 153 |
| 154 ParentDataNode(UINode content, this.parentData): super(content); |
| 155 } |
| 156 |
| 151 /* | 157 /* |
| 152 * SkyNodeWrappers correspond to a desired state of a RenderCSS. They are fully | 158 * SkyNodeWrappers correspond to a desired state of a RenderCSS. They are fully |
| 153 * immutable, with one exception: A UINode which is a Component which lives with
in | 159 * immutable, with one exception: A UINode which is a Component which lives with
in |
| 154 * an SkyElementWrapper's children list, may be replaced with the "old" instance
if it | 160 * an SkyElementWrapper's children list, may be replaced with the "old" instance
if it |
| 155 * has become stateful. | 161 * has become stateful. |
| 156 */ | 162 */ |
| 157 abstract class SkyNodeWrapper extends UINode { | 163 abstract class SkyNodeWrapper extends UINode { |
| 158 | 164 |
| 159 static final Map<RenderCSS, SkyNodeWrapper> _nodeMap = | 165 static final Map<RenderCSS, SkyNodeWrapper> _nodeMap = |
| 160 new HashMap<RenderCSS, SkyNodeWrapper>(); | 166 new HashMap<RenderCSS, SkyNodeWrapper>(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 388 } |
| 383 return false; | 389 return false; |
| 384 } | 390 } |
| 385 | 391 |
| 386 void _syncNode(SkyNodeWrapper old) { | 392 void _syncNode(SkyNodeWrapper old) { |
| 387 SkyElementWrapper oldSkyElementWrapper = old as SkyElementWrapper; | 393 SkyElementWrapper oldSkyElementWrapper = old as SkyElementWrapper; |
| 388 | 394 |
| 389 List<Style> styles = new List<Style>(); | 395 List<Style> styles = new List<Style>(); |
| 390 if (style != null) | 396 if (style != null) |
| 391 styles.add(style); | 397 styles.add(style); |
| 398 ParentData parentData = null; |
| 392 UINode parent = _parent; | 399 UINode parent = _parent; |
| 393 while (parent != null && parent is! SkyNodeWrapper) { | 400 while (parent != null && parent is! SkyNodeWrapper) { |
| 394 if (parent is StyleNode && parent.style != null) | 401 if (parent is StyleNode && parent.style != null) |
| 395 styles.add(parent.style); | 402 styles.add(parent.style); |
| 403 else |
| 404 if (parent is ParentDataNode && parent.parentData != null) { |
| 405 if (parentData != null) |
| 406 parentData.merge(parent.parentData); // this will throw if the types a
ren't the same |
| 407 else |
| 408 parentData = parent.parentData; |
| 409 } |
| 396 parent = parent._parent; | 410 parent = parent._parent; |
| 397 } | 411 } |
| 398 _root.updateStyles(styles); | 412 _root.updateStyles(styles); |
| 399 | 413 if (parentData != null) { |
| 414 assert(_root.parentData != null); |
| 415 _root.parentData.merge(parentData); // this will throw if the types aren't
approriate |
| 416 assert(parent != null); |
| 417 assert(parent._root != null); |
| 418 parent._root.markNeedsLayout(); |
| 419 } |
| 400 _root.updateInlineStyle(inlineStyle); | 420 _root.updateInlineStyle(inlineStyle); |
| 401 | 421 |
| 402 _syncChildren(oldSkyElementWrapper); | 422 _syncChildren(oldSkyElementWrapper); |
| 403 } | 423 } |
| 404 | 424 |
| 405 void _syncChildren(SkyElementWrapper oldSkyElementWrapper) { | 425 void _syncChildren(SkyElementWrapper oldSkyElementWrapper) { |
| 406 if (_root is! RenderCSSContainer) | 426 if (_root is! RenderCSSContainer) |
| 407 return; | 427 return; |
| 408 | 428 |
| 409 var startIndex = 0; | 429 var startIndex = 0; |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } | 848 } |
| 829 | 849 |
| 830 void _buildIfDirty() { | 850 void _buildIfDirty() { |
| 831 if (!_dirty || _defunct) | 851 if (!_dirty || _defunct) |
| 832 return; | 852 return; |
| 833 | 853 |
| 834 _trace('$_key rebuilding...'); | 854 _trace('$_key rebuilding...'); |
| 835 _sync(null, _host, _root); | 855 _sync(null, _host, _root); |
| 836 } | 856 } |
| 837 } | 857 } |
| OLD | NEW |