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

Side by Side Diff: sky/framework/layout.dart

Issue 1137153002: Revert "[Effen] Move 'flex' out of CSS also." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « sky/framework/fn.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library layout; 1 library layout;
2 2
3 import 'node.dart'; 3 import 'node.dart';
4 import 'dart:sky' as sky; 4 import 'dart:sky' as sky;
5 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 // UTILS 7 // UTILS
8 8
9 // Bridge to legacy CSS-like style specification 9 // Bridge to legacy CSS-like style specification
10 // Eventually we'll replace this with something else 10 // Eventually we'll replace this with something else
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 48
49 // ABSTRACT LAYOUT 49 // ABSTRACT LAYOUT
50 50
51 class ParentData { 51 class ParentData {
52 void detach() { 52 void detach() {
53 detachSiblings(); 53 detachSiblings();
54 } 54 }
55 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart 55 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart
56 void merge(ParentData other) {
57 // override this in subclasses to merge in data from other into this
58 assert(other.runtimeType == this.runtimeType);
59 }
60 } 56 }
61 57
62 abstract class RenderNode extends Node { 58 abstract class RenderNode extends Node {
63 59
64 // LAYOUT 60 // LAYOUT
65 61
66 // parentData is only for use by the RenderNode that actually lays this 62 // parentData is only for use by the RenderNode that actually lays this
67 // node out, and any other nodes who happen to know exactly what 63 // node out, and any other nodes who happen to know exactly what
68 // kind of node that is. 64 // kind of node that is.
69 ParentData parentData; 65 ParentData parentData;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 sky.Element createSkyElement(); 254 sky.Element createSkyElement();
259 255
260 void updateStyles(List<Style> styles) { 256 void updateStyles(List<Style> styles) {
261 _skyElement.setAttribute('class', stylesToClasses(styles)); 257 _skyElement.setAttribute('class', stylesToClasses(styles));
262 } 258 }
263 259
264 String stylesToClasses(List<Style> styles) { 260 String stylesToClasses(List<Style> styles) {
265 return styles.map((s) => s._className).join(' '); 261 return styles.map((s) => s._className).join(' ');
266 } 262 }
267 263
268 String _inlineStyles = '';
269 String _additionalStylesFromParent = ''; // used internally to propagate paren tData settings to the child
270
271 void updateInlineStyle(String newStyle) { 264 void updateInlineStyle(String newStyle) {
272 _inlineStyles = newStyle; 265 _skyElement.setAttribute('style', newStyle);
273 _updateInlineStyleAttribute();
274 }
275
276 void _updateInlineStyleAttribute() {
277 _skyElement.setAttribute('style', "$_inlineStyles;$_additionalStylesFromPare nt");
278 } 266 }
279 267
280 double get width { 268 double get width {
281 sky.ClientRect rect = _skyElement.getBoundingClientRect(); 269 sky.ClientRect rect = _skyElement.getBoundingClientRect();
282 return rect.width; 270 return rect.width;
283 } 271 }
284 272
285 double get height { 273 double get height {
286 sky.ClientRect rect = _skyElement.getBoundingClientRect(); 274 sky.ClientRect rect = _skyElement.getBoundingClientRect();
287 return rect.height; 275 return rect.height;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 _skyElement.appendChild(child._skyElement); 313 _skyElement.appendChild(child._skyElement);
326 } 314 }
327 } 315 }
328 void remove(RenderCSS child) { 316 void remove(RenderCSS child) {
329 child._skyElement.remove(); 317 child._skyElement.remove();
330 super.remove(child); 318 super.remove(child);
331 } 319 }
332 320
333 } 321 }
334 322
335 class FlexBoxParentData extends CSSParentData { 323 class FlexBoxParentData extends CSSParentData { }
336 int flex;
337 void merge(FlexBoxParentData other) {
338 if (other.flex != null)
339 flex = other.flex;
340 super.merge(other);
341 }
342 }
343 324
344 enum FlexDirection { Row } 325 enum FlexDirection { Row }
345 326
346 class RenderCSSFlex extends RenderCSSContainer { 327 class RenderCSSFlex extends RenderCSSContainer {
347 328
348 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super( debug); 329 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super( debug);
349 330
350 FlexDirection _direction; 331 FlexDirection _direction;
351 FlexDirection get direction => _direction; 332 FlexDirection get direction => _direction;
352 void set direction (FlexDirection value) { 333 void set direction (FlexDirection value) {
(...skipping 10 matching lines...) Expand all
363 static final Style _displayFlexRow = new Style('flex-direction:row'); 344 static final Style _displayFlexRow = new Style('flex-direction:row');
364 345
365 String stylesToClasses(List<Style> styles) { 346 String stylesToClasses(List<Style> styles) {
366 var settings = _displayFlex._className; 347 var settings = _displayFlex._className;
367 switch (_direction) { 348 switch (_direction) {
368 case FlexDirection.Row: settings += ' ' + _displayFlexRow._className; 349 case FlexDirection.Row: settings += ' ' + _displayFlexRow._className;
369 } 350 }
370 return super.stylesToClasses(styles) + ' ' + settings; 351 return super.stylesToClasses(styles) + ' ' + settings;
371 } 352 }
372 353
373 void markNeedsLayout() {
374 super.markNeedsLayout();
375
376 // pretend we did the layout:
377 RenderCSS child = _firstChild;
378 while (child != null) {
379 assert(child.parentData is FlexBoxParentData);
380 if (child.parentData.flex != null) {
381 child._additionalStylesFromParent = 'flex:${child.parentData.flex};';
382 child._updateInlineStyleAttribute();
383 }
384 child = child.parentData.nextSibling;
385 }
386 }
387
388 } 354 }
389 355
390 class RenderCSSText extends RenderCSS { 356 class RenderCSSText extends RenderCSS {
391 357
392 RenderCSSText(debug, String newData) : super(debug) { 358 RenderCSSText(debug, String newData) : super(debug) {
393 data = newData; 359 data = newData;
394 } 360 }
395 361
396 static final Style _displayParagraph = new Style('display:paragraph'); 362 static final Style _displayParagraph = new Style('display:paragraph');
397 363
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 print(prefix + node.toString() + _attributes(node)); 434 print(prefix + node.toString() + _attributes(node));
469 var children = node.getChildNodes(); 435 var children = node.getChildNodes();
470 prefix = prefix + ' '; 436 prefix = prefix + ' ';
471 for (var child in children) 437 for (var child in children)
472 _serialiseDOM(child, prefix); 438 _serialiseDOM(child, prefix);
473 } 439 }
474 440
475 void dumpState() { 441 void dumpState() {
476 _serialiseDOM(sky.document); 442 _serialiseDOM(sky.document);
477 } 443 }
OLDNEW
« no previous file with comments | « sky/framework/fn.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698