| OLD | NEW |
| 1 library layout; | 1 library layout; |
| 2 | 2 |
| 3 import 'node.dart'; | 3 import 'node.dart'; |
| 4 import 'dart:sky' as sky; | 4 import 'dart:sky' as sky; |
| 5 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 // UTILS | 7 // UTILS |
| 8 | 8 |
| 9 // Bridge to legacy CSS-like style specification | 9 // Bridge to legacy CSS-like style specification |
| 10 // Eventually we'll replace this with something else | 10 // Eventually we'll replace this with something else |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 class FlexBoxParentData extends CSSParentData { | 338 class FlexBoxParentData extends CSSParentData { |
| 339 int flex; | 339 int flex; |
| 340 void merge(FlexBoxParentData other) { | 340 void merge(FlexBoxParentData other) { |
| 341 if (other.flex != null) | 341 if (other.flex != null) |
| 342 flex = other.flex; | 342 flex = other.flex; |
| 343 super.merge(other); | 343 super.merge(other); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 enum FlexDirection { Row } | 347 enum FlexDirection { Row, Column } |
| 348 | 348 |
| 349 class RenderCSSFlex extends RenderCSSContainer { | 349 class RenderCSSFlex extends RenderCSSContainer { |
| 350 | 350 |
| 351 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super(
debug); | 351 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super(
debug); |
| 352 | 352 |
| 353 FlexDirection _direction; | 353 FlexDirection _direction; |
| 354 FlexDirection get direction => _direction; | 354 FlexDirection get direction => _direction; |
| 355 void set direction (FlexDirection value) { | 355 void set direction (FlexDirection value) { |
| 356 _direction = value; | 356 _direction = value; |
| 357 markNeedsLayout(); | 357 markNeedsLayout(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void setupPos(RenderNode child) { | 360 void setupPos(RenderNode child) { |
| 361 if (child.parentData is! FlexBoxParentData) | 361 if (child.parentData is! FlexBoxParentData) |
| 362 child.parentData = new FlexBoxParentData(); | 362 child.parentData = new FlexBoxParentData(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 static final Style _displayFlex = new Style('display:flex'); | 365 static final Style _displayFlex = new Style('display:flex'); |
| 366 static final Style _displayFlexRow = new Style('flex-direction:row'); | 366 static final Style _displayFlexRow = new Style('flex-direction:row'); |
| 367 static final Style _displayFlexColumn = new Style('flex-direction:column'); |
| 367 | 368 |
| 368 String stylesToClasses(List<Style> styles) { | 369 String stylesToClasses(List<Style> styles) { |
| 369 var settings = _displayFlex._className; | 370 var settings = _displayFlex._className; |
| 370 switch (_direction) { | 371 switch (_direction) { |
| 371 case FlexDirection.Row: settings += ' ' + _displayFlexRow._className; | 372 case FlexDirection.Row: settings += ' ' + _displayFlexRow._className; brea
k; |
| 373 case FlexDirection.Column: settings += ' ' + _displayFlexColumn._className
; break; |
| 372 } | 374 } |
| 373 return super.stylesToClasses(styles) + ' ' + settings; | 375 return super.stylesToClasses(styles) + ' ' + settings; |
| 374 } | 376 } |
| 375 | 377 |
| 376 void markNeedsLayout() { | 378 void markNeedsLayout() { |
| 377 super.markNeedsLayout(); | 379 super.markNeedsLayout(); |
| 378 | 380 |
| 379 // pretend we did the layout: | 381 // pretend we did the layout: |
| 380 RenderCSS child = _firstChild; | 382 RenderCSS child = _firstChild; |
| 381 while (child != null) { | 383 while (child != null) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 print(prefix + node.toString() + _attributes(node)); | 476 print(prefix + node.toString() + _attributes(node)); |
| 475 var children = node.getChildNodes(); | 477 var children = node.getChildNodes(); |
| 476 prefix = prefix + ' '; | 478 prefix = prefix + ' '; |
| 477 for (var child in children) | 479 for (var child in children) |
| 478 _serialiseDOM(child, prefix); | 480 _serialiseDOM(child, prefix); |
| 479 } | 481 } |
| 480 | 482 |
| 481 void dumpState() { | 483 void dumpState() { |
| 482 _serialiseDOM(sky.document); | 484 _serialiseDOM(sky.document); |
| 483 } | 485 } |
| OLD | NEW |