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

Side by Side Diff: utils/apidoc/mdn/extract.dart

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 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
OLDNEW
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 import "dart:collection"; 5 import "dart:collection";
6 import 'dart:convert';
6 import 'dart:html'; 7 import 'dart:html';
7 import 'dart:json' as json;
8 8
9 // Workaround for HTML lib missing feature. 9 // Workaround for HTML lib missing feature.
10 Range newRange() { 10 Range newRange() {
11 return document.createRange(); 11 return document.createRange();
12 } 12 }
13 13
14 // Temporary range object to optimize performance computing client rects 14 // Temporary range object to optimize performance computing client rects
15 // from text nodes. 15 // from text nodes.
16 Range _tempRange; 16 Range _tempRange;
17 // Hacks because ASYNC measurement is annoying when just writing a script. 17 // Hacks because ASYNC measurement is annoying when just writing a script.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return true; 339 return true;
340 } 340 }
341 341
342 bool isSkippable(Node n) { 342 bool isSkippable(Node n) {
343 if (!isSkippableType(n)) return false; 343 if (!isSkippableType(n)) return false;
344 return n.text.trim().length == 0; 344 return n.text.trim().length == 0;
345 } 345 }
346 346
347 void onEnd() { 347 void onEnd() {
348 // Hideous hack to send JSON back to JS. 348 // Hideous hack to send JSON back to JS.
349 String dbJson = json.stringify(dbEntry); 349 String dbJson = JSON.encode(dbEntry);
350 // workaround bug in json.parse. 350 // workaround bug in JSON.decode.
351 dbJson = dbJson.replaceAll("ZDARTIUMDOESNTESCAPESLASHNJXXXX", "\\n"); 351 dbJson = dbJson.replaceAll("ZDARTIUMDOESNTESCAPESLASHNJXXXX", "\\n");
352 352
353 // Use postMessage to end the JSON to JavaScript. TODO(jacobr): use a simple 353 // Use postMessage to end the JSON to JavaScript. TODO(jacobr): use a simple
354 // isolate based Dart-JS interop solution in the future. 354 // isolate based Dart-JS interop solution in the future.
355 window.postMessage("START_DART_MESSAGE_UNIQUE_IDENTIFIER$dbJson", "*"); 355 window.postMessage("START_DART_MESSAGE_UNIQUE_IDENTIFIER$dbJson", "*");
356 } 356 }
357 357
358 class SectionParseResult { 358 class SectionParseResult {
359 final String html; 359 final String html;
360 final String url; 360 final String url;
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 onEnd(); 1307 onEnd();
1308 } 1308 }
1309 1309
1310 void main() { 1310 void main() {
1311 window.on.load.add(documentLoaded); 1311 window.on.load.add(documentLoaded);
1312 } 1312 }
1313 1313
1314 void documentLoaded(event) { 1314 void documentLoaded(event) {
1315 // Load the database of expected methods and properties with an HttpRequest. 1315 // Load the database of expected methods and properties with an HttpRequest.
1316 new HttpRequest.get('${window.location}.json', (req) { 1316 new HttpRequest.get('${window.location}.json', (req) {
1317 data = json.parse(req.responseText); 1317 data = JSON.decode(req.responseText);
1318 dbEntry = {'members': [], 'srcUrl': pageUrl}; 1318 dbEntry = {'members': [], 'srcUrl': pageUrl};
1319 run(); 1319 run();
1320 }); 1320 });
1321 } 1321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698