Chromium Code Reviews| Index: sky/framework/layout.dart |
| diff --git a/sky/framework/layout.dart b/sky/framework/layout.dart |
| index 5678fd88f35a839c39f05ea5533e5294ad1c360a..d512ccd1c0979e58315f9776e14ce4891d5eb81f 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,22 @@ 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); |
| + if (newStyle == null) |
|
eseidel
2015/05/12 17:31:59
dart doesn't have a fancy pattern for this?
_inli
|
| + _inlineStyles = ''; |
| + else |
| + _inlineStyles = newStyle; |
| + _updateInlineStyleAttribute(); |
| + } |
| + |
| + void _updateInlineStyleAttribute() { |
| + if ((_inlineStyles != '') && (_additionalStylesFromParent != '')) |
|
eseidel
2015/05/12 17:31:59
style = [inlineStyles, additionalStylesFromParent]
|
| + _skyElement.setAttribute('style', "$_inlineStyles;$_additionalStylesFromParent"); |
| + else |
| + _skyElement.setAttribute('style', "$_inlineStyles$_additionalStylesFromParent"); |
| } |
| double get width { |
| @@ -320,7 +338,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 +376,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 { |