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

Side by Side Diff: samples/ui_lib/view/MeasureText.dart

Issue 10919146: Get rid of a lot of () for getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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/touch/TouchUtil.dart ('k') | samples/ui_lib/view/view.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 // TODO(jacobr): handle splitting lines on symbols such as '-' that aren't 5 // TODO(jacobr): handle splitting lines on symbols such as '-' that aren't
6 // whitespace but are valid word breaking points. 6 // whitespace but are valid word breaking points.
7 /** 7 /**
8 * Utility class to efficiently word break and measure text without requiring 8 * Utility class to efficiently word break and measure text without requiring
9 * access to the DOM. 9 * access to the DOM.
10 */ 10 */
(...skipping 20 matching lines...) Expand all
31 31
32 // TODO(jacobr): we are DOA for i18N... 32 // TODO(jacobr): we are DOA for i18N...
33 // the right solution is for the server to send us text perparsed into words 33 // the right solution is for the server to send us text perparsed into words
34 // perhaps even with hints on the guess for the correct breaks so on the 34 // perhaps even with hints on the guess for the correct breaks so on the
35 // client all we have to do is verify and fix errors rather than perform the 35 // client all we have to do is verify and fix errors rather than perform the
36 // full calculation. 36 // full calculation.
37 static bool isWhitespace(String character) { 37 static bool isWhitespace(String character) {
38 return character == ' ' || character == '\t' || character == '\n'; 38 return character == ' ' || character == '\t' || character == '\n';
39 } 39 }
40 40
41 num get typicalCharLength() { 41 num get typicalCharLength {
42 return _typicalCharLength; 42 return _typicalCharLength;
43 } 43 }
44 44
45 String quickTruncate(String text, num lineWidth, int maxLines) { 45 String quickTruncate(String text, num lineWidth, int maxLines) {
46 int targetLength = (lineWidth * maxLines / _typicalCharLength).toInt(); 46 int targetLength = (lineWidth * maxLines / _typicalCharLength).toInt();
47 // Advance to next word break point. 47 // Advance to next word break point.
48 while(targetLength < text.length && !isWhitespace(text[targetLength])) { 48 while(targetLength < text.length && !isWhitespace(text[targetLength])) {
49 targetLength++; 49 targetLength++;
50 } 50 }
51 51
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } else if (wordStartIndex === null && !whitespace) { 152 } else if (wordStartIndex === null && !whitespace) {
153 wordStartIndex = i; 153 wordStartIndex = i;
154 } 154 }
155 lastWhitespace = whitespace; 155 lastWhitespace = whitespace;
156 } 156 }
157 if (currentLength > 0) { 157 if (currentLength > 0) {
158 callback(startIndex, text.length, currentLength); 158 callback(startIndex, text.length, currentLength);
159 } 159 }
160 } 160 }
161 } 161 }
OLDNEW
« no previous file with comments | « samples/ui_lib/touch/TouchUtil.dart ('k') | samples/ui_lib/view/view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698