Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright (C) 2008-2011 Google Inc. | 1 // Copyright (C) 2008-2011 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 19 matching lines...) Expand all Loading... | |
30 var ELEMENT_DOM_INTERFACES = html4.ELEMENT_DOM_INTERFACES; | 30 var ELEMENT_DOM_INTERFACES = html4.ELEMENT_DOM_INTERFACES; |
31 var ATTRIBS = html4.ATTRIBS; | 31 var ATTRIBS = html4.ATTRIBS; |
32 var URIEFFECTS = html4.URIEFFECTS; | 32 var URIEFFECTS = html4.URIEFFECTS; |
33 var LOADERTYPES = html4.LOADERTYPES; | 33 var LOADERTYPES = html4.LOADERTYPES; |
34 var OPTIONAL_ENDTAG = html4.eflags.OPTIONAL_ENDTAG; | 34 var OPTIONAL_ENDTAG = html4.eflags.OPTIONAL_ENDTAG; |
35 var EMPTY = html4.eflags.EMPTY; | 35 var EMPTY = html4.eflags.EMPTY; |
36 var CDATA = html4.eflags.CDATA; | 36 var CDATA = html4.eflags.CDATA; |
37 var RCDATA = html4.eflags.RCDATA; | 37 var RCDATA = html4.eflags.RCDATA; |
38 var UNSAFE = html4.eflags.UNSAFE; | 38 var UNSAFE = html4.eflags.UNSAFE; |
39 var VIRTUALIZED = html4.eflags.VIRTUALIZED; | 39 var VIRTUALIZED = html4.eflags.VIRTUALIZED; |
40 var defaultInterface = "HTMLElement"; | 40 var unknownElementInterface = "HTMLUnknownElement"; |
41 | |
42 var hop = Object.prototype.hasOwnProperty; | |
41 | 43 |
42 var elemCache = {}; | 44 var elemCache = {}; |
43 var attrCache = {}; | 45 var attrCache = {}; |
46 var scriptInterfacesCache; | |
44 | 47 |
45 var unknownElementEntry = cajaVM.def({ | 48 var unknownElementEntry = cajaVM.def({ |
46 allowed: false, | 49 allowed: false, |
47 isVirtualizedElementName: false, | 50 isVirtualizedElementName: false, |
48 shouldVirtualize: true, | 51 shouldVirtualize: true, |
49 empty: false, | 52 empty: false, |
50 optionalEndTag: false, | 53 optionalEndTag: false, |
51 contentIsCDATA: false, | 54 contentIsCDATA: false, |
52 contentIsRCDATA: false, | 55 contentIsRCDATA: false, |
53 domInterface: defaultInterface | 56 domInterface: unknownElementInterface |
54 }); | 57 }); |
55 | 58 |
56 var unknownAttributeEntry = cajaVM.def({ | 59 var unknownAttributeEntry = cajaVM.def({ |
57 type: undefined, | 60 type: undefined, |
58 loaderType: undefined, | 61 loaderType: undefined, |
59 uriEffect: undefined | 62 uriEffect: undefined |
60 }); | 63 }); |
61 | 64 |
62 function makeAttributeFromSchema(attribKey) { | 65 function makeAttributeFromSchema(attribKey) { |
63 return cajaVM.def({ | 66 return cajaVM.def({ |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 } else { | 159 } else { |
157 entry = unknownAttributeEntry; | 160 entry = unknownAttributeEntry; |
158 } | 161 } |
159 } | 162 } |
160 return attrCache[attribKey] = entry; | 163 return attrCache[attribKey] = entry; |
161 } | 164 } |
162 }, | 165 }, |
163 | 166 |
164 isVirtualizedElementName: isVirtualizedElementName, | 167 isVirtualizedElementName: isVirtualizedElementName, |
165 realToVirtualElementName: realToVirtualElementName, | 168 realToVirtualElementName: realToVirtualElementName, |
166 virtualToRealElementName: virtualToRealElementName | 169 virtualToRealElementName: virtualToRealElementName, |
170 | |
171 getAllKnownScriptInterfaces: function() { | |
172 if (!scriptInterfacesCache) { | |
173 var table = {}; | |
174 for (var el in ELEMENT_DOM_INTERFACES) { | |
175 if (hop.call(ELEMENT_DOM_INTERFACES, el)) { | |
176 table[ELEMENT_DOM_INTERFACES[el]] = true; | |
Jasvir
2012/11/13 17:58:08
Note - it's safe to use object as a dictionary her
kpreid2
2012/11/13 18:14:10
I'm not sure which object (ELEMENT_DOM_INTERFACES
| |
177 } | |
178 } | |
179 scriptInterfacesCache = cajaVM.def(Object.getOwnPropertyNames(table)); | |
Jasvir
2012/11/13 17:58:08
Double check - this file gets run cajoled (in whic
kpreid2
2012/11/13 18:14:10
Yes. This is part of the bundle which includes Dom
| |
180 } | |
181 return scriptInterfacesCache; | |
182 } | |
167 }); | 183 }); |
168 | 184 |
169 return htmlSchema; | 185 return htmlSchema; |
170 } | 186 } |
171 | 187 |
172 return HtmlSchema; | 188 return HtmlSchema; |
173 })(); | 189 })(); |
174 | 190 |
175 // TODO(kpreid): Refactor this into parameters. | 191 // TODO(kpreid): Refactor this into parameters. |
176 var htmlSchema = new HtmlSchema(html4); | 192 var htmlSchema = new HtmlSchema(html4); |
177 | 193 |
178 // Exports for closure compiler. | 194 // Exports for closure compiler. |
179 if (typeof window !== 'undefined') { | 195 if (typeof window !== 'undefined') { |
180 window['HtmlSchema'] = HtmlSchema; | 196 window['HtmlSchema'] = HtmlSchema; |
181 window['htmlSchema'] = htmlSchema; | 197 window['htmlSchema'] = htmlSchema; |
182 } | 198 } |
183 | 199 |
LEFT | RIGHT |