| OLD | NEW |
| 1 library layout; | 1 library layout; |
| 2 | 2 |
| 3 // This version of layout.dart is a shim version of layout2.dart that is backed
using CSS and <div>s. | 3 // This version of layout.dart is a shim version of layout2.dart that is backed
using CSS and <div>s. |
| 4 | 4 |
| 5 import 'node.dart'; | 5 import 'node.dart'; |
| 6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 // UTILS | 9 // UTILS |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 abstract class RenderNode extends AbstractNode { | 69 abstract class RenderNode extends AbstractNode { |
| 70 | 70 |
| 71 // LAYOUT | 71 // LAYOUT |
| 72 | 72 |
| 73 // parentData is only for use by the RenderNode that actually lays this | 73 // parentData is only for use by the RenderNode that actually lays this |
| 74 // node out, and any other nodes who happen to know exactly what | 74 // node out, and any other nodes who happen to know exactly what |
| 75 // kind of node that is. | 75 // kind of node that is. |
| 76 ParentData parentData; | 76 ParentData parentData; |
| 77 void setupPos(RenderNode child) { | 77 void setParentData(RenderNode child) { |
| 78 // override this to setup .parentData correctly for your class | 78 // override this to setup .parentData correctly for your class |
| 79 if (child.parentData is! ParentData) | 79 if (child.parentData is! ParentData) |
| 80 child.parentData = new ParentData(); | 80 child.parentData = new ParentData(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void adoptChild(RenderNode child) { // only for use by subclasses | 83 void adoptChild(RenderNode child) { // only for use by subclasses |
| 84 // call this whenever you decide a node is a child | 84 // call this whenever you decide a node is a child |
| 85 assert(child != null); | 85 assert(child != null); |
| 86 setupPos(child); | 86 setParentData(child); |
| 87 super.adoptChild(child); | 87 super.adoptChild(child); |
| 88 } | 88 } |
| 89 void dropChild(RenderNode child) { // only for use by subclasses | 89 void dropChild(RenderNode child) { // only for use by subclasses |
| 90 assert(child != null); | 90 assert(child != null); |
| 91 assert(child.parentData != null); | 91 assert(child.parentData != null); |
| 92 child.parentData.detach(); | 92 child.parentData.detach(); |
| 93 super.dropChild(child); | 93 super.dropChild(child); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } | 96 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 | 305 |
| 306 } | 306 } |
| 307 | 307 |
| 308 class CSSParentData extends ParentData with ContainerParentDataMixin<RenderCSS>
{ } | 308 class CSSParentData extends ParentData with ContainerParentDataMixin<RenderCSS>
{ } |
| 309 | 309 |
| 310 class RenderCSSContainer extends RenderCSS with ContainerRenderNodeMixin<RenderC
SS, CSSParentData> { | 310 class RenderCSSContainer extends RenderCSS with ContainerRenderNodeMixin<RenderC
SS, CSSParentData> { |
| 311 | 311 |
| 312 RenderCSSContainer(debug) : super(debug); | 312 RenderCSSContainer(debug) : super(debug); |
| 313 | 313 |
| 314 void setupPos(RenderNode child) { | 314 void setParentData(RenderNode child) { |
| 315 if (child.parentData is! CSSParentData) | 315 if (child.parentData is! CSSParentData) |
| 316 child.parentData = new CSSParentData(); | 316 child.parentData = new CSSParentData(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 sky.Element createSkyElement() => sky.document.createElement('div') | 319 sky.Element createSkyElement() => sky.document.createElement('div') |
| 320 ..setAttribute('debug', debug.toS
tring()); | 320 ..setAttribute('debug', debug.toS
tring()); |
| 321 | 321 |
| 322 void markNeedsLayout() { } | 322 void markNeedsLayout() { } |
| 323 | 323 |
| 324 void add(RenderCSS child, { RenderCSS before }) { | 324 void add(RenderCSS child, { RenderCSS before }) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super(
debug); | 359 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super(
debug); |
| 360 | 360 |
| 361 FlexDirection _direction; | 361 FlexDirection _direction; |
| 362 FlexDirection get direction => _direction; | 362 FlexDirection get direction => _direction; |
| 363 void set direction (FlexDirection value) { | 363 void set direction (FlexDirection value) { |
| 364 _direction = value; | 364 _direction = value; |
| 365 markNeedsLayout(); | 365 markNeedsLayout(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void setupPos(RenderNode child) { | 368 void setParentData(RenderNode child) { |
| 369 if (child.parentData is! FlexBoxParentData) | 369 if (child.parentData is! FlexBoxParentData) |
| 370 child.parentData = new FlexBoxParentData(); | 370 child.parentData = new FlexBoxParentData(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 static final Style _displayFlex = new Style._addToCache('display:flex'); | 373 static final Style _displayFlex = new Style._addToCache('display:flex'); |
| 374 static final Style _displayFlexRow = new Style._addToCache('flex-direction:row
'); | 374 static final Style _displayFlexRow = new Style._addToCache('flex-direction:row
'); |
| 375 static final Style _displayFlexColumn = new Style._addToCache('flex-direction:
column'); | 375 static final Style _displayFlexColumn = new Style._addToCache('flex-direction:
column'); |
| 376 | 376 |
| 377 String stylesToClasses(List<Style> styles) { | 377 String stylesToClasses(List<Style> styles) { |
| 378 var settings = _displayFlex._className; | 378 var settings = _displayFlex._className; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 if (other.bottom != null) | 415 if (other.bottom != null) |
| 416 bottom = other.bottom; | 416 bottom = other.bottom; |
| 417 super.merge(other); | 417 super.merge(other); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 class RenderCSSStack extends RenderCSSContainer { | 421 class RenderCSSStack extends RenderCSSContainer { |
| 422 | 422 |
| 423 RenderCSSStack(debug) : super(debug); | 423 RenderCSSStack(debug) : super(debug); |
| 424 | 424 |
| 425 void setupPos(RenderNode child) { | 425 void setParentData(RenderNode child) { |
| 426 if (child.parentData is! StackParentData) | 426 if (child.parentData is! StackParentData) |
| 427 child.parentData = new StackParentData(); | 427 child.parentData = new StackParentData(); |
| 428 } | 428 } |
| 429 | 429 |
| 430 static final Style _displayPosition = new Style._addToCache('transform:transla
teX(0);position:relative'); | 430 static final Style _displayPosition = new Style._addToCache('transform:transla
teX(0);position:relative'); |
| 431 | 431 |
| 432 String stylesToClasses(List<Style> styles) { | 432 String stylesToClasses(List<Style> styles) { |
| 433 return super.stylesToClasses(styles) + ' ' + _displayPosition._className; | 433 return super.stylesToClasses(styles) + ' ' + _displayPosition._className; |
| 434 } | 434 } |
| 435 | 435 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 print(prefix + node.toString() + _attributes(node)); | 553 print(prefix + node.toString() + _attributes(node)); |
| 554 var children = node.getChildNodes(); | 554 var children = node.getChildNodes(); |
| 555 prefix = prefix + ' '; | 555 prefix = prefix + ' '; |
| 556 for (var child in children) | 556 for (var child in children) |
| 557 _serialiseDOM(child, prefix); | 557 _serialiseDOM(child, prefix); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void dumpState() { | 560 void dumpState() { |
| 561 _serialiseDOM(sky.document); | 561 _serialiseDOM(sky.document); |
| 562 } | 562 } |
| OLD | NEW |