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

Side by Side Diff: client/layout/GridLayout.dart

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011, 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 /** 5 /**
6 * Implements a grid-based layout system based on: 6 * Implements a grid-based layout system based on:
7 * [http://dev.w3.org/csswg/css3-grid-align/] 7 * [http://dev.w3.org/csswg/css3-grid-align/]
8 * 8 *
9 * This layout is designed to support animations and work on browsers that 9 * This layout is designed to support animations and work on browsers that
10 * don't support grid natively. As such, we implement it on top of absolute 10 * don't support grid natively. As such, we implement it on top of absolute
11 * positioning. 11 * positioning.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 88
89 int get currentWidth() => _gridWidth; 89 int get currentWidth() => _gridWidth;
90 int get currentHeight() => _gridHeight; 90 int get currentHeight() => _gridHeight;
91 91
92 void cacheExistingBrowserLayout() { 92 void cacheExistingBrowserLayout() {
93 // We don't need to do anything as we don't rely on the _cachedViewRect 93 // We don't need to do anything as we don't rely on the _cachedViewRect
94 // when the grid layout is used. 94 // when the grid layout is used.
95 } 95 }
96 96
97 // TODO(jacobr): cleanup this method so that it returns a Future
98 // rather than taking a Completer as an argument.
99 /** The main entry point for layout computation. */ 97 /** The main entry point for layout computation. */
100 void measureLayout(Future<Size> size, Completer<bool> changed) { 98 bool measureLayout(int width, int height) {
99 assert(window.inMeasurementFrame);
101 _ensureAllTracks(); 100 _ensureAllTracks();
102 window.requestLayoutFrame(() { 101 _gridWidth = width;
103 _gridWidth = size.value.width; 102 _gridHeight = height;
104 _gridHeight = size.value.height;
105 103
106 if (_rowTracks.length > 0 && _columnTracks.length > 0) { 104 if (_rowTracks.length > 0 && _columnTracks.length > 0) {
107 _measureTracks(); 105 _measureTracks();
108 _setBoundsOfChildren(); 106 _setBoundsOfChildren();
109 if (changed != null) { 107 return true;
110 changed.complete(true); 108 }
111 } 109 return false;
112 }
113 });
114 } 110 }
115 111
116 /** 112 /**
117 * The top level measurement function. 113 * The top level measurement function.
118 * [http://dev.w3.org/csswg/css3-grid-align/#calculating-size-of-grid-tracks] 114 * [http://dev.w3.org/csswg/css3-grid-align/#calculating-size-of-grid-tracks]
119 */ 115 */
120 void _measureTracks() { 116 void _measureTracks() {
121 // Resolve logical width, then height. Width comes first so we can use 117 // Resolve logical width, then height. Width comes first so we can use
122 // the width when determining the content-sized height. 118 // the width when determining the content-sized height.
123 try { 119 try {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 507 }
512 return result; 508 return result;
513 } 509 }
514 510
515 int _getSpanCount(ViewLayout item) { 511 int _getSpanCount(ViewLayout item) {
516 GridLayoutParams childLayout = item.layoutParams; 512 GridLayoutParams childLayout = item.layoutParams;
517 return (_dimension == Dimension.WIDTH ? 513 return (_dimension == Dimension.WIDTH ?
518 childLayout.columnSpan : childLayout.rowSpan); 514 childLayout.columnSpan : childLayout.rowSpan);
519 } 515 }
520 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698