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

Side by Side Diff: samples/tests/samples/lib/layout/grid_layout_demo.dart

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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/swarm/Views.dart ('k') | samples/tests/samples/lib/layout/layout_test.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 /** 5 /**
6 * An app for testing the grid layout system. 6 * An app for testing the grid layout system.
7 */ 7 */
8 8
9 /** Creates a grid view structure given the CSS styles. */ 9 /** Creates a grid view structure given the CSS styles. */
10 View createGrid(Map<String, Map<String, String>> styles) { 10 View createGrid(Map<String, Map<String, String>> styles) {
11 final gridStyle = styles['#grid']; 11 final gridStyle = styles['#grid'];
12 12
13 final children = new List<MockView>(); 13 final children = new List<MockView>();
14 for (final String id in styles.getKeys()) { 14 for (final String id in styles.keys) {
15 // All selectors in this test are id selectors string the # prefix. 15 // All selectors in this test are id selectors string the # prefix.
16 assert(id.startsWith('#')); 16 assert(id.startsWith('#'));
17 String elemId = id.substring(1); 17 String elemId = id.substring(1);
18 if (elemId != 'grid') { 18 if (elemId != 'grid') {
19 children.add(new MockView(elemId, styles[id])); 19 children.add(new MockView(elemId, styles[id]));
20 } 20 }
21 } 21 }
22 22
23 return new MockCompositeView('grid', gridStyle, children); 23 return new MockCompositeView('grid', gridStyle, children);
24 } 24 }
25 25
26 void _onLoad() { 26 void _onLoad() {
27 var query = Uri.parseQuery(window.location.search)['q']; 27 var query = Uri.parseQuery(window.location.search)['q'];
28 if (query != null && query.length == 1) { 28 if (query != null && query.length == 1) {
29 query = Uri.decodeComponent(query[0]); 29 query = Uri.decodeComponent(query[0]);
30 addGridStyles('100%', '100%', 'margin:0px;'); 30 addGridStyles('100%', '100%', 'margin:0px;');
31 final view = createGrid(GridExamples.styles[query]); 31 final view = createGrid(GridExamples.styles[query]);
32 view.addToDocument(document.body); 32 view.addToDocument(document.body);
33 _addColorStyles(); 33 _addColorStyles();
34 printMetrics(query); 34 printMetrics(query);
35 } else { 35 } else {
36 final html = new StringBuffer(); 36 final html = new StringBuffer();
37 for (String ex in GridExamples.styles.getKeys()) { 37 for (String ex in GridExamples.styles.keys) {
38 html.add('<div><a href="?q=$ex">Grid Example $ex</a></div>'); 38 html.add('<div><a href="?q=$ex">Grid Example $ex</a></div>');
39 } 39 }
40 document.body.innerHTML = html.toString(); 40 document.body.innerHTML = html.toString();
41 } 41 }
42 } 42 }
43 43
44 void addGridStyles(String width, String height, [String margin = '']) { 44 void addGridStyles(String width, String height, [String margin = '']) {
45 // Use monospace font and fixed line-height so the text size is predictable. 45 // Use monospace font and fixed line-height so the text size is predictable.
46 // TODO(jmesserly): only tested on Chromium Mac/Linux 46 // TODO(jmesserly): only tested on Chromium Mac/Linux
47 Dom.addStyle(''' 47 Dom.addStyle('''
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 void _appendMetrics(StringBuffer sb, Element node, ElementRect rect, 125 void _appendMetrics(StringBuffer sb, Element node, ElementRect rect,
126 [String indent = '']) { 126 [String indent = '']) {
127 String id = node.id; 127 String id = node.id;
128 final offset = rect.offset; 128 final offset = rect.offset;
129 num left = offset.left, top = offset.top; 129 num left = offset.left, top = offset.top;
130 num width = offset.width, height = offset.height; 130 num width = offset.width, height = offset.height;
131 sb.add("${indent}'$id': [$left, $top, $width, $height],\n"); 131 sb.add("${indent}'$id': [$left, $top, $width, $height],\n");
132 } 132 }
OLDNEW
« no previous file with comments | « samples/swarm/Views.dart ('k') | samples/tests/samples/lib/layout/layout_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698