| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 /** | 247 /** |
| 248 * This method computes a '1fr' value, referred to as the | 248 * This method computes a '1fr' value, referred to as the |
| 249 * tempBreadth, for a set of Grid Tracks. The value computed | 249 * tempBreadth, for a set of Grid Tracks. The value computed |
| 250 * will ensure that when the tempBreadth is multiplied by the | 250 * will ensure that when the tempBreadth is multiplied by the |
| 251 * fractions associated with tracks, that the UsedBreadths of tracks | 251 * fractions associated with tracks, that the UsedBreadths of tracks |
| 252 * will increase by an amount equal to the maximum of zero and the specified | 252 * will increase by an amount equal to the maximum of zero and the specified |
| 253 * freeSpace less the sum of the current UsedBreadths. | 253 * freeSpace less the sum of the current UsedBreadths. |
| 254 */ | 254 */ |
| 255 num _calcNormalizedFractionBreadth(List<GridTrack> tracks) { | 255 num _calcNormalizedFractionBreadth(List<GridTrack> tracks) { |
| 256 | 256 |
| 257 final fractionTracks = tracks.where((t) => t.maxSizing.isFraction); | 257 final fractionTracks = tracks.where((t) => t.maxSizing.isFraction).toList(); |
| 258 | 258 |
| 259 // Note: the spec has various bugs in this function, such as mismatched | 259 // Note: the spec has various bugs in this function, such as mismatched |
| 260 // identifiers and names that aren't defined. For the most part it's | 260 // identifiers and names that aren't defined. For the most part it's |
| 261 // possible to figure out the meaning. It's also a bit confused about | 261 // possible to figure out the meaning. It's also a bit confused about |
| 262 // how to compute spaceNeededFromFractionTracks, but that should just be the | 262 // how to compute spaceNeededFromFractionTracks, but that should just be the |
| 263 // set to the remaining free space after usedBreadth is accounted for. | 263 // set to the remaining free space after usedBreadth is accounted for. |
| 264 | 264 |
| 265 // We use the tempBreadth field to store the normalized fraction breadth | 265 // We use the tempBreadth field to store the normalized fraction breadth |
| 266 for (final t in fractionTracks) { | 266 for (final t in fractionTracks) { |
| 267 t.tempBreadth = t.usedBreadth / t.maxSizing.fractionValue; | 267 t.tempBreadth = t.usedBreadth / t.maxSizing.fractionValue; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 * in content-sized Grid Tracks by the Grid Item's spanCount. That is, Grid | 334 * in content-sized Grid Tracks by the Grid Item's spanCount. That is, Grid |
| 335 * Items having a lower spanCount have an opportunity to increase the size of | 335 * Items having a lower spanCount have an opportunity to increase the size of |
| 336 * the Grid Tracks they cover before those with larger SpanCounts. | 336 * the Grid Tracks they cover before those with larger SpanCounts. |
| 337 * | 337 * |
| 338 * Note: items are assumed to be already sorted in increasing span count | 338 * Note: items are assumed to be already sorted in increasing span count |
| 339 */ | 339 */ |
| 340 void _distributeSpaceBySpanCount(List<ViewLayout> items, | 340 void _distributeSpaceBySpanCount(List<ViewLayout> items, |
| 341 ContentSizeMode sizeMode, _BreadthAccumulator breadth) { | 341 ContentSizeMode sizeMode, _BreadthAccumulator breadth) { |
| 342 | 342 |
| 343 items = items.where((item) => | 343 items = items.where((item) => |
| 344 _hasContentSizedTracks(_getTracks(item), sizeMode, breadth)); | 344 _hasContentSizedTracks(_getTracks(item), sizeMode, breadth)).toList(); |
| 345 | 345 |
| 346 var tracks = []; | 346 var tracks = []; |
| 347 | 347 |
| 348 for (int i = 0; i < items.length; i++) { | 348 for (int i = 0; i < items.length; i++) { |
| 349 final item = items[i]; | 349 final item = items[i]; |
| 350 | 350 |
| 351 final itemTargetSize = item.measureContent(this, _dimension, sizeMode); | 351 final itemTargetSize = item.measureContent(this, _dimension, sizeMode); |
| 352 | 352 |
| 353 final spannedTracks = _getTracks(item); | 353 final spannedTracks = _getTracks(item); |
| 354 _distributeSpaceToTracks(spannedTracks, itemTargetSize, breadth, true); | 354 _distributeSpaceToTracks(spannedTracks, itemTargetSize, breadth, true); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 510 } |
| 511 return result; | 511 return result; |
| 512 } | 512 } |
| 513 | 513 |
| 514 int _getSpanCount(ViewLayout item) { | 514 int _getSpanCount(ViewLayout item) { |
| 515 GridLayoutParams childLayout = item.layoutParams; | 515 GridLayoutParams childLayout = item.layoutParams; |
| 516 return (_dimension == Dimension.WIDTH ? | 516 return (_dimension == Dimension.WIDTH ? |
| 517 childLayout.columnSpan : childLayout.rowSpan); | 517 childLayout.columnSpan : childLayout.rowSpan); |
| 518 } | 518 } |
| 519 } | 519 } |
| OLD | NEW |