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