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

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

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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) 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 part of layout_tests; 5 part of layout_tests;
6 6
7 /** 7 /**
8 * An app for testing the grid layout system. 8 * An app for testing the grid layout system.
9 */ 9 */
10 10
(...skipping 19 matching lines...) Expand all
30 if (query != null && query.length == 1) { 30 if (query != null && query.length == 1) {
31 query = Uri.decodeComponent(query[0]); 31 query = Uri.decodeComponent(query[0]);
32 addGridStyles('100%', '100%', 'margin:0px;'); 32 addGridStyles('100%', '100%', 'margin:0px;');
33 final view = createGrid(GridExamples.styles[query]); 33 final view = createGrid(GridExamples.styles[query]);
34 view.addToDocument(document.body); 34 view.addToDocument(document.body);
35 _addColorStyles(); 35 _addColorStyles();
36 printMetrics(query); 36 printMetrics(query);
37 } else { 37 } else {
38 final html = new StringBuffer(); 38 final html = new StringBuffer();
39 for (String ex in GridExamples.styles.keys) { 39 for (String ex in GridExamples.styles.keys) {
40 html.add('<div><a href="?q=$ex">Grid Example $ex</a></div>'); 40 html.write('<div><a href="?q=$ex">Grid Example $ex</a></div>');
41 } 41 }
42 document.body.innerHTML = html.toString(); 42 document.body.innerHTML = html.toString();
43 } 43 }
44 } 44 }
45 45
46 void addGridStyles(String width, String height, [String margin = '']) { 46 void addGridStyles(String width, String height, [String margin = '']) {
47 // Use monospace font and fixed line-height so the text size is predictable. 47 // Use monospace font and fixed line-height so the text size is predictable.
48 // TODO(jmesserly): only tested on Chromium Mac/Linux 48 // TODO(jmesserly): only tested on Chromium Mac/Linux
49 Dom.addStyle(''' 49 Dom.addStyle('''
50 body { $margin } 50 body { $margin }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // TODO(jmesserly): this is needed to get horizontal content-sizing to work 99 // TODO(jmesserly): this is needed to get horizontal content-sizing to work
100 node.style.display = 'inline-block'; 100 node.style.display = 'inline-block';
101 } 101 }
102 } 102 }
103 103
104 104
105 void printMetrics(String example) { 105 void printMetrics(String example) {
106 final node = document.body.query('#grid'); 106 final node = document.body.query('#grid');
107 String exampleId = example.split(' ')[0]; 107 String exampleId = example.split(' ')[0];
108 final sb = new StringBuffer(); 108 final sb = new StringBuffer();
109 sb.add("test('Spec Example $exampleId', () {\n"); 109 sb.write("test('Spec Example $exampleId', () {\n");
110 sb.add(" verifyExample('$example', {\n"); 110 sb.write(" verifyExample('$example', {\n");
111 final children = node.children; 111 final children = node.children;
112 112
113 window.setImmediate(() { 113 window.setImmediate(() {
114 for (int i = 0; i < children.length; i++) { 114 for (int i = 0; i < children.length; i++) {
115 _appendMetrics(sb, children[i], ' '); 115 _appendMetrics(sb, children[i], ' ');
116 } 116 }
117 sb.add(' });\n'); 117 sb.write(' });\n');
118 sb.add('});\n\n'); 118 sb.write('});\n\n');
119 window.console.log(sb.toString()); 119 window.console.log(sb.toString());
120 }); 120 });
121 } 121 }
122 122
123 void _appendMetrics(StringBuffer sb, Element node, [String indent = '']) { 123 void _appendMetrics(StringBuffer sb, Element node, [String indent = '']) {
124 String id = node.id; 124 String id = node.id;
125 num left = node.offsetLeft, top = node.offsetTop; 125 num left = node.offsetLeft, top = node.offsetTop;
126 num width = node.offsetWidth, height = node.offsetHeight; 126 num width = node.offsetWidth, height = node.offsetHeight;
127 sb.add("${indent}'$id': [$left, $top, $width, $height],\n"); 127 sb.write("${indent}'$id': [$left, $top, $width, $height],\n");
128 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698