| OLD | NEW |
| 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 webdriver; | 5 part of webdriver; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A simple base64 decoder class, used to decode web browser screenshots | 8 * A simple base64 decoder class, used to decode web browser screenshots |
| 9 * returned by WebDriver. | 9 * returned by WebDriver. |
| 10 */ | 10 */ |
| 11 class Base64Decoder { | 11 class Base64Decoder { |
| 12 | 12 |
| 13 static int getVal(String s, pos) { | 13 static int getVal(String s, pos) { |
| 14 int code = s.charCodeAt(pos); | 14 int code = s.codeUnitAt(pos); |
| 15 if (code >= 65 && code < (65+26)) { // 'A'..'Z' | 15 if (code >= 65 && code < (65+26)) { // 'A'..'Z' |
| 16 return code - 65; | 16 return code - 65; |
| 17 } else if (code >= 97 && code < (97+26)) { // 'a'..'z' | 17 } else if (code >= 97 && code < (97+26)) { // 'a'..'z' |
| 18 return code - 97 + 26; | 18 return code - 97 + 26; |
| 19 } else if (code >= 48 && code < (48+10)) { // '0'..'9' | 19 } else if (code >= 48 && code < (48+10)) { // '0'..'9' |
| 20 return code - 48 + 52; | 20 return code - 48 + 52; |
| 21 } else if (code == 43) { // '+' | 21 } else if (code == 43) { // '+' |
| 22 return 62; | 22 return 62; |
| 23 } else if (code == 47) { // '/' | 23 } else if (code == 47) { // '/' |
| 24 return 63; | 24 return 63; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 (getVal(s, pos + 2) << 6) | getVal(s, pos+3); | 46 (getVal(s, pos + 2) << 6) | getVal(s, pos+3); |
| 47 pos += 4; | 47 pos += 4; |
| 48 rtn.add((v >> 16 ) & 0xff); | 48 rtn.add((v >> 16 ) & 0xff); |
| 49 rtn.add((v >> 8) & 0xff); | 49 rtn.add((v >> 8) & 0xff); |
| 50 rtn.add(v & 0xff); | 50 rtn.add(v & 0xff); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 return rtn; | 53 return rtn; |
| 54 } | 54 } |
| 55 } | 55 } |
| OLD | NEW |