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

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

Issue 1128743003: [Effen] Convert action_bar.dart to using a FlexContainer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: more better line wrapping 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
« sky/framework/fn.dart ('K') | « 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 sky.Element _skyElement; 247 sky.Element _skyElement;
248 248
249 RenderCSS(this.debug) { 249 RenderCSS(this.debug) {
250 _skyElement = createSkyElement(); 250 _skyElement = createSkyElement();
251 registerEventTarget(_skyElement, this); 251 registerEventTarget(_skyElement, this);
252 } 252 }
253 253
254 sky.Element createSkyElement(); 254 sky.Element createSkyElement();
255 255
256 void updateStyles(List<Style> styles) { 256 void updateStyles(List<Style> styles) {
257 _skyElement.setAttribute('class', styles.map((s) => s._className).join(' ')) ; 257 _skyElement.setAttribute('class', stylesToClasses(styles));
258 }
259
260 String stylesToClasses(List<Style> styles) {
261 return styles.map((s) => s._className).join(' ');
258 } 262 }
259 263
260 void updateInlineStyle(String newStyle) { 264 void updateInlineStyle(String newStyle) {
261 _skyElement.setAttribute('style', newStyle); 265 _skyElement.setAttribute('style', newStyle);
262 } 266 }
263 267
264 double get width { 268 double get width {
265 sky.ClientRect rect = _skyElement.getBoundingClientRect(); 269 sky.ClientRect rect = _skyElement.getBoundingClientRect();
266 return rect.width; 270 return rect.width;
267 } 271 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 _skyElement.appendChild(child._skyElement); 313 _skyElement.appendChild(child._skyElement);
310 } 314 }
311 } 315 }
312 void remove(RenderCSS child) { 316 void remove(RenderCSS child) {
313 child._skyElement.remove(); 317 child._skyElement.remove();
314 super.remove(child); 318 super.remove(child);
315 } 319 }
316 320
317 } 321 }
318 322
323 class FlexBoxParentData extends CSSParentData { }
324
325 enum FlexDirection { Row }
eseidel 2015/05/11 22:04:24 Did you wish to support both?
Hixie 2015/05/11 22:06:07 Eventually. I'll add column when I run into someth
326
327 class RenderCSSFlex extends RenderCSSContainer {
328
329 RenderCSSFlex(debug, FlexDirection direction) : _direction = direction, super( debug);
330
331 FlexDirection _direction;
332 FlexDirection get direction => _direction;
333 void set direction (FlexDirection value) {
334 _direction = value;
335 markNeedsLayout();
336 }
337
338 void setupPos(RenderNode child) {
339 if (child.parentData is! FlexBoxParentData)
340 child.parentData = new FlexBoxParentData();
341 }
342
343 static final Style _displayFlex = new Style('display:flex');
344 static final Style _displayFlexRow = new Style('flex-direction:row');
345
346 String stylesToClasses(List<Style> styles) {
347 var settings = _displayFlex._className;
348 switch (_direction) {
349 case FlexDirection.Row: settings += ' ' + _displayFlexRow._className;
350 }
351 return super.stylesToClasses(styles) + ' ' + settings;
352 }
353
354 }
355
319 class RenderCSSText extends RenderCSS { 356 class RenderCSSText extends RenderCSS {
320 357
321 RenderCSSText(debug, String newData) : super(debug) { 358 RenderCSSText(debug, String newData) : super(debug) {
322 data = newData; 359 data = newData;
323 } 360 }
324 361
325 static final Style _displayParagraph = new Style('display:paragraph'); 362 static final Style _displayParagraph = new Style('display:paragraph');
326 363
327 sky.Element createSkyElement() { 364 sky.Element createSkyElement() {
328 return sky.document.createElement('div') 365 return sky.document.createElement('div')
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 print(prefix + node.toString() + _attributes(node)); 434 print(prefix + node.toString() + _attributes(node));
398 var children = node.getChildNodes(); 435 var children = node.getChildNodes();
399 prefix = prefix + ' '; 436 prefix = prefix + ' ';
400 for (var child in children) 437 for (var child in children)
401 _serialiseDOM(child, prefix); 438 _serialiseDOM(child, prefix);
402 } 439 }
403 440
404 void dumpState() { 441 void dumpState() {
405 _serialiseDOM(sky.document); 442 _serialiseDOM(sky.document);
406 } 443 }
OLDNEW
« sky/framework/fn.dart ('K') | « sky/framework/fn.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698