Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: sky/framework/layout.dart

Issue 1122413006: [Effen] Move 'flex' out of CSS also. (mark II) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: git cl description Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/fn.dart ('k') | sky/tests/framework/basic.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « sky/framework/fn.dart ('k') | sky/tests/framework/basic.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698