Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 intl; | |
| 6 | |
| 5 /** | 7 /** |
| 6 * Bidi stands for Bi-directional text. | 8 * Bidi stands for Bi-directional text. |
| 7 * According to http://en.wikipedia.org/wiki/Bi-directional_text: | 9 * According to http://en.wikipedia.org/wiki/Bi-directional_text: |
| 8 * Bi-directional text is text containing text in both text directionalities, | 10 * Bi-directional text is text containing text in both text directionalities, |
| 9 * both right-to-left (RTL) and left-to-right (LTR). It generally involves text | 11 * both right-to-left (RTL) and left-to-right (LTR). It generally involves text |
| 10 * containing different types of alphabets, but may also refer to boustrophedon, | 12 * containing different types of alphabets, but may also refer to boustrophedon, |
| 11 * which is changing text directionality in each row. | 13 * which is changing text directionality in each row. |
| 12 * | 14 * |
| 13 * This file provides some utility classes for determining directionality of | 15 * This file provides some utility classes for determining directionality of |
| 14 * text, switching CSS layout from LTR to RTL, and other normalizing utilities | 16 * text, switching CSS layout from LTR to RTL, and other normalizing utilities |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 | 352 |
| 351 /** | 353 /** |
| 352 * Find the first index in [str] of the first closing parenthesis that does | 354 * Find the first index in [str] of the first closing parenthesis that does |
| 353 * not match an opening parenthesis. | 355 * not match an opening parenthesis. |
| 354 */ | 356 */ |
| 355 static int _unmatchedParenIndex(String str) { | 357 static int _unmatchedParenIndex(String str) { |
| 356 int sum = 0; | 358 int sum = 0; |
| 357 int index = 0; | 359 int index = 0; |
| 358 while (sum >= 0 || index > str.length) { | 360 while (sum >= 0 || index > str.length) { |
| 359 int char = str.charCodeAt(index); | 361 int char = str.charCodeAt(index); |
| 360 if (char == '('.charCodeAt(0)) sum++; | 362 if (char == '('.charCodeAt(0)) { sum++; |
|
Emily Fortuna
2012/10/31 20:17:32
adding brackets here while sum++ is still on the s
Alan Knight
2012/10/31 21:31:59
Interesting. That's something the tool must have d
scheglov
2012/11/01 03:23:27
You probably have some clean ups on "Style" page a
| |
| 361 else if (char == ')'.charCodeAt(0)) sum--; | 363 } else if (char == ')'.charCodeAt(0)) sum--; |
| 362 index++; | 364 index++; |
| 363 } | 365 } |
| 364 return index; | 366 return index; |
| 365 } | 367 } |
| 366 | 368 |
| 367 /** | 369 /** |
| 368 * Replace the double and single quote directly after a Hebrew character in | 370 * Replace the double and single quote directly after a Hebrew character in |
| 369 * [str] with GERESH and GERSHAYIM. This is most likely the user's intention. | 371 * [str] with GERESH and GERSHAYIM. This is most likely the user's intention. |
| 370 */ | 372 */ |
| 371 static String normalizeHebrewQuote(String str) { | 373 static String normalizeHebrewQuote(String str) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 391 | 393 |
| 392 /** | 394 /** |
| 393 * Check the estimated directionality of [str], return true if the piece of | 395 * Check the estimated directionality of [str], return true if the piece of |
| 394 * text should be laid out in RTL direction. If [isHtml] is true, the string | 396 * text should be laid out in RTL direction. If [isHtml] is true, the string |
| 395 * is HTML or HTML-escaped. | 397 * is HTML or HTML-escaped. |
| 396 */ | 398 */ |
| 397 static bool detectRtlDirectionality(String str, {bool isHtml: false}) { | 399 static bool detectRtlDirectionality(String str, {bool isHtml: false}) { |
| 398 return estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL; | 400 return estimateDirectionOfText(str, isHtml: isHtml) == TextDirection.RTL; |
| 399 } | 401 } |
| 400 } | 402 } |
| OLD | NEW |