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

Side by Side Diff: samples/ui_lib/layout/GridTracks.dart

Issue 11235054: Removed IllegalAccessException and UnsupportedOperationException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ADded test expectations. Created 8 years, 2 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 | « samples/ui_lib/layout/GridLayoutParams.dart ('k') | samples/ui_lib/layout/SizingFunctions.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) 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 // This file has classes representing the grid tracks and grid template 5 // This file has classes representing the grid tracks and grid template
6 6
7 /** 7 /**
8 * The data structure representing the grid-rows or grid-columns 8 * The data structure representing the grid-rows or grid-columns
9 * properties. 9 * properties.
10 */ 10 */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 final String value; 67 final String value;
68 68
69 // 'start' | 'end' | 'center' | 'stretch' 69 // 'start' | 'end' | 'center' | 'stretch'
70 GridItemAlignment.fromString(String value) 70 GridItemAlignment.fromString(String value)
71 : this.value = (value == null) ? 'stretch' : value { 71 : this.value = (value == null) ? 'stretch' : value {
72 72
73 switch (this.value) { 73 switch (this.value) {
74 case 'start': case 'end': case 'center': case 'stretch': 74 case 'start': case 'end': case 'center': case 'stretch':
75 break; 75 break;
76 default: 76 default:
77 throw new UnsupportedOperationException( 77 throw new UnsupportedError(
78 'invalid row/column alignment "$value"'); 78 'invalid row/column alignment "$value"');
79 } 79 }
80 } 80 }
81 81
82 _GridLocation align(_GridLocation span, int size) { 82 _GridLocation align(_GridLocation span, int size) {
83 switch (value) { 83 switch (value) {
84 case 'start': 84 case 'start':
85 return new _GridLocation(span.start, size); 85 return new _GridLocation(span.start, size);
86 case 'end': 86 case 'end':
87 return new _GridLocation(span.end - size, size); 87 return new _GridLocation(span.end - size, size);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 for (final rect in _rects.getValues()) { 130 for (final rect in _rects.getValues()) {
131 rect.checkValid(); 131 rect.checkValid();
132 } 132 }
133 } 133 }
134 134
135 /** 135 /**
136 * Looks up the given cell in the template, and returns the rect. 136 * Looks up the given cell in the template, and returns the rect.
137 */ 137 */
138 _GridTemplateRect lookupCell(String cell) { 138 _GridTemplateRect lookupCell(String cell) {
139 if (cell.length != 1) { 139 if (cell.length != 1) {
140 throw new UnsupportedOperationException( 140 throw new UnsupportedError(
141 'grid-cell "$cell" must be a one character string'); 141 'grid-cell "$cell" must be a one character string');
142 } 142 }
143 final rect = _rects[cell.charCodeAt(0)]; 143 final rect = _rects[cell.charCodeAt(0)];
144 if (rect == null) { 144 if (rect == null) {
145 throw new UnsupportedOperationException( 145 throw new UnsupportedError(
146 'grid-cell "$cell" not found in parent\'s grid-template'); 146 'grid-cell "$cell" not found in parent\'s grid-template');
147 } 147 }
148 return rect; 148 return rect;
149 } 149 }
150 } 150 }
151 151
152 /** Used by GridTemplate to track a single cell's bounds. */ 152 /** Used by GridTemplate to track a single cell's bounds. */
153 class _GridTemplateRect { 153 class _GridTemplateRect {
154 int row, column, rowSpan, columnSpan, _count, _char; 154 int row, column, rowSpan, columnSpan, _count, _char;
155 _GridTemplateRect(this._char, this.row, this.column) 155 _GridTemplateRect(this._char, this.row, this.column)
156 : rowSpan = 1, columnSpan = 1, _count = 1 {} 156 : rowSpan = 1, columnSpan = 1, _count = 1 {}
157 157
158 void add(int r, int c) { 158 void add(int r, int c) {
159 assert (r >= row && c >= column); 159 assert (r >= row && c >= column);
160 _count++; 160 _count++;
161 rowSpan = Math.max(rowSpan, r - row + 1); 161 rowSpan = Math.max(rowSpan, r - row + 1);
162 columnSpan = Math.max(columnSpan, c - column + 1); 162 columnSpan = Math.max(columnSpan, c - column + 1);
163 } 163 }
164 164
165 void checkValid() { 165 void checkValid() {
166 int expected = rowSpan * columnSpan; 166 int expected = rowSpan * columnSpan;
167 if (expected != _count) { 167 if (expected != _count) {
168 // TODO(jmesserly): not sure if we should throw here, due to CSS's 168 // TODO(jmesserly): not sure if we should throw here, due to CSS's
169 // permissiveness. At the moment we're noisy about errors. 169 // permissiveness. At the moment we're noisy about errors.
170 String cell = new String.fromCharCodes([_char]); 170 String cell = new String.fromCharCodes([_char]);
171 throw new UnsupportedOperationException('grid-template "$cell"' 171 throw new UnsupportedError('grid-template "$cell"'
172 ' is not square, expected $expected cells but got $_count'); 172 ' is not square, expected $expected cells but got $_count');
173 } 173 }
174 } 174 }
175 } 175 }
176 176
177 177
178 /** 178 /**
179 * Used to return a row/column and span during parsing of grid-row and 179 * Used to return a row/column and span during parsing of grid-row and
180 * grid-column during parsing. 180 * grid-column during parsing.
181 */ 181 */
182 class _GridLocation { 182 class _GridLocation {
183 final int start, length; 183 final int start, length;
184 _GridLocation(this.start, this.length) {} 184 _GridLocation(this.start, this.length) {}
185 185
186 int get end => start + length; 186 int get end => start + length;
187 } 187 }
OLDNEW
« no previous file with comments | « samples/ui_lib/layout/GridLayoutParams.dart ('k') | samples/ui_lib/layout/SizingFunctions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698