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

Unified Diff: sky/framework/layout.dart

Issue 1132983007: [Layout] Put in some guards to prevent us from reintroducing 'display' properties into the CSS. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: git cl status 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/components/menu_item.dart ('k') | no next file » | 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 7eb4aae4ae152c94be387417ee0ccb13fbd6a1b6..f402b990263fc118518d0e5894927b95480c952b 100644
--- a/sky/framework/layout.dart
+++ b/sky/framework/layout.dart
@@ -20,21 +20,26 @@ class Style {
var className = "$_className ${other._className}";
return _cache.putIfAbsent(className, () {
- return new Style._internal(className);
+ return new Style._construct(className);
});
}
factory Style(String styles) {
+ assert(!styles.contains(new RegExp('\\b(display|flex|flex-direction)\\b')));
+ return new Style._addToCache(styles);
+ }
+
+ factory Style._addToCache(String styles) {
return _cache.putIfAbsent(styles, () {
var className = _getNextClassName();
sky.Element styleNode = sky.document.createElement('style');
styleNode.setChild(new sky.Text(".$className { $styles }"));
sky.document.appendChild(styleNode);
- return new Style._internal(className);
+ return new Style._construct(className);
});
}
- Style._internal(this._className);
+ Style._construct(this._className);
}
class Rect {
@@ -269,6 +274,7 @@ abstract class RenderCSS extends RenderBox {
String _additionalStylesFromParent = ''; // used internally to propagate parentData settings to the child
void updateInlineStyle(String newStyle) {
+ assert(newStyle == null || !newStyle.contains(new RegExp('\\b(display|flex|flex-direction)\\b')));
_inlineStyles = newStyle != null ? newStyle : '';
_updateInlineStyleAttribute();
}
@@ -362,9 +368,9 @@ class RenderCSSFlex extends RenderCSSContainer {
child.parentData = new FlexBoxParentData();
}
- static final Style _displayFlex = new Style('display:flex');
- static final Style _displayFlexRow = new Style('flex-direction:row');
- static final Style _displayFlexColumn = new Style('flex-direction:column');
+ static final Style _displayFlex = new Style._addToCache('display:flex');
+ static final Style _displayFlexRow = new Style._addToCache('flex-direction:row');
+ static final Style _displayFlexColumn = new Style._addToCache('flex-direction:column');
String stylesToClasses(List<Style> styles) {
var settings = _displayFlex._className;
@@ -396,7 +402,7 @@ class RenderCSSParagraph extends RenderCSSContainer {
RenderCSSParagraph(debug) : super(debug);
- static final Style _displayParagraph = new Style('display:paragraph');
+ static final Style _displayParagraph = new Style._addToCache('display:paragraph');
String stylesToClasses(List<Style> styles) {
return super.stylesToClasses(styles) + ' ' + _displayParagraph._className;
@@ -410,7 +416,7 @@ class RenderCSSInline extends RenderCSS {
data = newData;
}
- static final Style _displayInline = new Style('display:inline');
+ static final Style _displayInline = new Style._addToCache('display:inline');
String stylesToClasses(List<Style> styles) {
return super.stylesToClasses(styles) + ' ' + _displayInline._className;
« no previous file with comments | « sky/framework/components/menu_item.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698