From 02045e37a417e8bbdeaad71cefcf82bef447410c Mon Sep 17 00:00:00 2001 From: Hixie Date: Tue, 12 May 2015 10:40:43 -0700 Subject: [PATCH] [Effen] Move 'flex' out of CSS also. (mark II) This introduces a new kind of ContentNode similar to Style but which instead of changing the styles that apply to the node, provides new settings to apply to the "parentData" structure. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1122413006 --- framework/components/action_bar.dart | 7 +++-- framework/fn.dart | 22 ++++++++++++++- framework/layout.dart | 41 ++++++++++++++++++++++++++-- tests/framework/basic-expected.txt | 2 +- tests/framework/basic.sky | 8 +++++- 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/framework/components/action_bar.dart b/framework/components/action_bar.dart index f874009412c..309fb9b8661 100644 --- a/framework/components/action_bar.dart +++ b/framework/components/action_bar.dart @@ -16,8 +16,9 @@ class ActionBar extends Component { padding-top: ${kStatusBarHeight}px;'''); static Style _centerStyle = new Style(''' - padding-left: 24px; - flex: 1;'''); + padding-left: 24px;'''); + + static FlexBoxParentData _centerLayoutSettings = new FlexBoxParentData()..flex = 1; UINode left; UINode center; @@ -31,7 +32,7 @@ class ActionBar extends Component { }) : super(key: key); UINode build() { - List children = [left, new StyleNode(center, _centerStyle)]; + List children = [left, new StyleNode(new ParentDataNode(center, _centerLayoutSettings), _centerStyle)]; if (right != null) children.addAll(right); diff --git a/framework/fn.dart b/framework/fn.dart index 1a1118c07e5..29caedab927 100644 --- a/framework/fn.dart +++ b/framework/fn.dart @@ -148,6 +148,12 @@ class StyleNode extends ContentNode { StyleNode(UINode content, this.style): super(content); } +class ParentDataNode extends ContentNode { + final ParentData parentData; + + ParentDataNode(UINode content, this.parentData): super(content); +} + /* * SkyNodeWrappers correspond to a desired state of a RenderCSS. They are fully * immutable, with one exception: A UINode which is a Component which lives within @@ -389,14 +395,28 @@ abstract class SkyElementWrapper extends SkyNodeWrapper { List diff --git a/tests/framework/basic.sky b/tests/framework/basic.sky index 244057a6420..efe8e0cff43 100644 --- a/tests/framework/basic.sky +++ b/tests/framework/basic.sky @@ -8,7 +8,13 @@ import 'dart:sky.internals' as internals; void main() { new TestApp(); runAfterDisplay(() { - internals.notifyTestComplete(serializeNode(document.lastChild.previousSibling) + serializeNode(document.lastChild)); + var result = serializeNode(document.lastChild.previousSibling) + serializeNode(document.lastChild); + try { + internals.notifyTestComplete(result); + } catch (e) { + print(e); + print(result); + } }); }