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

Side by Side Diff: pkg/third_party/html5lib/lib/src/inputstream.dart

Issue 421503004: Switch transformers over to source_span (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 library inputstream; 1 library inputstream;
2 2
3 import 'dart:collection'; 3 import 'dart:collection';
4 import 'package:utf/utf.dart'; 4 import 'package:utf/utf.dart';
5 import 'package:source_maps/span.dart' show SourceFile; 5 import 'package:source_span/source_span.dart';
6 import 'char_encodings.dart'; 6 import 'char_encodings.dart';
7 import 'constants.dart'; 7 import 'constants.dart';
8 import 'utils.dart'; 8 import 'utils.dart';
9 import 'encoding_parser.dart'; 9 import 'encoding_parser.dart';
10 10
11 /// Hooks to call into dart:io without directly referencing it. 11 /// Hooks to call into dart:io without directly referencing it.
12 class ConsoleSupport { 12 class ConsoleSupport {
13 List<int> bytesFromFile(source) => null; 13 List<int> bytesFromFile(source) => null;
14 } 14 }
15 15
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 c = NEWLINE; 128 c = NEWLINE;
129 } 129 }
130 130
131 _chars.add(c); 131 _chars.add(c);
132 if (c == NEWLINE) _lineStarts.add(_chars.length); 132 if (c == NEWLINE) _lineStarts.add(_chars.length);
133 } 133 }
134 134
135 // Free decoded characters if they aren't needed anymore. 135 // Free decoded characters if they aren't needed anymore.
136 if (_rawBytes != null) _rawChars = null; 136 if (_rawBytes != null) _rawChars = null;
137 137
138 fileInfo = new SourceFile(sourceUrl, _lineStarts, 138 fileInfo = new SourceFile.decoded(_chars, url: sourceUrl);
Siggi Cherem (dart-lang) 2014/07/29 20:56:32 could we do this maybe only when generateSpans is
nweiz 2014/07/29 21:13:17 Done.
nweiz 2014/07/30 00:25:53 It turns out this made a test fail, so I changed i
139 generateSpans ? _chars : null);
140 } 139 }
141 140
142 141
143 void detectEncoding([bool parseMeta = true]) { 142 void detectEncoding([bool parseMeta = true]) {
144 // First look for a BOM 143 // First look for a BOM
145 // This will also read past the BOM if present 144 // This will also read past the BOM if present
146 charEncodingName = detectBOM(); 145 charEncodingName = detectBOM();
147 charEncodingCertain = true; 146 charEncodingCertain = true;
148 147
149 // If there is no BOM need to look for meta elements with encoding 148 // If there is no BOM need to look for meta elements with encoding
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 /// Return the python codec name corresponding to an encoding or null if the 284 /// Return the python codec name corresponding to an encoding or null if the
286 /// string doesn't correspond to a valid encoding. 285 /// string doesn't correspond to a valid encoding.
287 String codecName(String encoding) { 286 String codecName(String encoding) {
288 final asciiPunctuation = new RegExp( 287 final asciiPunctuation = new RegExp(
289 "[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]"); 288 "[\u0009-\u000D\u0020-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E]");
290 289
291 if (encoding == null) return null; 290 if (encoding == null) return null;
292 var canonicalName = encoding.replaceAll(asciiPunctuation, '').toLowerCase(); 291 var canonicalName = encoding.replaceAll(asciiPunctuation, '').toLowerCase();
293 return encodings[canonicalName]; 292 return encodings[canonicalName];
294 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698