OLD | NEW |
1 #import ("dart:html"); | 1 #import ("dart:html"); |
2 #import ("dart:json"); | 2 #import ("dart: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 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 /** | 27 /** |
28 * CSS class that is added to elements in the DOM to indicate that they should | 28 * CSS class that is added to elements in the DOM to indicate that they should |
29 * be removed when extracting blocks of documentation. This is helpful when | 29 * be removed when extracting blocks of documentation. This is helpful when |
30 * running this script in a web browser as it is easy to visually see what | 30 * running this script in a web browser as it is easy to visually see what |
31 * blocks of information were extracted when using CSS such as DEBUG_CSS | 31 * blocks of information were extracted when using CSS such as DEBUG_CSS |
32 * which highlights elements that should be removed. | 32 * which highlights elements that should be removed. |
33 */ | 33 */ |
34 final DART_REMOVED = "dart-removed"; | 34 const DART_REMOVED = "dart-removed"; |
35 | 35 |
36 final DEBUG_CSS = """ | 36 const DEBUG_CSS = """ |
37 <style type="text/css"> | 37 <style type="text/css"> |
38 .dart-removed { | 38 .dart-removed { |
39 background-color: rgba(255, 0, 0, 0.5); | 39 background-color: rgba(255, 0, 0, 0.5); |
40 } | 40 } |
41 </style>"""; | 41 </style>"""; |
42 | 42 |
43 final MIN_PIXELS_DIFFERENT_LINES = 10; | 43 const MIN_PIXELS_DIFFERENT_LINES = 10; |
44 | 44 |
45 final IDL_SELECTOR = "pre.eval, pre.idl"; | 45 const IDL_SELECTOR = "pre.eval, pre.idl"; |
46 | 46 |
47 Map data; | 47 Map data; |
48 | 48 |
49 // TODO(rnystrom): Hack! Copied from domTypes.json. Instead of hard-coding | 49 // TODO(rnystrom): Hack! Copied from domTypes.json. Instead of hard-coding |
50 // these, should use the same mapping that the DOM/HTML code generators use. | 50 // these, should use the same mapping that the DOM/HTML code generators use. |
51 var domTypes; | 51 var domTypes; |
52 final domTypesRaw = const [ | 52 const domTypesRaw = const [ |
53 "AbstractWorker", "ArrayBuffer", "ArrayBufferView", "Attr", | 53 "AbstractWorker", "ArrayBuffer", "ArrayBufferView", "Attr", |
54 "AudioBuffer", "AudioBufferSourceNode", "AudioChannelMerger", | 54 "AudioBuffer", "AudioBufferSourceNode", "AudioChannelMerger", |
55 "AudioChannelSplitter", "AudioContext", "AudioDestinationNode", | 55 "AudioChannelSplitter", "AudioContext", "AudioDestinationNode", |
56 "AudioGain", "AudioGainNode", "AudioListener", "AudioNode", | 56 "AudioGain", "AudioGainNode", "AudioListener", "AudioNode", |
57 "AudioPannerNode", "AudioParam", "AudioProcessingEvent", | 57 "AudioPannerNode", "AudioParam", "AudioProcessingEvent", |
58 "AudioSourceNode", "BarInfo", "BeforeLoadEvent", "BiquadFilterNode", | 58 "AudioSourceNode", "BarInfo", "BeforeLoadEvent", "BiquadFilterNode", |
59 "Blob", "CDATASection", "CSSCharsetRule", "CSSFontFaceRule", | 59 "Blob", "CDATASection", "CSSCharsetRule", "CSSFontFaceRule", |
60 "CSSImportRule", "CSSMediaRule", "CSSPageRule", "CSSPrimitiveValue", | 60 "CSSImportRule", "CSSMediaRule", "CSSPageRule", "CSSPrimitiveValue", |
61 "CSSRule", "CSSRuleList", "CSSStyleDeclaration", "CSSStyleRule", | 61 "CSSRule", "CSSRuleList", "CSSStyleDeclaration", "CSSStyleRule", |
62 "CSSStyleSheet", "CSSUnknownRule", "CSSValue", "CSSValueList", | 62 "CSSStyleSheet", "CSSUnknownRule", "CSSValue", "CSSValueList", |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 } | 1114 } |
1115 | 1115 |
1116 // Flatten the list of known DOM types into a faster and case-insensitive | 1116 // Flatten the list of known DOM types into a faster and case-insensitive |
1117 // map. | 1117 // map. |
1118 domTypes = {}; | 1118 domTypes = {}; |
1119 for (final domType in domTypesRaw) { | 1119 for (final domType in domTypesRaw) { |
1120 domTypes[domType.toLowerCase()] = domType; | 1120 domTypes[domType.toLowerCase()] = domType; |
1121 } | 1121 } |
1122 | 1122 |
1123 // Fix up links. | 1123 // Fix up links. |
1124 final SHORT_LINK = const RegExp(@'^[\w/]+$'); | 1124 const SHORT_LINK = const RegExp(@'^[\w/]+$'); |
1125 final INNER_LINK = const RegExp(@'[Ee]n/(?:[\w/]+/|)([\w#.]+)(?:\(\))?$'); | 1125 const INNER_LINK = const RegExp(@'[Ee]n/(?:[\w/]+/|)([\w#.]+)(?:\(\))?$'); |
1126 final MEMBER_LINK = const RegExp(@'(\w+)[.#](\w+)'); | 1126 const MEMBER_LINK = const RegExp(@'(\w+)[.#](\w+)'); |
1127 final RELATIVE_LINK = const RegExp(@'^(?:../)*/?[Ee][Nn]/(.+)'); | 1127 const RELATIVE_LINK = const RegExp(@'^(?:../)*/?[Ee][Nn]/(.+)'); |
1128 | 1128 |
1129 // - Make relative links absolute. | 1129 // - Make relative links absolute. |
1130 // - If we can, take links that point to other MDN pages and retarget them | 1130 // - If we can, take links that point to other MDN pages and retarget them |
1131 // to appropriate pages in our docs. | 1131 // to appropriate pages in our docs. |
1132 // TODO(rnystrom): Add rel external to links we didn't fix. | 1132 // TODO(rnystrom): Add rel external to links we didn't fix. |
1133 for (AnchorElement a in document.queryAll('a')) { | 1133 for (AnchorElement a in document.queryAll('a')) { |
1134 // Get the raw attribute because we *don't* want the browser to fully- | 1134 // Get the raw attribute because we *don't* want the browser to fully- |
1135 // qualify the name for us since it has the wrong base address for the | 1135 // qualify the name for us since it has the wrong base address for the |
1136 // page. | 1136 // page. |
1137 var href = a.attributes['href']; | 1137 var href = a.attributes['href']; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 } | 1305 } |
1306 | 1306 |
1307 void documentLoaded(event) { | 1307 void documentLoaded(event) { |
1308 // Load the database of expected methods and properties with an HttpRequest. | 1308 // Load the database of expected methods and properties with an HttpRequest. |
1309 new HttpRequest.get('${window.location}.json', (req) { | 1309 new HttpRequest.get('${window.location}.json', (req) { |
1310 data = JSON.parse(req.responseText); | 1310 data = JSON.parse(req.responseText); |
1311 dbEntry = {'members': [], 'srcUrl': pageUrl}; | 1311 dbEntry = {'members': [], 'srcUrl': pageUrl}; |
1312 run(); | 1312 run(); |
1313 }); | 1313 }); |
1314 } | 1314 } |
OLD | NEW |