| OLD | NEW |
| 1 import 'dart:html'; | 1 import 'dart:html'; |
| 2 import 'dart:json'; | 2 import 'dart:json' as json; |
| 3 | 3 |
| 4 // Workaround for HTML lib missing feature. | 4 // Workaround for HTML lib missing feature. |
| 5 Range newRange() { | 5 Range newRange() { |
| 6 return document.createRange(); | 6 return document.createRange(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 // Temporary range object to optimize performance computing client rects | 9 // Temporary range object to optimize performance computing client rects |
| 10 // from text nodes. | 10 // from text nodes. |
| 11 Range _tempRange; | 11 Range _tempRange; |
| 12 // Hacks because ASYNC measurement is annoying when just writing a script. | 12 // Hacks because ASYNC measurement is annoying when just writing a script. |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return true; | 334 return true; |
| 335 } | 335 } |
| 336 | 336 |
| 337 bool isSkippable(Node n) { | 337 bool isSkippable(Node n) { |
| 338 if (!isSkippableType(n)) return false; | 338 if (!isSkippableType(n)) return false; |
| 339 return n.text.trim().length == 0; | 339 return n.text.trim().length == 0; |
| 340 } | 340 } |
| 341 | 341 |
| 342 void onEnd() { | 342 void onEnd() { |
| 343 // Hideous hack to send JSON back to JS. | 343 // Hideous hack to send JSON back to JS. |
| 344 String dbJson = JSON.stringify(dbEntry); | 344 String dbJson = json.stringify(dbEntry); |
| 345 // workaround bug in JSON parser. | 345 // workaround bug in json.parse. |
| 346 dbJson = dbJson.replaceAll("ZDARTIUMDOESNTESCAPESLASHNJXXXX", "\\n"); | 346 dbJson = dbJson.replaceAll("ZDARTIUMDOESNTESCAPESLASHNJXXXX", "\\n"); |
| 347 | 347 |
| 348 // Use postMessage to end the JSON to JavaScript. TODO(jacobr): use a simple | 348 // Use postMessage to end the JSON to JavaScript. TODO(jacobr): use a simple |
| 349 // isolate based Dart-JS interop solution in the future. | 349 // isolate based Dart-JS interop solution in the future. |
| 350 window.postMessage("START_DART_MESSAGE_UNIQUE_IDENTIFIER$dbJson", "*"); | 350 window.postMessage("START_DART_MESSAGE_UNIQUE_IDENTIFIER$dbJson", "*"); |
| 351 } | 351 } |
| 352 | 352 |
| 353 class SectionParseResult { | 353 class SectionParseResult { |
| 354 final String html; | 354 final String html; |
| 355 final String url; | 355 final String url; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 442 } |
| 443 | 443 |
| 444 String genPrettyHtmlFromElement(Element e) { | 444 String genPrettyHtmlFromElement(Element e) { |
| 445 e = e.clone(true); | 445 e = e.clone(true); |
| 446 return genCleanHtml(e); | 446 return genCleanHtml(e); |
| 447 } | 447 } |
| 448 | 448 |
| 449 class PostOrderTraversalIterator implements Iterator<Node> { | 449 class PostOrderTraversalIterator implements Iterator<Node> { |
| 450 | 450 |
| 451 Node _next; | 451 Node _next; |
| 452 Node _current; |
| 452 | 453 |
| 453 PostOrderTraversalIterator(Node start) { | 454 PostOrderTraversalIterator(Node start) { |
| 454 _next = _leftMostDescendent(start); | 455 _next = _leftMostDescendent(start); |
| 455 } | 456 } |
| 456 | 457 |
| 458 Node get current => _current; |
| 457 bool get hasNext => _next != null; | 459 bool get hasNext => _next != null; |
| 458 | 460 |
| 459 Node next() { | 461 bool moveNext() { |
| 460 if (_next == null) return null; | 462 _current = _next; |
| 461 final ret = _next; | 463 if (_next == null) return false; |
| 462 if (_next.nextNode != null) { | 464 if (_next.nextNode != null) { |
| 463 _next = _leftMostDescendent(_next.nextNode); | 465 _next = _leftMostDescendent(_next.nextNode); |
| 464 } else { | 466 } else { |
| 465 _next = _next.parent; | 467 _next = _next.parent; |
| 466 } | 468 } |
| 467 return ret; | 469 return true; |
| 468 } | 470 } |
| 469 | 471 |
| 470 static Node _leftMostDescendent(Node n) { | 472 static Node _leftMostDescendent(Node n) { |
| 471 while (n.nodes.length > 0) { | 473 while (n.nodes.length > 0) { |
| 472 n = n.nodes.first; | 474 n = n.nodes.first; |
| 473 } | 475 } |
| 474 return n; | 476 return n; |
| 475 } | 477 } |
| 476 } | 478 } |
| 477 | 479 |
| 478 class PostOrderTraversal implements Iterable<Node> { | 480 class PostOrderTraversal extends Iterable<Node> { |
| 479 final Node _node; | 481 final Node _node; |
| 480 PostOrderTraversal(this._node); | 482 PostOrderTraversal(this._node); |
| 481 | 483 |
| 482 Iterator<Node> iterator() => new PostOrderTraversalIterator(_node); | 484 Iterator<Node> get iterator => new PostOrderTraversalIterator(_node); |
| 483 } | 485 } |
| 484 | 486 |
| 485 /** | 487 /** |
| 486 * Estimate what content represents the first line of text within the [section] | 488 * Estimate what content represents the first line of text within the [section] |
| 487 * range returning null if there isn't a plausible first line of text that | 489 * range returning null if there isn't a plausible first line of text that |
| 488 * contains the string [prop]. We measure the actual rendered client rectangle | 490 * contains the string [prop]. We measure the actual rendered client rectangle |
| 489 * for the text and use heuristics defining how many pixels text can vary by | 491 * for the text and use heuristics defining how many pixels text can vary by |
| 490 * and still be viewed as being on the same line. | 492 * and still be viewed as being on the same line. |
| 491 */ | 493 */ |
| 492 Range findFirstLine(Range section, String prop) { | 494 Range findFirstLine(Range section, String prop) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 final txt = r.text.trim().split(" ")[0].toLowerCase(); | 741 final txt = r.text.trim().split(" ")[0].toLowerCase(); |
| 740 if (txt == "description") { | 742 if (txt == "description") { |
| 741 helpIndex = i; | 743 helpIndex = i; |
| 742 break; | 744 break; |
| 743 } | 745 } |
| 744 i++; | 746 i++; |
| 745 } | 747 } |
| 746 | 748 |
| 747 // Figure out which column in the table contains member names by | 749 // Figure out which column in the table contains member names by |
| 748 // tracking how many member names each column contains. | 750 // tracking how many member names each column contains. |
| 749 final numMatches = new List<int>(i); | 751 final numMatches = new List<int>.fixedLength(i); |
| 750 for (int j = 0; j < i; j++) { | 752 for (int j = 0; j < i; j++) { |
| 751 numMatches[j] = 0; | 753 numMatches[j] = 0; |
| 752 } | 754 } |
| 753 | 755 |
| 754 // Find the column that seems to have the most names that look like | 756 // Find the column that seems to have the most names that look like |
| 755 // expected properties. | 757 // expected properties. |
| 756 for (Element r in t.queryAll("tbody tr")) { | 758 for (Element r in t.queryAll("tbody tr")) { |
| 757 ElementList row = r.elements; | 759 ElementList row = r.elements; |
| 758 if (row.length == 0 || row.first.classes.contains(".header")) { | 760 if (row.length == 0 || row.first.classes.contains(".header")) { |
| 759 continue; | 761 continue; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 if (e is Element) { | 956 if (e is Element) { |
| 955 e.classes.add(DART_REMOVED); | 957 e.classes.add(DART_REMOVED); |
| 956 } else { | 958 } else { |
| 957 for (Element el in e) { | 959 for (Element el in e) { |
| 958 el.classes.add(DART_REMOVED); | 960 el.classes.add(DART_REMOVED); |
| 959 } | 961 } |
| 960 } | 962 } |
| 961 } | 963 } |
| 962 } | 964 } |
| 963 | 965 |
| 964 // TODO(jacobr): remove this when the dartium JSON parser handles \n correctly. | 966 // TODO(jacobr): remove this when the dartium JSON parse handles \n correctly. |
| 965 String JSONFIXUPHACK(String value) { | 967 String JSONFIXUPHACK(String value) { |
| 966 return value.replaceAll("\n", "ZDARTIUMDOESNTESCAPESLASHNJXXXX"); | 968 return value.replaceAll("\n", "ZDARTIUMDOESNTESCAPESLASHNJXXXX"); |
| 967 } | 969 } |
| 968 | 970 |
| 969 String mozToWebkit(String name) { | 971 String mozToWebkit(String name) { |
| 970 return name.replaceFirst(new RegExp("^moz"), "webkit"); | 972 return name.replaceFirst(new RegExp("^moz"), "webkit"); |
| 971 } | 973 } |
| 972 | 974 |
| 973 String stripWebkit(String name) { | 975 String stripWebkit(String name) { |
| 974 return trimPrefix(name, "webkit"); | 976 return trimPrefix(name, "webkit"); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1300 onEnd(); | 1302 onEnd(); |
| 1301 } | 1303 } |
| 1302 | 1304 |
| 1303 void main() { | 1305 void main() { |
| 1304 window.on.load.add(documentLoaded); | 1306 window.on.load.add(documentLoaded); |
| 1305 } | 1307 } |
| 1306 | 1308 |
| 1307 void documentLoaded(event) { | 1309 void documentLoaded(event) { |
| 1308 // Load the database of expected methods and properties with an HttpRequest. | 1310 // Load the database of expected methods and properties with an HttpRequest. |
| 1309 new HttpRequest.get('${window.location}.json', (req) { | 1311 new HttpRequest.get('${window.location}.json', (req) { |
| 1310 data = JSON.parse(req.responseText); | 1312 data = json.parse(req.responseText); |
| 1311 dbEntry = {'members': [], 'srcUrl': pageUrl}; | 1313 dbEntry = {'members': [], 'srcUrl': pageUrl}; |
| 1312 run(); | 1314 run(); |
| 1313 }); | 1315 }); |
| 1314 } | 1316 } |
| OLD | NEW |