Index: sky/framework/layout.dart |
diff --git a/sky/framework/layout.dart b/sky/framework/layout.dart |
index 5678fd88f35a839c39f05ea5533e5294ad1c360a..f93fd98df264890b993368c33d91725e42ba2558 100644 |
--- a/sky/framework/layout.dart |
+++ b/sky/framework/layout.dart |
@@ -53,6 +53,10 @@ class ParentData { |
detachSiblings(); |
} |
void detachSiblings() { } // workaround for lack of inter-class mixins in Dart |
+ void merge(ParentData other) { |
+ // override this in subclasses to merge in data from other into this |
+ assert(other.runtimeType == this.runtimeType); |
+ } |
} |
abstract class RenderNode extends Node { |
@@ -261,8 +265,19 @@ abstract class RenderCSS extends RenderBox { |
return styles.map((s) => s._className).join(' '); |
} |
+ String _inlineStyles = ''; |
+ String _additionalStylesFromParent = ''; // used internally to propagate parentData settings to the child |
+ |
void updateInlineStyle(String newStyle) { |
- _skyElement.setAttribute('style', newStyle); |
+ _inlineStyles = newStyle != null ? newStyle : ''; |
+ _updateInlineStyleAttribute(); |
+ } |
+ |
+ void _updateInlineStyleAttribute() { |
+ if ((_inlineStyles != '') && (_additionalStylesFromParent != '')) |
+ _skyElement.setAttribute('style', "$_inlineStyles;$_additionalStylesFromParent"); |
+ else |
+ _skyElement.setAttribute('style', "$_inlineStyles$_additionalStylesFromParent"); |
} |
double get width { |
@@ -320,7 +335,14 @@ class RenderCSSContainer extends RenderCSS with ContainerRenderNodeMixin<RenderC |
} |
-class FlexBoxParentData extends CSSParentData { } |
+class FlexBoxParentData extends CSSParentData { |
+ int flex; |
+ void merge(FlexBoxParentData other) { |
+ if (other.flex != null) |
+ flex = other.flex; |
+ super.merge(other); |
+ } |
+} |
enum FlexDirection { Row } |
@@ -351,6 +373,21 @@ class RenderCSSFlex extends RenderCSSContainer { |
return super.stylesToClasses(styles) + ' ' + settings; |
} |
+ void markNeedsLayout() { |
+ super.markNeedsLayout(); |
+ |
+ // pretend we did the layout: |
+ RenderCSS child = _firstChild; |
+ while (child != null) { |
+ assert(child.parentData is FlexBoxParentData); |
+ if (child.parentData.flex != null) { |
+ child._additionalStylesFromParent = 'flex:${child.parentData.flex};'; |
+ child._updateInlineStyleAttribute(); |
+ } |
+ child = child.parentData.nextSibling; |
+ } |
+ } |
+ |
} |
class RenderCSSText extends RenderCSS { |