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

Side by Side Diff: samples/swarm/swarm_ui_lib/view/view.dart

Issue 14992002: More fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library view; 5 library view;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:math' as Math; 9 import 'dart:math' as Math;
10 10
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 322
323 void doLayout() { 323 void doLayout() {
324 _measureLayout().then((changed) { 324 _measureLayout().then((changed) {
325 if (changed) { 325 if (changed) {
326 _applyLayoutToChildren(); 326 _applyLayoutToChildren();
327 } 327 }
328 }); 328 });
329 } 329 }
330 330
331 Future<bool> _measureLayout() { 331 Future<bool> _measureLayout() {
332 final changed = new Completer<bool>(); 332 // TODO(10459): code should not use Completer.sync.
333 final changed = new Completer<bool>.sync();
333 _measureLayoutHelper(changed); 334 _measureLayoutHelper(changed);
334 335
335 var changedComplete = false; 336 var changedComplete = false;
336 changed.future.then((_) { 337 changed.future.then((_) {
337 changedComplete = true; 338 changedComplete = true;
338 }); 339 });
339 340
340 window.setImmediate(() { 341 window.setImmediate(() {
341 if (!changedComplete) { 342 if (!changedComplete) {
342 changed.complete(false); 343 changed.complete(false);
343 } 344 }
344 }); 345 });
345 return changed.future; 346 return changed.future;
346 } 347 }
347 348
348 void _measureLayoutHelper(Completer<bool> changed) { 349 void _measureLayoutHelper(Completer<bool> changed) {
349 windowResized(); 350 windowResized();
350 351
351 // TODO(jmesserly): this logic is more complex than it needs to be because 352 // TODO(jmesserly): this logic is more complex than it needs to be because
352 // we're taking pains to not initialize _layout if it's not needed. Is that 353 // we're taking pains to not initialize _layout if it's not needed. Is that
353 // a good tradeoff? 354 // a good tradeoff?
354 if (ViewLayout.hasCustomLayout(this)) { 355 if (ViewLayout.hasCustomLayout(this)) {
355 Completer sizeCompleter = new Completer<Size>(); 356 // TODO(10459): code should not use Completer.sync.
357 Completer sizeCompleter = new Completer<Size>.sync();
356 window.setImmediate(() { 358 window.setImmediate(() {
357 sizeCompleter.complete( 359 sizeCompleter.complete(
358 new Size(_node.client.width, _node.client.height)); 360 new Size(_node.client.width, _node.client.height));
359 }); 361 });
360 layout.measureLayout(sizeCompleter.future, changed); 362 layout.measureLayout(sizeCompleter.future, changed);
361 } else { 363 } else {
362 for (final child in childViews) { 364 for (final child in childViews) {
363 child._measureLayoutHelper(changed); 365 child._measureLayoutHelper(changed);
364 } 366 }
365 } 367 }
366 } 368 }
367 369
368 void _applyLayoutToChildren() { 370 void _applyLayoutToChildren() {
369 for (final child in childViews) { 371 for (final child in childViews) {
370 child._applyLayout(); 372 child._applyLayout();
371 } 373 }
372 } 374 }
373 375
374 void _applyLayout() { 376 void _applyLayout() {
375 if (_layout != null) { 377 if (_layout != null) {
376 _layout.applyLayout(); 378 _layout.applyLayout();
377 } 379 }
378 _applyLayoutToChildren(); 380 _applyLayoutToChildren();
379 } 381 }
380 } 382 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698