| OLD | NEW |
| 1 import 'dart:html'; | 1 import 'dart:html'; |
| 2 import 'dart:json' as 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. |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 // Strip tags we don't want | 604 // Strip tags we don't want |
| 605 for (Element e in fragment.queryAll("script, object, style")) { | 605 for (Element e in fragment.queryAll("script, object, style")) { |
| 606 e.remove(); | 606 e.remove(); |
| 607 } | 607 } |
| 608 | 608 |
| 609 // Extract idl | 609 // Extract idl |
| 610 final idl = new StringBuffer(); | 610 final idl = new StringBuffer(); |
| 611 if (prop != null && prop.length > 0) { | 611 if (prop != null && prop.length > 0) { |
| 612 // Only expect properties to have HTML. | 612 // Only expect properties to have HTML. |
| 613 for(Element e in fragment.queryAll(IDL_SELECTOR)) { | 613 for(Element e in fragment.queryAll(IDL_SELECTOR)) { |
| 614 idl.add(e.outerHTML); | 614 idl.write(e.outerHTML); |
| 615 e.remove(); | 615 e.remove(); |
| 616 } | 616 } |
| 617 // TODO(jacobr) this is a very basic regex to see if text looks like IDL | 617 // TODO(jacobr) this is a very basic regex to see if text looks like IDL |
| 618 RegExp likelyIdl = new RegExp(" $prop\\w*\\("); | 618 RegExp likelyIdl = new RegExp(" $prop\\w*\\("); |
| 619 | 619 |
| 620 for (Element e in fragment.queryAll("pre")) { | 620 for (Element e in fragment.queryAll("pre")) { |
| 621 // Check if it looks like idl... | 621 // Check if it looks like idl... |
| 622 String txt = e.text.trim(); | 622 String txt = e.text.trim(); |
| 623 if (likelyIdl.hasMatch(txt) && txt.contains("\n") && txt.contains(")")) { | 623 if (likelyIdl.hasMatch(txt) && txt.contains("\n") && txt.contains(")")) { |
| 624 idl.add(e.outerHTML); | 624 idl.write(e.outerHTML); |
| 625 e.remove(); | 625 e.remove(); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 return new SectionParseResult(genCleanHtml(fragment), url, idl.toString()); | 629 return new SectionParseResult(genCleanHtml(fragment), url, idl.toString()); |
| 630 } | 630 } |
| 631 | 631 |
| 632 /** | 632 /** |
| 633 * Find the best child element of [root] that appears to be an API definition | 633 * Find the best child element of [root] that appears to be an API definition |
| 634 * for [prop]. [allText] is a list of all text nodes under root computed by | 634 * for [prop]. [allText] is a list of all text nodes under root computed by |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 } | 1266 } |
| 1267 if (exampleHtml.length > 0) { | 1267 if (exampleHtml.length > 0) { |
| 1268 dbEntry['examples'] = exampleHtml; | 1268 dbEntry['examples'] = exampleHtml; |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 // Extract the class summary. | 1271 // Extract the class summary. |
| 1272 // Basically everything left over after the #Summary or #Description tag is | 1272 // Basically everything left over after the #Summary or #Description tag is |
| 1273 // safe to include in the summary. | 1273 // safe to include in the summary. |
| 1274 StringBuffer summary = new StringBuffer(); | 1274 StringBuffer summary = new StringBuffer(); |
| 1275 for (Element e in root.queryAll("#Summary, #Description")) { | 1275 for (Element e in root.queryAll("#Summary, #Description")) { |
| 1276 summary.add(filteredHtml(root, e, null, removeHeaders).html); | 1276 summary.write(filteredHtml(root, e, null, removeHeaders).html); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 if (summary.length == 0) { | 1279 if (summary.length == 0) { |
| 1280 // Remove the "Gecko DOM Reference text" | 1280 // Remove the "Gecko DOM Reference text" |
| 1281 Element ref = root.query(".lang.lang-en"); | 1281 Element ref = root.query(".lang.lang-en"); |
| 1282 if (ref != null) { | 1282 if (ref != null) { |
| 1283 ref = ref.parent; | 1283 ref = ref.parent; |
| 1284 String refText = ref.text.trim(); | 1284 String refText = ref.text.trim(); |
| 1285 if (refText == "Gecko DOM Reference" || | 1285 if (refText == "Gecko DOM Reference" || |
| 1286 refText == "« Gecko DOM Reference") { | 1286 refText == "« Gecko DOM Reference") { |
| 1287 ref.remove(); | 1287 ref.remove(); |
| 1288 } | 1288 } |
| 1289 } | 1289 } |
| 1290 // Risky... this might add stuff we shouldn't. | 1290 // Risky... this might add stuff we shouldn't. |
| 1291 summary.add(filteredHtml(root, root, null, removeHeaders).html); | 1291 summary.write(filteredHtml(root, root, null, removeHeaders).html); |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 if (summary.length > 0) { | 1294 if (summary.length > 0) { |
| 1295 dbEntry['summary'] = summary.toString(); | 1295 dbEntry['summary'] = summary.toString(); |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 // Inject CSS to aid debugging in the browser. | 1298 // Inject CSS to aid debugging in the browser. |
| 1299 // We could avoid doing this if we know we are not running in a browser.. | 1299 // We could avoid doing this if we know we are not running in a browser.. |
| 1300 document.head.nodes.add(new Element.html(DEBUG_CSS)); | 1300 document.head.nodes.add(new Element.html(DEBUG_CSS)); |
| 1301 | 1301 |
| 1302 onEnd(); | 1302 onEnd(); |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 void main() { | 1305 void main() { |
| 1306 window.on.load.add(documentLoaded); | 1306 window.on.load.add(documentLoaded); |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 void documentLoaded(event) { | 1309 void documentLoaded(event) { |
| 1310 // Load the database of expected methods and properties with an HttpRequest. | 1310 // Load the database of expected methods and properties with an HttpRequest. |
| 1311 new HttpRequest.get('${window.location}.json', (req) { | 1311 new HttpRequest.get('${window.location}.json', (req) { |
| 1312 data = json.parse(req.responseText); | 1312 data = json.parse(req.responseText); |
| 1313 dbEntry = {'members': [], 'srcUrl': pageUrl}; | 1313 dbEntry = {'members': [], 'srcUrl': pageUrl}; |
| 1314 run(); | 1314 run(); |
| 1315 }); | 1315 }); |
| 1316 } | 1316 } |
| OLD | NEW |