1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 sw=2 et tw=78: */
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is mozilla.org code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 2000
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Johnny Stenback <jst@netscape.com> (original author)
25 : * Ms2ger <ms2ger@gmail.com>
26 : *
27 : * Alternatively, the contents of this file may be used under the terms of
28 : * either of the GNU General Public License Version 2 or later (the "GPL"),
29 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 : * in which case the provisions of the GPL or the LGPL are applicable instead
31 : * of those above. If you wish to allow use of your version of this file only
32 : * under the terms of either the GPL or the LGPL, and not to allow others to
33 : * use your version of this file under the terms of the MPL, indicate your
34 : * decision by deleting the provisions above and replace them with the notice
35 : * and other provisions required by the GPL or the LGPL. If you do not delete
36 : * the provisions above, a recipient may use your version of this file under
37 : * the terms of any one of the MPL, the GPL or the LGPL.
38 : *
39 : * ***** END LICENSE BLOCK ***** */
40 :
41 : #include "mozilla/Util.h"
42 : #include "SmsFilter.h" // On top because it includes basictypes.h.
43 :
44 : #ifdef XP_WIN
45 : #undef GetClassName
46 : #endif
47 :
48 : // JavaScript includes
49 : #include "jsapi.h"
50 : #include "jsfriendapi.h"
51 : #include "jsprvtd.h" // we are using private JS typedefs...
52 : #include "jsdbgapi.h"
53 : #include "WrapperFactory.h"
54 : #include "AccessCheck.h"
55 :
56 : #include "xpcprivate.h"
57 : #include "XPCWrapper.h"
58 :
59 : #include "nscore.h"
60 : #include "nsDOMClassInfo.h"
61 : #include "nsCRT.h"
62 : #include "nsCRTGlue.h"
63 : #include "nsIServiceManager.h"
64 : #include "nsICategoryManager.h"
65 : #include "nsIComponentRegistrar.h"
66 : #include "nsXPCOM.h"
67 : #include "nsISupportsPrimitives.h"
68 : #include "nsIXPConnect.h"
69 : #include "nsIJSContextStack.h"
70 : #include "nsIXPCSecurityManager.h"
71 : #include "nsIStringBundle.h"
72 : #include "nsIConsoleService.h"
73 : #include "nsIScriptError.h"
74 : #include "nsXPIDLString.h"
75 : #include "nsReadableUtils.h"
76 : #include "nsUnicharUtils.h"
77 : #include "xptcall.h"
78 : #include "prprf.h"
79 : #include "nsTArray.h"
80 : #include "nsCSSValue.h"
81 : #include "nsIRunnable.h"
82 : #include "nsThreadUtils.h"
83 : #include "nsDOMEventTargetHelper.h"
84 : #include "xpcprivate.h"
85 : #include "XrayWrapper.h"
86 :
87 : // General helper includes
88 : #include "nsGlobalWindow.h"
89 : #include "nsHistory.h"
90 : #include "nsIContent.h"
91 : #include "nsIAttribute.h"
92 : #include "nsIDocument.h"
93 : #include "nsIDOMDocument.h"
94 : #include "nsIDOMXMLDocument.h"
95 : #include "nsIDOMEvent.h"
96 : #include "nsIDOMNSEvent.h"
97 : #include "nsIDOMKeyEvent.h"
98 : #include "nsIDOMEventListener.h"
99 : #include "nsIDOMPopStateEvent.h"
100 : #include "nsIDOMHashChangeEvent.h"
101 : #include "nsContentUtils.h"
102 : #include "nsDOMWindowUtils.h"
103 : #include "nsIDOMGlobalPropertyInitializer.h"
104 : #include "mozilla/Preferences.h"
105 : #include "nsLocation.h"
106 :
107 : // Window scriptable helper includes
108 : #include "nsIDocShell.h"
109 : #include "nsIDocShellTreeItem.h"
110 : #include "nsIDocShellTreeNode.h"
111 : #include "nsIScriptExternalNameSet.h"
112 : #include "nsJSUtils.h"
113 : #include "nsIInterfaceRequestor.h"
114 : #include "nsIInterfaceRequestorUtils.h"
115 : #include "nsScriptNameSpaceManager.h"
116 : #include "nsIScriptObjectOwner.h"
117 : #include "nsIJSNativeInitializer.h"
118 : #include "nsJSEnvironment.h"
119 :
120 : // DOM base includes
121 : #include "nsIDOMPluginArray.h"
122 : #include "nsIDOMPlugin.h"
123 : #include "nsIDOMMimeTypeArray.h"
124 : #include "nsIDOMMimeType.h"
125 : #include "nsIDOMLocation.h"
126 : #include "nsIDOMWindow.h"
127 : #include "nsPIDOMWindow.h"
128 : #include "nsIDOMJSWindow.h"
129 : #include "nsIDOMWindowCollection.h"
130 : #include "nsIDOMHistory.h"
131 : #include "nsIDOMMediaList.h"
132 : #include "nsIDOMChromeWindow.h"
133 : #include "nsIDOMConstructor.h"
134 : #include "nsIDOMPerformanceTiming.h"
135 : #include "nsIDOMPerformanceNavigation.h"
136 : #include "nsIDOMPerformance.h"
137 : #include "nsClientRect.h"
138 :
139 : // DOM core includes
140 : #include "nsDOMError.h"
141 : #include "nsIDOMDOMException.h"
142 : #include "nsIDOMNode.h"
143 : #include "nsIDOMNamedNodeMap.h"
144 : #include "nsIDOMDOMStringList.h"
145 : #include "nsIDOMDOMTokenList.h"
146 : #include "nsIDOMDOMSettableTokenList.h"
147 : #include "nsIDOMNSElement.h"
148 :
149 : #include "nsDOMStringMap.h"
150 :
151 : // HTMLFormElement helper includes
152 : #include "nsIForm.h"
153 : #include "nsIFormControl.h"
154 : #include "nsIDOMHTMLFormElement.h"
155 : #include "nsHTMLDocument.h"
156 :
157 : // Constraint Validation API helper includes
158 : #include "nsIDOMValidityState.h"
159 :
160 : // HTMLSelectElement helper includes
161 : #include "nsIDOMHTMLSelectElement.h"
162 :
163 : // HTMLEmbed/ObjectElement helper includes
164 : #include "nsNPAPIPluginInstance.h"
165 : #include "nsIObjectFrame.h"
166 : #include "nsIObjectLoadingContent.h"
167 : #include "nsIPluginHost.h"
168 :
169 : #include "nsIDOMHTMLOptionElement.h"
170 : #include "nsGenericElement.h"
171 :
172 : // Event related includes
173 : #include "nsEventListenerManager.h"
174 : #include "nsIDOMEventTarget.h"
175 :
176 : // CSS related includes
177 : #include "nsIDOMStyleSheet.h"
178 : #include "nsIDOMStyleSheetList.h"
179 : #include "nsIDOMCSSStyleDeclaration.h"
180 : #include "nsIDOMCSSRule.h"
181 : #include "nsICSSRuleList.h"
182 : #include "nsIDOMRect.h"
183 : #include "nsIDOMRGBColor.h"
184 : #include "nsIDOMNSRGBAColor.h"
185 : #include "nsDOMCSSAttrDeclaration.h"
186 :
187 : // XBL related includes.
188 : #include "nsIXBLService.h"
189 : #include "nsXBLBinding.h"
190 : #include "nsBindingManager.h"
191 : #include "nsIFrame.h"
192 : #include "nsIPresShell.h"
193 : #include "nsIDOMElement.h"
194 : #include "nsIDOMCSSStyleDeclaration.h"
195 : #include "nsStyleContext.h"
196 : #include "nsAutoPtr.h"
197 : #include "nsMemory.h"
198 :
199 : // Tranformiix
200 : #include "nsIDOMXPathEvaluator.h"
201 : #include "nsIXSLTProcessor.h"
202 : #include "nsIXSLTProcessorPrivate.h"
203 :
204 : #include "nsIDOMLSProgressEvent.h"
205 : #include "nsIDOMParser.h"
206 : #include "nsIDOMSerializer.h"
207 : #include "nsXMLHttpRequest.h"
208 : #include "nsWebSocket.h"
209 : #include "nsIDOMCloseEvent.h"
210 : #include "nsEventSource.h"
211 :
212 : // includes needed for the prototype chain interfaces
213 : #include "nsIDOMNavigator.h"
214 : #include "nsIDOMBarProp.h"
215 : #include "nsIDOMScreen.h"
216 : #include "nsIDOMDocumentType.h"
217 : #include "nsIDOMDOMImplementation.h"
218 : #include "nsIDOMDocumentFragment.h"
219 : #include "nsDOMAttribute.h"
220 : #include "nsIDOMText.h"
221 : #include "nsIDOMComment.h"
222 : #include "nsIDOMCDATASection.h"
223 : #include "nsIDOMProcessingInstruction.h"
224 : #include "nsIDOMDataContainerEvent.h"
225 : #include "nsIDOMKeyEvent.h"
226 : #include "nsIDOMCompositionEvent.h"
227 : #include "nsIDOMMouseEvent.h"
228 : #include "nsIDOMMouseScrollEvent.h"
229 : #include "nsIDOMDragEvent.h"
230 : #include "nsIDOMCommandEvent.h"
231 : #include "nsIDOMPopupBlockedEvent.h"
232 : #include "nsIDOMBeforeUnloadEvent.h"
233 : #include "nsIDOMMutationEvent.h"
234 : #include "nsIDOMSmartCardEvent.h"
235 : #include "nsIDOMXULCommandEvent.h"
236 : #include "nsIDOMPageTransitionEvent.h"
237 : #include "nsIDOMMessageEvent.h"
238 : #include "nsPaintRequest.h"
239 : #include "nsIDOMNotifyPaintEvent.h"
240 : #include "nsIDOMNotifyAudioAvailableEvent.h"
241 : #include "nsIDOMScrollAreaEvent.h"
242 : #include "nsIDOMTransitionEvent.h"
243 : #include "nsIDOMAnimationEvent.h"
244 : #include "nsIDOMDocumentXBL.h"
245 : #include "nsIDOMElementCSSInlineStyle.h"
246 : #include "nsIDOMLinkStyle.h"
247 : #include "nsIDOMHTMLDocument.h"
248 : #include "nsIDOMHTMLElement.h"
249 : #include "nsIDOMHTMLAnchorElement.h"
250 : #include "nsIDOMHTMLAppletElement.h"
251 : #include "nsIDOMHTMLAreaElement.h"
252 : #include "nsIDOMHTMLBRElement.h"
253 : #include "nsIDOMHTMLBaseElement.h"
254 : #include "nsIDOMHTMLBodyElement.h"
255 : #include "nsIDOMHTMLButtonElement.h"
256 : #include "nsIDOMHTMLCanvasElement.h"
257 : #include "nsIDOMHTMLDataListElement.h"
258 : #include "nsIDOMHTMLDListElement.h"
259 : #include "nsIDOMHTMLDirectoryElement.h"
260 : #include "nsIDOMHTMLDivElement.h"
261 : #include "nsIDOMHTMLEmbedElement.h"
262 : #include "nsIDOMHTMLFieldSetElement.h"
263 : #include "nsIDOMHTMLFontElement.h"
264 : #include "nsIDOMHTMLFrameElement.h"
265 : #include "nsIDOMHTMLFrameSetElement.h"
266 : #include "nsIDOMHTMLFrameElement.h"
267 : #include "nsIDOMHTMLHRElement.h"
268 : #include "nsIDOMHTMLHeadElement.h"
269 : #include "nsIDOMHTMLHeadingElement.h"
270 : #include "nsIDOMHTMLHtmlElement.h"
271 : #include "nsIDOMHTMLIFrameElement.h"
272 : #include "nsIDOMHTMLImageElement.h"
273 : #include "nsIDOMHTMLInputElement.h"
274 : #include "nsIDOMHTMLLIElement.h"
275 : #include "nsIDOMHTMLLabelElement.h"
276 : #include "nsIDOMHTMLLegendElement.h"
277 : #include "nsIDOMHTMLLinkElement.h"
278 : #include "nsIDOMHTMLMapElement.h"
279 : #include "nsIDOMHTMLMenuElement.h"
280 : #include "nsIDOMHTMLMenuItemElement.h"
281 : #include "nsIDOMHTMLMetaElement.h"
282 : #include "nsIDOMHTMLModElement.h"
283 : #include "nsIDOMHTMLOListElement.h"
284 : #include "nsIDOMHTMLObjectElement.h"
285 : #include "nsIDOMHTMLOptGroupElement.h"
286 : #include "nsIDOMHTMLOutputElement.h"
287 : #include "nsIDOMHTMLParagraphElement.h"
288 : #include "nsIDOMHTMLParamElement.h"
289 : #include "nsIDOMHTMLPreElement.h"
290 : #include "nsIDOMHTMLProgressElement.h"
291 : #include "nsIDOMHTMLQuoteElement.h"
292 : #include "nsIDOMHTMLScriptElement.h"
293 : #include "nsIDOMHTMLStyleElement.h"
294 : #include "nsIDOMHTMLTableCaptionElem.h"
295 : #include "nsIDOMHTMLTableCellElement.h"
296 : #include "nsIDOMHTMLTableColElement.h"
297 : #include "nsIDOMHTMLTableElement.h"
298 : #include "nsIDOMHTMLTableRowElement.h"
299 : #include "nsIDOMHTMLTableSectionElem.h"
300 : #include "nsIDOMHTMLTextAreaElement.h"
301 : #include "nsIDOMHTMLTitleElement.h"
302 : #include "nsIDOMHTMLUListElement.h"
303 : #include "nsIDOMHTMLUnknownElement.h"
304 : #include "nsIDOMMediaError.h"
305 : #include "nsIDOMTimeRanges.h"
306 : #include "nsIDOMHTMLSourceElement.h"
307 : #include "nsIDOMHTMLVideoElement.h"
308 : #include "nsIDOMHTMLAudioElement.h"
309 : #include "nsIDOMProgressEvent.h"
310 : #include "nsIDOMCSS2Properties.h"
311 : #include "nsIDOMCSSCharsetRule.h"
312 : #include "nsIDOMCSSImportRule.h"
313 : #include "nsIDOMCSSMediaRule.h"
314 : #include "nsIDOMCSSFontFaceRule.h"
315 : #include "nsIDOMCSSMozDocumentRule.h"
316 : #include "nsIDOMMozCSSKeyframeRule.h"
317 : #include "nsIDOMMozCSSKeyframesRule.h"
318 : #include "nsIDOMCSSPrimitiveValue.h"
319 : #include "nsIDOMCSSStyleRule.h"
320 : #include "nsIDOMCSSStyleSheet.h"
321 : #include "nsDOMCSSValueList.h"
322 : #include "nsIDOMDeviceOrientationEvent.h"
323 : #include "nsIDOMDeviceMotionEvent.h"
324 : #include "nsIDOMRange.h"
325 : #include "nsIDOMNodeIterator.h"
326 : #include "nsIDOMTreeWalker.h"
327 : #include "nsIDOMXULDocument.h"
328 : #include "nsIDOMXULElement.h"
329 : #include "nsIDOMXULCommandDispatcher.h"
330 : #include "nsIDOMCrypto.h"
331 : #include "nsIDOMCRMFObject.h"
332 : #include "nsIControllers.h"
333 : #include "nsISelection.h"
334 : #include "nsIBoxObject.h"
335 : #ifdef MOZ_XUL
336 : #include "nsITreeSelection.h"
337 : #include "nsITreeContentView.h"
338 : #include "nsITreeView.h"
339 : #include "nsIXULTemplateBuilder.h"
340 : #include "nsTreeColumns.h"
341 : #endif
342 : #include "nsIDOMXPathException.h"
343 : #include "nsIDOMXPathExpression.h"
344 : #include "nsIDOMNSXPathExpression.h"
345 : #include "nsIDOMXPathNSResolver.h"
346 : #include "nsIDOMXPathResult.h"
347 : #include "nsIDOMMozBrowserFrame.h"
348 :
349 : #include "nsIDOMGetSVGDocument.h"
350 : #include "nsIDOMSVGAElement.h"
351 : #include "nsIDOMSVGAltGlyphElement.h"
352 : #include "nsIDOMSVGAngle.h"
353 : #include "nsIDOMSVGAnimatedAngle.h"
354 : #include "nsIDOMSVGAnimatedBoolean.h"
355 : #include "nsIDOMSVGAnimatedEnum.h"
356 : #include "nsIDOMSVGAnimatedInteger.h"
357 : #include "nsIDOMSVGAnimatedLength.h"
358 : #include "nsIDOMSVGAnimatedLengthList.h"
359 : #include "nsIDOMSVGAnimatedNumber.h"
360 : #include "nsIDOMSVGAnimatedNumberList.h"
361 : #include "nsIDOMSVGAnimatedPathData.h"
362 : #include "nsIDOMSVGAnimatedPoints.h"
363 : #include "nsIDOMSVGAnimatedRect.h"
364 : #include "nsIDOMSVGAnimatedString.h"
365 : #include "nsIDOMSVGAnimPresAspRatio.h"
366 : #include "nsIDOMSVGAnimateElement.h"
367 : #include "nsIDOMSVGAnimateTransformElement.h"
368 : #include "nsIDOMSVGAnimateMotionElement.h"
369 : #include "nsIDOMSVGMpathElement.h"
370 : #include "nsIDOMSVGSetElement.h"
371 : #include "nsIDOMSVGAnimationElement.h"
372 : #include "nsIDOMElementTimeControl.h"
373 : #include "nsIDOMTimeEvent.h"
374 : #include "nsIDOMSVGAnimTransformList.h"
375 : #include "nsIDOMSVGCircleElement.h"
376 : #include "nsIDOMSVGClipPathElement.h"
377 : #include "nsIDOMSVGDefsElement.h"
378 : #include "nsIDOMSVGDescElement.h"
379 : #include "nsIDOMSVGDocument.h"
380 : #include "nsIDOMSVGElement.h"
381 : #include "nsIDOMSVGEllipseElement.h"
382 : #include "nsIDOMSVGEvent.h"
383 : #include "nsIDOMSVGException.h"
384 : #include "nsIDOMSVGFilterElement.h"
385 : #include "nsIDOMSVGFilters.h"
386 : #include "nsIDOMSVGFitToViewBox.h"
387 : #include "nsIDOMSVGForeignObjectElem.h"
388 : #include "nsIDOMSVGGElement.h"
389 : #include "nsIDOMSVGGradientElement.h"
390 : #include "nsIDOMSVGImageElement.h"
391 : #include "nsIDOMSVGLength.h"
392 : #include "nsIDOMSVGLengthList.h"
393 : #include "nsIDOMSVGLineElement.h"
394 : #include "nsIDOMSVGLocatable.h"
395 : #include "nsIDOMSVGMarkerElement.h"
396 : #include "nsIDOMSVGMaskElement.h"
397 : #include "nsIDOMSVGMatrix.h"
398 : #include "nsIDOMSVGMetadataElement.h"
399 : #include "nsIDOMSVGNumber.h"
400 : #include "nsIDOMSVGNumberList.h"
401 : #include "nsIDOMSVGPathElement.h"
402 : #include "nsIDOMSVGPathSeg.h"
403 : #include "nsIDOMSVGPathSegList.h"
404 : #include "nsIDOMSVGPatternElement.h"
405 : #include "nsIDOMSVGPoint.h"
406 : #include "nsIDOMSVGPointList.h"
407 : #include "nsIDOMSVGPolygonElement.h"
408 : #include "nsIDOMSVGPolylineElement.h"
409 : #include "nsIDOMSVGPresAspectRatio.h"
410 : #include "nsIDOMSVGRect.h"
411 : #include "nsIDOMSVGRectElement.h"
412 : #include "nsIDOMSVGScriptElement.h"
413 : #include "nsIDOMSVGStopElement.h"
414 : #include "nsIDOMSVGStylable.h"
415 : #include "nsIDOMSVGStyleElement.h"
416 : #include "nsIDOMSVGSVGElement.h"
417 : #include "nsIDOMSVGSwitchElement.h"
418 : #include "nsIDOMSVGSymbolElement.h"
419 : #include "nsIDOMSVGTests.h"
420 : #include "nsIDOMSVGTextElement.h"
421 : #include "nsIDOMSVGTextPathElement.h"
422 : #include "nsIDOMSVGTitleElement.h"
423 : #include "nsIDOMSVGTransform.h"
424 : #include "nsIDOMSVGTransformable.h"
425 : #include "nsIDOMSVGTransformList.h"
426 : #include "nsIDOMSVGTSpanElement.h"
427 : #include "nsIDOMSVGUnitTypes.h"
428 : #include "nsIDOMSVGURIReference.h"
429 : #include "nsIDOMSVGUseElement.h"
430 : #include "nsIDOMSVGZoomAndPan.h"
431 : #include "nsIDOMSVGZoomEvent.h"
432 :
433 : #include "nsIDOMCanvasRenderingContext2D.h"
434 : #include "nsIDOMWebGLRenderingContext.h"
435 :
436 : #include "nsIImageDocument.h"
437 :
438 : // Storage includes
439 : #include "nsDOMStorage.h"
440 :
441 : // Drag and drop
442 : #include "nsIDOMDataTransfer.h"
443 :
444 : // Geolocation
445 : #include "nsIDOMGeoGeolocation.h"
446 : #include "nsIDOMGeoPosition.h"
447 : #include "nsIDOMGeoPositionCoords.h"
448 : #include "nsIDOMGeoPositionError.h"
449 :
450 : // Workers
451 : #include "mozilla/dom/workers/Workers.h"
452 :
453 : #include "nsDOMFile.h"
454 : #include "nsDOMFileReader.h"
455 : #include "nsIDOMFileException.h"
456 : #include "nsIDOMFormData.h"
457 :
458 : #include "nsIDOMDOMStringMap.h"
459 :
460 : #include "nsIDOMDesktopNotification.h"
461 : #include "nsIDOMNavigatorDesktopNotification.h"
462 : #include "nsIDOMNavigatorGeolocation.h"
463 : #include "Navigator.h"
464 :
465 : #include "nsPluginArray.h"
466 : #include "nsMimeTypeArray.h"
467 :
468 : // Simple gestures include
469 : #include "nsIDOMSimpleGestureEvent.h"
470 : #include "nsIDOMMozTouchEvent.h"
471 :
472 : #include "nsIEventListenerService.h"
473 : #include "nsIFrameMessageManager.h"
474 : #include "mozilla/dom/Element.h"
475 : #include "nsHTMLSelectElement.h"
476 : #include "nsHTMLLegendElement.h"
477 :
478 : #include "DOMSVGLengthList.h"
479 : #include "DOMSVGNumberList.h"
480 : #include "DOMSVGPathSegList.h"
481 : #include "DOMSVGPointList.h"
482 : #include "DOMSVGStringList.h"
483 : #include "DOMSVGTransformList.h"
484 :
485 : #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
486 : #include "mozilla/dom/indexedDB/IDBFactory.h"
487 : #include "mozilla/dom/indexedDB/IDBRequest.h"
488 : #include "mozilla/dom/indexedDB/IDBDatabase.h"
489 : #include "mozilla/dom/indexedDB/IDBEvents.h"
490 : #include "mozilla/dom/indexedDB/IDBObjectStore.h"
491 : #include "mozilla/dom/indexedDB/IDBTransaction.h"
492 : #include "mozilla/dom/indexedDB/IDBCursor.h"
493 : #include "mozilla/dom/indexedDB/IDBKeyRange.h"
494 : #include "mozilla/dom/indexedDB/IDBIndex.h"
495 : #include "nsIIDBDatabaseException.h"
496 :
497 : using mozilla::dom::indexedDB::IDBWrapperCache;
498 :
499 : #include "nsIDOMMediaQueryList.h"
500 :
501 : #include "nsDOMTouchEvent.h"
502 : #include "nsIDOMCustomEvent.h"
503 :
504 : #include "nsWrapperCacheInlines.h"
505 : #include "dombindings.h"
506 :
507 : #include "nsIDOMBatteryManager.h"
508 : #include "BatteryManager.h"
509 : #include "nsIDOMPowerManager.h"
510 : #include "nsIDOMWakeLock.h"
511 : #include "nsIDOMSmsManager.h"
512 : #include "nsIDOMSmsMessage.h"
513 : #include "nsIDOMSmsEvent.h"
514 : #include "nsIDOMSmsRequest.h"
515 : #include "nsIDOMSmsFilter.h"
516 : #include "nsIDOMSmsCursor.h"
517 : #include "nsIPrivateDOMEvent.h"
518 : #include "nsIDOMConnection.h"
519 : #include "mozilla/dom/network/Utils.h"
520 :
521 : #ifdef MOZ_B2G_RIL
522 : #include "Telephony.h"
523 : #include "TelephonyCall.h"
524 : #include "CallEvent.h"
525 : #endif
526 :
527 : #ifdef MOZ_B2G_BT
528 : #include "BluetoothAdapter.h"
529 : #endif
530 :
531 : #include "DOMError.h"
532 : #include "DOMRequest.h"
533 :
534 : using namespace mozilla;
535 : using namespace mozilla::dom;
536 :
537 : static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
538 :
539 : static const char kDOMStringBundleURL[] =
540 : "chrome://global/locale/dom/dom.properties";
541 :
542 : // NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
543 : // are defined in nsIDOMClassInfo.h.
544 :
545 : #define WINDOW_SCRIPTABLE_FLAGS \
546 : (nsIXPCScriptable::WANT_GETPROPERTY | \
547 : nsIXPCScriptable::WANT_PRECREATE | \
548 : nsIXPCScriptable::WANT_FINALIZE | \
549 : nsIXPCScriptable::WANT_ENUMERATE | \
550 : nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
551 : nsIXPCScriptable::USE_STUB_EQUALITY_HOOK | \
552 : nsIXPCScriptable::IS_GLOBAL_OBJECT | \
553 : nsIXPCScriptable::WANT_OUTER_OBJECT)
554 :
555 : #define NODE_SCRIPTABLE_FLAGS \
556 : ((DOM_DEFAULT_SCRIPTABLE_FLAGS | \
557 : nsIXPCScriptable::USE_STUB_EQUALITY_HOOK | \
558 : nsIXPCScriptable::WANT_ADDPROPERTY) & \
559 : ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
560 :
561 : // We need to let JavaScript QI elements to interfaces that are not in
562 : // the classinfo since XBL can be used to dynamically implement new
563 : // unknown interfaces on elements, accessibility relies on this being
564 : // possible.
565 :
566 : #define ELEMENT_SCRIPTABLE_FLAGS \
567 : ((NODE_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY) | \
568 : nsIXPCScriptable::WANT_POSTCREATE | \
569 : nsIXPCScriptable::WANT_ENUMERATE)
570 :
571 : #define EXTERNAL_OBJ_SCRIPTABLE_FLAGS \
572 : ((ELEMENT_SCRIPTABLE_FLAGS & \
573 : ~nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY) | \
574 : nsIXPCScriptable::WANT_POSTCREATE | \
575 : nsIXPCScriptable::WANT_GETPROPERTY | \
576 : nsIXPCScriptable::WANT_SETPROPERTY | \
577 : nsIXPCScriptable::WANT_CALL)
578 :
579 : #define DOCUMENT_SCRIPTABLE_FLAGS \
580 : (NODE_SCRIPTABLE_FLAGS | \
581 : nsIXPCScriptable::WANT_POSTCREATE | \
582 : nsIXPCScriptable::WANT_ENUMERATE)
583 :
584 : #define ARRAY_SCRIPTABLE_FLAGS \
585 : (DOM_DEFAULT_SCRIPTABLE_FLAGS | \
586 : nsIXPCScriptable::WANT_GETPROPERTY | \
587 : nsIXPCScriptable::WANT_ENUMERATE)
588 :
589 : #define DOMSTRINGMAP_SCRIPTABLE_FLAGS \
590 : (DOM_DEFAULT_SCRIPTABLE_FLAGS | \
591 : nsIXPCScriptable::WANT_ENUMERATE | \
592 : nsIXPCScriptable::WANT_PRECREATE | \
593 : nsIXPCScriptable::WANT_DELPROPERTY | \
594 : nsIXPCScriptable::WANT_SETPROPERTY | \
595 : nsIXPCScriptable::WANT_GETPROPERTY)
596 :
597 : #define EVENTTARGET_SCRIPTABLE_FLAGS \
598 : (DOM_DEFAULT_SCRIPTABLE_FLAGS | \
599 : nsIXPCScriptable::WANT_ADDPROPERTY)
600 :
601 : #define IDBEVENTTARGET_SCRIPTABLE_FLAGS \
602 : (EVENTTARGET_SCRIPTABLE_FLAGS)
603 :
604 : #define DOMCLASSINFO_STANDARD_FLAGS \
605 : (nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::DOM_OBJECT)
606 :
607 :
608 : #ifdef NS_DEBUG
609 : #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
610 : eDOMClassInfo_##_class##_id,
611 : #else
612 : #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
613 : // nothing
614 : #endif
615 :
616 : DOMCI_DATA(Crypto, void)
617 : DOMCI_DATA(CRMFObject, void)
618 : DOMCI_DATA(SmartCardEvent, void)
619 : DOMCI_DATA(ContentFrameMessageManager, void)
620 :
621 : DOMCI_DATA(DOMPrototype, void)
622 : DOMCI_DATA(DOMConstructor, void)
623 :
624 : #define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper, \
625 : _flags) \
626 : { #_name, \
627 : nsnull, \
628 : { _helper::doCreate }, \
629 : nsnull, \
630 : nsnull, \
631 : nsnull, \
632 : _flags, \
633 : true, \
634 : 0, \
635 : false, \
636 : false, \
637 : NULL, \
638 : NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
639 : },
640 :
641 : #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _name, \
642 : _helper, _flags) \
643 : { #_name, \
644 : nsnull, \
645 : { _helper::doCreate }, \
646 : nsnull, \
647 : nsnull, \
648 : nsnull, \
649 : _flags, \
650 : true, \
651 : 0, \
652 : true, \
653 : false, \
654 : NULL, \
655 : NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
656 : },
657 :
658 : #define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
659 : NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
660 :
661 : #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
662 : NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
663 : _flags)
664 :
665 : namespace {
666 :
667 : class IDBEventTargetSH : public nsEventTargetSH
668 : {
669 : protected:
670 174 : IDBEventTargetSH(nsDOMClassInfoData* aData) : nsEventTargetSH(aData)
671 174 : { }
672 :
673 348 : virtual ~IDBEventTargetSH()
674 696 : { }
675 :
676 : public:
677 : NS_IMETHOD PreCreate(nsISupports *aNativeObj, JSContext *aCx,
678 : JSObject *aGlobalObj, JSObject **aParentObj);
679 :
680 174 : static nsIClassInfo *doCreate(nsDOMClassInfoData *aData)
681 : {
682 174 : return new IDBEventTargetSH(aData);
683 : }
684 : };
685 :
686 : } // anonymous namespace
687 :
688 : // This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
689 : // classes their correct behavior when used through XPConnect. The
690 : // arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
691 : //
692 : // 1. Class name as it should appear in JavaScript, this name is also
693 : // used to find the id of the class in nsDOMClassInfo
694 : // (i.e. e<classname>_id)
695 : // 2. Scriptable helper class
696 : // 3. nsIClassInfo/nsIXPCScriptable flags (i.e. for GetScriptableFlags)
697 :
698 : static nsDOMClassInfoData sClassInfoData[] = {
699 : // Base classes
700 :
701 : // The Window class lets you QI into interfaces that are not in the
702 : // flattened set (i.e. nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY
703 : // is not set), because of this make sure all scriptable interfaces
704 : // that are implemented by nsGlobalWindow can securely be exposed
705 : // to JS.
706 :
707 :
708 : NS_DEFINE_CLASSINFO_DATA(Window, nsWindowSH,
709 : DEFAULT_SCRIPTABLE_FLAGS |
710 : WINDOW_SCRIPTABLE_FLAGS)
711 :
712 : NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
713 : (DOM_DEFAULT_SCRIPTABLE_FLAGS &
714 : ~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
715 :
716 : NS_DEFINE_CLASSINFO_DATA(Navigator, nsNavigatorSH,
717 : DOM_DEFAULT_SCRIPTABLE_FLAGS |
718 : nsIXPCScriptable::WANT_PRECREATE |
719 : nsIXPCScriptable::WANT_NEWRESOLVE)
720 : NS_DEFINE_CLASSINFO_DATA(Plugin, nsPluginSH,
721 : ARRAY_SCRIPTABLE_FLAGS)
722 : NS_DEFINE_CLASSINFO_DATA(PluginArray, nsPluginArraySH,
723 : ARRAY_SCRIPTABLE_FLAGS)
724 : NS_DEFINE_CLASSINFO_DATA(MimeType, nsDOMGenericSH,
725 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
726 : NS_DEFINE_CLASSINFO_DATA(MimeTypeArray, nsMimeTypeArraySH,
727 : ARRAY_SCRIPTABLE_FLAGS)
728 : NS_DEFINE_CLASSINFO_DATA(BarProp, nsDOMGenericSH,
729 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
730 : NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
731 : ARRAY_SCRIPTABLE_FLAGS |
732 : nsIXPCScriptable::WANT_PRECREATE)
733 : NS_DEFINE_CLASSINFO_DATA(PerformanceTiming, nsDOMGenericSH,
734 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
735 : NS_DEFINE_CLASSINFO_DATA(PerformanceNavigation, nsDOMGenericSH,
736 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
737 : NS_DEFINE_CLASSINFO_DATA(Performance, nsDOMGenericSH,
738 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
739 : NS_DEFINE_CLASSINFO_DATA(Screen, nsDOMGenericSH,
740 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
741 : NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
742 : DOM_BASE_SCRIPTABLE_FLAGS |
743 : nsIXPCScriptable::WANT_PRECREATE |
744 : nsIXPCScriptable::WANT_NEWRESOLVE |
745 : nsIXPCScriptable::WANT_HASINSTANCE |
746 : nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
747 : NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMConstructorSH,
748 : DOM_BASE_SCRIPTABLE_FLAGS |
749 : nsIXPCScriptable::WANT_PRECREATE |
750 : nsIXPCScriptable::WANT_NEWRESOLVE |
751 : nsIXPCScriptable::WANT_HASINSTANCE |
752 : nsIXPCScriptable::WANT_CALL |
753 : nsIXPCScriptable::WANT_CONSTRUCT |
754 : nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
755 :
756 : // Core classes
757 : NS_DEFINE_CLASSINFO_DATA(XMLDocument, nsDocumentSH,
758 : DOCUMENT_SCRIPTABLE_FLAGS)
759 : NS_DEFINE_CLASSINFO_DATA(DocumentType, nsNodeSH,
760 : NODE_SCRIPTABLE_FLAGS)
761 : NS_DEFINE_CLASSINFO_DATA(DOMImplementation, nsDOMGenericSH,
762 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
763 : NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
764 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
765 : NS_DEFINE_CLASSINFO_DATA(DOMTokenList, nsDOMTokenListSH,
766 : ARRAY_SCRIPTABLE_FLAGS)
767 : NS_DEFINE_CLASSINFO_DATA(DOMSettableTokenList, nsDOMTokenListSH,
768 : ARRAY_SCRIPTABLE_FLAGS)
769 : NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
770 : NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
771 : ELEMENT_SCRIPTABLE_FLAGS)
772 : NS_DEFINE_CLASSINFO_DATA(Attr, nsAttributeSH,
773 : NODE_SCRIPTABLE_FLAGS)
774 : NS_DEFINE_CLASSINFO_DATA(Text, nsNodeSH,
775 : NODE_SCRIPTABLE_FLAGS)
776 : NS_DEFINE_CLASSINFO_DATA(Comment, nsNodeSH,
777 : NODE_SCRIPTABLE_FLAGS)
778 : NS_DEFINE_CLASSINFO_DATA(CDATASection, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
779 : NS_DEFINE_CLASSINFO_DATA(ProcessingInstruction, nsNodeSH,
780 : NODE_SCRIPTABLE_FLAGS)
781 : NS_DEFINE_CLASSINFO_DATA(NodeList, nsDOMGenericSH,
782 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
783 : NS_DEFINE_CLASSINFO_DATA(NamedNodeMap, nsNamedNodeMapSH,
784 : ARRAY_SCRIPTABLE_FLAGS)
785 :
786 : // Misc Core related classes
787 :
788 : // Event
789 : NS_DEFINE_CLASSINFO_DATA(Event, nsDOMGenericSH,
790 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
791 : NS_DEFINE_CLASSINFO_DATA(MutationEvent, nsDOMGenericSH,
792 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
793 : NS_DEFINE_CLASSINFO_DATA(UIEvent, nsDOMGenericSH,
794 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
795 : NS_DEFINE_CLASSINFO_DATA(MouseEvent, nsDOMGenericSH,
796 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
797 : NS_DEFINE_CLASSINFO_DATA(MouseScrollEvent, nsDOMGenericSH,
798 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
799 : NS_DEFINE_CLASSINFO_DATA(DragEvent, nsDOMGenericSH,
800 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
801 : NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
802 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
803 : NS_DEFINE_CLASSINFO_DATA(CompositionEvent, nsDOMGenericSH,
804 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
805 : NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
806 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
807 : // Device Orientation
808 : NS_DEFINE_CLASSINFO_DATA(DeviceOrientationEvent, nsDOMGenericSH,
809 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
810 : NS_DEFINE_CLASSINFO_DATA(DeviceMotionEvent, nsDOMGenericSH,
811 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
812 : NS_DEFINE_CLASSINFO_DATA(DeviceAcceleration, nsDOMGenericSH,
813 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
814 : NS_DEFINE_CLASSINFO_DATA(DeviceRotationRate, nsDOMGenericSH,
815 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
816 :
817 : // Misc HTML classes
818 : NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH,
819 : DOCUMENT_SCRIPTABLE_FLAGS |
820 : nsIXPCScriptable::WANT_GETPROPERTY)
821 : NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection, nsDOMGenericSH,
822 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
823 : NS_DEFINE_CLASSINFO_DATA(HTMLCollection, nsDOMGenericSH,
824 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
825 :
826 : // HTML element classes
827 : NS_DEFINE_CLASSINFO_DATA(HTMLElement, nsElementSH,
828 : ELEMENT_SCRIPTABLE_FLAGS)
829 : NS_DEFINE_CLASSINFO_DATA(HTMLAnchorElement, nsElementSH,
830 : ELEMENT_SCRIPTABLE_FLAGS)
831 : NS_DEFINE_CLASSINFO_DATA(HTMLAppletElement, nsHTMLPluginObjElementSH,
832 : EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
833 : NS_DEFINE_CLASSINFO_DATA(HTMLAreaElement, nsElementSH,
834 : ELEMENT_SCRIPTABLE_FLAGS)
835 : NS_DEFINE_CLASSINFO_DATA(HTMLBRElement, nsElementSH,
836 : ELEMENT_SCRIPTABLE_FLAGS)
837 : NS_DEFINE_CLASSINFO_DATA(HTMLBaseElement, nsElementSH,
838 : ELEMENT_SCRIPTABLE_FLAGS)
839 : NS_DEFINE_CLASSINFO_DATA(HTMLBodyElement, nsElementSH,
840 : ELEMENT_SCRIPTABLE_FLAGS)
841 : NS_DEFINE_CLASSINFO_DATA(HTMLButtonElement, nsElementSH,
842 : ELEMENT_SCRIPTABLE_FLAGS)
843 : NS_DEFINE_CLASSINFO_DATA(HTMLDataListElement, nsElementSH,
844 : ELEMENT_SCRIPTABLE_FLAGS)
845 : NS_DEFINE_CLASSINFO_DATA(HTMLDListElement, nsElementSH,
846 : ELEMENT_SCRIPTABLE_FLAGS)
847 : NS_DEFINE_CLASSINFO_DATA(HTMLDirectoryElement, nsElementSH,
848 : ELEMENT_SCRIPTABLE_FLAGS)
849 : NS_DEFINE_CLASSINFO_DATA(HTMLDivElement, nsElementSH,
850 : ELEMENT_SCRIPTABLE_FLAGS)
851 : NS_DEFINE_CLASSINFO_DATA(HTMLEmbedElement, nsHTMLPluginObjElementSH,
852 : EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
853 : NS_DEFINE_CLASSINFO_DATA(HTMLFieldSetElement, nsElementSH,
854 : ELEMENT_SCRIPTABLE_FLAGS)
855 : NS_DEFINE_CLASSINFO_DATA(HTMLFontElement, nsElementSH,
856 : ELEMENT_SCRIPTABLE_FLAGS)
857 : NS_DEFINE_CLASSINFO_DATA(HTMLFormElement, nsHTMLFormElementSH,
858 : ELEMENT_SCRIPTABLE_FLAGS |
859 : nsIXPCScriptable::WANT_GETPROPERTY |
860 : nsIXPCScriptable::WANT_NEWENUMERATE)
861 : NS_DEFINE_CLASSINFO_DATA(HTMLFrameElement, nsElementSH,
862 : ELEMENT_SCRIPTABLE_FLAGS)
863 : NS_DEFINE_CLASSINFO_DATA(HTMLFrameSetElement, nsElementSH,
864 : ELEMENT_SCRIPTABLE_FLAGS)
865 : NS_DEFINE_CLASSINFO_DATA(HTMLHRElement, nsElementSH,
866 : ELEMENT_SCRIPTABLE_FLAGS)
867 : NS_DEFINE_CLASSINFO_DATA(HTMLHeadElement, nsElementSH,
868 : ELEMENT_SCRIPTABLE_FLAGS)
869 : NS_DEFINE_CLASSINFO_DATA(HTMLHeadingElement, nsElementSH,
870 : ELEMENT_SCRIPTABLE_FLAGS)
871 : NS_DEFINE_CLASSINFO_DATA(HTMLHtmlElement, nsElementSH,
872 : ELEMENT_SCRIPTABLE_FLAGS)
873 : NS_DEFINE_CLASSINFO_DATA(HTMLIFrameElement, nsElementSH,
874 : ELEMENT_SCRIPTABLE_FLAGS)
875 : NS_DEFINE_CLASSINFO_DATA(HTMLImageElement, nsElementSH,
876 : ELEMENT_SCRIPTABLE_FLAGS)
877 : NS_DEFINE_CLASSINFO_DATA(HTMLInputElement, nsElementSH,
878 : ELEMENT_SCRIPTABLE_FLAGS)
879 : NS_DEFINE_CLASSINFO_DATA(HTMLLIElement, nsElementSH,
880 : ELEMENT_SCRIPTABLE_FLAGS)
881 : NS_DEFINE_CLASSINFO_DATA(HTMLLabelElement, nsElementSH,
882 : ELEMENT_SCRIPTABLE_FLAGS)
883 : NS_DEFINE_CLASSINFO_DATA(HTMLLegendElement, nsElementSH,
884 : ELEMENT_SCRIPTABLE_FLAGS)
885 : NS_DEFINE_CLASSINFO_DATA(HTMLLinkElement, nsElementSH,
886 : ELEMENT_SCRIPTABLE_FLAGS)
887 : NS_DEFINE_CLASSINFO_DATA(HTMLMapElement, nsElementSH,
888 : ELEMENT_SCRIPTABLE_FLAGS)
889 : NS_DEFINE_CLASSINFO_DATA(HTMLMenuElement, nsElementSH,
890 : ELEMENT_SCRIPTABLE_FLAGS)
891 : NS_DEFINE_CLASSINFO_DATA(HTMLMenuItemElement, nsElementSH,
892 : ELEMENT_SCRIPTABLE_FLAGS)
893 : NS_DEFINE_CLASSINFO_DATA(HTMLMetaElement, nsElementSH,
894 : ELEMENT_SCRIPTABLE_FLAGS)
895 : NS_DEFINE_CLASSINFO_DATA(HTMLModElement, nsElementSH,
896 : ELEMENT_SCRIPTABLE_FLAGS)
897 : NS_DEFINE_CLASSINFO_DATA(HTMLOListElement, nsElementSH,
898 : ELEMENT_SCRIPTABLE_FLAGS)
899 : NS_DEFINE_CLASSINFO_DATA(HTMLObjectElement, nsHTMLPluginObjElementSH,
900 : EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
901 : NS_DEFINE_CLASSINFO_DATA(HTMLOptGroupElement, nsElementSH,
902 : ELEMENT_SCRIPTABLE_FLAGS)
903 : NS_DEFINE_CLASSINFO_DATA(HTMLOptionElement, nsElementSH,
904 : ELEMENT_SCRIPTABLE_FLAGS)
905 : NS_DEFINE_CLASSINFO_DATA(HTMLOutputElement, nsElementSH,
906 : ELEMENT_SCRIPTABLE_FLAGS)
907 : NS_DEFINE_CLASSINFO_DATA(HTMLParagraphElement, nsElementSH,
908 : ELEMENT_SCRIPTABLE_FLAGS)
909 : NS_DEFINE_CLASSINFO_DATA(HTMLParamElement, nsElementSH,
910 : ELEMENT_SCRIPTABLE_FLAGS)
911 : NS_DEFINE_CLASSINFO_DATA(HTMLPreElement, nsElementSH,
912 : ELEMENT_SCRIPTABLE_FLAGS)
913 : NS_DEFINE_CLASSINFO_DATA(HTMLProgressElement, nsElementSH,
914 : ELEMENT_SCRIPTABLE_FLAGS)
915 : NS_DEFINE_CLASSINFO_DATA(HTMLQuoteElement, nsElementSH,
916 : ELEMENT_SCRIPTABLE_FLAGS)
917 : NS_DEFINE_CLASSINFO_DATA(HTMLScriptElement, nsElementSH,
918 : ELEMENT_SCRIPTABLE_FLAGS)
919 : NS_DEFINE_CLASSINFO_DATA(HTMLSelectElement, nsHTMLSelectElementSH,
920 : ELEMENT_SCRIPTABLE_FLAGS |
921 : nsIXPCScriptable::WANT_SETPROPERTY |
922 : nsIXPCScriptable::WANT_GETPROPERTY)
923 : NS_DEFINE_CLASSINFO_DATA(HTMLSpanElement, nsElementSH,
924 : ELEMENT_SCRIPTABLE_FLAGS)
925 : NS_DEFINE_CLASSINFO_DATA(HTMLStyleElement, nsElementSH,
926 : ELEMENT_SCRIPTABLE_FLAGS)
927 : NS_DEFINE_CLASSINFO_DATA(HTMLTableCaptionElement, nsElementSH,
928 : ELEMENT_SCRIPTABLE_FLAGS)
929 : NS_DEFINE_CLASSINFO_DATA(HTMLTableCellElement, nsElementSH,
930 : ELEMENT_SCRIPTABLE_FLAGS)
931 : NS_DEFINE_CLASSINFO_DATA(HTMLTableColElement, nsElementSH,
932 : ELEMENT_SCRIPTABLE_FLAGS)
933 : NS_DEFINE_CLASSINFO_DATA(HTMLTableElement, nsElementSH,
934 : ELEMENT_SCRIPTABLE_FLAGS)
935 : NS_DEFINE_CLASSINFO_DATA(HTMLTableRowElement, nsElementSH,
936 : ELEMENT_SCRIPTABLE_FLAGS)
937 : NS_DEFINE_CLASSINFO_DATA(HTMLTableSectionElement, nsElementSH,
938 : ELEMENT_SCRIPTABLE_FLAGS)
939 : NS_DEFINE_CLASSINFO_DATA(HTMLTextAreaElement, nsElementSH,
940 : ELEMENT_SCRIPTABLE_FLAGS)
941 : NS_DEFINE_CLASSINFO_DATA(HTMLTitleElement, nsElementSH,
942 : ELEMENT_SCRIPTABLE_FLAGS)
943 : NS_DEFINE_CLASSINFO_DATA(HTMLUListElement, nsElementSH,
944 : ELEMENT_SCRIPTABLE_FLAGS)
945 : NS_DEFINE_CLASSINFO_DATA(HTMLUnknownElement, nsElementSH,
946 : ELEMENT_SCRIPTABLE_FLAGS)
947 :
948 : // Constraint Validation API classes
949 : NS_DEFINE_CLASSINFO_DATA(ValidityState, nsDOMGenericSH,
950 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
951 :
952 : // CSS classes
953 : NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
954 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
955 : NS_DEFINE_CLASSINFO_DATA(CSSCharsetRule, nsDOMGenericSH,
956 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
957 : NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
958 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
959 : NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
960 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
961 : NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
962 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
963 : NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
964 : ARRAY_SCRIPTABLE_FLAGS)
965 : NS_DEFINE_CLASSINFO_DATA(CSSGroupRuleRuleList, nsCSSRuleListSH,
966 : ARRAY_SCRIPTABLE_FLAGS)
967 : NS_DEFINE_CLASSINFO_DATA(MediaList, nsMediaListSH,
968 : ARRAY_SCRIPTABLE_FLAGS)
969 : NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
970 : ARRAY_SCRIPTABLE_FLAGS)
971 : NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
972 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
973 : NS_DEFINE_CLASSINFO_DATA(CSSStyleDeclaration, nsCSSStyleDeclSH,
974 : ARRAY_SCRIPTABLE_FLAGS)
975 : NS_DEFINE_CLASSINFO_DATA(ROCSSPrimitiveValue, nsDOMGenericSH,
976 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
977 :
978 : // Range classes
979 : NS_DEFINE_CLASSINFO_DATA(Range, nsDOMGenericSH,
980 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
981 : NS_DEFINE_CLASSINFO_DATA(Selection, nsDOMGenericSH,
982 : DEFAULT_SCRIPTABLE_FLAGS)
983 :
984 : // XUL classes
985 : #ifdef MOZ_XUL
986 : NS_DEFINE_CLASSINFO_DATA(XULDocument, nsDocumentSH,
987 : DOCUMENT_SCRIPTABLE_FLAGS)
988 : NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH,
989 : ELEMENT_SCRIPTABLE_FLAGS)
990 : NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
991 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
992 : #endif
993 : NS_DEFINE_CLASSINFO_DATA(XULControllers, nsNonDOMObjectSH,
994 : DEFAULT_SCRIPTABLE_FLAGS)
995 : NS_DEFINE_CLASSINFO_DATA(BoxObject, nsDOMGenericSH,
996 : DEFAULT_SCRIPTABLE_FLAGS)
997 : #ifdef MOZ_XUL
998 : NS_DEFINE_CLASSINFO_DATA(TreeSelection, nsDOMGenericSH,
999 : DEFAULT_SCRIPTABLE_FLAGS)
1000 : NS_DEFINE_CLASSINFO_DATA(TreeContentView, nsDOMGenericSH,
1001 : DEFAULT_SCRIPTABLE_FLAGS)
1002 : #endif
1003 :
1004 : // Crypto classes
1005 : NS_DEFINE_CLASSINFO_DATA(Crypto, nsDOMGenericSH,
1006 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1007 : NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH,
1008 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1009 :
1010 : // DOM Traversal classes
1011 : NS_DEFINE_CLASSINFO_DATA(TreeWalker, nsDOMGenericSH,
1012 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1013 :
1014 : // We are now trying to preserve binary compat in classinfo. No
1015 : // more putting things in those categories up there. New entries
1016 : // are to be added to the end of the list
1017 : NS_DEFINE_CLASSINFO_DATA(CSSRect, nsDOMGenericSH,
1018 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1019 :
1020 : // DOM Chrome Window class.
1021 : NS_DEFINE_CLASSINFO_DATA(ChromeWindow, nsWindowSH,
1022 : DEFAULT_SCRIPTABLE_FLAGS |
1023 : WINDOW_SCRIPTABLE_FLAGS)
1024 :
1025 : NS_DEFINE_CLASSINFO_DATA(CSSRGBColor, nsDOMGenericSH,
1026 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1027 :
1028 : NS_DEFINE_CLASSINFO_DATA(CSSValueList, nsCSSValueListSH,
1029 : ARRAY_SCRIPTABLE_FLAGS)
1030 :
1031 : NS_DEFINE_CLASSINFO_DATA_WITH_NAME(ContentList, HTMLCollection,
1032 : nsDOMGenericSH,
1033 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1034 :
1035 : NS_DEFINE_CLASSINFO_DATA(XMLStylesheetProcessingInstruction, nsNodeSH,
1036 : NODE_SCRIPTABLE_FLAGS)
1037 :
1038 : NS_DEFINE_CLASSINFO_DATA(ImageDocument, nsHTMLDocumentSH,
1039 : DOCUMENT_SCRIPTABLE_FLAGS)
1040 :
1041 : #ifdef MOZ_XUL
1042 : NS_DEFINE_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
1043 : DEFAULT_SCRIPTABLE_FLAGS)
1044 :
1045 : NS_DEFINE_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
1046 : DEFAULT_SCRIPTABLE_FLAGS)
1047 : #endif
1048 :
1049 : NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
1050 : ARRAY_SCRIPTABLE_FLAGS)
1051 :
1052 : #ifdef MOZ_XUL
1053 : NS_DEFINE_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
1054 : DEFAULT_SCRIPTABLE_FLAGS)
1055 :
1056 : NS_DEFINE_CLASSINFO_DATA(TreeColumns, nsTreeColumnsSH,
1057 : ARRAY_SCRIPTABLE_FLAGS)
1058 : #endif
1059 :
1060 : NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
1061 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1062 :
1063 : NS_DEFINE_CLASSINFO_DATA(BeforeUnloadEvent, nsDOMGenericSH,
1064 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1065 :
1066 : // SVG document
1067 : NS_DEFINE_CLASSINFO_DATA(SVGDocument, nsDocumentSH,
1068 : DOCUMENT_SCRIPTABLE_FLAGS)
1069 :
1070 : // SVG element classes
1071 : NS_DEFINE_CLASSINFO_DATA(SVGAElement, nsElementSH,
1072 : ELEMENT_SCRIPTABLE_FLAGS)
1073 : NS_DEFINE_CLASSINFO_DATA(SVGAltGlyphElement, nsElementSH,
1074 : ELEMENT_SCRIPTABLE_FLAGS)
1075 : NS_DEFINE_CLASSINFO_DATA(SVGAnimateElement, nsElementSH,
1076 : ELEMENT_SCRIPTABLE_FLAGS)
1077 : NS_DEFINE_CLASSINFO_DATA(SVGAnimateTransformElement, nsElementSH,
1078 : ELEMENT_SCRIPTABLE_FLAGS)
1079 : NS_DEFINE_CLASSINFO_DATA(SVGAnimateMotionElement, nsElementSH,
1080 : ELEMENT_SCRIPTABLE_FLAGS)
1081 : NS_DEFINE_CLASSINFO_DATA(SVGMpathElement, nsElementSH,
1082 : ELEMENT_SCRIPTABLE_FLAGS)
1083 : NS_DEFINE_CLASSINFO_DATA(SVGSetElement, nsElementSH,
1084 : ELEMENT_SCRIPTABLE_FLAGS)
1085 : NS_DEFINE_CLASSINFO_DATA(TimeEvent, nsDOMGenericSH,
1086 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1087 : NS_DEFINE_CLASSINFO_DATA(SVGCircleElement, nsElementSH,
1088 : ELEMENT_SCRIPTABLE_FLAGS)
1089 : NS_DEFINE_CLASSINFO_DATA(SVGClipPathElement, nsElementSH,
1090 : ELEMENT_SCRIPTABLE_FLAGS)
1091 : NS_DEFINE_CLASSINFO_DATA(SVGDefsElement, nsElementSH,
1092 : ELEMENT_SCRIPTABLE_FLAGS)
1093 : NS_DEFINE_CLASSINFO_DATA(SVGDescElement, nsElementSH,
1094 : ELEMENT_SCRIPTABLE_FLAGS)
1095 : NS_DEFINE_CLASSINFO_DATA(SVGEllipseElement, nsElementSH,
1096 : ELEMENT_SCRIPTABLE_FLAGS)
1097 : NS_DEFINE_CLASSINFO_DATA(SVGFEBlendElement, nsElementSH,
1098 : ELEMENT_SCRIPTABLE_FLAGS)
1099 : NS_DEFINE_CLASSINFO_DATA(SVGFEColorMatrixElement, nsElementSH,
1100 : ELEMENT_SCRIPTABLE_FLAGS)
1101 : NS_DEFINE_CLASSINFO_DATA(SVGFEComponentTransferElement, nsElementSH,
1102 : ELEMENT_SCRIPTABLE_FLAGS)
1103 : NS_DEFINE_CLASSINFO_DATA(SVGFECompositeElement, nsElementSH,
1104 : ELEMENT_SCRIPTABLE_FLAGS)
1105 : NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH,
1106 : ELEMENT_SCRIPTABLE_FLAGS)
1107 : NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH,
1108 : ELEMENT_SCRIPTABLE_FLAGS)
1109 : NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH,
1110 : ELEMENT_SCRIPTABLE_FLAGS)
1111 : NS_DEFINE_CLASSINFO_DATA(SVGFEDistantLightElement, nsElementSH,
1112 : ELEMENT_SCRIPTABLE_FLAGS)
1113 : NS_DEFINE_CLASSINFO_DATA(SVGFEFloodElement, nsElementSH,
1114 : ELEMENT_SCRIPTABLE_FLAGS)
1115 : NS_DEFINE_CLASSINFO_DATA(SVGFEFuncAElement, nsElementSH,
1116 : ELEMENT_SCRIPTABLE_FLAGS)
1117 : NS_DEFINE_CLASSINFO_DATA(SVGFEFuncBElement, nsElementSH,
1118 : ELEMENT_SCRIPTABLE_FLAGS)
1119 : NS_DEFINE_CLASSINFO_DATA(SVGFEFuncGElement, nsElementSH,
1120 : ELEMENT_SCRIPTABLE_FLAGS)
1121 : NS_DEFINE_CLASSINFO_DATA(SVGFEFuncRElement, nsElementSH,
1122 : ELEMENT_SCRIPTABLE_FLAGS)
1123 : NS_DEFINE_CLASSINFO_DATA(SVGFEGaussianBlurElement, nsElementSH,
1124 : ELEMENT_SCRIPTABLE_FLAGS)
1125 : NS_DEFINE_CLASSINFO_DATA(SVGFEImageElement, nsElementSH,
1126 : ELEMENT_SCRIPTABLE_FLAGS)
1127 : NS_DEFINE_CLASSINFO_DATA(SVGFEMergeElement, nsElementSH,
1128 : ELEMENT_SCRIPTABLE_FLAGS)
1129 : NS_DEFINE_CLASSINFO_DATA(SVGFEMergeNodeElement, nsElementSH,
1130 : ELEMENT_SCRIPTABLE_FLAGS)
1131 : NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH,
1132 : ELEMENT_SCRIPTABLE_FLAGS)
1133 : NS_DEFINE_CLASSINFO_DATA(SVGFEOffsetElement, nsElementSH,
1134 : ELEMENT_SCRIPTABLE_FLAGS)
1135 : NS_DEFINE_CLASSINFO_DATA(SVGFEPointLightElement, nsElementSH,
1136 : ELEMENT_SCRIPTABLE_FLAGS)
1137 : NS_DEFINE_CLASSINFO_DATA(SVGFESpecularLightingElement, nsElementSH,
1138 : ELEMENT_SCRIPTABLE_FLAGS)
1139 : NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH,
1140 : ELEMENT_SCRIPTABLE_FLAGS)
1141 : NS_DEFINE_CLASSINFO_DATA(SVGFETileElement, nsElementSH,
1142 : ELEMENT_SCRIPTABLE_FLAGS)
1143 : NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH,
1144 : ELEMENT_SCRIPTABLE_FLAGS)
1145 : NS_DEFINE_CLASSINFO_DATA(SVGFilterElement, nsElementSH,
1146 : ELEMENT_SCRIPTABLE_FLAGS)
1147 : NS_DEFINE_CLASSINFO_DATA(SVGGElement, nsElementSH,
1148 : ELEMENT_SCRIPTABLE_FLAGS)
1149 : NS_DEFINE_CLASSINFO_DATA(SVGImageElement, nsElementSH,
1150 : ELEMENT_SCRIPTABLE_FLAGS)
1151 : NS_DEFINE_CLASSINFO_DATA(SVGLinearGradientElement, nsElementSH,
1152 : ELEMENT_SCRIPTABLE_FLAGS)
1153 : NS_DEFINE_CLASSINFO_DATA(SVGLineElement, nsElementSH,
1154 : ELEMENT_SCRIPTABLE_FLAGS)
1155 : NS_DEFINE_CLASSINFO_DATA(SVGMarkerElement, nsElementSH,
1156 : ELEMENT_SCRIPTABLE_FLAGS)
1157 : NS_DEFINE_CLASSINFO_DATA(SVGMaskElement, nsElementSH,
1158 : ELEMENT_SCRIPTABLE_FLAGS)
1159 : NS_DEFINE_CLASSINFO_DATA(SVGMetadataElement, nsElementSH,
1160 : ELEMENT_SCRIPTABLE_FLAGS)
1161 : NS_DEFINE_CLASSINFO_DATA(SVGPathElement, nsElementSH,
1162 : ELEMENT_SCRIPTABLE_FLAGS)
1163 : NS_DEFINE_CLASSINFO_DATA(SVGPatternElement, nsElementSH,
1164 : ELEMENT_SCRIPTABLE_FLAGS)
1165 : NS_DEFINE_CLASSINFO_DATA(SVGPolygonElement, nsElementSH,
1166 : ELEMENT_SCRIPTABLE_FLAGS)
1167 : NS_DEFINE_CLASSINFO_DATA(SVGPolylineElement, nsElementSH,
1168 : ELEMENT_SCRIPTABLE_FLAGS)
1169 : NS_DEFINE_CLASSINFO_DATA(SVGRadialGradientElement, nsElementSH,
1170 : ELEMENT_SCRIPTABLE_FLAGS)
1171 : NS_DEFINE_CLASSINFO_DATA(SVGRectElement, nsElementSH,
1172 : ELEMENT_SCRIPTABLE_FLAGS)
1173 : NS_DEFINE_CLASSINFO_DATA(SVGScriptElement, nsElementSH,
1174 : ELEMENT_SCRIPTABLE_FLAGS)
1175 : NS_DEFINE_CLASSINFO_DATA(SVGStopElement, nsElementSH,
1176 : ELEMENT_SCRIPTABLE_FLAGS)
1177 : NS_DEFINE_CLASSINFO_DATA(SVGStyleElement, nsElementSH,
1178 : ELEMENT_SCRIPTABLE_FLAGS)
1179 : NS_DEFINE_CLASSINFO_DATA(SVGSVGElement, nsElementSH,
1180 : ELEMENT_SCRIPTABLE_FLAGS)
1181 : NS_DEFINE_CLASSINFO_DATA(SVGSwitchElement, nsElementSH,
1182 : ELEMENT_SCRIPTABLE_FLAGS)
1183 : NS_DEFINE_CLASSINFO_DATA(SVGSymbolElement, nsElementSH,
1184 : ELEMENT_SCRIPTABLE_FLAGS)
1185 : NS_DEFINE_CLASSINFO_DATA(SVGTextElement, nsElementSH,
1186 : ELEMENT_SCRIPTABLE_FLAGS)
1187 : NS_DEFINE_CLASSINFO_DATA(SVGTextPathElement, nsElementSH,
1188 : ELEMENT_SCRIPTABLE_FLAGS)
1189 : NS_DEFINE_CLASSINFO_DATA(SVGTitleElement, nsElementSH,
1190 : ELEMENT_SCRIPTABLE_FLAGS)
1191 : NS_DEFINE_CLASSINFO_DATA(SVGTSpanElement, nsElementSH,
1192 : ELEMENT_SCRIPTABLE_FLAGS)
1193 : NS_DEFINE_CLASSINFO_DATA_WITH_NAME(SVGUnknownElement, SVGElement, nsElementSH,
1194 : ELEMENT_SCRIPTABLE_FLAGS)
1195 : NS_DEFINE_CLASSINFO_DATA(SVGUseElement, nsElementSH,
1196 : ELEMENT_SCRIPTABLE_FLAGS)
1197 :
1198 : // other SVG classes
1199 : NS_DEFINE_CLASSINFO_DATA(SVGAngle, nsDOMGenericSH,
1200 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1201 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedAngle, nsDOMGenericSH,
1202 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1203 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedBoolean, nsDOMGenericSH,
1204 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1205 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedEnumeration, nsDOMGenericSH,
1206 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1207 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH,
1208 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1209 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLength, nsDOMGenericSH,
1210 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1211 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLengthList, nsDOMGenericSH,
1212 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1213 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH,
1214 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1215 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumberList, nsDOMGenericSH,
1216 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1217 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedPreserveAspectRatio, nsDOMGenericSH,
1218 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1219 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedRect, nsDOMGenericSH,
1220 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1221 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedString, nsDOMGenericSH,
1222 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1223 : NS_DEFINE_CLASSINFO_DATA(SVGAnimatedTransformList, nsDOMGenericSH,
1224 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1225 : NS_DEFINE_CLASSINFO_DATA(SVGEvent, nsDOMGenericSH,
1226 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1227 : NS_DEFINE_CLASSINFO_DATA(SVGException, nsDOMGenericSH,
1228 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1229 : NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
1230 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1231 : NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsSVGLengthListSH,
1232 : ARRAY_SCRIPTABLE_FLAGS)
1233 : NS_DEFINE_CLASSINFO_DATA(SVGMatrix, nsDOMGenericSH,
1234 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1235 : NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
1236 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1237 : NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsSVGNumberListSH,
1238 : ARRAY_SCRIPTABLE_FLAGS)
1239 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcAbs, nsDOMGenericSH,
1240 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1241 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcRel, nsDOMGenericSH,
1242 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1243 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegClosePath, nsDOMGenericSH,
1244 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1245 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicAbs, nsDOMGenericSH,
1246 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1247 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicRel, nsDOMGenericSH,
1248 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1249 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothAbs, nsDOMGenericSH,
1250 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1251 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothRel, nsDOMGenericSH,
1252 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1253 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticAbs, nsDOMGenericSH,
1254 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1255 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticRel, nsDOMGenericSH,
1256 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1257 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothAbs, nsDOMGenericSH,
1258 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1259 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothRel, nsDOMGenericSH,
1260 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1261 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoAbs, nsDOMGenericSH,
1262 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1263 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalAbs, nsDOMGenericSH,
1264 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1265 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalRel, nsDOMGenericSH,
1266 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1267 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoRel, nsDOMGenericSH,
1268 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1269 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalAbs, nsDOMGenericSH,
1270 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1271 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalRel, nsDOMGenericSH,
1272 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1273 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsSVGPathSegListSH,
1274 : ARRAY_SCRIPTABLE_FLAGS)
1275 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoAbs, nsDOMGenericSH,
1276 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1277 : NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoRel, nsDOMGenericSH,
1278 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1279 : NS_DEFINE_CLASSINFO_DATA(SVGPoint, nsDOMGenericSH,
1280 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1281 : NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsSVGPointListSH,
1282 : ARRAY_SCRIPTABLE_FLAGS)
1283 : NS_DEFINE_CLASSINFO_DATA(SVGPreserveAspectRatio, nsDOMGenericSH,
1284 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1285 : NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH,
1286 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1287 : NS_DEFINE_CLASSINFO_DATA(SVGStringList, nsSVGStringListSH,
1288 : ARRAY_SCRIPTABLE_FLAGS)
1289 : NS_DEFINE_CLASSINFO_DATA(SVGTransform, nsDOMGenericSH,
1290 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1291 : NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsSVGTransformListSH,
1292 : ARRAY_SCRIPTABLE_FLAGS)
1293 : NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
1294 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1295 :
1296 : NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsElementSH,
1297 : ELEMENT_SCRIPTABLE_FLAGS)
1298 : NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContext2D, nsDOMGenericSH,
1299 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1300 : NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
1301 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1302 : NS_DEFINE_CLASSINFO_DATA(CanvasPattern, nsDOMGenericSH,
1303 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1304 : NS_DEFINE_CLASSINFO_DATA(TextMetrics, nsDOMGenericSH,
1305 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1306 :
1307 : NS_DEFINE_CLASSINFO_DATA(SmartCardEvent, nsDOMGenericSH,
1308 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1309 : NS_DEFINE_CLASSINFO_DATA(PageTransitionEvent, nsDOMGenericSH,
1310 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1311 : NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH,
1312 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1313 :
1314 : NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
1315 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1316 :
1317 : NS_DEFINE_CLASSINFO_DATA(XPathEvaluator, nsDOMGenericSH,
1318 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1319 : NS_DEFINE_CLASSINFO_DATA(XPathException, nsDOMGenericSH,
1320 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1321 : NS_DEFINE_CLASSINFO_DATA(XPathExpression, nsDOMGenericSH,
1322 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1323 : NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
1324 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1325 : NS_DEFINE_CLASSINFO_DATA(XPathResult, nsDOMGenericSH,
1326 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1327 :
1328 : // WhatWG Storage
1329 :
1330 : // mrbkap says we don't need WANT_ADDPROPERTY on Storage objects
1331 : // since a call to addProperty() is always followed by a call to
1332 : // setProperty(), except in the case when a getter or setter is set
1333 : // for a property. But we don't care about getters or setters here.
1334 : NS_DEFINE_CLASSINFO_DATA(StorageObsolete, nsStorageSH,
1335 : DOM_DEFAULT_SCRIPTABLE_FLAGS |
1336 : nsIXPCScriptable::WANT_NEWRESOLVE |
1337 : nsIXPCScriptable::WANT_GETPROPERTY |
1338 : nsIXPCScriptable::WANT_SETPROPERTY |
1339 : nsIXPCScriptable::WANT_DELPROPERTY |
1340 : nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
1341 : nsIXPCScriptable::WANT_NEWENUMERATE)
1342 :
1343 : NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
1344 : DOM_DEFAULT_SCRIPTABLE_FLAGS |
1345 : nsIXPCScriptable::WANT_NEWRESOLVE |
1346 : nsIXPCScriptable::WANT_GETPROPERTY |
1347 : nsIXPCScriptable::WANT_SETPROPERTY |
1348 : nsIXPCScriptable::WANT_DELPROPERTY |
1349 : nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
1350 : nsIXPCScriptable::WANT_NEWENUMERATE)
1351 : NS_DEFINE_CLASSINFO_DATA(StorageList, nsStorageListSH,
1352 : ARRAY_SCRIPTABLE_FLAGS)
1353 : NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
1354 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1355 : NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
1356 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1357 : NS_DEFINE_CLASSINFO_DATA(StorageEventObsolete, nsDOMGenericSH,
1358 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1359 :
1360 : NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
1361 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1362 : NS_DEFINE_CLASSINFO_DATA(XMLSerializer, nsDOMGenericSH,
1363 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1364 :
1365 : NS_DEFINE_CLASSINFO_DATA(XMLHttpProgressEvent, nsDOMGenericSH,
1366 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1367 : NS_DEFINE_CLASSINFO_DATA(XMLHttpRequest, nsEventTargetSH,
1368 : EVENTTARGET_SCRIPTABLE_FLAGS)
1369 :
1370 : NS_DEFINE_CLASSINFO_DATA(EventSource, nsEventTargetSH,
1371 : EVENTTARGET_SCRIPTABLE_FLAGS)
1372 :
1373 : NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
1374 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1375 : NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsClientRectListSH,
1376 : ARRAY_SCRIPTABLE_FLAGS)
1377 :
1378 : NS_DEFINE_CLASSINFO_DATA(SVGForeignObjectElement, nsElementSH,
1379 : ELEMENT_SCRIPTABLE_FLAGS)
1380 :
1381 : NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsDOMGenericSH,
1382 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1383 :
1384 : NS_DEFINE_CLASSINFO_DATA(CommandEvent, nsDOMGenericSH,
1385 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1386 : NS_DEFINE_CLASSINFO_DATA(OfflineResourceList, nsOfflineResourceListSH,
1387 : ARRAY_SCRIPTABLE_FLAGS)
1388 :
1389 : NS_DEFINE_CLASSINFO_DATA(FileList, nsFileListSH,
1390 : ARRAY_SCRIPTABLE_FLAGS)
1391 : NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
1392 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1393 : NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
1394 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1395 : NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
1396 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1397 : NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
1398 : EVENTTARGET_SCRIPTABLE_FLAGS)
1399 : NS_DEFINE_CLASSINFO_DATA(MozURLProperty, nsDOMGenericSH,
1400 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1401 : NS_DEFINE_CLASSINFO_DATA(MozBlobBuilder, nsDOMGenericSH,
1402 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1403 :
1404 : NS_DEFINE_CLASSINFO_DATA(DOMStringMap, nsDOMStringMapSH,
1405 : DOMSTRINGMAP_SCRIPTABLE_FLAGS)
1406 :
1407 : NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
1408 : DEFAULT_SCRIPTABLE_FLAGS |
1409 : WINDOW_SCRIPTABLE_FLAGS)
1410 :
1411 : NS_DEFINE_CLASSINFO_DATA(DataContainerEvent, nsDOMGenericSH,
1412 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1413 :
1414 : NS_DEFINE_CLASSINFO_DATA(MessageEvent, nsDOMGenericSH,
1415 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1416 :
1417 : NS_DEFINE_CLASSINFO_DATA(GeoGeolocation, nsDOMGenericSH,
1418 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1419 :
1420 : NS_DEFINE_CLASSINFO_DATA(GeoPosition, nsDOMGenericSH,
1421 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1422 :
1423 : NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsDOMGenericSH,
1424 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1425 :
1426 : NS_DEFINE_CLASSINFO_DATA(GeoPositionAddress, nsDOMGenericSH,
1427 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1428 :
1429 : NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
1430 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1431 :
1432 : NS_DEFINE_CLASSINFO_DATA(MozBatteryManager, nsDOMGenericSH,
1433 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1434 :
1435 : NS_DEFINE_CLASSINFO_DATA(MozPowerManager, nsDOMGenericSH,
1436 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1437 :
1438 : NS_DEFINE_CLASSINFO_DATA(MozWakeLock, nsDOMGenericSH,
1439 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1440 :
1441 : NS_DEFINE_CLASSINFO_DATA(MozSmsManager, nsDOMGenericSH,
1442 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1443 :
1444 : NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
1445 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1446 :
1447 : NS_DEFINE_CLASSINFO_DATA(MozSmsEvent, nsDOMGenericSH,
1448 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1449 :
1450 : NS_DEFINE_CLASSINFO_DATA(MozSmsRequest, nsDOMGenericSH,
1451 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1452 :
1453 : NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
1454 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1455 :
1456 : NS_DEFINE_CLASSINFO_DATA(MozSmsCursor, nsDOMGenericSH,
1457 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1458 :
1459 : NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
1460 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1461 :
1462 : NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
1463 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1464 : NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
1465 : ARRAY_SCRIPTABLE_FLAGS)
1466 :
1467 : #if defined(MOZ_MEDIA)
1468 : NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
1469 : ELEMENT_SCRIPTABLE_FLAGS)
1470 : NS_DEFINE_CLASSINFO_DATA(HTMLSourceElement, nsElementSH,
1471 : ELEMENT_SCRIPTABLE_FLAGS)
1472 : NS_DEFINE_CLASSINFO_DATA(MediaError, nsDOMGenericSH,
1473 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1474 : NS_DEFINE_CLASSINFO_DATA(HTMLAudioElement, nsElementSH,
1475 : ELEMENT_SCRIPTABLE_FLAGS)
1476 : NS_DEFINE_CLASSINFO_DATA(TimeRanges, nsDOMGenericSH,
1477 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1478 : #endif
1479 :
1480 : NS_DEFINE_CLASSINFO_DATA(ProgressEvent, nsDOMGenericSH,
1481 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1482 :
1483 : NS_DEFINE_CLASSINFO_DATA(XMLHttpRequestUpload, nsEventTargetSH,
1484 : EVENTTARGET_SCRIPTABLE_FLAGS)
1485 :
1486 : // DOM Traversal NodeIterator class
1487 : NS_DEFINE_CLASSINFO_DATA(NodeIterator, nsDOMGenericSH,
1488 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1489 :
1490 : // data transfer for drag and drop
1491 : NS_DEFINE_CLASSINFO_DATA(DataTransfer, nsDOMGenericSH,
1492 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1493 :
1494 : NS_DEFINE_CLASSINFO_DATA(NotifyPaintEvent, nsDOMGenericSH,
1495 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1496 :
1497 : NS_DEFINE_CLASSINFO_DATA(NotifyAudioAvailableEvent, nsDOMGenericSH,
1498 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1499 :
1500 : NS_DEFINE_CLASSINFO_DATA(SimpleGestureEvent, nsDOMGenericSH,
1501 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1502 :
1503 : NS_DEFINE_CLASSINFO_DATA(MozTouchEvent, nsDOMGenericSH,
1504 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1505 : NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
1506 : ELEMENT_SCRIPTABLE_FLAGS)
1507 :
1508 : NS_DEFINE_CLASSINFO_DATA(WebGLRenderingContext, nsWebGLViewportHandlerSH,
1509 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1510 : NS_DEFINE_CLASSINFO_DATA(WebGLBuffer, nsDOMGenericSH,
1511 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1512 : NS_DEFINE_CLASSINFO_DATA(WebGLTexture, nsDOMGenericSH,
1513 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1514 : NS_DEFINE_CLASSINFO_DATA(WebGLProgram, nsDOMGenericSH,
1515 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1516 : NS_DEFINE_CLASSINFO_DATA(WebGLShader, nsDOMGenericSH,
1517 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1518 : NS_DEFINE_CLASSINFO_DATA(WebGLFramebuffer, nsDOMGenericSH,
1519 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1520 : NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
1521 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1522 : NS_DEFINE_CLASSINFO_DATA(WebGLUniformLocation, nsDOMGenericSH,
1523 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1524 : NS_DEFINE_CLASSINFO_DATA(WebGLShaderPrecisionFormat, nsDOMGenericSH,
1525 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1526 : NS_DEFINE_CLASSINFO_DATA(WebGLActiveInfo, nsDOMGenericSH,
1527 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1528 : NS_DEFINE_CLASSINFO_DATA(WebGLExtension, nsDOMGenericSH,
1529 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1530 : NS_DEFINE_CLASSINFO_DATA(WebGLExtensionStandardDerivatives, nsDOMGenericSH,
1531 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1532 : NS_DEFINE_CLASSINFO_DATA(WebGLExtensionTextureFilterAnisotropic, nsDOMGenericSH,
1533 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1534 : NS_DEFINE_CLASSINFO_DATA(WebGLExtensionLoseContext, nsDOMGenericSH,
1535 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1536 :
1537 : NS_DEFINE_CLASSINFO_DATA(PaintRequest, nsDOMGenericSH,
1538 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1539 : NS_DEFINE_CLASSINFO_DATA(PaintRequestList, nsPaintRequestListSH,
1540 : ARRAY_SCRIPTABLE_FLAGS)
1541 :
1542 : NS_DEFINE_CLASSINFO_DATA(ScrollAreaEvent, nsDOMGenericSH,
1543 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1544 : NS_DEFINE_CLASSINFO_DATA(PopStateEvent, nsDOMGenericSH,
1545 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1546 : NS_DEFINE_CLASSINFO_DATA(HashChangeEvent, nsDOMGenericSH,
1547 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1548 : NS_DEFINE_CLASSINFO_DATA(EventListenerInfo, nsDOMGenericSH,
1549 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1550 : NS_DEFINE_CLASSINFO_DATA(TransitionEvent, nsDOMGenericSH,
1551 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1552 : NS_DEFINE_CLASSINFO_DATA(AnimationEvent, nsDOMGenericSH,
1553 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1554 : NS_DEFINE_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
1555 : DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::IS_GLOBAL_OBJECT)
1556 :
1557 : NS_DEFINE_CLASSINFO_DATA(FormData, nsDOMGenericSH,
1558 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1559 :
1560 : NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
1561 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1562 : NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
1563 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1564 :
1565 : NS_DEFINE_CLASSINFO_DATA(WebSocket, nsEventTargetSH,
1566 : EVENTTARGET_SCRIPTABLE_FLAGS)
1567 :
1568 : NS_DEFINE_CLASSINFO_DATA(CloseEvent, nsDOMGenericSH,
1569 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1570 :
1571 : NS_DEFINE_CLASSINFO_DATA(IDBFactory, nsDOMGenericSH,
1572 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1573 : NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
1574 : IDBEVENTTARGET_SCRIPTABLE_FLAGS)
1575 : NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
1576 : IDBEVENTTARGET_SCRIPTABLE_FLAGS)
1577 : NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
1578 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1579 : NS_DEFINE_CLASSINFO_DATA(IDBTransaction, IDBEventTargetSH,
1580 : IDBEVENTTARGET_SCRIPTABLE_FLAGS)
1581 : NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
1582 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1583 : NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
1584 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1585 : NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
1586 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1587 : NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
1588 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1589 : NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeEvent, nsDOMGenericSH,
1590 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1591 : NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
1592 : IDBEVENTTARGET_SCRIPTABLE_FLAGS)
1593 : NS_DEFINE_CLASSINFO_DATA(IDBDatabaseException, nsDOMGenericSH,
1594 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1595 :
1596 : NS_DEFINE_CLASSINFO_DATA(Touch, nsDOMGenericSH,
1597 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1598 : NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMTouchListSH,
1599 : ARRAY_SCRIPTABLE_FLAGS)
1600 : NS_DEFINE_CLASSINFO_DATA(TouchEvent, nsDOMGenericSH,
1601 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1602 :
1603 : NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframeRule, nsDOMGenericSH,
1604 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1605 : NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframesRule, nsDOMGenericSH,
1606 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1607 :
1608 : NS_DEFINE_CLASSINFO_DATA(MediaQueryList, nsDOMGenericSH,
1609 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1610 : NS_DEFINE_CLASSINFO_DATA(CustomEvent, nsDOMGenericSH,
1611 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1612 :
1613 : #ifdef MOZ_B2G_RIL
1614 : NS_DEFINE_CLASSINFO_DATA(Telephony, nsEventTargetSH,
1615 : EVENTTARGET_SCRIPTABLE_FLAGS)
1616 : NS_DEFINE_CLASSINFO_DATA(TelephonyCall, nsEventTargetSH,
1617 : EVENTTARGET_SCRIPTABLE_FLAGS)
1618 : NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
1619 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1620 : #endif
1621 :
1622 : #ifdef MOZ_B2G_BT
1623 : NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
1624 : EVENTTARGET_SCRIPTABLE_FLAGS)
1625 : #endif
1626 :
1627 : NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH,
1628 : DOM_DEFAULT_SCRIPTABLE_FLAGS)
1629 :
1630 : NS_DEFINE_CLASSINFO_DATA(DOMRequest, nsEventTargetSH,
1631 : EVENTTARGET_SCRIPTABLE_FLAGS)
1632 : };
1633 :
1634 : // Objects that should be constructable through |new Name();|
1635 : struct nsContractIDMapData
1636 : {
1637 : PRInt32 mDOMClassInfoID;
1638 : const char *mContractID;
1639 : };
1640 :
1641 : #define NS_DEFINE_CONSTRUCTOR_DATA(_class, _contract_id) \
1642 : { eDOMClassInfo_##_class##_id, _contract_id },
1643 :
1644 : static const nsContractIDMapData kConstructorMap[] =
1645 : {
1646 : NS_DEFINE_CONSTRUCTOR_DATA(DOMParser, NS_DOMPARSER_CONTRACTID)
1647 : NS_DEFINE_CONSTRUCTOR_DATA(FileReader, NS_FILEREADER_CONTRACTID)
1648 : NS_DEFINE_CONSTRUCTOR_DATA(FormData, NS_FORMDATA_CONTRACTID)
1649 : NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
1650 : NS_DEFINE_CONSTRUCTOR_DATA(XMLHttpRequest, NS_XMLHTTPREQUEST_CONTRACTID)
1651 : NS_DEFINE_CONSTRUCTOR_DATA(WebSocket, NS_WEBSOCKET_CONTRACTID)
1652 : NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
1653 : NS_DEFINE_CONSTRUCTOR_DATA(XSLTProcessor,
1654 : "@mozilla.org/document-transformer;1?type=xslt")
1655 : NS_DEFINE_CONSTRUCTOR_DATA(EventSource, NS_EVENTSOURCE_CONTRACTID)
1656 : };
1657 :
1658 : #define NS_DEFINE_EVENT_CTOR(_class) \
1659 : nsresult \
1660 : NS_DOM##_class##Ctor(nsISupports** aInstancePtrResult) \
1661 : { \
1662 : nsIDOMEvent* e = nsnull; \
1663 : nsresult rv = NS_NewDOM##_class(&e, nsnull, nsnull); \
1664 : *aInstancePtrResult = e; \
1665 : return rv; \
1666 : }
1667 :
1668 0 : NS_DEFINE_EVENT_CTOR(Event)
1669 0 : NS_DEFINE_EVENT_CTOR(CustomEvent)
1670 0 : NS_DEFINE_EVENT_CTOR(PopStateEvent)
1671 0 : NS_DEFINE_EVENT_CTOR(HashChangeEvent)
1672 0 : NS_DEFINE_EVENT_CTOR(PageTransitionEvent)
1673 0 : NS_DEFINE_EVENT_CTOR(CloseEvent)
1674 0 : NS_DEFINE_EVENT_CTOR(UIEvent)
1675 0 : NS_DEFINE_EVENT_CTOR(MouseEvent)
1676 : nsresult
1677 0 : NS_DOMStorageEventCtor(nsISupports** aInstancePtrResult)
1678 : {
1679 0 : nsDOMStorageEvent* e = new nsDOMStorageEvent();
1680 0 : return CallQueryInterface(e, aInstancePtrResult);
1681 : }
1682 :
1683 : struct nsConstructorFuncMapData
1684 : {
1685 : PRInt32 mDOMClassInfoID;
1686 : nsDOMConstructorFunc mConstructorFunc;
1687 : };
1688 :
1689 : #define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func) \
1690 : { eDOMClassInfo_##_class##_id, _func },
1691 :
1692 : #define NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(_class) \
1693 : { eDOMClassInfo_##_class##_id, NS_DOM##_class##Ctor },
1694 :
1695 : static const nsConstructorFuncMapData kConstructorFuncMap[] =
1696 : {
1697 : NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, nsDOMMultipartFile::NewBlob)
1698 : NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, nsDOMFileFile::NewFile)
1699 : NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozBlobBuilder, NS_NewBlobBuilder)
1700 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
1701 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
1702 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PopStateEvent)
1703 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(HashChangeEvent)
1704 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PageTransitionEvent)
1705 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CloseEvent)
1706 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UIEvent)
1707 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MouseEvent)
1708 : NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(StorageEvent)
1709 : NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter)
1710 : };
1711 :
1712 : nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
1713 : nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
1714 : bool nsDOMClassInfo::sIsInitialized = false;
1715 : bool nsDOMClassInfo::sDisableDocumentAllSupport = false;
1716 : bool nsDOMClassInfo::sDisableGlobalScopePollutionSupport = false;
1717 :
1718 :
1719 1396 : jsid nsDOMClassInfo::sParent_id = JSID_VOID;
1720 1396 : jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID;
1721 1396 : jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
1722 1396 : jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
1723 1396 : jsid nsDOMClassInfo::s_content_id = JSID_VOID;
1724 1396 : jsid nsDOMClassInfo::sContent_id = JSID_VOID;
1725 1396 : jsid nsDOMClassInfo::sMenubar_id = JSID_VOID;
1726 1396 : jsid nsDOMClassInfo::sToolbar_id = JSID_VOID;
1727 1396 : jsid nsDOMClassInfo::sLocationbar_id = JSID_VOID;
1728 1396 : jsid nsDOMClassInfo::sPersonalbar_id = JSID_VOID;
1729 1396 : jsid nsDOMClassInfo::sStatusbar_id = JSID_VOID;
1730 1396 : jsid nsDOMClassInfo::sDialogArguments_id = JSID_VOID;
1731 1396 : jsid nsDOMClassInfo::sControllers_id = JSID_VOID;
1732 1396 : jsid nsDOMClassInfo::sLength_id = JSID_VOID;
1733 1396 : jsid nsDOMClassInfo::sInnerHeight_id = JSID_VOID;
1734 1396 : jsid nsDOMClassInfo::sInnerWidth_id = JSID_VOID;
1735 1396 : jsid nsDOMClassInfo::sOuterHeight_id = JSID_VOID;
1736 1396 : jsid nsDOMClassInfo::sOuterWidth_id = JSID_VOID;
1737 1396 : jsid nsDOMClassInfo::sScreenX_id = JSID_VOID;
1738 1396 : jsid nsDOMClassInfo::sScreenY_id = JSID_VOID;
1739 1396 : jsid nsDOMClassInfo::sStatus_id = JSID_VOID;
1740 1396 : jsid nsDOMClassInfo::sName_id = JSID_VOID;
1741 1396 : jsid nsDOMClassInfo::sScrollX_id = JSID_VOID;
1742 1396 : jsid nsDOMClassInfo::sScrollY_id = JSID_VOID;
1743 1396 : jsid nsDOMClassInfo::sScrollMaxX_id = JSID_VOID;
1744 1396 : jsid nsDOMClassInfo::sScrollMaxY_id = JSID_VOID;
1745 1396 : jsid nsDOMClassInfo::sItem_id = JSID_VOID;
1746 1396 : jsid nsDOMClassInfo::sNamedItem_id = JSID_VOID;
1747 1396 : jsid nsDOMClassInfo::sEnumerate_id = JSID_VOID;
1748 1396 : jsid nsDOMClassInfo::sNavigator_id = JSID_VOID;
1749 1396 : jsid nsDOMClassInfo::sDocument_id = JSID_VOID;
1750 1396 : jsid nsDOMClassInfo::sFrames_id = JSID_VOID;
1751 1396 : jsid nsDOMClassInfo::sSelf_id = JSID_VOID;
1752 1396 : jsid nsDOMClassInfo::sOpener_id = JSID_VOID;
1753 1396 : jsid nsDOMClassInfo::sAll_id = JSID_VOID;
1754 1396 : jsid nsDOMClassInfo::sTags_id = JSID_VOID;
1755 1396 : jsid nsDOMClassInfo::sAddEventListener_id= JSID_VOID;
1756 1396 : jsid nsDOMClassInfo::sBaseURIObject_id = JSID_VOID;
1757 1396 : jsid nsDOMClassInfo::sNodePrincipal_id = JSID_VOID;
1758 1396 : jsid nsDOMClassInfo::sDocumentURIObject_id=JSID_VOID;
1759 1396 : jsid nsDOMClassInfo::sJava_id = JSID_VOID;
1760 1396 : jsid nsDOMClassInfo::sPackages_id = JSID_VOID;
1761 1396 : jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
1762 1396 : jsid nsDOMClassInfo::sURL_id = JSID_VOID;
1763 1396 : jsid nsDOMClassInfo::sKeyPath_id = JSID_VOID;
1764 1396 : jsid nsDOMClassInfo::sAutoIncrement_id = JSID_VOID;
1765 1396 : jsid nsDOMClassInfo::sUnique_id = JSID_VOID;
1766 1396 : jsid nsDOMClassInfo::sMultiEntry_id = JSID_VOID;
1767 1396 : jsid nsDOMClassInfo::sOnload_id = JSID_VOID;
1768 1396 : jsid nsDOMClassInfo::sOnerror_id = JSID_VOID;
1769 :
1770 : static const JSClass *sObjectClass = nsnull;
1771 :
1772 : /**
1773 : * Set our JSClass pointer for the Object class
1774 : */
1775 : static void
1776 305 : FindObjectClass(JSObject* aGlobalObject)
1777 : {
1778 305 : NS_ASSERTION(!sObjectClass,
1779 : "Double set of sObjectClass");
1780 305 : JSObject *obj, *proto = aGlobalObject;
1781 610 : do {
1782 610 : obj = proto;
1783 610 : proto = js::GetObjectProto(obj);
1784 : } while (proto);
1785 :
1786 305 : sObjectClass = js::GetObjectJSClass(obj);
1787 305 : }
1788 :
1789 : static void
1790 0 : PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
1791 : {
1792 : nsCOMPtr<nsIStringBundleService> stringService =
1793 0 : mozilla::services::GetStringBundleService();
1794 0 : if (!stringService) {
1795 : return;
1796 : }
1797 :
1798 0 : nsCOMPtr<nsIStringBundle> bundle;
1799 0 : stringService->CreateBundle(kDOMStringBundleURL, getter_AddRefs(bundle));
1800 0 : if (!bundle) {
1801 : return;
1802 : }
1803 :
1804 0 : nsXPIDLString msg;
1805 0 : bundle->GetStringFromName(NS_ConvertASCIItoUTF16(stringBundleProperty).get(),
1806 0 : getter_Copies(msg));
1807 :
1808 0 : if (msg.IsEmpty()) {
1809 0 : NS_ERROR("Failed to get strings from dom.properties!");
1810 : return;
1811 : }
1812 :
1813 : nsCOMPtr<nsIConsoleService> consoleService
1814 0 : (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
1815 0 : if (!consoleService) {
1816 : return;
1817 : }
1818 :
1819 : nsCOMPtr<nsIScriptError> scriptError =
1820 0 : do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
1821 0 : if (!scriptError) {
1822 : return;
1823 : }
1824 :
1825 0 : JSStackFrame *fp, *iterator = nsnull;
1826 0 : fp = ::JS_FrameIterator(cx, &iterator);
1827 0 : PRUint32 lineno = 0;
1828 0 : nsAutoString sourcefile;
1829 0 : if (fp) {
1830 0 : JSScript* script = ::JS_GetFrameScript(cx, fp);
1831 0 : if (script) {
1832 0 : const char* filename = ::JS_GetScriptFilename(cx, script);
1833 0 : if (filename) {
1834 0 : CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
1835 : }
1836 0 : jsbytecode* pc = ::JS_GetFramePC(cx, fp);
1837 0 : if (pc) {
1838 0 : lineno = ::JS_PCToLineNumber(cx, script, pc);
1839 : }
1840 : }
1841 : }
1842 :
1843 0 : nsresult rv = scriptError->InitWithWindowID(msg.get(),
1844 : sourcefile.get(),
1845 0 : EmptyString().get(),
1846 : lineno,
1847 : 0, // column for error is not available
1848 : nsIScriptError::warningFlag,
1849 : "DOM:HTML",
1850 0 : nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
1851 :
1852 0 : if (NS_SUCCEEDED(rv)) {
1853 0 : consoleService->LogMessage(scriptError);
1854 : }
1855 : }
1856 :
1857 : static inline JSString *
1858 73 : IdToString(JSContext *cx, jsid id)
1859 : {
1860 73 : if (JSID_IS_STRING(id))
1861 73 : return JSID_TO_STRING(id);
1862 : jsval idval;
1863 0 : if (!::JS_IdToValue(cx, id, &idval))
1864 0 : return nsnull;
1865 0 : return JS_ValueToString(cx, idval);
1866 : }
1867 :
1868 : static inline nsresult
1869 15146 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
1870 : nsWrapperCache *cache, const nsIID* aIID, jsval *vp,
1871 : nsIXPConnectJSObjectHolder** aHolder, bool aAllowWrapping)
1872 : {
1873 15146 : if (!native) {
1874 0 : NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!");
1875 :
1876 0 : *vp = JSVAL_NULL;
1877 :
1878 0 : return NS_OK;
1879 : }
1880 :
1881 15146 : JSObject *wrapper = xpc_FastGetCachedWrapper(cache, scope, vp);
1882 15146 : if (wrapper) {
1883 15141 : return NS_OK;
1884 : }
1885 :
1886 5 : return nsDOMClassInfo::XPConnect()->WrapNativeToJSVal(cx, scope, native,
1887 : cache, aIID,
1888 : aAllowWrapping, vp,
1889 5 : aHolder);
1890 : }
1891 :
1892 : static inline nsresult
1893 3 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
1894 : const nsIID* aIID, bool aAllowWrapping, jsval *vp,
1895 : // If non-null aHolder will keep the jsval alive
1896 : // while there's a ref to it
1897 : nsIXPConnectJSObjectHolder** aHolder = nsnull)
1898 : {
1899 : return WrapNative(cx, scope, native, nsnull, aIID, vp, aHolder,
1900 3 : aAllowWrapping);
1901 : }
1902 :
1903 : // Same as the WrapNative above, but use these if aIID is nsISupports' IID.
1904 : static inline nsresult
1905 0 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
1906 : bool aAllowWrapping, jsval *vp,
1907 : // If non-null aHolder will keep the jsval alive
1908 : // while there's a ref to it
1909 : nsIXPConnectJSObjectHolder** aHolder = nsnull)
1910 : {
1911 : return WrapNative(cx, scope, native, nsnull, nsnull, vp, aHolder,
1912 0 : aAllowWrapping);
1913 : }
1914 :
1915 : static inline nsresult
1916 15143 : WrapNative(JSContext *cx, JSObject *scope, nsISupports *native,
1917 : nsWrapperCache *cache, bool aAllowWrapping, jsval *vp,
1918 : // If non-null aHolder will keep the jsval alive
1919 : // while there's a ref to it
1920 : nsIXPConnectJSObjectHolder** aHolder = nsnull)
1921 : {
1922 : return WrapNative(cx, scope, native, cache, nsnull, vp, aHolder,
1923 15143 : aAllowWrapping);
1924 : }
1925 :
1926 : // Used for cases where PreCreate needs to wrap the native parent, and the
1927 : // native parent is likely to have been wrapped already. |native| must
1928 : // implement nsWrapperCache, and nativeWrapperCache must be |native|'s
1929 : // nsWrapperCache.
1930 : static inline nsresult
1931 15143 : WrapNativeParent(JSContext *cx, JSObject *scope, nsISupports *native,
1932 : nsWrapperCache *nativeWrapperCache,
1933 : JSObject **parentObj)
1934 : {
1935 : // In the common case, |native| is a wrapper cache with an existing wrapper
1936 : #ifdef DEBUG
1937 15143 : nsWrapperCache* cache = nsnull;
1938 15143 : CallQueryInterface(native, &cache);
1939 15143 : NS_PRECONDITION(nativeWrapperCache &&
1940 : cache == nativeWrapperCache, "What happened here?");
1941 : #endif
1942 :
1943 15143 : JSObject* obj = nativeWrapperCache->GetWrapper();
1944 15143 : if (obj) {
1945 : #ifdef DEBUG
1946 : jsval debugVal;
1947 : nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false,
1948 15141 : &debugVal);
1949 15141 : NS_ASSERTION(NS_SUCCEEDED(rv) && JSVAL_TO_OBJECT(debugVal) == obj,
1950 : "Unexpected object in nsWrapperCache");
1951 : #endif
1952 15141 : *parentObj = obj;
1953 15141 : return NS_OK;
1954 : }
1955 :
1956 : jsval v;
1957 2 : nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, false, &v);
1958 2 : NS_ENSURE_SUCCESS(rv, rv);
1959 2 : *parentObj = JSVAL_TO_OBJECT(v);
1960 2 : return NS_OK;
1961 : }
1962 :
1963 : // static
1964 :
1965 : nsISupports *
1966 5 : nsDOMClassInfo::GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj)
1967 : {
1968 5 : return wrapper ? wrapper->Native() : static_cast<nsISupports*>(js::GetObjectPrivate(obj));
1969 : }
1970 :
1971 : nsresult
1972 305 : nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
1973 : {
1974 : #define SET_JSID_TO_STRING(_id, _cx, _str) \
1975 : if (JSString *str = ::JS_InternString(_cx, _str)) \
1976 : _id = INTERNED_STRING_TO_JSID(_cx, str); \
1977 : else \
1978 : return NS_ERROR_OUT_OF_MEMORY;
1979 :
1980 610 : JSAutoRequest ar(cx);
1981 :
1982 305 : SET_JSID_TO_STRING(sParent_id, cx, "parent");
1983 610 : SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
1984 610 : SET_JSID_TO_STRING(sLocation_id, cx, "location");
1985 610 : SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
1986 610 : SET_JSID_TO_STRING(s_content_id, cx, "_content");
1987 610 : SET_JSID_TO_STRING(sContent_id, cx, "content");
1988 610 : SET_JSID_TO_STRING(sMenubar_id, cx, "menubar");
1989 610 : SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar");
1990 610 : SET_JSID_TO_STRING(sLocationbar_id, cx, "locationbar");
1991 610 : SET_JSID_TO_STRING(sPersonalbar_id, cx, "personalbar");
1992 610 : SET_JSID_TO_STRING(sStatusbar_id, cx, "statusbar");
1993 610 : SET_JSID_TO_STRING(sDialogArguments_id, cx, "dialogArguments");
1994 610 : SET_JSID_TO_STRING(sControllers_id, cx, "controllers");
1995 610 : SET_JSID_TO_STRING(sLength_id, cx, "length");
1996 610 : SET_JSID_TO_STRING(sInnerHeight_id, cx, "innerHeight");
1997 610 : SET_JSID_TO_STRING(sInnerWidth_id, cx, "innerWidth");
1998 610 : SET_JSID_TO_STRING(sOuterHeight_id, cx, "outerHeight");
1999 610 : SET_JSID_TO_STRING(sOuterWidth_id, cx, "outerWidth");
2000 610 : SET_JSID_TO_STRING(sScreenX_id, cx, "screenX");
2001 610 : SET_JSID_TO_STRING(sScreenY_id, cx, "screenY");
2002 610 : SET_JSID_TO_STRING(sStatus_id, cx, "status");
2003 610 : SET_JSID_TO_STRING(sName_id, cx, "name");
2004 610 : SET_JSID_TO_STRING(sScrollX_id, cx, "scrollX");
2005 610 : SET_JSID_TO_STRING(sScrollY_id, cx, "scrollY");
2006 610 : SET_JSID_TO_STRING(sScrollMaxX_id, cx, "scrollMaxX");
2007 610 : SET_JSID_TO_STRING(sScrollMaxY_id, cx, "scrollMaxY");
2008 610 : SET_JSID_TO_STRING(sItem_id, cx, "item");
2009 610 : SET_JSID_TO_STRING(sNamedItem_id, cx, "namedItem");
2010 610 : SET_JSID_TO_STRING(sEnumerate_id, cx, "enumerateProperties");
2011 610 : SET_JSID_TO_STRING(sNavigator_id, cx, "navigator");
2012 610 : SET_JSID_TO_STRING(sDocument_id, cx, "document");
2013 610 : SET_JSID_TO_STRING(sFrames_id, cx, "frames");
2014 610 : SET_JSID_TO_STRING(sSelf_id, cx, "self");
2015 610 : SET_JSID_TO_STRING(sOpener_id, cx, "opener");
2016 610 : SET_JSID_TO_STRING(sAll_id, cx, "all");
2017 610 : SET_JSID_TO_STRING(sTags_id, cx, "tags");
2018 610 : SET_JSID_TO_STRING(sAddEventListener_id,cx, "addEventListener");
2019 610 : SET_JSID_TO_STRING(sBaseURIObject_id, cx, "baseURIObject");
2020 610 : SET_JSID_TO_STRING(sNodePrincipal_id, cx, "nodePrincipal");
2021 610 : SET_JSID_TO_STRING(sDocumentURIObject_id,cx,"documentURIObject");
2022 610 : SET_JSID_TO_STRING(sJava_id, cx, "java");
2023 610 : SET_JSID_TO_STRING(sPackages_id, cx, "Packages");
2024 610 : SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject");
2025 610 : SET_JSID_TO_STRING(sURL_id, cx, "URL");
2026 610 : SET_JSID_TO_STRING(sKeyPath_id, cx, "keyPath");
2027 610 : SET_JSID_TO_STRING(sAutoIncrement_id, cx, "autoIncrement");
2028 610 : SET_JSID_TO_STRING(sUnique_id, cx, "unique");
2029 610 : SET_JSID_TO_STRING(sMultiEntry_id, cx, "multiEntry");
2030 610 : SET_JSID_TO_STRING(sOnload_id, cx, "onload");
2031 610 : SET_JSID_TO_STRING(sOnerror_id, cx, "onerror");
2032 :
2033 305 : return NS_OK;
2034 : }
2035 :
2036 : static nsresult
2037 3 : CreateExceptionFromResult(JSContext *cx, nsresult aResult)
2038 : {
2039 : nsCOMPtr<nsIExceptionService> xs =
2040 6 : do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
2041 3 : if (!xs) {
2042 0 : return NS_ERROR_FAILURE;
2043 : }
2044 :
2045 6 : nsCOMPtr<nsIExceptionManager> xm;
2046 3 : nsresult rv = xs->GetCurrentExceptionManager(getter_AddRefs(xm));
2047 3 : if (NS_FAILED(rv)) {
2048 0 : return NS_ERROR_FAILURE;
2049 : }
2050 :
2051 6 : nsCOMPtr<nsIException> exception;
2052 3 : rv = xm->GetExceptionFromProvider(aResult, 0, getter_AddRefs(exception));
2053 3 : if (NS_FAILED(rv) || !exception) {
2054 0 : return NS_ERROR_FAILURE;
2055 : }
2056 :
2057 : jsval jv;
2058 6 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
2059 : rv = WrapNative(cx, ::JS_GetGlobalObject(cx), exception,
2060 : &NS_GET_IID(nsIException), false, &jv,
2061 3 : getter_AddRefs(holder));
2062 3 : if (NS_FAILED(rv) || JSVAL_IS_NULL(jv)) {
2063 0 : return NS_ERROR_FAILURE;
2064 : }
2065 :
2066 6 : JSAutoEnterCompartment ac;
2067 :
2068 3 : if (JSVAL_IS_OBJECT(jv)) {
2069 3 : if (!ac.enter(cx, JSVAL_TO_OBJECT(jv))) {
2070 0 : return NS_ERROR_UNEXPECTED;
2071 : }
2072 : }
2073 :
2074 3 : JS_SetPendingException(cx, jv);
2075 3 : return NS_OK;
2076 : }
2077 :
2078 : // static
2079 : nsresult
2080 3 : nsDOMClassInfo::ThrowJSException(JSContext *cx, nsresult aResult)
2081 : {
2082 6 : JSAutoRequest ar(cx);
2083 :
2084 3 : if (NS_SUCCEEDED(CreateExceptionFromResult(cx, aResult))) {
2085 3 : return NS_OK;
2086 : }
2087 :
2088 : // XXX This probably wants to be localized, but that can fail in ways that
2089 : // are hard to report correctly.
2090 : JSString *str =
2091 0 : JS_NewStringCopyZ(cx, "An error occurred throwing an exception");
2092 0 : if (!str) {
2093 : // JS_NewStringCopyZ reported the error for us.
2094 0 : return NS_OK;
2095 : }
2096 0 : JS_SetPendingException(cx, STRING_TO_JSVAL(str));
2097 0 : return NS_OK;
2098 : }
2099 :
2100 : // static
2101 : bool
2102 224 : nsDOMClassInfo::ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
2103 : {
2104 224 : return xpc::WrapperFactory::IsXrayWrapper(obj) &&
2105 224 : !xpc::WrapperFactory::IsPartiallyTransparent(obj);
2106 : }
2107 :
2108 1680 : nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
2109 : {
2110 1680 : }
2111 :
2112 2301 : nsDOMClassInfo::~nsDOMClassInfo()
2113 : {
2114 1675 : if (IS_EXTERNAL(mData->mCachedClassInfo)) {
2115 : // Some compilers don't like delete'ing a const nsDOMClassInfo*
2116 0 : nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
2117 : delete static_cast<nsExternalDOMClassInfoData*>(data);
2118 : }
2119 4602 : }
2120 :
2121 92690 : NS_IMPL_ADDREF(nsDOMClassInfo)
2122 92683 : NS_IMPL_RELEASE(nsDOMClassInfo)
2123 :
2124 57897 : NS_INTERFACE_MAP_BEGIN(nsDOMClassInfo)
2125 57897 : if (aIID.Equals(NS_GET_IID(nsXPCClassInfo)))
2126 : foundInterface = static_cast<nsIClassInfo*>(
2127 12398 : static_cast<nsXPCClassInfo*>(this));
2128 : else
2129 45499 : NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
2130 2782 : NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
2131 0 : NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIClassInfo)
2132 0 : NS_INTERFACE_MAP_END
2133 :
2134 :
2135 : static JSClass sDOMConstructorProtoClass = {
2136 : "DOM Constructor.prototype", 0,
2137 : JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
2138 : JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nsnull
2139 : };
2140 :
2141 :
2142 : static const char *
2143 182129 : CutPrefix(const char *aName) {
2144 : static const char prefix_nsIDOM[] = "nsIDOM";
2145 : static const char prefix_nsI[] = "nsI";
2146 :
2147 182129 : if (strncmp(aName, prefix_nsIDOM, sizeof(prefix_nsIDOM) - 1) == 0) {
2148 166541 : return aName + sizeof(prefix_nsIDOM) - 1;
2149 : }
2150 :
2151 15588 : if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
2152 15588 : return aName + sizeof(prefix_nsI) - 1;
2153 : }
2154 :
2155 0 : return aName;
2156 : }
2157 :
2158 : // static
2159 : nsresult
2160 114985 : nsDOMClassInfo::RegisterClassName(PRInt32 aClassInfoID)
2161 : {
2162 : nsScriptNameSpaceManager *nameSpaceManager =
2163 114985 : nsJSRuntime::GetNameSpaceManager();
2164 114985 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2165 :
2166 : nameSpaceManager->RegisterClassName(sClassInfoData[aClassInfoID].mName,
2167 : aClassInfoID,
2168 : sClassInfoData[aClassInfoID].mChromeOnly,
2169 : sClassInfoData[aClassInfoID].mDisabled,
2170 114985 : &sClassInfoData[aClassInfoID].mNameUTF16);
2171 :
2172 114985 : return NS_OK;
2173 : }
2174 :
2175 : // static
2176 : nsresult
2177 114985 : nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID)
2178 : {
2179 : nsScriptNameSpaceManager *nameSpaceManager =
2180 114985 : nsJSRuntime::GetNameSpaceManager();
2181 114985 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2182 : bool found_old;
2183 :
2184 114985 : const nsIID *primary_iid = sClassInfoData[aClassInfoID].mProtoChainInterface;
2185 :
2186 114985 : if (!primary_iid || primary_iid == &NS_GET_IID(nsISupports)) {
2187 0 : return NS_OK;
2188 : }
2189 :
2190 : nsCOMPtr<nsIInterfaceInfoManager>
2191 229970 : iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
2192 114985 : NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
2193 :
2194 229970 : nsCOMPtr<nsIInterfaceInfo> if_info;
2195 114985 : bool first = true;
2196 :
2197 114985 : iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
2198 :
2199 350445 : while (if_info) {
2200 235460 : const nsIID *iid = nsnull;
2201 :
2202 235460 : if_info->GetIIDShared(&iid);
2203 235460 : NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
2204 :
2205 235460 : if (iid->Equals(NS_GET_IID(nsISupports))) {
2206 55815 : break;
2207 : }
2208 :
2209 179645 : const char *name = nsnull;
2210 179645 : if_info->GetNameShared(&name);
2211 179645 : NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
2212 :
2213 179645 : nameSpaceManager->RegisterClassProto(CutPrefix(name), iid, &found_old);
2214 :
2215 179645 : if (first) {
2216 114985 : first = false;
2217 64660 : } else if (found_old) {
2218 59170 : break;
2219 : }
2220 :
2221 240950 : nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
2222 120475 : tmp->GetParent(getter_AddRefs(if_info));
2223 : }
2224 :
2225 114985 : return NS_OK;
2226 : }
2227 :
2228 : // static
2229 : nsresult
2230 305 : nsDOMClassInfo::RegisterExternalClasses()
2231 : {
2232 : nsScriptNameSpaceManager *nameSpaceManager =
2233 305 : nsJSRuntime::GetNameSpaceManager();
2234 305 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2235 :
2236 610 : nsCOMPtr<nsIComponentRegistrar> registrar;
2237 305 : nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
2238 305 : NS_ENSURE_SUCCESS(rv, rv);
2239 :
2240 : nsCOMPtr<nsICategoryManager> cm =
2241 610 : do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
2242 305 : NS_ENSURE_SUCCESS(rv, rv);
2243 :
2244 610 : nsCOMPtr<nsISimpleEnumerator> e;
2245 305 : rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
2246 305 : NS_ENSURE_SUCCESS(rv, rv);
2247 :
2248 610 : nsXPIDLCString contractId;
2249 610 : nsCAutoString categoryEntry;
2250 610 : nsCOMPtr<nsISupports> entry;
2251 :
2252 610 : while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
2253 0 : nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
2254 :
2255 0 : if (!category) {
2256 0 : NS_WARNING("Category entry not an nsISupportsCString!");
2257 0 : continue;
2258 : }
2259 :
2260 0 : rv = category->GetData(categoryEntry);
2261 :
2262 0 : cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
2263 0 : getter_Copies(contractId));
2264 0 : NS_ENSURE_SUCCESS(rv, rv);
2265 :
2266 : nsCID *cid;
2267 0 : rv = registrar->ContractIDToCID(contractId, &cid);
2268 0 : if (NS_FAILED(rv)) {
2269 0 : NS_WARNING("Bad contract id registered with the script namespace manager");
2270 0 : continue;
2271 : }
2272 :
2273 0 : rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
2274 0 : nsMemory::Free(cid);
2275 0 : NS_ENSURE_SUCCESS(rv, rv);
2276 : }
2277 :
2278 305 : return nameSpaceManager->RegisterExternalInterfaces(true);
2279 : }
2280 :
2281 : #define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if, _disabled) \
2282 : { \
2283 : nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
2284 : d.mProtoChainInterface = _ifptr; \
2285 : d.mHasClassInterface = _has_class_if; \
2286 : d.mInterfacesBitmap = kDOMClassInfo_##_class##_interfaces; \
2287 : d.mDisabled = _disabled; \
2288 : static const nsIID *interface_list[] = {
2289 :
2290 : #define DOM_CLASSINFO_MAP_BEGIN(_class, _interface) \
2291 : _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, false)
2292 :
2293 : #define DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(_class, _interface, _disable) \
2294 : _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), true, _disable)
2295 :
2296 : #define DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(_class, _interface) \
2297 : _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), false, false)
2298 :
2299 : #define DOM_CLASSINFO_MAP_ENTRY(_if) \
2300 : &NS_GET_IID(_if),
2301 :
2302 : #define DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(_if, _cond) \
2303 : (_cond) ? &NS_GET_IID(_if) : nsnull,
2304 :
2305 : #define DOM_CLASSINFO_MAP_END \
2306 : nsnull \
2307 : }; \
2308 : \
2309 : /* Compact the interface list */ \
2310 : size_t count = ArrayLength(interface_list); \
2311 : /* count is the number of array entries, which is one greater than the */ \
2312 : /* number of interfaces due to the terminating null */ \
2313 : for (size_t i = 0; i < count - 1; ++i) { \
2314 : if (!interface_list[i]) { \
2315 : /* We are moving the element at index i+1 and successors, */ \
2316 : /* so we must move only count - (i+1) elements total. */ \
2317 : memmove(&interface_list[i], &interface_list[i+1], \
2318 : sizeof(nsIID*) * (count - (i+1))); \
2319 : /* Make sure to examine the new pointer we ended up with at this */ \
2320 : /* slot, since it may be null too */ \
2321 : --i; \
2322 : --count; \
2323 : } \
2324 : } \
2325 : \
2326 : d.mInterfaces = interface_list; \
2327 : }
2328 :
2329 : #define DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES \
2330 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL) \
2331 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
2332 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator) \
2333 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
2334 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
2335 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMDocumentTouch, \
2336 : nsDOMTouchEvent::PrefEnabled())
2337 :
2338 :
2339 : #define DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES \
2340 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle) \
2341 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
2342 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
2343 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
2344 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
2345 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
2346 : nsDOMTouchEvent::PrefEnabled())
2347 :
2348 : #define DOM_CLASSINFO_EVENT_MAP_ENTRIES \
2349 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent) \
2350 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent) \
2351 :
2352 : #define DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES \
2353 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMUIEvent) \
2354 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2355 :
2356 : #define DOM_CLASSINFO_WINDOW_MAP_ENTRIES(_support_indexed_db) \
2357 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow) \
2358 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow) \
2359 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
2360 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
2361 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMStorageIndexedDB, \
2362 : _support_indexed_db) \
2363 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMWindowPerformance, \
2364 : nsGlobalWindow::HasPerformanceSupport()) \
2365 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
2366 : nsDOMTouchEvent::PrefEnabled())
2367 :
2368 : nsresult
2369 305 : nsDOMClassInfo::Init()
2370 : {
2371 : /* Errors that can trigger early returns are done first,
2372 : otherwise nsDOMClassInfo is left in a half inited state. */
2373 : NS_ASSERTION(sizeof(PtrBits) == sizeof(void*),
2374 : "BAD! You'll need to adjust the size of PtrBits to the size "
2375 : "of a pointer on your platform.");
2376 :
2377 305 : NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
2378 :
2379 305 : nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
2380 305 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2381 :
2382 305 : nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
2383 305 : NS_ENSURE_SUCCESS(rv, rv);
2384 :
2385 610 : nsCOMPtr<nsIXPCFunctionThisTranslator> old;
2386 :
2387 610 : nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
2388 305 : NS_ENSURE_TRUE(elt, NS_ERROR_OUT_OF_MEMORY);
2389 :
2390 : sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener),
2391 305 : elt, getter_AddRefs(old));
2392 :
2393 : nsCOMPtr<nsIScriptSecurityManager> sm =
2394 610 : do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
2395 305 : NS_ENSURE_SUCCESS(rv, rv);
2396 :
2397 305 : sSecMan = sm;
2398 305 : NS_ADDREF(sSecMan);
2399 :
2400 : nsCOMPtr<nsIThreadJSContextStack> stack =
2401 610 : do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
2402 305 : NS_ENSURE_SUCCESS(rv, rv);
2403 :
2404 305 : JSContext *cx = nsnull;
2405 :
2406 305 : rv = stack->GetSafeJSContext(&cx);
2407 305 : NS_ENSURE_SUCCESS(rv, rv);
2408 :
2409 305 : DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
2410 915 : DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
2411 1220 : DOM_CLASSINFO_MAP_END
2412 :
2413 305 : DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
2414 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
2415 305 : DOM_CLASSINFO_MAP_END
2416 :
2417 305 : DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
2418 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
2419 305 : DOM_CLASSINFO_MAP_END
2420 :
2421 305 : DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
2422 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
2423 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
2424 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMNavigatorDesktopNotification,
2425 : Navigator::HasDesktopNotificationSupport())
2426 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
2427 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorBattery,
2428 : battery::BatteryManager::HasSupport())
2429 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozNavigatorSms)
2430 : #ifdef MOZ_B2G_RIL
2431 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorTelephony)
2432 : #endif
2433 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsIDOMMozNavigatorNetwork,
2434 : network::IsAPIEnabled())
2435 : #ifdef MOZ_B2G_BT
2436 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorBluetooth)
2437 : #endif
2438 1220 : DOM_CLASSINFO_MAP_END
2439 :
2440 305 : DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
2441 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin)
2442 305 : DOM_CLASSINFO_MAP_END
2443 :
2444 305 : DOM_CLASSINFO_MAP_BEGIN(PluginArray, nsIDOMPluginArray)
2445 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPluginArray)
2446 305 : DOM_CLASSINFO_MAP_END
2447 :
2448 305 : DOM_CLASSINFO_MAP_BEGIN(MimeType, nsIDOMMimeType)
2449 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeType)
2450 305 : DOM_CLASSINFO_MAP_END
2451 :
2452 305 : DOM_CLASSINFO_MAP_BEGIN(MimeTypeArray, nsIDOMMimeTypeArray)
2453 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeTypeArray)
2454 305 : DOM_CLASSINFO_MAP_END
2455 :
2456 305 : DOM_CLASSINFO_MAP_BEGIN(BarProp, nsIDOMBarProp)
2457 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMBarProp)
2458 305 : DOM_CLASSINFO_MAP_END
2459 :
2460 305 : DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
2461 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
2462 305 : DOM_CLASSINFO_MAP_END
2463 :
2464 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceTiming, nsIDOMPerformanceTiming,
2465 : !nsGlobalWindow::HasPerformanceSupport())
2466 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceTiming)
2467 305 : DOM_CLASSINFO_MAP_END
2468 :
2469 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceNavigation, nsIDOMPerformanceNavigation,
2470 : !nsGlobalWindow::HasPerformanceSupport())
2471 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceNavigation)
2472 305 : DOM_CLASSINFO_MAP_END
2473 :
2474 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Performance, nsIDOMPerformance,
2475 : !nsGlobalWindow::HasPerformanceSupport())
2476 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance)
2477 305 : DOM_CLASSINFO_MAP_END
2478 :
2479 305 : DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
2480 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
2481 305 : DOM_CLASSINFO_MAP_END
2482 :
2483 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
2484 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
2485 305 : DOM_CLASSINFO_MAP_END
2486 :
2487 305 : DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
2488 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
2489 305 : DOM_CLASSINFO_MAP_END
2490 :
2491 305 : DOM_CLASSINFO_MAP_BEGIN(XMLDocument, nsIDOMXMLDocument)
2492 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
2493 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXMLDocument)
2494 305 : DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
2495 610 : DOM_CLASSINFO_MAP_END
2496 :
2497 305 : DOM_CLASSINFO_MAP_BEGIN(DocumentType, nsIDOMDocumentType)
2498 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentType)
2499 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2500 305 : DOM_CLASSINFO_MAP_END
2501 :
2502 305 : DOM_CLASSINFO_MAP_BEGIN(DOMImplementation, nsIDOMDOMImplementation)
2503 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMImplementation)
2504 305 : DOM_CLASSINFO_MAP_END
2505 :
2506 305 : DOM_CLASSINFO_MAP_BEGIN(DOMException, nsIDOMDOMException)
2507 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMException)
2508 : DOM_CLASSINFO_MAP_ENTRY(nsIException)
2509 305 : DOM_CLASSINFO_MAP_END
2510 :
2511 305 : DOM_CLASSINFO_MAP_BEGIN(DOMTokenList, nsIDOMDOMTokenList)
2512 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMTokenList)
2513 305 : DOM_CLASSINFO_MAP_END
2514 :
2515 305 : DOM_CLASSINFO_MAP_BEGIN(DOMSettableTokenList, nsIDOMDOMSettableTokenList)
2516 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMSettableTokenList)
2517 305 : DOM_CLASSINFO_MAP_END
2518 :
2519 305 : DOM_CLASSINFO_MAP_BEGIN(DocumentFragment, nsIDOMDocumentFragment)
2520 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentFragment)
2521 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2522 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2523 305 : DOM_CLASSINFO_MAP_END
2524 :
2525 305 : DOM_CLASSINFO_MAP_BEGIN(Element, nsIDOMElement)
2526 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
2527 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
2528 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2529 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2530 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
2531 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
2532 : nsDOMTouchEvent::PrefEnabled())
2533 610 : DOM_CLASSINFO_MAP_END
2534 :
2535 305 : DOM_CLASSINFO_MAP_BEGIN(Attr, nsIDOMAttr)
2536 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMAttr)
2537 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2538 305 : DOM_CLASSINFO_MAP_END
2539 :
2540 305 : DOM_CLASSINFO_MAP_BEGIN(Text, nsIDOMText)
2541 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMText)
2542 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2543 305 : DOM_CLASSINFO_MAP_END
2544 :
2545 305 : DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment)
2546 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMComment)
2547 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2548 305 : DOM_CLASSINFO_MAP_END
2549 :
2550 305 : DOM_CLASSINFO_MAP_BEGIN(CDATASection, nsIDOMCDATASection)
2551 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCDATASection)
2552 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2553 305 : DOM_CLASSINFO_MAP_END
2554 :
2555 305 : DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)
2556 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
2557 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCharacterData)
2558 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2559 305 : DOM_CLASSINFO_MAP_END
2560 :
2561 305 : DOM_CLASSINFO_MAP_BEGIN(NodeList, nsIDOMNodeList)
2562 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
2563 305 : DOM_CLASSINFO_MAP_END
2564 :
2565 305 : DOM_CLASSINFO_MAP_BEGIN(NamedNodeMap, nsIDOMNamedNodeMap)
2566 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNamedNodeMap)
2567 305 : DOM_CLASSINFO_MAP_END
2568 :
2569 305 : DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
2570 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2571 305 : DOM_CLASSINFO_MAP_END
2572 :
2573 305 : DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
2574 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
2575 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2576 305 : DOM_CLASSINFO_MAP_END
2577 :
2578 305 : DOM_CLASSINFO_MAP_BEGIN(DeviceOrientationEvent, nsIDOMDeviceOrientationEvent)
2579 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
2580 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2581 305 : DOM_CLASSINFO_MAP_END
2582 :
2583 305 : DOM_CLASSINFO_MAP_BEGIN(DeviceMotionEvent, nsIDOMDeviceMotionEvent)
2584 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceMotionEvent)
2585 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2586 305 : DOM_CLASSINFO_MAP_END
2587 :
2588 305 : DOM_CLASSINFO_MAP_BEGIN(DeviceAcceleration, nsIDOMDeviceAcceleration)
2589 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceAcceleration)
2590 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2591 305 : DOM_CLASSINFO_MAP_END
2592 :
2593 305 : DOM_CLASSINFO_MAP_BEGIN(DeviceRotationRate, nsIDOMDeviceRotationRate)
2594 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceRotationRate)
2595 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2596 305 : DOM_CLASSINFO_MAP_END
2597 :
2598 305 : DOM_CLASSINFO_MAP_BEGIN(SmartCardEvent, nsIDOMSmartCardEvent)
2599 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
2600 305 : DOM_CLASSINFO_MAP_END
2601 :
2602 305 : DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
2603 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPageTransitionEvent)
2604 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2605 305 : DOM_CLASSINFO_MAP_END
2606 :
2607 305 : DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
2608 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
2609 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2610 305 : DOM_CLASSINFO_MAP_END
2611 :
2612 305 : DOM_CLASSINFO_MAP_BEGIN(UIEvent, nsIDOMUIEvent)
2613 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2614 305 : DOM_CLASSINFO_MAP_END
2615 :
2616 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(KeyboardEvent, nsIDOMKeyEvent)
2617 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
2618 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2619 305 : DOM_CLASSINFO_MAP_END
2620 :
2621 305 : DOM_CLASSINFO_MAP_BEGIN(CompositionEvent, nsIDOMCompositionEvent)
2622 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCompositionEvent)
2623 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2624 305 : DOM_CLASSINFO_MAP_END
2625 :
2626 305 : DOM_CLASSINFO_MAP_BEGIN(MouseEvent, nsIDOMMouseEvent)
2627 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2628 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2629 305 : DOM_CLASSINFO_MAP_END
2630 :
2631 305 : DOM_CLASSINFO_MAP_BEGIN(MouseScrollEvent, nsIDOMMouseScrollEvent)
2632 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseScrollEvent)
2633 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2634 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2635 305 : DOM_CLASSINFO_MAP_END
2636 :
2637 305 : DOM_CLASSINFO_MAP_BEGIN(DragEvent, nsIDOMDragEvent)
2638 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDragEvent)
2639 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2640 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2641 305 : DOM_CLASSINFO_MAP_END
2642 :
2643 305 : DOM_CLASSINFO_MAP_BEGIN(PopStateEvent, nsIDOMPopStateEvent)
2644 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopStateEvent)
2645 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2646 305 : DOM_CLASSINFO_MAP_END
2647 :
2648 305 : DOM_CLASSINFO_MAP_BEGIN(HashChangeEvent, nsIDOMHashChangeEvent)
2649 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHashChangeEvent)
2650 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
2651 305 : DOM_CLASSINFO_MAP_END
2652 :
2653 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLDocument, nsIDOMHTMLDocument)
2654 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
2655 305 : DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
2656 610 : DOM_CLASSINFO_MAP_END
2657 :
2658 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLOptionsCollection, nsIDOMHTMLOptionsCollection)
2659 : // Order is significant. nsIDOMHTMLOptionsCollection.length shadows
2660 : // nsIDOMHTMLCollection.length, which is readonly.
2661 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionsCollection)
2662 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
2663 305 : DOM_CLASSINFO_MAP_END
2664 :
2665 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLCollection, nsIDOMHTMLCollection)
2666 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
2667 305 : DOM_CLASSINFO_MAP_END
2668 :
2669 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLElement, nsIDOMHTMLElement)
2670 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
2671 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2672 610 : DOM_CLASSINFO_MAP_END
2673 :
2674 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLAnchorElement, nsIDOMHTMLAnchorElement)
2675 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAnchorElement)
2676 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2677 610 : DOM_CLASSINFO_MAP_END
2678 :
2679 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLAppletElement, nsIDOMHTMLAppletElement)
2680 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAppletElement)
2681 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2682 610 : DOM_CLASSINFO_MAP_END
2683 :
2684 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLAreaElement, nsIDOMHTMLAreaElement)
2685 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAreaElement)
2686 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2687 610 : DOM_CLASSINFO_MAP_END
2688 :
2689 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLBRElement, nsIDOMHTMLBRElement)
2690 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBRElement)
2691 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2692 610 : DOM_CLASSINFO_MAP_END
2693 :
2694 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLBaseElement, nsIDOMHTMLBaseElement)
2695 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBaseElement)
2696 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2697 610 : DOM_CLASSINFO_MAP_END
2698 :
2699 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLBodyElement, nsIDOMHTMLBodyElement)
2700 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBodyElement)
2701 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2702 610 : DOM_CLASSINFO_MAP_END
2703 :
2704 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLButtonElement, nsIDOMHTMLButtonElement)
2705 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLButtonElement)
2706 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2707 610 : DOM_CLASSINFO_MAP_END
2708 :
2709 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLDataListElement, nsIDOMHTMLDataListElement)
2710 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDataListElement)
2711 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2712 610 : DOM_CLASSINFO_MAP_END
2713 :
2714 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLDListElement, nsIDOMHTMLDListElement)
2715 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDListElement)
2716 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2717 610 : DOM_CLASSINFO_MAP_END
2718 :
2719 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLDirectoryElement, nsIDOMHTMLDirectoryElement)
2720 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDirectoryElement)
2721 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2722 610 : DOM_CLASSINFO_MAP_END
2723 :
2724 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLDivElement, nsIDOMHTMLDivElement)
2725 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDivElement)
2726 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2727 610 : DOM_CLASSINFO_MAP_END
2728 :
2729 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLEmbedElement, nsIDOMHTMLEmbedElement)
2730 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLEmbedElement)
2731 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2732 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2733 610 : DOM_CLASSINFO_MAP_END
2734 :
2735 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLFieldSetElement, nsIDOMHTMLFieldSetElement)
2736 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFieldSetElement)
2737 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2738 610 : DOM_CLASSINFO_MAP_END
2739 :
2740 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLFontElement, nsIDOMHTMLFontElement)
2741 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFontElement)
2742 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2743 610 : DOM_CLASSINFO_MAP_END
2744 :
2745 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLFormElement, nsIDOMHTMLFormElement)
2746 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFormElement)
2747 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2748 610 : DOM_CLASSINFO_MAP_END
2749 :
2750 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLFrameElement, nsIDOMHTMLFrameElement)
2751 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameElement)
2752 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
2753 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2754 610 : DOM_CLASSINFO_MAP_END
2755 :
2756 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLFrameSetElement, nsIDOMHTMLFrameSetElement)
2757 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameSetElement)
2758 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2759 610 : DOM_CLASSINFO_MAP_END
2760 :
2761 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLHRElement, nsIDOMHTMLHRElement)
2762 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHRElement)
2763 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2764 610 : DOM_CLASSINFO_MAP_END
2765 :
2766 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLHeadElement, nsIDOMHTMLHeadElement)
2767 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadElement)
2768 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2769 610 : DOM_CLASSINFO_MAP_END
2770 :
2771 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLHeadingElement, nsIDOMHTMLHeadingElement)
2772 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadingElement)
2773 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2774 610 : DOM_CLASSINFO_MAP_END
2775 :
2776 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLHtmlElement, nsIDOMHTMLHtmlElement)
2777 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHtmlElement)
2778 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2779 610 : DOM_CLASSINFO_MAP_END
2780 :
2781 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLIFrameElement, nsIDOMHTMLIFrameElement)
2782 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIFrameElement)
2783 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2784 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
2785 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2786 610 : DOM_CLASSINFO_MAP_END
2787 :
2788 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLImageElement, nsIDOMHTMLImageElement)
2789 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLImageElement)
2790 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2791 610 : DOM_CLASSINFO_MAP_END
2792 :
2793 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLInputElement, nsIDOMHTMLInputElement)
2794 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLInputElement)
2795 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2796 610 : DOM_CLASSINFO_MAP_END
2797 :
2798 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLLIElement, nsIDOMHTMLLIElement)
2799 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLIElement)
2800 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2801 610 : DOM_CLASSINFO_MAP_END
2802 :
2803 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLLabelElement, nsIDOMHTMLLabelElement)
2804 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLabelElement)
2805 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2806 610 : DOM_CLASSINFO_MAP_END
2807 :
2808 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLLegendElement, nsIDOMHTMLLegendElement)
2809 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLegendElement)
2810 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2811 610 : DOM_CLASSINFO_MAP_END
2812 :
2813 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLLinkElement, nsIDOMHTMLLinkElement)
2814 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLinkElement)
2815 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
2816 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2817 610 : DOM_CLASSINFO_MAP_END
2818 :
2819 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLMapElement, nsIDOMHTMLMapElement)
2820 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMapElement)
2821 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2822 610 : DOM_CLASSINFO_MAP_END
2823 :
2824 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLMenuElement, nsIDOMHTMLMenuElement)
2825 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMenuElement)
2826 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2827 610 : DOM_CLASSINFO_MAP_END
2828 :
2829 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLMenuItemElement, nsIDOMHTMLMenuItemElement)
2830 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMenuItemElement)
2831 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2832 610 : DOM_CLASSINFO_MAP_END
2833 :
2834 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLMetaElement, nsIDOMHTMLMetaElement)
2835 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMetaElement)
2836 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2837 610 : DOM_CLASSINFO_MAP_END
2838 :
2839 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLModElement, nsIDOMHTMLModElement)
2840 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLModElement)
2841 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2842 610 : DOM_CLASSINFO_MAP_END
2843 :
2844 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLOListElement, nsIDOMHTMLOListElement)
2845 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOListElement)
2846 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2847 610 : DOM_CLASSINFO_MAP_END
2848 :
2849 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLObjectElement, nsIDOMHTMLObjectElement)
2850 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLObjectElement)
2851 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2852 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2853 610 : DOM_CLASSINFO_MAP_END
2854 :
2855 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLOptGroupElement, nsIDOMHTMLOptGroupElement)
2856 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptGroupElement)
2857 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2858 610 : DOM_CLASSINFO_MAP_END
2859 :
2860 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLOptionElement, nsIDOMHTMLOptionElement)
2861 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionElement)
2862 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2863 610 : DOM_CLASSINFO_MAP_END
2864 :
2865 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLOutputElement, nsIDOMHTMLOutputElement)
2866 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOutputElement)
2867 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2868 610 : DOM_CLASSINFO_MAP_END
2869 :
2870 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLParagraphElement, nsIDOMHTMLParagraphElement)
2871 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParagraphElement)
2872 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2873 610 : DOM_CLASSINFO_MAP_END
2874 :
2875 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLParamElement, nsIDOMHTMLParamElement)
2876 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParamElement)
2877 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2878 610 : DOM_CLASSINFO_MAP_END
2879 :
2880 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLPreElement, nsIDOMHTMLPreElement)
2881 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLPreElement)
2882 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2883 610 : DOM_CLASSINFO_MAP_END
2884 :
2885 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLProgressElement, nsIDOMHTMLProgressElement)
2886 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLProgressElement)
2887 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2888 610 : DOM_CLASSINFO_MAP_END
2889 :
2890 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLQuoteElement, nsIDOMHTMLQuoteElement)
2891 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLQuoteElement)
2892 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2893 610 : DOM_CLASSINFO_MAP_END
2894 :
2895 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLScriptElement, nsIDOMHTMLScriptElement)
2896 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLScriptElement)
2897 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2898 610 : DOM_CLASSINFO_MAP_END
2899 :
2900 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLSelectElement, nsIDOMHTMLSelectElement)
2901 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement)
2902 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2903 610 : DOM_CLASSINFO_MAP_END
2904 :
2905 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLSpanElement, nsIDOMHTMLElement)
2906 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
2907 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2908 610 : DOM_CLASSINFO_MAP_END
2909 :
2910 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLStyleElement, nsIDOMHTMLStyleElement)
2911 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLStyleElement)
2912 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
2913 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2914 610 : DOM_CLASSINFO_MAP_END
2915 :
2916 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableCaptionElement,
2917 : nsIDOMHTMLTableCaptionElement)
2918 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCaptionElement)
2919 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2920 610 : DOM_CLASSINFO_MAP_END
2921 :
2922 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableCellElement, nsIDOMHTMLTableCellElement)
2923 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCellElement)
2924 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2925 610 : DOM_CLASSINFO_MAP_END
2926 :
2927 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableColElement, nsIDOMHTMLTableColElement)
2928 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableColElement)
2929 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2930 610 : DOM_CLASSINFO_MAP_END
2931 :
2932 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableElement, nsIDOMHTMLTableElement)
2933 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableElement)
2934 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2935 610 : DOM_CLASSINFO_MAP_END
2936 :
2937 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableRowElement, nsIDOMHTMLTableRowElement)
2938 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableRowElement)
2939 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2940 610 : DOM_CLASSINFO_MAP_END
2941 :
2942 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTableSectionElement,
2943 : nsIDOMHTMLTableSectionElement)
2944 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableSectionElement)
2945 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2946 610 : DOM_CLASSINFO_MAP_END
2947 :
2948 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTextAreaElement, nsIDOMHTMLTextAreaElement)
2949 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
2950 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2951 610 : DOM_CLASSINFO_MAP_END
2952 :
2953 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLTitleElement, nsIDOMHTMLTitleElement)
2954 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTitleElement)
2955 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2956 610 : DOM_CLASSINFO_MAP_END
2957 :
2958 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLUListElement, nsIDOMHTMLUListElement)
2959 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLUListElement)
2960 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2961 610 : DOM_CLASSINFO_MAP_END
2962 :
2963 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLUnknownElement, nsIDOMHTMLUnknownElement)
2964 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLUnknownElement)
2965 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2966 610 : DOM_CLASSINFO_MAP_END
2967 :
2968 305 : DOM_CLASSINFO_MAP_BEGIN(ValidityState, nsIDOMValidityState)
2969 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMValidityState)
2970 305 : DOM_CLASSINFO_MAP_END
2971 :
2972 305 : DOM_CLASSINFO_MAP_BEGIN(CSSStyleRule, nsIDOMCSSStyleRule)
2973 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
2974 305 : DOM_CLASSINFO_MAP_END
2975 :
2976 305 : DOM_CLASSINFO_MAP_BEGIN(CSSCharsetRule, nsIDOMCSSCharsetRule)
2977 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSCharsetRule)
2978 305 : DOM_CLASSINFO_MAP_END
2979 :
2980 305 : DOM_CLASSINFO_MAP_BEGIN(CSSImportRule, nsIDOMCSSImportRule)
2981 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSImportRule)
2982 305 : DOM_CLASSINFO_MAP_END
2983 :
2984 305 : DOM_CLASSINFO_MAP_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
2985 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
2986 305 : DOM_CLASSINFO_MAP_END
2987 :
2988 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSNameSpaceRule, nsIDOMCSSRule)
2989 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
2990 305 : DOM_CLASSINFO_MAP_END
2991 :
2992 305 : DOM_CLASSINFO_MAP_BEGIN(CSSRuleList, nsIDOMCSSRuleList)
2993 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
2994 305 : DOM_CLASSINFO_MAP_END
2995 :
2996 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSGroupRuleRuleList, nsIDOMCSSRuleList)
2997 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
2998 305 : DOM_CLASSINFO_MAP_END
2999 :
3000 305 : DOM_CLASSINFO_MAP_BEGIN(MediaList, nsIDOMMediaList)
3001 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaList)
3002 305 : DOM_CLASSINFO_MAP_END
3003 :
3004 305 : DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
3005 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
3006 305 : DOM_CLASSINFO_MAP_END
3007 :
3008 305 : DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
3009 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
3010 305 : DOM_CLASSINFO_MAP_END
3011 :
3012 305 : DOM_CLASSINFO_MAP_BEGIN(CSSStyleDeclaration, nsIDOMCSSStyleDeclaration)
3013 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
3014 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
3015 305 : DOM_CLASSINFO_MAP_END
3016 :
3017 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ROCSSPrimitiveValue,
3018 : nsIDOMCSSPrimitiveValue)
3019 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSPrimitiveValue)
3020 305 : DOM_CLASSINFO_MAP_END
3021 :
3022 305 : DOM_CLASSINFO_MAP_BEGIN(CSSValueList, nsIDOMCSSValueList)
3023 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSValueList)
3024 305 : DOM_CLASSINFO_MAP_END
3025 :
3026 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRect, nsIDOMRect)
3027 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMRect)
3028 305 : DOM_CLASSINFO_MAP_END
3029 :
3030 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRGBColor, nsIDOMRGBColor)
3031 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMRGBColor)
3032 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSRGBAColor)
3033 305 : DOM_CLASSINFO_MAP_END
3034 :
3035 305 : DOM_CLASSINFO_MAP_BEGIN(Range, nsIDOMRange)
3036 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMRange)
3037 305 : DOM_CLASSINFO_MAP_END
3038 :
3039 305 : DOM_CLASSINFO_MAP_BEGIN(NodeIterator, nsIDOMNodeIterator)
3040 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeIterator)
3041 305 : DOM_CLASSINFO_MAP_END
3042 :
3043 305 : DOM_CLASSINFO_MAP_BEGIN(TreeWalker, nsIDOMTreeWalker)
3044 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTreeWalker)
3045 305 : DOM_CLASSINFO_MAP_END
3046 :
3047 305 : DOM_CLASSINFO_MAP_BEGIN(Selection, nsISelection)
3048 : DOM_CLASSINFO_MAP_ENTRY(nsISelection)
3049 305 : DOM_CLASSINFO_MAP_END
3050 :
3051 : #ifdef MOZ_XUL
3052 305 : DOM_CLASSINFO_MAP_BEGIN(XULDocument, nsIDOMXULDocument)
3053 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
3054 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULDocument)
3055 305 : DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
3056 610 : DOM_CLASSINFO_MAP_END
3057 :
3058 305 : DOM_CLASSINFO_MAP_BEGIN(XULElement, nsIDOMXULElement)
3059 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULElement)
3060 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3061 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
3062 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle)
3063 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
3064 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
3065 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
3066 : nsDOMTouchEvent::PrefEnabled())
3067 610 : DOM_CLASSINFO_MAP_END
3068 :
3069 305 : DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
3070 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
3071 305 : DOM_CLASSINFO_MAP_END
3072 : #endif
3073 :
3074 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControllers, nsIControllers)
3075 : DOM_CLASSINFO_MAP_ENTRY(nsIControllers)
3076 305 : DOM_CLASSINFO_MAP_END
3077 :
3078 305 : DOM_CLASSINFO_MAP_BEGIN(BoxObject, nsIBoxObject)
3079 : DOM_CLASSINFO_MAP_ENTRY(nsIBoxObject)
3080 305 : DOM_CLASSINFO_MAP_END
3081 :
3082 : #ifdef MOZ_XUL
3083 305 : DOM_CLASSINFO_MAP_BEGIN(TreeSelection, nsITreeSelection)
3084 : DOM_CLASSINFO_MAP_ENTRY(nsITreeSelection)
3085 305 : DOM_CLASSINFO_MAP_END
3086 :
3087 305 : DOM_CLASSINFO_MAP_BEGIN(TreeContentView, nsITreeContentView)
3088 : DOM_CLASSINFO_MAP_ENTRY(nsITreeContentView)
3089 : DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
3090 305 : DOM_CLASSINFO_MAP_END
3091 : #endif
3092 :
3093 305 : DOM_CLASSINFO_MAP_BEGIN(Crypto, nsIDOMCrypto)
3094 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCrypto)
3095 305 : DOM_CLASSINFO_MAP_END
3096 :
3097 305 : DOM_CLASSINFO_MAP_BEGIN(CRMFObject, nsIDOMCRMFObject)
3098 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject)
3099 305 : DOM_CLASSINFO_MAP_END
3100 :
3101 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLStylesheetProcessingInstruction, nsIDOMProcessingInstruction)
3102 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
3103 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
3104 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3105 305 : DOM_CLASSINFO_MAP_END
3106 :
3107 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
3108 610 : DOM_CLASSINFO_WINDOW_MAP_ENTRIES(true)
3109 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
3110 915 : DOM_CLASSINFO_MAP_END
3111 :
3112 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentList, nsIDOMHTMLCollection)
3113 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
3114 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
3115 305 : DOM_CLASSINFO_MAP_END
3116 :
3117 305 : DOM_CLASSINFO_MAP_BEGIN(ImageDocument, nsIImageDocument)
3118 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
3119 : DOM_CLASSINFO_MAP_ENTRY(nsIImageDocument)
3120 305 : DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
3121 610 : DOM_CLASSINFO_MAP_END
3122 :
3123 : #ifdef MOZ_XUL
3124 305 : DOM_CLASSINFO_MAP_BEGIN(XULTemplateBuilder, nsIXULTemplateBuilder)
3125 : DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
3126 305 : DOM_CLASSINFO_MAP_END
3127 :
3128 305 : DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
3129 : DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
3130 : DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
3131 305 : DOM_CLASSINFO_MAP_END
3132 : #endif
3133 :
3134 305 : DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
3135 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
3136 305 : DOM_CLASSINFO_MAP_END
3137 :
3138 : #ifdef MOZ_XUL
3139 305 : DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
3140 : DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
3141 305 : DOM_CLASSINFO_MAP_END
3142 :
3143 305 : DOM_CLASSINFO_MAP_BEGIN(TreeColumns, nsITreeColumns)
3144 : DOM_CLASSINFO_MAP_ENTRY(nsITreeColumns)
3145 305 : DOM_CLASSINFO_MAP_END
3146 : #endif
3147 :
3148 305 : DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
3149 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
3150 305 : DOM_CLASSINFO_MAP_END
3151 :
3152 305 : DOM_CLASSINFO_MAP_BEGIN(BeforeUnloadEvent, nsIDOMBeforeUnloadEvent)
3153 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
3154 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3155 305 : DOM_CLASSINFO_MAP_END
3156 :
3157 : #define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES \
3158 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
3159 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement) \
3160 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
3161 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
3162 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers) \
3163 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver, \
3164 : nsDOMTouchEvent::PrefEnabled())
3165 :
3166 : #define DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES \
3167 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement) \
3168 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests) \
3169 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) \
3170 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3171 :
3172 : #define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \
3173 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable) \
3174 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable) \
3175 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) \
3176 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3177 :
3178 : // XXX - the proto chain stuff is sort of hackish, because of the MI in
3179 : // the SVG interfaces. I doubt that extending the proto on one interface
3180 : // works properly on an element which inherits off multiple interfaces.
3181 : // Tough luck. - bbaetz
3182 :
3183 : // The SVG document
3184 :
3185 305 : DOM_CLASSINFO_MAP_BEGIN(SVGDocument, nsIDOMSVGDocument)
3186 : // Order is significant. nsIDOMDocument.title shadows
3187 : // nsIDOMSVGDocument.title, which is readonly.
3188 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
3189 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDocument)
3190 305 : DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
3191 610 : DOM_CLASSINFO_MAP_END
3192 :
3193 : // SVG element classes
3194 :
3195 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAElement, nsIDOMSVGAElement)
3196 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAElement)
3197 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3198 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3199 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3200 610 : DOM_CLASSINFO_MAP_END
3201 :
3202 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAltGlyphElement, nsIDOMSVGAltGlyphElement)
3203 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3204 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3205 305 : DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
3206 610 : DOM_CLASSINFO_MAP_END
3207 :
3208 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimateElement, nsIDOMSVGAnimateElement)
3209 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3210 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3211 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateElement)
3212 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3213 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3214 610 : DOM_CLASSINFO_MAP_END
3215 :
3216 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimateTransformElement,
3217 : nsIDOMSVGAnimateTransformElement)
3218 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3219 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3220 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateTransformElement)
3221 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3222 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3223 610 : DOM_CLASSINFO_MAP_END
3224 :
3225 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimateMotionElement,
3226 : nsIDOMSVGAnimateMotionElement)
3227 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3228 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3229 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateMotionElement)
3230 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3231 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3232 610 : DOM_CLASSINFO_MAP_END
3233 :
3234 305 : DOM_CLASSINFO_MAP_BEGIN(SVGSetElement,
3235 : nsIDOMSVGSetElement)
3236 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3237 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3238 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSetElement)
3239 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3240 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3241 610 : DOM_CLASSINFO_MAP_END
3242 :
3243 305 : DOM_CLASSINFO_MAP_BEGIN(SVGMpathElement, nsIDOMSVGMpathElement)
3244 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3245 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3246 610 : DOM_CLASSINFO_MAP_END
3247 :
3248 305 : DOM_CLASSINFO_MAP_BEGIN(TimeEvent, nsIDOMTimeEvent)
3249 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeEvent)
3250 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3251 305 : DOM_CLASSINFO_MAP_END
3252 :
3253 305 : DOM_CLASSINFO_MAP_BEGIN(SVGCircleElement, nsIDOMSVGCircleElement)
3254 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGCircleElement)
3255 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3256 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3257 610 : DOM_CLASSINFO_MAP_END
3258 :
3259 305 : DOM_CLASSINFO_MAP_BEGIN(SVGClipPathElement, nsIDOMSVGClipPathElement)
3260 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGClipPathElement)
3261 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3262 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3263 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3264 610 : DOM_CLASSINFO_MAP_END
3265 :
3266 305 : DOM_CLASSINFO_MAP_BEGIN(SVGDefsElement, nsIDOMSVGDefsElement)
3267 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDefsElement)
3268 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3269 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3270 610 : DOM_CLASSINFO_MAP_END
3271 :
3272 305 : DOM_CLASSINFO_MAP_BEGIN(SVGDescElement, nsIDOMSVGDescElement)
3273 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDescElement)
3274 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3275 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3276 610 : DOM_CLASSINFO_MAP_END
3277 :
3278 305 : DOM_CLASSINFO_MAP_BEGIN(SVGEllipseElement, nsIDOMSVGEllipseElement)
3279 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEllipseElement)
3280 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3281 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3282 610 : DOM_CLASSINFO_MAP_END
3283 :
3284 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEBlendElement, nsIDOMSVGFEBlendElement)
3285 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEBlendElement)
3286 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3287 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3288 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3289 610 : DOM_CLASSINFO_MAP_END
3290 :
3291 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEColorMatrixElement, nsIDOMSVGFEColorMatrixElement)
3292 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEColorMatrixElement)
3293 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3294 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3295 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3296 610 : DOM_CLASSINFO_MAP_END
3297 :
3298 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEComponentTransferElement, nsIDOMSVGFEComponentTransferElement)
3299 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEComponentTransferElement)
3300 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3301 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3302 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3303 610 : DOM_CLASSINFO_MAP_END
3304 :
3305 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFECompositeElement, nsIDOMSVGFECompositeElement)
3306 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFECompositeElement)
3307 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3308 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3309 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3310 610 : DOM_CLASSINFO_MAP_END
3311 :
3312 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEConvolveMatrixElement, nsIDOMSVGFEConvolveMatrixElement)
3313 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEConvolveMatrixElement)
3314 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3315 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3316 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3317 610 : DOM_CLASSINFO_MAP_END
3318 :
3319 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEDiffuseLightingElement, nsIDOMSVGFEDiffuseLightingElement)
3320 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement)
3321 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3322 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3323 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3324 610 : DOM_CLASSINFO_MAP_END
3325 :
3326 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEDisplacementMapElement, nsIDOMSVGFEDisplacementMapElement)
3327 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement)
3328 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3329 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3330 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3331 610 : DOM_CLASSINFO_MAP_END
3332 :
3333 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEDistantLightElement, nsIDOMSVGFEDistantLightElement)
3334 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDistantLightElement)
3335 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3336 610 : DOM_CLASSINFO_MAP_END
3337 :
3338 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEFloodElement, nsIDOMSVGFEFloodElement)
3339 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFloodElement)
3340 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3341 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3342 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3343 610 : DOM_CLASSINFO_MAP_END
3344 :
3345 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncAElement, nsIDOMSVGFEFuncAElement)
3346 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncAElement)
3347 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3348 610 : DOM_CLASSINFO_MAP_END
3349 :
3350 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncBElement, nsIDOMSVGFEFuncBElement)
3351 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncBElement)
3352 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3353 610 : DOM_CLASSINFO_MAP_END
3354 :
3355 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncGElement, nsIDOMSVGFEFuncGElement)
3356 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncGElement)
3357 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3358 610 : DOM_CLASSINFO_MAP_END
3359 :
3360 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncRElement, nsIDOMSVGFEFuncRElement)
3361 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncRElement)
3362 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3363 610 : DOM_CLASSINFO_MAP_END
3364 :
3365 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEGaussianBlurElement, nsIDOMSVGFEGaussianBlurElement)
3366 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEGaussianBlurElement)
3367 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3368 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3369 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3370 610 : DOM_CLASSINFO_MAP_END
3371 :
3372 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEImageElement, nsIDOMSVGFEImageElement)
3373 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEImageElement)
3374 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3375 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3376 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3377 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3378 610 : DOM_CLASSINFO_MAP_END
3379 :
3380 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeElement, nsIDOMSVGFEMergeElement)
3381 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeElement)
3382 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3383 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3384 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3385 610 : DOM_CLASSINFO_MAP_END
3386 :
3387 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEMorphologyElement, nsIDOMSVGFEMorphologyElement)
3388 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMorphologyElement)
3389 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3390 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3391 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3392 610 : DOM_CLASSINFO_MAP_END
3393 :
3394 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeNodeElement, nsIDOMSVGFEMergeNodeElement)
3395 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeNodeElement)
3396 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3397 610 : DOM_CLASSINFO_MAP_END
3398 :
3399 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEOffsetElement, nsIDOMSVGFEOffsetElement)
3400 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEOffsetElement)
3401 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3402 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3403 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3404 610 : DOM_CLASSINFO_MAP_END
3405 :
3406 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFEPointLightElement, nsIDOMSVGFEPointLightElement)
3407 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEPointLightElement)
3408 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3409 610 : DOM_CLASSINFO_MAP_END
3410 :
3411 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFESpecularLightingElement, nsIDOMSVGFESpecularLightingElement)
3412 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement)
3413 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3414 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3415 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3416 610 : DOM_CLASSINFO_MAP_END
3417 :
3418 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFESpotLightElement, nsIDOMSVGFESpotLightElement)
3419 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpotLightElement)
3420 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3421 610 : DOM_CLASSINFO_MAP_END
3422 :
3423 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFETileElement, nsIDOMSVGFETileElement)
3424 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETileElement)
3425 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3426 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3427 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3428 610 : DOM_CLASSINFO_MAP_END
3429 :
3430 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement)
3431 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
3432 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3433 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3434 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3435 610 : DOM_CLASSINFO_MAP_END
3436 :
3437 305 : DOM_CLASSINFO_MAP_BEGIN(SVGFilterElement, nsIDOMSVGFilterElement)
3438 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterElement)
3439 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3440 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3441 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3442 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3443 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3444 610 : DOM_CLASSINFO_MAP_END
3445 :
3446 305 : DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement)
3447 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
3448 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3449 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3450 610 : DOM_CLASSINFO_MAP_END
3451 :
3452 305 : DOM_CLASSINFO_MAP_BEGIN(SVGGElement, nsIDOMSVGGElement)
3453 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGElement)
3454 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3455 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3456 610 : DOM_CLASSINFO_MAP_END
3457 :
3458 305 : DOM_CLASSINFO_MAP_BEGIN(SVGImageElement, nsIDOMSVGImageElement)
3459 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGImageElement)
3460 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3461 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3462 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3463 610 : DOM_CLASSINFO_MAP_END
3464 :
3465 305 : DOM_CLASSINFO_MAP_BEGIN(SVGLinearGradientElement, nsIDOMSVGLinearGradientElement)
3466 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
3467 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
3468 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3469 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3470 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3471 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3472 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3473 610 : DOM_CLASSINFO_MAP_END
3474 :
3475 305 : DOM_CLASSINFO_MAP_BEGIN(SVGLineElement, nsIDOMSVGLineElement)
3476 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLineElement)
3477 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3478 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3479 610 : DOM_CLASSINFO_MAP_END
3480 :
3481 305 : DOM_CLASSINFO_MAP_BEGIN(SVGMarkerElement, nsIDOMSVGMarkerElement)
3482 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMarkerElement)
3483 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3484 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3485 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3486 610 : DOM_CLASSINFO_MAP_END
3487 :
3488 305 : DOM_CLASSINFO_MAP_BEGIN(SVGMaskElement, nsIDOMSVGMaskElement)
3489 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMaskElement)
3490 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3491 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3492 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3493 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3494 610 : DOM_CLASSINFO_MAP_END
3495 :
3496 305 : DOM_CLASSINFO_MAP_BEGIN(SVGMetadataElement, nsIDOMSVGMetadataElement)
3497 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMetadataElement)
3498 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3499 610 : DOM_CLASSINFO_MAP_END
3500 :
3501 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathElement, nsIDOMSVGPathElement)
3502 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathElement)
3503 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3504 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
3505 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3506 610 : DOM_CLASSINFO_MAP_END
3507 :
3508 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPatternElement, nsIDOMSVGPatternElement)
3509 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPatternElement)
3510 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3511 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3512 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3513 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3514 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3515 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3516 610 : DOM_CLASSINFO_MAP_END
3517 :
3518 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPolygonElement, nsIDOMSVGPolygonElement)
3519 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolygonElement)
3520 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3521 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
3522 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3523 610 : DOM_CLASSINFO_MAP_END
3524 :
3525 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPolylineElement, nsIDOMSVGPolylineElement)
3526 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolylineElement)
3527 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3528 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
3529 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3530 610 : DOM_CLASSINFO_MAP_END
3531 :
3532 305 : DOM_CLASSINFO_MAP_BEGIN(SVGRadialGradientElement, nsIDOMSVGRadialGradientElement)
3533 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
3534 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
3535 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3536 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3537 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3538 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3539 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3540 610 : DOM_CLASSINFO_MAP_END
3541 :
3542 305 : DOM_CLASSINFO_MAP_BEGIN(SVGRectElement, nsIDOMSVGRectElement)
3543 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRectElement)
3544 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3545 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3546 610 : DOM_CLASSINFO_MAP_END
3547 :
3548 305 : DOM_CLASSINFO_MAP_BEGIN(SVGScriptElement, nsIDOMSVGScriptElement)
3549 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGScriptElement)
3550 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3551 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3552 610 : DOM_CLASSINFO_MAP_END
3553 :
3554 305 : DOM_CLASSINFO_MAP_BEGIN(SVGStopElement, nsIDOMSVGStopElement)
3555 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStopElement)
3556 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3557 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3558 610 : DOM_CLASSINFO_MAP_END
3559 :
3560 305 : DOM_CLASSINFO_MAP_BEGIN(SVGStyleElement, nsIDOMSVGStyleElement)
3561 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStyleElement)
3562 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
3563 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3564 610 : DOM_CLASSINFO_MAP_END
3565 :
3566 305 : DOM_CLASSINFO_MAP_BEGIN(SVGSVGElement, nsIDOMSVGSVGElement)
3567 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSVGElement)
3568 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3569 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
3570 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3571 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3572 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomAndPan)
3573 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3574 610 : DOM_CLASSINFO_MAP_END
3575 :
3576 305 : DOM_CLASSINFO_MAP_BEGIN(SVGSwitchElement, nsIDOMSVGSwitchElement)
3577 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSwitchElement)
3578 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3579 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3580 610 : DOM_CLASSINFO_MAP_END
3581 :
3582 305 : DOM_CLASSINFO_MAP_BEGIN(SVGSymbolElement, nsIDOMSVGSymbolElement)
3583 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3584 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSymbolElement)
3585 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3586 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3587 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3588 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3589 610 : DOM_CLASSINFO_MAP_END
3590 :
3591 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTextElement, nsIDOMSVGTextElement)
3592 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3593 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
3594 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3595 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3596 610 : DOM_CLASSINFO_MAP_END
3597 :
3598 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTextPathElement, nsIDOMSVGTextPathElement)
3599 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3600 305 : DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
3601 610 : DOM_CLASSINFO_MAP_END
3602 :
3603 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTitleElement, nsIDOMSVGTitleElement)
3604 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTitleElement)
3605 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3606 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3607 610 : DOM_CLASSINFO_MAP_END
3608 :
3609 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTSpanElement, nsIDOMSVGTSpanElement)
3610 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3611 305 : DOM_CLASSINFO_SVG_TEXT_CONTENT_ELEMENT_MAP_ENTRIES
3612 610 : DOM_CLASSINFO_MAP_END
3613 :
3614 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(SVGUnknownElement, nsIDOMSVGElement)
3615 305 : DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3616 610 : DOM_CLASSINFO_MAP_END
3617 :
3618 305 : DOM_CLASSINFO_MAP_BEGIN(SVGUseElement, nsIDOMSVGUseElement)
3619 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUseElement)
3620 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTests)
3621 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3622 305 : DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3623 610 : DOM_CLASSINFO_MAP_END
3624 :
3625 : // other SVG classes
3626 :
3627 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAngle, nsIDOMSVGAngle)
3628 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAngle)
3629 305 : DOM_CLASSINFO_MAP_END
3630 :
3631 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedAngle, nsIDOMSVGAnimatedAngle)
3632 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedAngle)
3633 305 : DOM_CLASSINFO_MAP_END
3634 :
3635 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedBoolean, nsIDOMSVGAnimatedBoolean)
3636 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedBoolean)
3637 305 : DOM_CLASSINFO_MAP_END
3638 :
3639 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedEnumeration, nsIDOMSVGAnimatedEnumeration)
3640 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
3641 305 : DOM_CLASSINFO_MAP_END
3642 :
3643 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger)
3644 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
3645 305 : DOM_CLASSINFO_MAP_END
3646 :
3647 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLength, nsIDOMSVGAnimatedLength)
3648 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLength)
3649 305 : DOM_CLASSINFO_MAP_END
3650 :
3651 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLengthList, nsIDOMSVGAnimatedLengthList)
3652 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLengthList)
3653 305 : DOM_CLASSINFO_MAP_END
3654 :
3655 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber)
3656 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber)
3657 305 : DOM_CLASSINFO_MAP_END
3658 :
3659 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumberList, nsIDOMSVGAnimatedNumberList)
3660 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumberList)
3661 305 : DOM_CLASSINFO_MAP_END
3662 :
3663 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedPreserveAspectRatio, nsIDOMSVGAnimatedPreserveAspectRatio)
3664 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPreserveAspectRatio)
3665 305 : DOM_CLASSINFO_MAP_END
3666 :
3667 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedRect, nsIDOMSVGAnimatedRect)
3668 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedRect)
3669 305 : DOM_CLASSINFO_MAP_END
3670 :
3671 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedString, nsIDOMSVGAnimatedString)
3672 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedString)
3673 305 : DOM_CLASSINFO_MAP_END
3674 :
3675 305 : DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedTransformList, nsIDOMSVGAnimatedTransformList)
3676 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
3677 305 : DOM_CLASSINFO_MAP_END
3678 :
3679 305 : DOM_CLASSINFO_MAP_BEGIN(SVGEvent, nsIDOMSVGEvent)
3680 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEvent)
3681 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3682 305 : DOM_CLASSINFO_MAP_END
3683 :
3684 305 : DOM_CLASSINFO_MAP_BEGIN(SVGException, nsIDOMSVGException)
3685 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGException)
3686 : DOM_CLASSINFO_MAP_ENTRY(nsIException)
3687 305 : DOM_CLASSINFO_MAP_END
3688 :
3689 305 : DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength)
3690 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength)
3691 305 : DOM_CLASSINFO_MAP_END
3692 :
3693 305 : DOM_CLASSINFO_MAP_BEGIN(SVGLengthList, nsIDOMSVGLengthList)
3694 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLengthList)
3695 305 : DOM_CLASSINFO_MAP_END
3696 :
3697 305 : DOM_CLASSINFO_MAP_BEGIN(SVGMatrix, nsIDOMSVGMatrix)
3698 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMatrix)
3699 305 : DOM_CLASSINFO_MAP_END
3700 :
3701 305 : DOM_CLASSINFO_MAP_BEGIN(SVGNumber, nsIDOMSVGNumber)
3702 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber)
3703 305 : DOM_CLASSINFO_MAP_END
3704 :
3705 305 : DOM_CLASSINFO_MAP_BEGIN(SVGNumberList, nsIDOMSVGNumberList)
3706 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumberList)
3707 305 : DOM_CLASSINFO_MAP_END
3708 :
3709 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcAbs, nsIDOMSVGPathSegArcAbs)
3710 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcAbs)
3711 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3712 305 : DOM_CLASSINFO_MAP_END
3713 :
3714 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcRel, nsIDOMSVGPathSegArcRel)
3715 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcRel)
3716 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3717 305 : DOM_CLASSINFO_MAP_END
3718 :
3719 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegClosePath, nsIDOMSVGPathSegClosePath)
3720 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegClosePath)
3721 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3722 305 : DOM_CLASSINFO_MAP_END
3723 :
3724 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicAbs, nsIDOMSVGPathSegCurvetoCubicAbs)
3725 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicAbs)
3726 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3727 305 : DOM_CLASSINFO_MAP_END
3728 :
3729 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicRel, nsIDOMSVGPathSegCurvetoCubicRel)
3730 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicRel)
3731 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3732 305 : DOM_CLASSINFO_MAP_END
3733 :
3734 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothAbs, nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
3735 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
3736 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3737 305 : DOM_CLASSINFO_MAP_END
3738 :
3739 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothRel, nsIDOMSVGPathSegCurvetoCubicSmoothRel)
3740 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothRel)
3741 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3742 305 : DOM_CLASSINFO_MAP_END
3743 :
3744 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticAbs, nsIDOMSVGPathSegCurvetoQuadraticAbs)
3745 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticAbs)
3746 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3747 305 : DOM_CLASSINFO_MAP_END
3748 :
3749 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticRel, nsIDOMSVGPathSegCurvetoQuadraticRel)
3750 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticRel)
3751 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3752 305 : DOM_CLASSINFO_MAP_END
3753 :
3754 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothAbs, nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
3755 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
3756 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3757 305 : DOM_CLASSINFO_MAP_END
3758 :
3759 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothRel, nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
3760 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
3761 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3762 305 : DOM_CLASSINFO_MAP_END
3763 :
3764 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoAbs, nsIDOMSVGPathSegLinetoAbs)
3765 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoAbs)
3766 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3767 305 : DOM_CLASSINFO_MAP_END
3768 :
3769 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalAbs, nsIDOMSVGPathSegLinetoHorizontalAbs)
3770 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalAbs)
3771 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3772 305 : DOM_CLASSINFO_MAP_END
3773 :
3774 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalRel, nsIDOMSVGPathSegLinetoHorizontalRel)
3775 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalRel)
3776 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3777 305 : DOM_CLASSINFO_MAP_END
3778 :
3779 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoRel, nsIDOMSVGPathSegLinetoRel)
3780 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoRel)
3781 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3782 305 : DOM_CLASSINFO_MAP_END
3783 :
3784 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalAbs, nsIDOMSVGPathSegLinetoVerticalAbs)
3785 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalAbs)
3786 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3787 305 : DOM_CLASSINFO_MAP_END
3788 :
3789 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalRel, nsIDOMSVGPathSegLinetoVerticalRel)
3790 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalRel)
3791 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3792 305 : DOM_CLASSINFO_MAP_END
3793 :
3794 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegList, nsIDOMSVGPathSegList)
3795 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegList)
3796 305 : DOM_CLASSINFO_MAP_END
3797 :
3798 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoAbs, nsIDOMSVGPathSegMovetoAbs)
3799 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoAbs)
3800 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3801 305 : DOM_CLASSINFO_MAP_END
3802 :
3803 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoRel, nsIDOMSVGPathSegMovetoRel)
3804 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoRel)
3805 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3806 305 : DOM_CLASSINFO_MAP_END
3807 :
3808 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPoint, nsIDOMSVGPoint)
3809 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPoint)
3810 305 : DOM_CLASSINFO_MAP_END
3811 :
3812 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPointList, nsIDOMSVGPointList)
3813 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPointList)
3814 305 : DOM_CLASSINFO_MAP_END
3815 :
3816 305 : DOM_CLASSINFO_MAP_BEGIN(SVGPreserveAspectRatio, nsIDOMSVGPreserveAspectRatio)
3817 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPreserveAspectRatio)
3818 305 : DOM_CLASSINFO_MAP_END
3819 :
3820 305 : DOM_CLASSINFO_MAP_BEGIN(SVGRect, nsIDOMSVGRect)
3821 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRect)
3822 305 : DOM_CLASSINFO_MAP_END
3823 :
3824 305 : DOM_CLASSINFO_MAP_BEGIN(SVGStringList, nsIDOMSVGStringList)
3825 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStringList)
3826 305 : DOM_CLASSINFO_MAP_END
3827 :
3828 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTransform, nsIDOMSVGTransform)
3829 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransform)
3830 305 : DOM_CLASSINFO_MAP_END
3831 :
3832 305 : DOM_CLASSINFO_MAP_BEGIN(SVGTransformList, nsIDOMSVGTransformList)
3833 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
3834 305 : DOM_CLASSINFO_MAP_END
3835 :
3836 305 : DOM_CLASSINFO_MAP_BEGIN(SVGZoomEvent, nsIDOMSVGZoomEvent)
3837 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
3838 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3839 305 : DOM_CLASSINFO_MAP_END
3840 :
3841 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
3842 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
3843 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
3844 610 : DOM_CLASSINFO_MAP_END
3845 :
3846 305 : DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D)
3847 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasRenderingContext2D)
3848 305 : DOM_CLASSINFO_MAP_END
3849 :
3850 305 : DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
3851 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
3852 305 : DOM_CLASSINFO_MAP_END
3853 :
3854 305 : DOM_CLASSINFO_MAP_BEGIN(CanvasPattern, nsIDOMCanvasPattern)
3855 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasPattern)
3856 305 : DOM_CLASSINFO_MAP_END
3857 :
3858 305 : DOM_CLASSINFO_MAP_BEGIN(TextMetrics, nsIDOMTextMetrics)
3859 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTextMetrics)
3860 305 : DOM_CLASSINFO_MAP_END
3861 :
3862 305 : DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
3863 : DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
3864 : DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
3865 305 : DOM_CLASSINFO_MAP_END
3866 :
3867 305 : DOM_CLASSINFO_MAP_BEGIN(XPathEvaluator, nsIDOMXPathEvaluator)
3868 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator)
3869 305 : DOM_CLASSINFO_MAP_END
3870 :
3871 305 : DOM_CLASSINFO_MAP_BEGIN(XPathException, nsIDOMXPathException)
3872 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathException)
3873 : DOM_CLASSINFO_MAP_ENTRY(nsIException)
3874 305 : DOM_CLASSINFO_MAP_END
3875 :
3876 305 : DOM_CLASSINFO_MAP_BEGIN(XPathExpression, nsIDOMXPathExpression)
3877 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathExpression)
3878 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSXPathExpression)
3879 305 : DOM_CLASSINFO_MAP_END
3880 :
3881 305 : DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
3882 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
3883 305 : DOM_CLASSINFO_MAP_END
3884 :
3885 305 : DOM_CLASSINFO_MAP_BEGIN(XPathResult, nsIDOMXPathResult)
3886 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathResult)
3887 305 : DOM_CLASSINFO_MAP_END
3888 :
3889 305 : DOM_CLASSINFO_MAP_BEGIN(StorageObsolete, nsIDOMStorageObsolete)
3890 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageObsolete)
3891 305 : DOM_CLASSINFO_MAP_END
3892 :
3893 305 : DOM_CLASSINFO_MAP_BEGIN(Storage, nsIDOMStorage)
3894 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
3895 305 : DOM_CLASSINFO_MAP_END
3896 :
3897 305 : DOM_CLASSINFO_MAP_BEGIN(StorageList, nsIDOMStorageList)
3898 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageList)
3899 305 : DOM_CLASSINFO_MAP_END
3900 :
3901 305 : DOM_CLASSINFO_MAP_BEGIN(StorageItem, nsIDOMStorageItem)
3902 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageItem)
3903 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMToString)
3904 305 : DOM_CLASSINFO_MAP_END
3905 :
3906 305 : DOM_CLASSINFO_MAP_BEGIN(StorageEvent, nsIDOMStorageEvent)
3907 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEvent)
3908 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3909 305 : DOM_CLASSINFO_MAP_END
3910 :
3911 305 : DOM_CLASSINFO_MAP_BEGIN(StorageEventObsolete, nsIDOMStorageEventObsolete)
3912 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEventObsolete)
3913 305 : DOM_CLASSINFO_MAP_END
3914 :
3915 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMParser, nsIDOMParser)
3916 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMParser)
3917 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMParserJS)
3918 305 : DOM_CLASSINFO_MAP_END
3919 :
3920 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLSerializer, nsIDOMSerializer)
3921 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSerializer)
3922 305 : DOM_CLASSINFO_MAP_END
3923 :
3924 305 : DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequest, nsIXMLHttpRequest)
3925 : DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequest)
3926 : DOM_CLASSINFO_MAP_ENTRY(nsIJSXMLHttpRequest)
3927 : DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
3928 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3929 : DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
3930 305 : DOM_CLASSINFO_MAP_END
3931 :
3932 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLHttpProgressEvent, nsIDOMEvent)
3933 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMLSProgressEvent)
3934 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
3935 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3936 305 : DOM_CLASSINFO_MAP_END
3937 :
3938 305 : DOM_CLASSINFO_MAP_BEGIN(EventSource, nsIEventSource)
3939 : DOM_CLASSINFO_MAP_ENTRY(nsIEventSource)
3940 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3941 305 : DOM_CLASSINFO_MAP_END
3942 :
3943 305 : DOM_CLASSINFO_MAP_BEGIN(XULCommandEvent, nsIDOMXULCommandEvent)
3944 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandEvent)
3945 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3946 305 : DOM_CLASSINFO_MAP_END
3947 :
3948 305 : DOM_CLASSINFO_MAP_BEGIN(CommandEvent, nsIDOMCommandEvent)
3949 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCommandEvent)
3950 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
3951 305 : DOM_CLASSINFO_MAP_END
3952 :
3953 305 : DOM_CLASSINFO_MAP_BEGIN(OfflineResourceList, nsIDOMOfflineResourceList)
3954 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMOfflineResourceList)
3955 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3956 305 : DOM_CLASSINFO_MAP_END
3957 :
3958 305 : DOM_CLASSINFO_MAP_BEGIN(ClientRect, nsIDOMClientRect)
3959 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRect)
3960 305 : DOM_CLASSINFO_MAP_END
3961 :
3962 305 : DOM_CLASSINFO_MAP_BEGIN(ClientRectList, nsIDOMClientRectList)
3963 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRectList)
3964 305 : DOM_CLASSINFO_MAP_END
3965 :
3966 305 : DOM_CLASSINFO_MAP_BEGIN(FileList, nsIDOMFileList)
3967 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileList)
3968 305 : DOM_CLASSINFO_MAP_END
3969 :
3970 305 : DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
3971 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
3972 305 : DOM_CLASSINFO_MAP_END
3973 :
3974 305 : DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
3975 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
3976 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
3977 305 : DOM_CLASSINFO_MAP_END
3978 :
3979 305 : DOM_CLASSINFO_MAP_BEGIN(FileException, nsIDOMFileException)
3980 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileException)
3981 : DOM_CLASSINFO_MAP_ENTRY(nsIException)
3982 305 : DOM_CLASSINFO_MAP_END
3983 :
3984 305 : DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
3985 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
3986 : DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
3987 305 : DOM_CLASSINFO_MAP_END
3988 :
3989 305 : DOM_CLASSINFO_MAP_BEGIN(MozURLProperty, nsIDOMMozURLProperty)
3990 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozURLProperty)
3991 305 : DOM_CLASSINFO_MAP_END
3992 :
3993 305 : DOM_CLASSINFO_MAP_BEGIN(MozBlobBuilder, nsIDOMMozBlobBuilder)
3994 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBlobBuilder)
3995 305 : DOM_CLASSINFO_MAP_END
3996 :
3997 305 : DOM_CLASSINFO_MAP_BEGIN(DOMStringMap, nsIDOMDOMStringMap)
3998 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringMap)
3999 305 : DOM_CLASSINFO_MAP_END
4000 :
4001 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
4002 915 : DOM_CLASSINFO_WINDOW_MAP_ENTRIES(nsGlobalWindow::HasIndexedDBSupport())
4003 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
4004 1220 : DOM_CLASSINFO_MAP_END
4005 :
4006 305 : DOM_CLASSINFO_MAP_BEGIN(DataContainerEvent, nsIDOMDataContainerEvent)
4007 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataContainerEvent)
4008 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4009 305 : DOM_CLASSINFO_MAP_END
4010 :
4011 305 : DOM_CLASSINFO_MAP_BEGIN(MessageEvent, nsIDOMMessageEvent)
4012 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMessageEvent)
4013 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4014 305 : DOM_CLASSINFO_MAP_END
4015 :
4016 305 : DOM_CLASSINFO_MAP_BEGIN(GeoGeolocation, nsIDOMGeoGeolocation)
4017 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoGeolocation)
4018 305 : DOM_CLASSINFO_MAP_END
4019 :
4020 305 : DOM_CLASSINFO_MAP_BEGIN(GeoPosition, nsIDOMGeoPosition)
4021 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPosition)
4022 305 : DOM_CLASSINFO_MAP_END
4023 :
4024 305 : DOM_CLASSINFO_MAP_BEGIN(GeoPositionCoords, nsIDOMGeoPositionCoords)
4025 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionCoords)
4026 305 : DOM_CLASSINFO_MAP_END
4027 :
4028 305 : DOM_CLASSINFO_MAP_BEGIN(GeoPositionAddress, nsIDOMGeoPositionAddress)
4029 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionAddress)
4030 305 : DOM_CLASSINFO_MAP_END
4031 :
4032 305 : DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError)
4033 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
4034 305 : DOM_CLASSINFO_MAP_END
4035 :
4036 305 : DOM_CLASSINFO_MAP_BEGIN(MozBatteryManager, nsIDOMMozBatteryManager)
4037 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBatteryManager)
4038 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4039 305 : DOM_CLASSINFO_MAP_END
4040 :
4041 305 : DOM_CLASSINFO_MAP_BEGIN(MozPowerManager, nsIDOMMozPowerManager)
4042 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozPowerManager)
4043 305 : DOM_CLASSINFO_MAP_END
4044 :
4045 305 : DOM_CLASSINFO_MAP_BEGIN(MozWakeLock, nsIDOMMozWakeLock)
4046 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozWakeLock)
4047 305 : DOM_CLASSINFO_MAP_END
4048 :
4049 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsManager, nsIDOMMozSmsManager)
4050 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsManager)
4051 305 : DOM_CLASSINFO_MAP_END
4052 :
4053 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
4054 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
4055 305 : DOM_CLASSINFO_MAP_END
4056 :
4057 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsEvent, nsIDOMMozSmsEvent)
4058 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsEvent)
4059 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4060 305 : DOM_CLASSINFO_MAP_END
4061 :
4062 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsRequest, nsIDOMMozSmsRequest)
4063 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsRequest)
4064 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4065 305 : DOM_CLASSINFO_MAP_END
4066 :
4067 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
4068 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
4069 305 : DOM_CLASSINFO_MAP_END
4070 :
4071 305 : DOM_CLASSINFO_MAP_BEGIN(MozSmsCursor, nsIDOMMozSmsCursor)
4072 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
4073 305 : DOM_CLASSINFO_MAP_END
4074 :
4075 305 : DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
4076 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
4077 305 : DOM_CLASSINFO_MAP_END
4078 :
4079 305 : DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
4080 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
4081 305 : DOM_CLASSINFO_MAP_END
4082 :
4083 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
4084 : nsIDOMCSSStyleDeclaration)
4085 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
4086 305 : DOM_CLASSINFO_MAP_END
4087 :
4088 : #if defined (MOZ_MEDIA)
4089 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLVideoElement, nsIDOMHTMLVideoElement)
4090 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLVideoElement)
4091 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
4092 610 : DOM_CLASSINFO_MAP_END
4093 :
4094 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLSourceElement, nsIDOMHTMLSourceElement)
4095 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSourceElement)
4096 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
4097 610 : DOM_CLASSINFO_MAP_END
4098 :
4099 305 : DOM_CLASSINFO_MAP_BEGIN(MediaError, nsIDOMMediaError)
4100 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaError)
4101 305 : DOM_CLASSINFO_MAP_END
4102 :
4103 305 : DOM_CLASSINFO_MAP_BEGIN(HTMLAudioElement, nsIDOMHTMLAudioElement)
4104 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAudioElement)
4105 305 : DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
4106 610 : DOM_CLASSINFO_MAP_END
4107 :
4108 305 : DOM_CLASSINFO_MAP_BEGIN(TimeRanges, nsIDOMTimeRanges)
4109 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeRanges)
4110 305 : DOM_CLASSINFO_MAP_END
4111 : #endif
4112 :
4113 305 : DOM_CLASSINFO_MAP_BEGIN(ProgressEvent, nsIDOMProgressEvent)
4114 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
4115 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4116 305 : DOM_CLASSINFO_MAP_END
4117 :
4118 305 : DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequestUpload, nsIXMLHttpRequestUpload)
4119 : DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
4120 : DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestUpload)
4121 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4122 305 : DOM_CLASSINFO_MAP_END
4123 :
4124 305 : DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer)
4125 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer)
4126 305 : DOM_CLASSINFO_MAP_END
4127 :
4128 305 : DOM_CLASSINFO_MAP_BEGIN(NotifyPaintEvent, nsIDOMNotifyPaintEvent)
4129 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyPaintEvent)
4130 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4131 305 : DOM_CLASSINFO_MAP_END
4132 :
4133 305 : DOM_CLASSINFO_MAP_BEGIN(NotifyAudioAvailableEvent, nsIDOMNotifyAudioAvailableEvent)
4134 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyAudioAvailableEvent)
4135 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4136 305 : DOM_CLASSINFO_MAP_END
4137 :
4138 305 : DOM_CLASSINFO_MAP_BEGIN(SimpleGestureEvent, nsIDOMSimpleGestureEvent)
4139 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMSimpleGestureEvent)
4140 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
4141 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
4142 305 : DOM_CLASSINFO_MAP_END
4143 :
4144 305 : DOM_CLASSINFO_MAP_BEGIN(MozTouchEvent, nsIDOMMozTouchEvent)
4145 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTouchEvent)
4146 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
4147 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
4148 305 : DOM_CLASSINFO_MAP_END
4149 :
4150 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(MathMLElement, nsIDOMElement)
4151 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
4152 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
4153 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4154 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
4155 : DOM_CLASSINFO_MAP_ENTRY(nsIInlineEventHandlers)
4156 305 : DOM_CLASSINFO_MAP_CONDITIONAL_ENTRY(nsITouchEventReceiver,
4157 : nsDOMTouchEvent::PrefEnabled())
4158 610 : DOM_CLASSINFO_MAP_END
4159 :
4160 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLRenderingContext, nsIDOMWebGLRenderingContext)
4161 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMWebGLRenderingContext)
4162 305 : DOM_CLASSINFO_MAP_END
4163 :
4164 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLBuffer, nsIWebGLBuffer)
4165 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLBuffer)
4166 305 : DOM_CLASSINFO_MAP_END
4167 :
4168 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLTexture, nsIWebGLTexture)
4169 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLTexture)
4170 305 : DOM_CLASSINFO_MAP_END
4171 :
4172 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLProgram, nsIWebGLProgram)
4173 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLProgram)
4174 305 : DOM_CLASSINFO_MAP_END
4175 :
4176 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLShader, nsIWebGLShader)
4177 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShader)
4178 305 : DOM_CLASSINFO_MAP_END
4179 :
4180 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLFramebuffer, nsIWebGLFramebuffer)
4181 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLFramebuffer)
4182 305 : DOM_CLASSINFO_MAP_END
4183 :
4184 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLRenderbuffer, nsIWebGLRenderbuffer)
4185 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
4186 305 : DOM_CLASSINFO_MAP_END
4187 :
4188 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLShaderPrecisionFormat, nsIWebGLShaderPrecisionFormat)
4189 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShaderPrecisionFormat)
4190 305 : DOM_CLASSINFO_MAP_END
4191 :
4192 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLUniformLocation, nsIWebGLUniformLocation)
4193 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLUniformLocation)
4194 305 : DOM_CLASSINFO_MAP_END
4195 :
4196 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLActiveInfo, nsIWebGLActiveInfo)
4197 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLActiveInfo)
4198 305 : DOM_CLASSINFO_MAP_END
4199 :
4200 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLExtension, nsIWebGLExtension)
4201 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtension)
4202 305 : DOM_CLASSINFO_MAP_END
4203 :
4204 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionStandardDerivatives, nsIWebGLExtensionStandardDerivatives)
4205 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionStandardDerivatives)
4206 305 : DOM_CLASSINFO_MAP_END
4207 :
4208 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionTextureFilterAnisotropic, nsIWebGLExtensionTextureFilterAnisotropic)
4209 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionTextureFilterAnisotropic)
4210 305 : DOM_CLASSINFO_MAP_END
4211 :
4212 305 : DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionLoseContext, nsIWebGLExtensionLoseContext)
4213 : DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionLoseContext)
4214 305 : DOM_CLASSINFO_MAP_END
4215 :
4216 305 : DOM_CLASSINFO_MAP_BEGIN(PaintRequest, nsIDOMPaintRequest)
4217 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequest)
4218 305 : DOM_CLASSINFO_MAP_END
4219 :
4220 305 : DOM_CLASSINFO_MAP_BEGIN(PaintRequestList, nsIDOMPaintRequestList)
4221 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequestList)
4222 305 : DOM_CLASSINFO_MAP_END
4223 :
4224 305 : DOM_CLASSINFO_MAP_BEGIN(ScrollAreaEvent, nsIDOMScrollAreaEvent)
4225 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMScrollAreaEvent)
4226 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
4227 305 : DOM_CLASSINFO_MAP_END
4228 :
4229 305 : DOM_CLASSINFO_MAP_BEGIN(EventListenerInfo, nsIEventListenerInfo)
4230 : DOM_CLASSINFO_MAP_ENTRY(nsIEventListenerInfo)
4231 305 : DOM_CLASSINFO_MAP_END
4232 :
4233 305 : DOM_CLASSINFO_MAP_BEGIN(TransitionEvent, nsIDOMTransitionEvent)
4234 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTransitionEvent)
4235 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4236 305 : DOM_CLASSINFO_MAP_END
4237 :
4238 305 : DOM_CLASSINFO_MAP_BEGIN(AnimationEvent, nsIDOMAnimationEvent)
4239 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMAnimationEvent)
4240 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4241 305 : DOM_CLASSINFO_MAP_END
4242 :
4243 305 : DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsIContentFrameMessageManager)
4244 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4245 : DOM_CLASSINFO_MAP_ENTRY(nsIFrameMessageManager)
4246 : DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
4247 : DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
4248 305 : DOM_CLASSINFO_MAP_END
4249 :
4250 305 : DOM_CLASSINFO_MAP_BEGIN(FormData, nsIDOMFormData)
4251 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMFormData)
4252 305 : DOM_CLASSINFO_MAP_END
4253 :
4254 305 : DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
4255 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
4256 305 : DOM_CLASSINFO_MAP_END
4257 :
4258 305 : DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
4259 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
4260 305 : DOM_CLASSINFO_MAP_END
4261 :
4262 305 : DOM_CLASSINFO_MAP_BEGIN(WebSocket, nsIWebSocket)
4263 : DOM_CLASSINFO_MAP_ENTRY(nsIWebSocket)
4264 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4265 305 : DOM_CLASSINFO_MAP_END
4266 :
4267 305 : DOM_CLASSINFO_MAP_BEGIN(CloseEvent, nsIDOMCloseEvent)
4268 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCloseEvent)
4269 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4270 305 : DOM_CLASSINFO_MAP_END
4271 :
4272 305 : DOM_CLASSINFO_MAP_BEGIN(IDBFactory, nsIIDBFactory)
4273 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBFactory)
4274 305 : DOM_CLASSINFO_MAP_END
4275 :
4276 305 : DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
4277 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
4278 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4279 305 : DOM_CLASSINFO_MAP_END
4280 :
4281 305 : DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase)
4282 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase)
4283 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4284 305 : DOM_CLASSINFO_MAP_END
4285 :
4286 305 : DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
4287 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
4288 305 : DOM_CLASSINFO_MAP_END
4289 :
4290 305 : DOM_CLASSINFO_MAP_BEGIN(IDBTransaction, nsIIDBTransaction)
4291 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBTransaction)
4292 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4293 305 : DOM_CLASSINFO_MAP_END
4294 :
4295 305 : DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
4296 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
4297 305 : DOM_CLASSINFO_MAP_END
4298 :
4299 305 : DOM_CLASSINFO_MAP_BEGIN(IDBCursorWithValue, nsIIDBCursorWithValue)
4300 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
4301 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursorWithValue)
4302 305 : DOM_CLASSINFO_MAP_END
4303 :
4304 305 : DOM_CLASSINFO_MAP_BEGIN(IDBKeyRange, nsIIDBKeyRange)
4305 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
4306 305 : DOM_CLASSINFO_MAP_END
4307 :
4308 305 : DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
4309 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
4310 305 : DOM_CLASSINFO_MAP_END
4311 :
4312 305 : DOM_CLASSINFO_MAP_BEGIN(IDBVersionChangeEvent, nsIIDBVersionChangeEvent)
4313 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBVersionChangeEvent)
4314 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
4315 305 : DOM_CLASSINFO_MAP_END
4316 :
4317 305 : DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
4318 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
4319 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
4320 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4321 305 : DOM_CLASSINFO_MAP_END
4322 :
4323 305 : DOM_CLASSINFO_MAP_BEGIN(IDBDatabaseException, nsIIDBDatabaseException)
4324 : DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabaseException)
4325 : DOM_CLASSINFO_MAP_ENTRY(nsIException)
4326 305 : DOM_CLASSINFO_MAP_END
4327 :
4328 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Touch, nsIDOMTouch,
4329 : !nsDOMTouchEvent::PrefEnabled())
4330 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouch)
4331 305 : DOM_CLASSINFO_MAP_END
4332 :
4333 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(TouchList, nsIDOMTouchList,
4334 : !nsDOMTouchEvent::PrefEnabled())
4335 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouchList)
4336 305 : DOM_CLASSINFO_MAP_END
4337 :
4338 305 : DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(TouchEvent, nsIDOMTouchEvent,
4339 : !nsDOMTouchEvent::PrefEnabled())
4340 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTouchEvent)
4341 : DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
4342 305 : DOM_CLASSINFO_MAP_END
4343 :
4344 305 : DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframeRule, nsIDOMMozCSSKeyframeRule)
4345 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframeRule)
4346 305 : DOM_CLASSINFO_MAP_END
4347 :
4348 305 : DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframesRule, nsIDOMMozCSSKeyframesRule)
4349 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
4350 305 : DOM_CLASSINFO_MAP_END
4351 :
4352 305 : DOM_CLASSINFO_MAP_BEGIN(MediaQueryList, nsIDOMMediaQueryList)
4353 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaQueryList)
4354 305 : DOM_CLASSINFO_MAP_END
4355 :
4356 305 : DOM_CLASSINFO_MAP_BEGIN(CustomEvent, nsIDOMCustomEvent)
4357 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCustomEvent)
4358 : DOM_CLASSINFO_EVENT_MAP_ENTRIES
4359 305 : DOM_CLASSINFO_MAP_END
4360 :
4361 : #ifdef MOZ_B2G_RIL
4362 : DOM_CLASSINFO_MAP_BEGIN(Telephony, nsIDOMTelephony)
4363 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephony)
4364 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4365 : DOM_CLASSINFO_MAP_END
4366 :
4367 : DOM_CLASSINFO_MAP_BEGIN(TelephonyCall, nsIDOMTelephonyCall)
4368 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMTelephonyCall)
4369 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4370 : DOM_CLASSINFO_MAP_END
4371 :
4372 : DOM_CLASSINFO_MAP_BEGIN(CallEvent, nsIDOMCallEvent)
4373 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMCallEvent)
4374 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
4375 : DOM_CLASSINFO_MAP_END
4376 : #endif
4377 :
4378 : #ifdef MOZ_B2G_BT
4379 : DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
4380 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
4381 : DOM_CLASSINFO_MAP_END
4382 : #endif
4383 :
4384 305 : DOM_CLASSINFO_MAP_BEGIN(DOMError, nsIDOMDOMError)
4385 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMError)
4386 305 : DOM_CLASSINFO_MAP_END
4387 :
4388 305 : DOM_CLASSINFO_MAP_BEGIN(DOMRequest, nsIDOMDOMRequest)
4389 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMRequest)
4390 : DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4391 305 : DOM_CLASSINFO_MAP_END
4392 :
4393 : #ifdef NS_DEBUG
4394 : {
4395 305 : PRUint32 i = ArrayLength(sClassInfoData);
4396 :
4397 305 : if (i != eDOMClassInfoIDCount) {
4398 : NS_ERROR("The number of items in sClassInfoData doesn't match the "
4399 0 : "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
4400 :
4401 0 : return NS_ERROR_NOT_INITIALIZED;
4402 : }
4403 :
4404 115290 : for (i = 0; i < eDOMClassInfoIDCount; i++) {
4405 114985 : if (!sClassInfoData[i].u.mConstructorFptr ||
4406 : sClassInfoData[i].mDebugID != i) {
4407 : NS_ERROR("Class info data out of sync, you forgot to update "
4408 : "nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
4409 0 : "mozilla will not work without this fixed!");
4410 :
4411 0 : return NS_ERROR_NOT_INITIALIZED;
4412 : }
4413 : }
4414 :
4415 115290 : for (i = 0; i < eDOMClassInfoIDCount; i++) {
4416 114985 : if (!sClassInfoData[i].mInterfaces) {
4417 : NS_ERROR("Class info data without an interface list! Fix this, "
4418 0 : "mozilla will not work without this fixed!");
4419 :
4420 0 : return NS_ERROR_NOT_INITIALIZED;
4421 : }
4422 : }
4423 : }
4424 : #endif
4425 :
4426 : // Initialize static JSString's
4427 305 : DefineStaticJSVals(cx);
4428 :
4429 : PRInt32 i;
4430 :
4431 115290 : for (i = 0; i < eDOMClassInfoIDCount; ++i) {
4432 114985 : RegisterClassName(i);
4433 : }
4434 :
4435 115290 : for (i = 0; i < eDOMClassInfoIDCount; ++i) {
4436 114985 : RegisterClassProtos(i);
4437 : }
4438 :
4439 305 : RegisterExternalClasses();
4440 :
4441 : sDisableDocumentAllSupport =
4442 305 : Preferences::GetBool("browser.dom.document.all.disabled");
4443 :
4444 : sDisableGlobalScopePollutionSupport =
4445 305 : Preferences::GetBool("browser.dom.global_scope_pollution.disabled");
4446 :
4447 305 : mozilla::dom::binding::Register(sClassInfoData);
4448 :
4449 305 : sIsInitialized = true;
4450 :
4451 305 : return NS_OK;
4452 : }
4453 :
4454 : // static
4455 : PRInt32
4456 34 : nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, jsid id, bool *aIsNumber)
4457 : {
4458 34 : if (aIsNumber) {
4459 34 : *aIsNumber = false;
4460 : }
4461 :
4462 : int i;
4463 34 : if (JSID_IS_INT(id)) {
4464 4 : i = JSID_TO_INT(id);
4465 : } else {
4466 60 : JSAutoRequest ar(cx);
4467 :
4468 : jsval idval;
4469 : double array_index;
4470 90 : if (!::JS_IdToValue(cx, id, &idval) ||
4471 30 : !::JS_ValueToNumber(cx, idval, &array_index) ||
4472 30 : !::JS_DoubleIsInt32(array_index, &i)) {
4473 30 : return -1;
4474 : }
4475 : }
4476 :
4477 4 : if (aIsNumber) {
4478 4 : *aIsNumber = true;
4479 : }
4480 :
4481 4 : return i;
4482 : }
4483 :
4484 : NS_IMETHODIMP
4485 2636 : nsDOMClassInfo::GetInterfaces(PRUint32 *aCount, nsIID ***aArray)
4486 : {
4487 2636 : PRUint32 count = 0;
4488 :
4489 15613 : while (mData->mInterfaces[count]) {
4490 10341 : count++;
4491 : }
4492 :
4493 2636 : *aCount = count;
4494 :
4495 2636 : if (!count) {
4496 0 : *aArray = nsnull;
4497 :
4498 0 : return NS_OK;
4499 : }
4500 :
4501 2636 : *aArray = static_cast<nsIID **>(nsMemory::Alloc(count * sizeof(nsIID *)));
4502 2636 : NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY);
4503 :
4504 : PRUint32 i;
4505 12977 : for (i = 0; i < count; i++) {
4506 10341 : nsIID *iid = static_cast<nsIID *>(nsMemory::Clone(mData->mInterfaces[i],
4507 10341 : sizeof(nsIID)));
4508 :
4509 10341 : if (!iid) {
4510 0 : NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, *aArray);
4511 :
4512 0 : return NS_ERROR_OUT_OF_MEMORY;
4513 : }
4514 :
4515 10341 : *((*aArray) + i) = iid;
4516 : }
4517 :
4518 2636 : return NS_OK;
4519 : }
4520 :
4521 : NS_IMETHODIMP
4522 0 : nsDOMClassInfo::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
4523 : {
4524 0 : if (language == nsIProgrammingLanguage::JAVASCRIPT) {
4525 0 : *_retval = static_cast<nsIXPCScriptable *>(this);
4526 :
4527 0 : NS_ADDREF(*_retval);
4528 : } else {
4529 0 : *_retval = nsnull;
4530 : }
4531 :
4532 0 : return NS_OK;
4533 : }
4534 :
4535 : NS_IMETHODIMP
4536 0 : nsDOMClassInfo::GetContractID(char **aContractID)
4537 : {
4538 0 : *aContractID = nsnull;
4539 :
4540 0 : return NS_OK;
4541 : }
4542 :
4543 : NS_IMETHODIMP
4544 0 : nsDOMClassInfo::GetClassDescription(char **aClassDescription)
4545 : {
4546 0 : return GetClassName(aClassDescription);
4547 : }
4548 :
4549 : NS_IMETHODIMP
4550 0 : nsDOMClassInfo::GetClassID(nsCID **aClassID)
4551 : {
4552 0 : *aClassID = nsnull;
4553 0 : return NS_OK;
4554 : }
4555 :
4556 : NS_IMETHODIMP
4557 0 : nsDOMClassInfo::GetClassIDNoAlloc(nsCID *aClassID)
4558 : {
4559 0 : return NS_ERROR_NOT_AVAILABLE;
4560 : }
4561 :
4562 : NS_IMETHODIMP
4563 0 : nsDOMClassInfo::GetImplementationLanguage(PRUint32 *aImplLanguage)
4564 : {
4565 0 : *aImplLanguage = nsIProgrammingLanguage::CPLUSPLUS;
4566 :
4567 0 : return NS_OK;
4568 : }
4569 :
4570 : NS_IMETHODIMP
4571 11800 : nsDOMClassInfo::GetFlags(PRUint32 *aFlags)
4572 : {
4573 11800 : *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
4574 :
4575 11800 : return NS_OK;
4576 : }
4577 :
4578 : // nsIXPCScriptable
4579 :
4580 : NS_IMETHODIMP
4581 2782 : nsDOMClassInfo::GetClassName(char **aClassName)
4582 : {
4583 2782 : *aClassName = NS_strdup(mData->mName);
4584 :
4585 2782 : return NS_OK;
4586 : }
4587 :
4588 : NS_IMETHODIMP
4589 32510 : nsDOMClassInfo::GetScriptableFlags(PRUint32 *aFlags)
4590 : {
4591 32510 : *aFlags = mData->mScriptableFlags;
4592 :
4593 32510 : return NS_OK;
4594 : }
4595 :
4596 : NS_IMETHODIMP
4597 7431 : nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
4598 : JSObject *globalObj, JSObject **parentObj)
4599 : {
4600 7431 : *parentObj = globalObj;
4601 :
4602 14862 : nsCOMPtr<nsPIDOMWindow> piwin = do_QueryWrapper(cx, globalObj);
4603 :
4604 7431 : if (!piwin) {
4605 7431 : return NS_OK;
4606 : }
4607 :
4608 0 : if (piwin->IsOuterWindow()) {
4609 0 : *parentObj = ((nsGlobalWindow *)piwin.get())->
4610 0 : GetCurrentInnerWindowInternal()->GetGlobalJSObject();
4611 : }
4612 :
4613 0 : return NS_OK;
4614 : }
4615 :
4616 : NS_IMETHODIMP
4617 0 : nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
4618 : JSContext *cx, JSObject *obj)
4619 : {
4620 0 : NS_WARNING("nsDOMClassInfo::Create Don't call me!");
4621 :
4622 0 : return NS_ERROR_UNEXPECTED;
4623 : }
4624 :
4625 : NS_IMETHODIMP
4626 0 : nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
4627 : JSContext *cx, JSObject *obj)
4628 : {
4629 0 : NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
4630 :
4631 0 : return NS_ERROR_UNEXPECTED;
4632 : }
4633 :
4634 : NS_IMETHODIMP
4635 0 : nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4636 : JSObject *obj, jsid id, jsval *vp,
4637 : bool *_retval)
4638 : {
4639 0 : NS_WARNING("nsDOMClassInfo::AddProperty Don't call me!");
4640 :
4641 0 : return NS_ERROR_UNEXPECTED;
4642 : }
4643 :
4644 : NS_IMETHODIMP
4645 0 : nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4646 : JSObject *obj, jsid id, jsval *vp,
4647 : bool *_retval)
4648 : {
4649 0 : NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
4650 :
4651 0 : return NS_ERROR_UNEXPECTED;
4652 : }
4653 :
4654 : NS_IMETHODIMP
4655 0 : nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4656 : JSObject *obj, jsid id, jsval *vp,
4657 : bool *_retval)
4658 : {
4659 0 : NS_WARNING("nsDOMClassInfo::GetProperty Don't call me!");
4660 :
4661 0 : return NS_OK;
4662 : }
4663 :
4664 : NS_IMETHODIMP
4665 0 : nsDOMClassInfo::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4666 : JSObject *obj, jsid id, jsval *vp,
4667 : bool *_retval)
4668 : {
4669 0 : NS_WARNING("nsDOMClassInfo::SetProperty Don't call me!");
4670 :
4671 0 : return NS_ERROR_UNEXPECTED;
4672 : }
4673 :
4674 : NS_IMETHODIMP
4675 0 : nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4676 : JSObject *obj, bool *_retval)
4677 : {
4678 : #ifdef DEBUG
4679 0 : if (!sSecMan) {
4680 0 : NS_ERROR("No security manager!!!");
4681 0 : return NS_OK;
4682 : }
4683 :
4684 : // Ask the security manager if it's OK to enumerate
4685 : nsresult rv =
4686 : sSecMan->CheckPropertyAccess(cx, obj, mData->mName, sEnumerate_id,
4687 0 : nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
4688 :
4689 0 : NS_ASSERTION(NS_SUCCEEDED(rv),
4690 : "XOWs should have stopped us from getting here!!!");
4691 : #endif
4692 :
4693 0 : return NS_OK;
4694 : }
4695 :
4696 : NS_IMETHODIMP
4697 0 : nsDOMClassInfo::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
4698 : JSContext *cx, JSObject *obj, PRUint32 enum_op,
4699 : jsval *statep, jsid *idp, bool *_retval)
4700 : {
4701 0 : NS_WARNING("nsDOMClassInfo::NewEnumerate Don't call me!");
4702 :
4703 0 : return NS_ERROR_UNEXPECTED;
4704 : }
4705 :
4706 : nsresult
4707 0 : nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *obj,
4708 : JSObject **objp)
4709 : {
4710 0 : JSObject *global = ::JS_GetGlobalForObject(cx, obj);
4711 :
4712 : jsval val;
4713 0 : JSAutoRequest ar(cx);
4714 0 : if (!::JS_LookupProperty(cx, global, mData->mName, &val)) {
4715 0 : return NS_ERROR_UNEXPECTED;
4716 : }
4717 :
4718 0 : if (!JSVAL_IS_PRIMITIVE(val)) {
4719 : // If val is not an (non-null) object there either is no
4720 : // constructor for this class, or someone messed with
4721 : // window.classname, just fall through and let the JS engine
4722 : // return the Object constructor.
4723 :
4724 0 : if (!::JS_DefinePropertyById(cx, obj, sConstructor_id, val, nsnull, nsnull,
4725 0 : JSPROP_ENUMERATE)) {
4726 0 : return NS_ERROR_UNEXPECTED;
4727 : }
4728 :
4729 0 : *objp = obj;
4730 : }
4731 :
4732 0 : return NS_OK;
4733 : }
4734 :
4735 : NS_IMETHODIMP
4736 20818 : nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4737 : JSObject *obj, jsid id, PRUint32 flags,
4738 : JSObject **objp, bool *_retval)
4739 : {
4740 20818 : if (id == sConstructor_id && !(flags & JSRESOLVE_ASSIGNING)) {
4741 0 : return ResolveConstructor(cx, obj, objp);
4742 : }
4743 :
4744 20818 : return NS_OK;
4745 : }
4746 :
4747 : NS_IMETHODIMP
4748 0 : nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4749 : JSObject *obj, PRUint32 type, jsval *vp,
4750 : bool *_retval)
4751 : {
4752 0 : NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
4753 :
4754 0 : return NS_ERROR_UNEXPECTED;
4755 : }
4756 :
4757 : NS_IMETHODIMP
4758 0 : nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4759 : JSObject *obj)
4760 : {
4761 0 : NS_WARNING("nsDOMClassInfo::Finalize Don't call me!");
4762 :
4763 0 : return NS_ERROR_UNEXPECTED;
4764 : }
4765 :
4766 : NS_IMETHODIMP
4767 0 : nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4768 : JSObject *obj, jsid id, PRUint32 mode,
4769 : jsval *vp, bool *_retval)
4770 : {
4771 0 : PRUint32 mode_type = mode & JSACC_TYPEMASK;
4772 :
4773 0 : if ((mode_type == JSACC_WATCH ||
4774 : mode_type == JSACC_PROTO ||
4775 : mode_type == JSACC_PARENT) &&
4776 : sSecMan) {
4777 :
4778 : nsresult rv;
4779 : JSObject *real_obj;
4780 0 : if (wrapper) {
4781 0 : rv = wrapper->GetJSObject(&real_obj);
4782 0 : NS_ENSURE_SUCCESS(rv, rv);
4783 : }
4784 : else {
4785 0 : real_obj = obj;
4786 : }
4787 :
4788 : rv =
4789 : sSecMan->CheckPropertyAccess(cx, real_obj, mData->mName, id,
4790 0 : nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
4791 :
4792 0 : if (NS_FAILED(rv)) {
4793 : // Let XPConnect know that the access was not granted.
4794 0 : *_retval = false;
4795 : }
4796 : }
4797 :
4798 0 : return NS_OK;
4799 : }
4800 :
4801 : NS_IMETHODIMP
4802 0 : nsDOMClassInfo::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4803 : JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
4804 : bool *_retval)
4805 : {
4806 0 : NS_WARNING("nsDOMClassInfo::Call Don't call me!");
4807 :
4808 0 : return NS_ERROR_UNEXPECTED;
4809 : }
4810 :
4811 : NS_IMETHODIMP
4812 0 : nsDOMClassInfo::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4813 : JSObject *obj, PRUint32 argc, jsval *argv,
4814 : jsval *vp, bool *_retval)
4815 : {
4816 0 : NS_WARNING("nsDOMClassInfo::Construct Don't call me!");
4817 :
4818 0 : return NS_ERROR_UNEXPECTED;
4819 : }
4820 :
4821 : NS_IMETHODIMP
4822 0 : nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4823 : JSObject *obj, const jsval &val, bool *bp,
4824 : bool *_retval)
4825 : {
4826 0 : NS_WARNING("nsDOMClassInfo::HasInstance Don't call me!");
4827 :
4828 0 : return NS_ERROR_UNEXPECTED;
4829 : }
4830 :
4831 : NS_IMETHODIMP
4832 0 : nsDOMClassInfo::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
4833 : JSObject * obj, const jsval &val, bool *bp)
4834 : {
4835 0 : NS_WARNING("nsDOMClassInfo::Equality Don't call me!");
4836 :
4837 0 : return NS_ERROR_UNEXPECTED;
4838 : }
4839 :
4840 : NS_IMETHODIMP
4841 0 : nsDOMClassInfo::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
4842 : JSObject * obj, JSObject * *_retval)
4843 : {
4844 0 : NS_WARNING("nsDOMClassInfo::OuterObject Don't call me!");
4845 :
4846 0 : return NS_ERROR_UNEXPECTED;
4847 : }
4848 :
4849 : static nsresult
4850 0 : GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
4851 : const nsString &aName,
4852 : const nsGlobalNameStruct *aStruct,
4853 : const nsGlobalNameStruct **aResult)
4854 : {
4855 0 : NS_ASSERTION(aStruct->mType ==
4856 : nsGlobalNameStruct::eTypeExternalClassInfoCreator,
4857 : "Wrong type!");
4858 :
4859 : nsresult rv;
4860 0 : nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
4861 0 : NS_ENSURE_SUCCESS(rv, rv);
4862 :
4863 0 : nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
4864 0 : NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
4865 :
4866 0 : rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
4867 0 : NS_ENSURE_SUCCESS(rv, rv);
4868 :
4869 : const nsGlobalNameStruct *name_struct;
4870 0 : rv = aNameSpaceManager->LookupName(aName, &name_struct);
4871 0 : if (NS_SUCCEEDED(rv) && name_struct &&
4872 : name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
4873 0 : *aResult = name_struct;
4874 : }
4875 : else {
4876 0 : NS_ERROR("Couldn't get the DOM ClassInfo data.");
4877 :
4878 0 : *aResult = nsnull;
4879 : }
4880 :
4881 0 : return NS_OK;
4882 : }
4883 :
4884 :
4885 : static nsresult
4886 : ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
4887 : JSObject *obj, const PRUnichar *name,
4888 : const nsDOMClassInfoData *ci_data,
4889 : const nsGlobalNameStruct *name_struct,
4890 : nsScriptNameSpaceManager *nameSpaceManager,
4891 : JSObject *dot_prototype, bool install, bool *did_resolve);
4892 :
4893 :
4894 : NS_IMETHODIMP
4895 2782 : nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
4896 : {
4897 : PRUint32 flags = (mData->mScriptableFlags & DONT_ENUM_STATIC_PROPS)
4898 : ? 0
4899 2782 : : JSPROP_ENUMERATE;
4900 :
4901 2782 : PRUint32 count = 0;
4902 16650 : while (mData->mInterfaces[count]) {
4903 11086 : count++;
4904 : }
4905 :
4906 2782 : if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
4907 2782 : count, mData->mInterfaces)) {
4908 0 : JS_ClearPendingException(cx);
4909 : }
4910 :
4911 : // This is called before any other location that requires
4912 : // sObjectClass, so compute it here. We assume that nobody has had a
4913 : // chance to monkey around with proto's prototype chain before this.
4914 2782 : if (!sObjectClass) {
4915 305 : FindObjectClass(proto);
4916 305 : NS_ASSERTION(sObjectClass && !strcmp(sObjectClass->name, "Object"),
4917 : "Incorrect object class!");
4918 : }
4919 :
4920 2782 : NS_ASSERTION(::JS_GetPrototype(proto) &&
4921 : JS_GetClass(::JS_GetPrototype(proto)) == sObjectClass,
4922 : "Hmm, somebody did something evil?");
4923 :
4924 : #ifdef DEBUG
4925 2782 : if (mData->mHasClassInterface && mData->mProtoChainInterface &&
4926 : mData->mProtoChainInterface != &NS_GET_IID(nsISupports)) {
4927 : nsCOMPtr<nsIInterfaceInfoManager>
4928 4968 : iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
4929 :
4930 2484 : if (iim) {
4931 4968 : nsCOMPtr<nsIInterfaceInfo> if_info;
4932 2484 : iim->GetInfoForIID(mData->mProtoChainInterface,
4933 2484 : getter_AddRefs(if_info));
4934 :
4935 2484 : if (if_info) {
4936 4968 : nsXPIDLCString name;
4937 2484 : if_info->GetName(getter_Copies(name));
4938 2484 : NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
4939 : "Class name and proto chain interface name mismatch!");
4940 : }
4941 : }
4942 : }
4943 : #endif
4944 :
4945 : // Make prototype delegation work correctly. Consider if a site sets
4946 : // HTMLElement.prototype.foopy = function () { ... } Now, calling
4947 : // document.body.foopy() needs to ensure that looking up foopy on
4948 : // document.body's prototype will find the right function.
4949 2782 : JSObject *global = ::JS_GetGlobalForObject(cx, proto);
4950 :
4951 : // Only do this if the global object is a window.
4952 : // XXX Is there a better way to check this?
4953 2782 : nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
4954 5564 : nsCOMPtr<nsPIDOMWindow> piwin = do_QueryInterface(globalNative);
4955 2782 : if (!piwin) {
4956 2782 : return NS_OK;
4957 : }
4958 :
4959 0 : nsGlobalWindow *win = nsGlobalWindow::FromSupports(globalNative);
4960 0 : if (win->IsClosedOrClosing()) {
4961 0 : return NS_OK;
4962 : }
4963 :
4964 : // If the window is in a different compartment than the global object, then
4965 : // it's likely that global is a sandbox object whose prototype is a window.
4966 : // Don't do anything in this case.
4967 0 : if (win->FastGetGlobalJSObject() &&
4968 0 : js::GetObjectCompartment(global) != js::GetObjectCompartment(win->FastGetGlobalJSObject())) {
4969 0 : return NS_OK;
4970 : }
4971 :
4972 0 : if (win->IsOuterWindow()) {
4973 : // XXXjst: Do security checks here when we remove the security
4974 : // checks on the inner window.
4975 :
4976 0 : win = win->GetCurrentInnerWindowInternal();
4977 :
4978 0 : if (!win || !(global = win->GetGlobalJSObject()) ||
4979 0 : win->IsClosedOrClosing()) {
4980 0 : return NS_OK;
4981 : }
4982 : }
4983 :
4984 : // Don't overwrite a property set by content.
4985 : JSBool found;
4986 0 : if (!::JS_AlreadyHasOwnUCProperty(cx, global, reinterpret_cast<const jschar*>(mData->mNameUTF16),
4987 0 : nsCRT::strlen(mData->mNameUTF16), &found)) {
4988 0 : return NS_ERROR_FAILURE;
4989 : }
4990 :
4991 : nsScriptNameSpaceManager *nameSpaceManager =
4992 0 : nsJSRuntime::GetNameSpaceManager();
4993 0 : NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
4994 :
4995 : bool unused;
4996 : return ResolvePrototype(sXPConnect, win, cx, global, mData->mNameUTF16,
4997 : mData, nsnull, nameSpaceManager, proto, !found,
4998 0 : &unused);
4999 : }
5000 :
5001 : // static
5002 : nsIClassInfo *
5003 27591 : NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
5004 : {
5005 27591 : if (aID >= eDOMClassInfoIDCount) {
5006 0 : NS_ERROR("Bad ID!");
5007 :
5008 0 : return nsnull;
5009 : }
5010 :
5011 27591 : if (!nsDOMClassInfo::sIsInitialized) {
5012 305 : nsresult rv = nsDOMClassInfo::Init();
5013 :
5014 305 : NS_ENSURE_SUCCESS(rv, nsnull);
5015 : }
5016 :
5017 27591 : if (!sClassInfoData[aID].mCachedClassInfo) {
5018 1680 : nsDOMClassInfoData& data = sClassInfoData[aID];
5019 :
5020 1680 : data.mCachedClassInfo = data.u.mConstructorFptr(&data);
5021 1680 : NS_ENSURE_TRUE(data.mCachedClassInfo, nsnull);
5022 :
5023 1680 : NS_ADDREF(data.mCachedClassInfo);
5024 : }
5025 :
5026 27591 : NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
5027 : "This is bad, internal class marked as external!");
5028 :
5029 27591 : return sClassInfoData[aID].mCachedClassInfo;
5030 : }
5031 :
5032 : // static
5033 : nsIClassInfo *
5034 0 : nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
5035 : {
5036 0 : NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
5037 : || !aData->mCachedClassInfo,
5038 : "This is bad, external class marked as internal!");
5039 :
5040 0 : if (!aData->mCachedClassInfo) {
5041 0 : if (aData->u.mExternalConstructorFptr) {
5042 : aData->mCachedClassInfo =
5043 0 : aData->u.mExternalConstructorFptr(aData->mName);
5044 : } else {
5045 0 : aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
5046 : }
5047 0 : NS_ENSURE_TRUE(aData->mCachedClassInfo, nsnull);
5048 :
5049 0 : NS_ADDREF(aData->mCachedClassInfo);
5050 0 : aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
5051 : }
5052 :
5053 0 : return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
5054 : }
5055 :
5056 :
5057 : // static
5058 : void
5059 1414 : nsDOMClassInfo::ShutDown()
5060 : {
5061 1414 : if (sClassInfoData[0].u.mConstructorFptr) {
5062 : PRUint32 i;
5063 :
5064 534492 : for (i = 0; i < eDOMClassInfoIDCount; i++) {
5065 533078 : NS_IF_RELEASE(sClassInfoData[i].mCachedClassInfo);
5066 : }
5067 : }
5068 :
5069 1414 : sParent_id = JSID_VOID;
5070 1414 : sScrollbars_id = JSID_VOID;
5071 1414 : sLocation_id = JSID_VOID;
5072 1414 : sConstructor_id = JSID_VOID;
5073 1414 : s_content_id = JSID_VOID;
5074 1414 : sContent_id = JSID_VOID;
5075 1414 : sMenubar_id = JSID_VOID;
5076 1414 : sToolbar_id = JSID_VOID;
5077 1414 : sLocationbar_id = JSID_VOID;
5078 1414 : sPersonalbar_id = JSID_VOID;
5079 1414 : sStatusbar_id = JSID_VOID;
5080 1414 : sDialogArguments_id = JSID_VOID;
5081 1414 : sControllers_id = JSID_VOID;
5082 1414 : sLength_id = JSID_VOID;
5083 1414 : sInnerHeight_id = JSID_VOID;
5084 1414 : sInnerWidth_id = JSID_VOID;
5085 1414 : sOuterHeight_id = JSID_VOID;
5086 1414 : sOuterWidth_id = JSID_VOID;
5087 1414 : sScreenX_id = JSID_VOID;
5088 1414 : sScreenY_id = JSID_VOID;
5089 1414 : sStatus_id = JSID_VOID;
5090 1414 : sName_id = JSID_VOID;
5091 1414 : sScrollX_id = JSID_VOID;
5092 1414 : sScrollY_id = JSID_VOID;
5093 1414 : sScrollMaxX_id = JSID_VOID;
5094 1414 : sScrollMaxY_id = JSID_VOID;
5095 1414 : sItem_id = JSID_VOID;
5096 1414 : sEnumerate_id = JSID_VOID;
5097 1414 : sNavigator_id = JSID_VOID;
5098 1414 : sDocument_id = JSID_VOID;
5099 1414 : sFrames_id = JSID_VOID;
5100 1414 : sSelf_id = JSID_VOID;
5101 1414 : sOpener_id = JSID_VOID;
5102 1414 : sAll_id = JSID_VOID;
5103 1414 : sTags_id = JSID_VOID;
5104 1414 : sAddEventListener_id= JSID_VOID;
5105 1414 : sBaseURIObject_id = JSID_VOID;
5106 1414 : sNodePrincipal_id = JSID_VOID;
5107 1414 : sDocumentURIObject_id=JSID_VOID;
5108 1414 : sJava_id = JSID_VOID;
5109 1414 : sPackages_id = JSID_VOID;
5110 1414 : sWrappedJSObject_id = JSID_VOID;
5111 1414 : sKeyPath_id = JSID_VOID;
5112 1414 : sAutoIncrement_id = JSID_VOID;
5113 1414 : sUnique_id = JSID_VOID;
5114 1414 : sMultiEntry_id = JSID_VOID;
5115 1414 : sOnload_id = JSID_VOID;
5116 1414 : sOnerror_id = JSID_VOID;
5117 :
5118 1414 : NS_IF_RELEASE(sXPConnect);
5119 1414 : NS_IF_RELEASE(sSecMan);
5120 1414 : sIsInitialized = false;
5121 1414 : }
5122 :
5123 : // Window helper
5124 :
5125 : NS_IMETHODIMP
5126 0 : nsWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
5127 : JSObject *globalObj, JSObject **parentObj)
5128 : {
5129 : // Normally ::PreCreate() is used to give XPConnect the parent
5130 : // object for the object that's being wrapped, this parent object is
5131 : // set as the parent of the wrapper and it's also used to find the
5132 : // right scope for the object being wrapped. Now, in the case of the
5133 : // global object the wrapper shouldn't have a parent but we supply
5134 : // one here anyway (the global object itself) and this will be used
5135 : // by XPConnect only to find the right scope, once the scope is
5136 : // found XPConnect will find the existing wrapper (which always
5137 : // exists since it's created on window construction), since an
5138 : // existing wrapper is found the parent we supply here is ignored
5139 : // after the wrapper is found.
5140 :
5141 0 : nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeObj));
5142 0 : NS_ASSERTION(sgo, "nativeObj not a global object!");
5143 :
5144 0 : nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
5145 0 : NS_ASSERTION(win->IsInnerWindow(), "Should be inner window.");
5146 :
5147 0 : JSObject *winObj = win->FastGetGlobalJSObject();
5148 0 : if (!winObj) {
5149 :
5150 : // See bug 691178 comment 11 for why this is necessary.
5151 0 : if (win->IsClosedOrClosing())
5152 0 : return NS_ERROR_FAILURE;
5153 :
5154 0 : NS_ASSERTION(win->GetOuterWindowInternal()->IsCreatingInnerWindow(),
5155 : "should have a JS object by this point");
5156 0 : return NS_OK;
5157 : }
5158 :
5159 0 : *parentObj = winObj;
5160 0 : return NS_OK;
5161 : }
5162 :
5163 : // This JS class piggybacks on nsHTMLDocumentSH::ReleaseDocument()...
5164 :
5165 : static JSClass sGlobalScopePolluterClass = {
5166 : "Global Scope Polluter",
5167 : JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE,
5168 : nsWindowSH::SecurityCheckOnAddDelProp,
5169 : nsWindowSH::SecurityCheckOnAddDelProp,
5170 : nsWindowSH::GlobalScopePolluterGetProperty,
5171 : nsWindowSH::SecurityCheckOnSetProp,
5172 : JS_EnumerateStub,
5173 : (JSResolveOp)nsWindowSH::GlobalScopePolluterNewResolve,
5174 : JS_ConvertStub,
5175 : nsHTMLDocumentSH::ReleaseDocument
5176 : };
5177 :
5178 :
5179 : // static
5180 : JSBool
5181 0 : nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
5182 : jsid id, jsval *vp)
5183 : {
5184 : // Someone is accessing a element by referencing its name/id in the
5185 : // global scope, do a security check to make sure that's ok.
5186 :
5187 : nsresult rv =
5188 : sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
5189 : "Window", id,
5190 0 : nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
5191 :
5192 0 : if (NS_FAILED(rv)) {
5193 : // The security check failed. The security manager set a JS
5194 : // exception for us.
5195 :
5196 0 : return JS_FALSE;
5197 : }
5198 :
5199 : // Print a warning on the console so developers have a chance to
5200 : // catch and fix these mistakes.
5201 0 : PrintWarningOnConsole(cx, "GlobalScopeElementReference");
5202 :
5203 0 : return JS_TRUE;
5204 : }
5205 :
5206 : // static
5207 : JSBool
5208 0 : nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
5209 : jsval *vp)
5210 : {
5211 : // Someone is accessing a element by referencing its name/id in the
5212 : // global scope, do a security check to make sure that's ok.
5213 :
5214 : nsresult rv =
5215 : sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
5216 : "Window", id,
5217 0 : nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
5218 :
5219 : // If !NS_SUCCEEDED(rv) the security check failed. The security
5220 : // manager set a JS exception for us.
5221 0 : return NS_SUCCEEDED(rv);
5222 : }
5223 :
5224 : // static
5225 : JSBool
5226 0 : nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
5227 : jsval *vp)
5228 : {
5229 0 : return SecurityCheckOnAddDelProp(cx, obj, id, vp);
5230 : }
5231 :
5232 : static nsHTMLDocument*
5233 0 : GetDocument(JSObject *obj)
5234 : {
5235 : return static_cast<nsHTMLDocument*>(
5236 0 : static_cast<nsIHTMLDocument*>(::JS_GetPrivate(obj)));
5237 : }
5238 :
5239 : // static
5240 : JSBool
5241 0 : nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
5242 : jsid id, unsigned flags,
5243 : JSObject **objp)
5244 : {
5245 0 : if (flags & (JSRESOLVE_ASSIGNING | JSRESOLVE_DECLARING |
5246 : JSRESOLVE_CLASSNAME | JSRESOLVE_QUALIFIED) ||
5247 0 : !JSID_IS_STRING(id)) {
5248 : // Nothing to do here if we're either assigning or declaring,
5249 : // resolving a class name, doing a qualified resolve, or
5250 : // resolving a number.
5251 :
5252 0 : return JS_TRUE;
5253 : }
5254 :
5255 0 : nsHTMLDocument *document = GetDocument(obj);
5256 :
5257 0 : if (!document ||
5258 0 : document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
5259 : // If we don't have a document, or if the document is not in
5260 : // quirks mode, return early.
5261 :
5262 0 : return JS_TRUE;
5263 : }
5264 :
5265 0 : JSObject *proto = ::JS_GetPrototype(obj);
5266 : JSBool hasProp;
5267 :
5268 0 : if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
5269 : hasProp) {
5270 : // No prototype, or the property exists on the prototype. Do
5271 : // nothing.
5272 :
5273 0 : return JS_TRUE;
5274 : }
5275 :
5276 0 : nsDependentJSString str(id);
5277 0 : nsCOMPtr<nsISupports> result;
5278 : nsWrapperCache *cache;
5279 : {
5280 0 : Element *element = document->GetElementById(str);
5281 0 : result = element;
5282 0 : cache = element;
5283 : }
5284 :
5285 0 : if (!result) {
5286 0 : document->ResolveName(str, nsnull, getter_AddRefs(result), &cache);
5287 : }
5288 :
5289 0 : if (result) {
5290 : jsval v;
5291 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
5292 : nsresult rv = WrapNative(cx, obj, result, cache, true, &v,
5293 0 : getter_AddRefs(holder));
5294 0 : NS_ENSURE_SUCCESS(rv, JS_FALSE);
5295 :
5296 0 : if (!JS_WrapValue(cx, &v) ||
5297 0 : !JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
5298 0 : return JS_FALSE;
5299 : }
5300 :
5301 0 : *objp = obj;
5302 : }
5303 :
5304 0 : return JS_TRUE;
5305 : }
5306 :
5307 : // static
5308 : void
5309 0 : nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj)
5310 : {
5311 : JSObject *proto;
5312 :
5313 0 : JSAutoRequest ar(cx);
5314 :
5315 0 : while ((proto = ::JS_GetPrototype(obj))) {
5316 0 : if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
5317 0 : nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(proto);
5318 :
5319 0 : NS_IF_RELEASE(doc);
5320 :
5321 0 : ::JS_SetPrivate(proto, nsnull);
5322 :
5323 : // Pull the global scope polluter out of the prototype chain so
5324 : // that it can be freed.
5325 0 : ::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(proto));
5326 :
5327 0 : break;
5328 : }
5329 :
5330 0 : obj = proto;
5331 : }
5332 0 : }
5333 :
5334 : // static
5335 : nsresult
5336 0 : nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
5337 : nsIHTMLDocument *doc)
5338 : {
5339 : // If global scope pollution is disabled, or if our document is not
5340 : // a HTML document, do nothing
5341 0 : if (sDisableGlobalScopePollutionSupport || !doc) {
5342 0 : return NS_OK;
5343 : }
5344 :
5345 0 : JSAutoRequest ar(cx);
5346 :
5347 0 : JSObject *gsp = ::JS_NewObjectWithUniqueType(cx, &sGlobalScopePolluterClass, nsnull, obj);
5348 0 : if (!gsp) {
5349 0 : return NS_ERROR_OUT_OF_MEMORY;
5350 : }
5351 :
5352 0 : JSObject *o = obj, *proto;
5353 :
5354 : // Find the place in the prototype chain where we want this global
5355 : // scope polluter (right before Object.prototype).
5356 :
5357 0 : while ((proto = ::JS_GetPrototype(o))) {
5358 0 : if (JS_GetClass(proto) == sObjectClass) {
5359 : // Set the global scope polluters prototype to Object.prototype
5360 0 : ::JS_SplicePrototype(cx, gsp, proto);
5361 :
5362 0 : break;
5363 : }
5364 :
5365 0 : o = proto;
5366 : }
5367 :
5368 : // And then set the prototype of the object whose prototype was
5369 : // Object.prototype to be the global scope polluter.
5370 0 : ::JS_SplicePrototype(cx, o, gsp);
5371 :
5372 0 : ::JS_SetPrivate(gsp, doc);
5373 :
5374 : // The global scope polluter will release doc on destruction (or
5375 : // invalidation).
5376 0 : NS_ADDREF(doc);
5377 :
5378 0 : return NS_OK;
5379 : }
5380 :
5381 : static
5382 : already_AddRefed<nsIDOMWindow>
5383 0 : GetChildFrame(nsGlobalWindow *win, PRUint32 index)
5384 : {
5385 0 : nsCOMPtr<nsIDOMWindowCollection> frames;
5386 0 : win->GetFrames(getter_AddRefs(frames));
5387 :
5388 0 : nsIDOMWindow *frame = nsnull;
5389 :
5390 0 : if (frames) {
5391 0 : frames->Item(index, &frame);
5392 : }
5393 :
5394 0 : return frame;
5395 : }
5396 :
5397 : NS_IMETHODIMP
5398 0 : nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5399 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
5400 : {
5401 0 : nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
5402 :
5403 0 : JSAutoRequest ar(cx);
5404 :
5405 : #ifdef DEBUG_SH_FORWARDING
5406 : {
5407 : JSString *jsstr = ::JS_ValueToString(cx, id);
5408 : if (jsstr) {
5409 : nsDependentJSString str(jsstr);
5410 :
5411 : if (win->IsInnerWindow()) {
5412 : #ifdef DEBUG_PRINT_INNER
5413 : printf("Property '%s' get on inner window %p\n",
5414 : NS_ConvertUTF16toUTF8(str).get(), (void *)win);
5415 : #endif
5416 : } else {
5417 : printf("Property '%s' get on outer window %p\n",
5418 : NS_ConvertUTF16toUTF8(str).get(), (void *)win);
5419 : }
5420 : }
5421 : }
5422 : #endif
5423 :
5424 : // The order in which things are done in this method are a bit
5425 : // whacky, that's because this method is *extremely* performace
5426 : // critical. Don't touch this unless you know what you're doing.
5427 :
5428 0 : if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
5429 : // If we're accessing a numeric property we'll treat that as if
5430 : // window.frames[n] is accessed (since window.frames === window),
5431 : // if window.frames[n] is a child frame, wrap the frame and return
5432 : // it without doing a security check.
5433 0 : PRUint32 index = PRUint32(JSID_TO_INT(id));
5434 0 : nsresult rv = NS_OK;
5435 0 : if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
5436 : // A numeric property accessed and the numeric property is a
5437 : // child frame, wrap the child frame without doing a security
5438 : // check and return.
5439 :
5440 0 : nsGlobalWindow *frameWin = (nsGlobalWindow *)frame.get();
5441 0 : NS_ASSERTION(frameWin->IsOuterWindow(), "GetChildFrame gave us an inner?");
5442 :
5443 0 : frameWin->EnsureInnerWindow();
5444 :
5445 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
5446 : jsval v;
5447 0 : rv = WrapNative(cx, frameWin->GetGlobalJSObject(), frame,
5448 : &NS_GET_IID(nsIDOMWindow), true, &v,
5449 0 : getter_AddRefs(holder));
5450 0 : NS_ENSURE_SUCCESS(rv, rv);
5451 :
5452 0 : if (!JS_WrapValue(cx, &v)) {
5453 0 : return NS_ERROR_FAILURE;
5454 : }
5455 :
5456 0 : *vp = v;
5457 : }
5458 :
5459 0 : return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
5460 : }
5461 :
5462 0 : if (JSID_IS_STRING(id) && !JSVAL_IS_PRIMITIVE(*vp) &&
5463 0 : ::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) {
5464 : // A named property accessed which could have been resolved to a
5465 : // child frame in nsWindowSH::NewResolve() (*vp will tell us if
5466 : // that's the case). If *vp is a window object (i.e. a child
5467 : // frame), return without doing a security check.
5468 : //
5469 : // Calling GetWrappedNativeOfJSObject() is not all that cheap, so
5470 : // only do that if the JSClass name is one that is likely to be a
5471 : // window object.
5472 :
5473 0 : const char *name = JS_GetClass(JSVAL_TO_OBJECT(*vp))->name;
5474 :
5475 : // The list of Window class names here need to be kept in sync
5476 : // with the actual class names! The class name
5477 : // XPCCrossOriginWrapper needs to be handled here too as XOWs
5478 : // define child frame names with a XOW as the value, and thus
5479 : // we'll need to get through here with XOWs class name too.
5480 0 : if ((*name == 'W' && strcmp(name, "Window") == 0) ||
5481 0 : (*name == 'C' && strcmp(name, "ChromeWindow") == 0) ||
5482 0 : (*name == 'M' && strcmp(name, "ModalContentWindow") == 0) ||
5483 : (*name == 'I' &&
5484 0 : (strcmp(name, "InnerWindow") == 0 ||
5485 0 : strcmp(name, "InnerChromeWindow") == 0 ||
5486 0 : strcmp(name, "InnerModalContentWindow") == 0)) ||
5487 0 : (*name == 'X' && strcmp(name, "XPCCrossOriginWrapper") == 0)) {
5488 0 : nsCOMPtr<nsIDOMWindow> window = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
5489 :
5490 0 : if (window) {
5491 : // Yup, *vp is a window object, return early (*vp is already
5492 : // the window, so no need to wrap it again).
5493 :
5494 0 : return NS_SUCCESS_I_DID_SOMETHING;
5495 : }
5496 : }
5497 : }
5498 :
5499 0 : if (id == sWrappedJSObject_id &&
5500 0 : xpc::AccessCheck::isChrome(js::GetContextCompartment(cx))) {
5501 0 : obj = JS_ObjectToOuterObject(cx, obj);
5502 0 : *vp = OBJECT_TO_JSVAL(obj);
5503 0 : return NS_SUCCESS_I_DID_SOMETHING;
5504 : }
5505 :
5506 0 : return NS_OK;
5507 : }
5508 :
5509 : NS_IMETHODIMP
5510 0 : nsWindowSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5511 : JSObject *obj, bool *_retval)
5512 : {
5513 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
5514 0 : *_retval = JS_EnumerateStandardClasses(cx, obj);
5515 : }
5516 :
5517 0 : return NS_OK;
5518 : }
5519 :
5520 : static const char*
5521 0 : FindConstructorContractID(const nsDOMClassInfoData *aDOMClassInfoData)
5522 : {
5523 : PRUint32 i;
5524 0 : for (i = 0; i < ArrayLength(kConstructorMap); ++i) {
5525 0 : if (&sClassInfoData[kConstructorMap[i].mDOMClassInfoID] ==
5526 : aDOMClassInfoData) {
5527 0 : return kConstructorMap[i].mContractID;
5528 : }
5529 : }
5530 0 : return nsnull;
5531 : }
5532 :
5533 : static nsDOMConstructorFunc
5534 0 : FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
5535 : {
5536 0 : for (PRUint32 i = 0; i < ArrayLength(kConstructorFuncMap); ++i) {
5537 0 : if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
5538 : aDOMClassInfoData) {
5539 0 : return kConstructorFuncMap[i].mConstructorFunc;
5540 : }
5541 : }
5542 0 : return nsnull;
5543 : }
5544 :
5545 : static nsresult
5546 0 : BaseStubConstructor(nsIWeakReference* aWeakOwner,
5547 : const nsGlobalNameStruct *name_struct, JSContext *cx,
5548 : JSObject *obj, unsigned argc, jsval *argv, jsval *rval)
5549 : {
5550 : nsresult rv;
5551 0 : nsCOMPtr<nsISupports> native;
5552 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
5553 : const nsDOMClassInfoData* ci_data =
5554 0 : &sClassInfoData[name_struct->mDOMClassInfoID];
5555 0 : const char *contractid = FindConstructorContractID(ci_data);
5556 0 : if (contractid) {
5557 0 : native = do_CreateInstance(contractid, &rv);
5558 : }
5559 : else {
5560 0 : nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
5561 0 : if (func) {
5562 0 : rv = func(getter_AddRefs(native));
5563 : }
5564 : else {
5565 0 : rv = NS_ERROR_NOT_AVAILABLE;
5566 : }
5567 : }
5568 0 : } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
5569 0 : native = do_CreateInstance(name_struct->mCID, &rv);
5570 0 : } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
5571 0 : native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
5572 : } else {
5573 0 : native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
5574 : }
5575 0 : if (NS_FAILED(rv)) {
5576 0 : NS_ERROR("Failed to create the object");
5577 0 : return rv;
5578 : }
5579 :
5580 0 : nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
5581 0 : if (initializer) {
5582 : // Initialize object using the current inner window, but only if
5583 : // the caller can access it.
5584 0 : nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
5585 0 : nsPIDOMWindow* outerWindow = owner ? owner->GetOuterWindow() : nsnull;
5586 : nsPIDOMWindow* currentInner =
5587 0 : outerWindow ? outerWindow->GetCurrentInnerWindow() : nsnull;
5588 0 : if (!currentInner ||
5589 0 : (owner != currentInner &&
5590 0 : !nsContentUtils::CanCallerAccess(currentInner))) {
5591 0 : return NS_ERROR_DOM_SECURITY_ERR;
5592 : }
5593 :
5594 0 : rv = initializer->Initialize(currentInner, cx, obj, argc, argv);
5595 0 : if (NS_FAILED(rv)) {
5596 0 : return rv;
5597 : }
5598 : }
5599 :
5600 0 : nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
5601 0 : if (owner) {
5602 0 : nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
5603 0 : if (!context) {
5604 0 : return NS_ERROR_UNEXPECTED;
5605 : }
5606 :
5607 : JSObject* new_obj;
5608 0 : rv = owner->GetScriptObject(context, (void**)&new_obj);
5609 :
5610 0 : if (NS_SUCCEEDED(rv)) {
5611 0 : *rval = OBJECT_TO_JSVAL(new_obj);
5612 : }
5613 :
5614 0 : return rv;
5615 : }
5616 :
5617 0 : return WrapNative(cx, obj, native, true, rval);
5618 : }
5619 :
5620 : static nsresult
5621 0 : DefineInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
5622 : {
5623 : nsCOMPtr<nsIInterfaceInfoManager>
5624 0 : iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
5625 0 : NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
5626 :
5627 0 : nsCOMPtr<nsIInterfaceInfo> if_info;
5628 :
5629 0 : nsresult rv = iim->GetInfoForIID(aIID, getter_AddRefs(if_info));
5630 0 : NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && if_info, rv);
5631 :
5632 : PRUint16 constant_count;
5633 :
5634 0 : if_info->GetConstantCount(&constant_count);
5635 :
5636 0 : if (!constant_count) {
5637 0 : return NS_OK;
5638 : }
5639 :
5640 0 : nsCOMPtr<nsIInterfaceInfo> parent_if_info;
5641 :
5642 0 : rv = if_info->GetParent(getter_AddRefs(parent_if_info));
5643 0 : NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && parent_if_info, rv);
5644 :
5645 : PRUint16 parent_constant_count, i;
5646 0 : parent_if_info->GetConstantCount(&parent_constant_count);
5647 :
5648 0 : for (i = parent_constant_count; i < constant_count; i++) {
5649 0 : const nsXPTConstant *c = nsnull;
5650 :
5651 0 : rv = if_info->GetConstant(i, &c);
5652 0 : NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && c, rv);
5653 :
5654 0 : PRUint16 type = c->GetType().TagPart();
5655 :
5656 : jsval v;
5657 0 : switch (type) {
5658 : case nsXPTType::T_I8:
5659 : case nsXPTType::T_U8:
5660 : {
5661 0 : v = INT_TO_JSVAL(c->GetValue()->val.u8);
5662 0 : break;
5663 : }
5664 : case nsXPTType::T_I16:
5665 : case nsXPTType::T_U16:
5666 : {
5667 0 : v = INT_TO_JSVAL(c->GetValue()->val.u16);
5668 0 : break;
5669 : }
5670 : case nsXPTType::T_I32:
5671 : {
5672 0 : if (!JS_NewNumberValue(cx, c->GetValue()->val.i32, &v)) {
5673 0 : return NS_ERROR_UNEXPECTED;
5674 : }
5675 0 : break;
5676 : }
5677 : case nsXPTType::T_U32:
5678 : {
5679 0 : if (!JS_NewNumberValue(cx, c->GetValue()->val.u32, &v)) {
5680 0 : return NS_ERROR_UNEXPECTED;
5681 : }
5682 0 : break;
5683 : }
5684 : default:
5685 : {
5686 : #ifdef NS_DEBUG
5687 0 : NS_ERROR("Non-numeric constant found in interface.");
5688 : #endif
5689 0 : continue;
5690 : }
5691 : }
5692 :
5693 0 : if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull,
5694 0 : JSPROP_ENUMERATE)) {
5695 0 : return NS_ERROR_UNEXPECTED;
5696 : }
5697 : }
5698 :
5699 0 : return NS_OK;
5700 : }
5701 :
5702 : // This code is temporary until we remove support for the constants defined
5703 : // on IDBCursor/IDBRequest/IDBTransaction
5704 :
5705 : struct IDBConstant
5706 : {
5707 : const char* interface;
5708 : const char* name;
5709 : const char* value;
5710 :
5711 : static const char* IDBCursor;
5712 : static const char* IDBRequest;
5713 : static const char* IDBTransaction;
5714 : };
5715 :
5716 : const char* IDBConstant::IDBCursor = "IDBCursor";
5717 : const char* IDBConstant::IDBRequest = "IDBRequest";
5718 : const char* IDBConstant::IDBTransaction = "IDBTransaction";
5719 :
5720 : static const IDBConstant sIDBConstants[] = {
5721 : { IDBConstant::IDBCursor, "NEXT", "next" },
5722 : { IDBConstant::IDBCursor, "NEXT_NO_DUPLICATE", "nextunique" },
5723 : { IDBConstant::IDBCursor, "PREV", "prev" },
5724 : { IDBConstant::IDBCursor, "PREV_NO_DUPLICATE", "prevunique" },
5725 : { IDBConstant::IDBRequest, "LOADING", "pending" },
5726 : { IDBConstant::IDBRequest, "DONE", "done" },
5727 : { IDBConstant::IDBTransaction, "READ_ONLY", "readonly" },
5728 : { IDBConstant::IDBTransaction, "READ_WRITE", "readwrite" },
5729 : { IDBConstant::IDBTransaction, "VERSION_CHANGE", "versionchange" },
5730 1396 : };
5731 :
5732 : static JSBool
5733 0 : IDBConstantGetter(JSContext *cx, JSObject *obj, jsid id, jsval* vp)
5734 : {
5735 0 : MOZ_ASSERT(JSID_IS_INT(id));
5736 :
5737 0 : int8_t index = JSID_TO_INT(id);
5738 :
5739 0 : MOZ_ASSERT((uint8_t)index < mozilla::ArrayLength(sIDBConstants));
5740 :
5741 0 : const IDBConstant& c = sIDBConstants[index];
5742 :
5743 : // Put a warning on the console
5744 : nsString warnText =
5745 0 : NS_LITERAL_STRING("The constant ") +
5746 0 : NS_ConvertASCIItoUTF16(c.interface) +
5747 0 : NS_LITERAL_STRING(".") +
5748 0 : NS_ConvertASCIItoUTF16(c.name) +
5749 0 : NS_LITERAL_STRING(" has been deprecated. Use the string value \"") +
5750 0 : NS_ConvertASCIItoUTF16(c.value) +
5751 0 : NS_LITERAL_STRING("\" instead.");
5752 :
5753 0 : PRUint64 windowID = 0;
5754 0 : nsIScriptContext* context = GetScriptContextFromJSContext(cx);
5755 0 : if (context) {
5756 : nsCOMPtr<nsPIDOMWindow> window =
5757 0 : do_QueryInterface(context->GetGlobalObject());
5758 0 : if (window) {
5759 0 : window = window->GetCurrentInnerWindow();
5760 : }
5761 0 : NS_WARN_IF_FALSE(window, "Missing a window, got a door?");
5762 0 : if (window) {
5763 0 : windowID = window->WindowID();
5764 : }
5765 : }
5766 :
5767 : nsCOMPtr<nsIScriptError> errorObject =
5768 0 : do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
5769 0 : NS_WARN_IF_FALSE(errorObject, "Failed to create error object");
5770 0 : if (errorObject) {
5771 0 : nsresult rv = errorObject->InitWithWindowID(warnText.get(),
5772 : nsnull, // file name
5773 : nsnull, // source line
5774 : 0, 0, // Line/col number
5775 : nsIScriptError::warningFlag,
5776 0 : "DOM Core", windowID);
5777 0 : NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init error object");
5778 :
5779 0 : if (NS_SUCCEEDED(rv)) {
5780 : nsCOMPtr<nsIConsoleService> consoleServ =
5781 0 : do_GetService(NS_CONSOLESERVICE_CONTRACTID);
5782 0 : if (consoleServ) {
5783 0 : consoleServ->LogMessage(errorObject);
5784 : }
5785 : }
5786 : }
5787 :
5788 : // Redefine property to remove getter
5789 0 : NS_ConvertASCIItoUTF16 valStr(c.value);
5790 : jsval value;
5791 0 : if (!xpc::StringToJsval(cx, valStr, &value)) {
5792 0 : return JS_FALSE;
5793 : }
5794 0 : if (!::JS_DefineProperty(cx, obj, c.name, value, nsnull, nsnull,
5795 0 : JSPROP_ENUMERATE)) {
5796 0 : return JS_FALSE;
5797 : }
5798 :
5799 : // Return value
5800 0 : *vp = value;
5801 0 : return JS_TRUE;
5802 : }
5803 :
5804 : static nsresult
5805 0 : DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
5806 : {
5807 : const char* interface;
5808 0 : if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
5809 0 : interface = IDBConstant::IDBCursor;
5810 : }
5811 0 : else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
5812 0 : interface = IDBConstant::IDBRequest;
5813 : }
5814 0 : else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
5815 0 : interface = IDBConstant::IDBTransaction;
5816 : }
5817 :
5818 0 : for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
5819 0 : const IDBConstant& c = sIDBConstants[i];
5820 0 : if (c.interface != interface) {
5821 0 : continue;
5822 : }
5823 :
5824 0 : if (!::JS_DefinePropertyWithTinyId(cx, obj, c.name, i, JSVAL_VOID,
5825 : IDBConstantGetter, nsnull,
5826 0 : JSPROP_ENUMERATE)) {
5827 0 : return NS_ERROR_UNEXPECTED;
5828 : }
5829 : }
5830 :
5831 0 : return NS_OK;
5832 : }
5833 :
5834 : class nsDOMConstructor : public nsIDOMDOMConstructor
5835 0 : {
5836 : protected:
5837 0 : nsDOMConstructor(const PRUnichar* aName,
5838 : bool aIsConstructable,
5839 : nsPIDOMWindow* aOwner)
5840 : : mClassName(aName),
5841 : mConstructable(aIsConstructable),
5842 0 : mWeakOwner(do_GetWeakReference(aOwner))
5843 : {
5844 0 : }
5845 :
5846 : public:
5847 :
5848 : static nsresult Create(const PRUnichar* aName,
5849 : const nsDOMClassInfoData* aData,
5850 : const nsGlobalNameStruct* aNameStruct,
5851 : nsPIDOMWindow* aOwner,
5852 : nsDOMConstructor** aResult);
5853 :
5854 : NS_DECL_ISUPPORTS
5855 : NS_DECL_NSIDOMDOMCONSTRUCTOR
5856 :
5857 : nsresult PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj);
5858 :
5859 : nsresult Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5860 : JSObject *obj, PRUint32 argc, jsval *argv,
5861 : jsval *vp, bool *_retval);
5862 :
5863 : nsresult HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5864 : JSObject *obj, const jsval &val, bool *bp,
5865 : bool *_retval);
5866 :
5867 0 : nsresult Install(JSContext *cx, JSObject *target, jsval thisAsVal)
5868 : {
5869 : // The 'attrs' argument used to be JSPROP_PERMANENT. See bug 628612.
5870 0 : JSBool ok = JS_WrapValue(cx, &thisAsVal) &&
5871 : ::JS_DefineUCProperty(cx, target,
5872 : reinterpret_cast<const jschar *>(mClassName),
5873 : nsCRT::strlen(mClassName), thisAsVal, nsnull,
5874 0 : nsnull, 0);
5875 :
5876 0 : return ok ? NS_OK : NS_ERROR_UNEXPECTED;
5877 : }
5878 :
5879 : nsresult ResolveInterfaceConstants(JSContext *cx, JSObject *obj);
5880 :
5881 : private:
5882 0 : const nsGlobalNameStruct *GetNameStruct()
5883 : {
5884 0 : if (!mClassName) {
5885 0 : NS_ERROR("Can't get name");
5886 0 : return nsnull;
5887 : }
5888 :
5889 : const nsGlobalNameStruct *nameStruct;
5890 : #ifdef DEBUG
5891 : nsresult rv =
5892 : #endif
5893 0 : GetNameStruct(nsDependentString(mClassName), &nameStruct);
5894 :
5895 0 : NS_ASSERTION(NS_FAILED(rv) || nameStruct, "Name isn't in hash.");
5896 :
5897 0 : return nameStruct;
5898 : }
5899 :
5900 0 : static nsresult GetNameStruct(const nsAString& aName,
5901 : const nsGlobalNameStruct **aNameStruct)
5902 : {
5903 0 : *aNameStruct = nsnull;
5904 :
5905 : nsScriptNameSpaceManager *nameSpaceManager =
5906 0 : nsJSRuntime::GetNameSpaceManager();
5907 0 : if (!nameSpaceManager) {
5908 0 : NS_ERROR("Can't get namespace manager.");
5909 0 : return NS_ERROR_UNEXPECTED;
5910 : }
5911 :
5912 0 : nameSpaceManager->LookupName(aName, aNameStruct);
5913 :
5914 : // Return NS_OK here, aName just isn't a DOM class but nothing failed.
5915 0 : return NS_OK;
5916 : }
5917 :
5918 0 : static bool IsConstructable(const nsDOMClassInfoData *aData)
5919 : {
5920 0 : if (IS_EXTERNAL(aData->mCachedClassInfo)) {
5921 : const nsExternalDOMClassInfoData* data =
5922 0 : static_cast<const nsExternalDOMClassInfoData*>(aData);
5923 0 : return data->mConstructorCID != nsnull;
5924 : }
5925 :
5926 0 : return FindConstructorContractID(aData) || FindConstructorFunc(aData);
5927 : }
5928 0 : static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
5929 : {
5930 : return
5931 : (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
5932 0 : IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
5933 : (aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
5934 0 : IsConstructable(aNameStruct->mData)) ||
5935 : aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor ||
5936 0 : aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias;
5937 : }
5938 :
5939 : const PRUnichar* mClassName;
5940 : const bool mConstructable;
5941 : nsWeakPtr mWeakOwner;
5942 : };
5943 :
5944 : //static
5945 : nsresult
5946 0 : nsDOMConstructor::Create(const PRUnichar* aName,
5947 : const nsDOMClassInfoData* aData,
5948 : const nsGlobalNameStruct* aNameStruct,
5949 : nsPIDOMWindow* aOwner,
5950 : nsDOMConstructor** aResult)
5951 : {
5952 0 : *aResult = nsnull;
5953 : // Prevent creating a constructor if aOwner is inner window which doesn't have
5954 : // an outer window. If the outer window doesn't have an inner window or the
5955 : // caller can't access the outer window's current inner window then try to use
5956 : // the owner (so long as it is, in fact, an inner window). If that doesn't
5957 : // work then prevent creation also.
5958 0 : nsPIDOMWindow* outerWindow = aOwner->GetOuterWindow();
5959 : nsPIDOMWindow* currentInner =
5960 0 : outerWindow ? outerWindow->GetCurrentInnerWindow() : aOwner;
5961 0 : if (!currentInner ||
5962 : (aOwner != currentInner &&
5963 0 : !nsContentUtils::CanCallerAccess(currentInner) &&
5964 0 : !(currentInner = aOwner)->IsInnerWindow())) {
5965 0 : return NS_ERROR_DOM_SECURITY_ERR;
5966 : }
5967 :
5968 : bool constructable = aNameStruct ?
5969 : IsConstructable(aNameStruct) :
5970 0 : IsConstructable(aData);
5971 :
5972 0 : *aResult = new nsDOMConstructor(aName, constructable, currentInner);
5973 0 : NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
5974 0 : NS_ADDREF(*aResult);
5975 0 : return NS_OK;
5976 : }
5977 :
5978 0 : NS_IMPL_ADDREF(nsDOMConstructor)
5979 0 : NS_IMPL_RELEASE(nsDOMConstructor)
5980 0 : NS_INTERFACE_MAP_BEGIN(nsDOMConstructor)
5981 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMDOMConstructor)
5982 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
5983 0 : if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
5984 : #ifdef DEBUG
5985 : {
5986 0 : const nsGlobalNameStruct *name_struct = GetNameStruct();
5987 0 : NS_ASSERTION(!name_struct ||
5988 : mConstructable == IsConstructable(name_struct),
5989 : "Can't change constructability dynamically!");
5990 : }
5991 : #endif
5992 : foundInterface =
5993 : NS_GetDOMClassInfoInstance(mConstructable ?
5994 : eDOMClassInfo_DOMConstructor_id :
5995 0 : eDOMClassInfo_DOMPrototype_id);
5996 0 : if (!foundInterface) {
5997 0 : *aInstancePtr = nsnull;
5998 0 : return NS_ERROR_OUT_OF_MEMORY;
5999 : }
6000 : } else
6001 0 : NS_INTERFACE_MAP_END
6002 :
6003 : nsresult
6004 0 : nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
6005 : {
6006 0 : nsCOMPtr<nsPIDOMWindow> owner(do_QueryReferent(mWeakOwner));
6007 0 : if (!owner) {
6008 : // Can't do anything.
6009 0 : return NS_OK;
6010 : }
6011 :
6012 0 : nsGlobalWindow *win = static_cast<nsGlobalWindow *>(owner.get());
6013 0 : *parentObj = win->FastGetGlobalJSObject();
6014 0 : return NS_OK;
6015 : }
6016 :
6017 : nsresult
6018 0 : nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
6019 : JSObject * obj, PRUint32 argc, jsval * argv,
6020 : jsval * vp, bool *_retval)
6021 : {
6022 0 : JSObject* class_obj = JSVAL_TO_OBJECT(argv[-2]);
6023 0 : if (!class_obj) {
6024 0 : NS_ERROR("nsDOMConstructor::Construct couldn't get constructor object.");
6025 0 : return NS_ERROR_UNEXPECTED;
6026 : }
6027 :
6028 0 : const nsGlobalNameStruct *name_struct = GetNameStruct();
6029 0 : NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE);
6030 :
6031 0 : if (!IsConstructable(name_struct)) {
6032 : // ignore return value, we return JS_FALSE anyway
6033 0 : return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
6034 : }
6035 :
6036 0 : return BaseStubConstructor(mWeakOwner, name_struct, cx, obj, argc, argv, vp);
6037 : }
6038 :
6039 : nsresult
6040 0 : nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
6041 : JSContext * cx, JSObject * obj,
6042 : const jsval &v, bool *bp, bool *_retval)
6043 :
6044 : {
6045 : // No need to look these up in the hash.
6046 0 : *bp = false;
6047 0 : if (JSVAL_IS_PRIMITIVE(v)) {
6048 0 : return NS_OK;
6049 : }
6050 :
6051 0 : JSObject *dom_obj = JSVAL_TO_OBJECT(v);
6052 0 : NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
6053 :
6054 : // This might not be the right object, if XPCNativeWrapping
6055 : // happened. Get the wrapped native for this object, then get its
6056 : // JS object.
6057 : JSObject *wrapped_obj;
6058 0 : nsresult rv = nsContentUtils::XPConnect()->GetJSObjectOfWrapper(cx, dom_obj,
6059 0 : &wrapped_obj);
6060 0 : if (NS_SUCCEEDED(rv)) {
6061 0 : dom_obj = wrapped_obj;
6062 : }
6063 :
6064 0 : JSClass *dom_class = JS_GetClass(dom_obj);
6065 0 : if (!dom_class) {
6066 0 : NS_ERROR("nsDOMConstructor::HasInstance can't get class.");
6067 0 : return NS_ERROR_UNEXPECTED;
6068 : }
6069 :
6070 : const nsGlobalNameStruct *name_struct;
6071 0 : rv = GetNameStruct(NS_ConvertASCIItoUTF16(dom_class->name), &name_struct);
6072 0 : if (NS_FAILED(rv)) {
6073 0 : return rv;
6074 : }
6075 :
6076 0 : if (!name_struct) {
6077 : // This isn't a normal DOM object, see if this constructor lives on its
6078 : // prototype chain.
6079 : jsval val;
6080 0 : if (!JS_GetProperty(cx, obj, "prototype", &val)) {
6081 0 : return NS_ERROR_UNEXPECTED;
6082 : }
6083 :
6084 0 : JS_ASSERT(!JSVAL_IS_PRIMITIVE(val));
6085 0 : JSObject *dot_prototype = JSVAL_TO_OBJECT(val);
6086 :
6087 0 : JSObject *proto = JS_GetPrototype(dom_obj);
6088 0 : for ( ; proto; proto = JS_GetPrototype(proto)) {
6089 0 : if (proto == dot_prototype) {
6090 0 : *bp = true;
6091 0 : break;
6092 : }
6093 : }
6094 :
6095 0 : return NS_OK;
6096 : }
6097 :
6098 0 : if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
6099 : name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo &&
6100 : name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructorAlias) {
6101 : // Doesn't have DOM interfaces.
6102 0 : return NS_OK;
6103 : }
6104 :
6105 0 : const nsGlobalNameStruct *class_name_struct = GetNameStruct();
6106 0 : NS_ENSURE_TRUE(class_name_struct, NS_ERROR_FAILURE);
6107 :
6108 0 : if (name_struct == class_name_struct) {
6109 0 : *bp = JS_TRUE;
6110 :
6111 0 : return NS_OK;
6112 : }
6113 :
6114 : nsScriptNameSpaceManager *nameSpaceManager =
6115 0 : nsJSRuntime::GetNameSpaceManager();
6116 0 : NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?");
6117 :
6118 : const nsIID *class_iid;
6119 0 : if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
6120 : class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
6121 0 : class_iid = &class_name_struct->mIID;
6122 0 : } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6123 : class_iid =
6124 0 : sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
6125 0 : } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6126 0 : class_iid = class_name_struct->mData->mProtoChainInterface;
6127 0 : } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
6128 : const nsGlobalNameStruct* alias_struct =
6129 0 : nameSpaceManager->GetConstructorProto(class_name_struct);
6130 0 : if (!alias_struct) {
6131 0 : NS_ERROR("Couldn't get constructor prototype.");
6132 0 : return NS_ERROR_UNEXPECTED;
6133 : }
6134 :
6135 0 : if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6136 : class_iid =
6137 0 : sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface;
6138 0 : } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6139 0 : class_iid = alias_struct->mData->mProtoChainInterface;
6140 : } else {
6141 0 : NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo.");
6142 0 : return NS_ERROR_UNEXPECTED;
6143 : }
6144 : } else {
6145 0 : *bp = JS_FALSE;
6146 :
6147 0 : return NS_OK;
6148 : }
6149 :
6150 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
6151 0 : name_struct = nameSpaceManager->GetConstructorProto(name_struct);
6152 0 : if (!name_struct) {
6153 0 : NS_ERROR("Couldn't get constructor prototype.");
6154 0 : return NS_ERROR_UNEXPECTED;
6155 : }
6156 : }
6157 :
6158 0 : NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
6159 : name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
6160 : "The constructor was set up with a struct of the wrong type.");
6161 :
6162 0 : const nsDOMClassInfoData *ci_data = nsnull;
6163 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
6164 : name_struct->mDOMClassInfoID >= 0) {
6165 0 : ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
6166 0 : } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6167 0 : ci_data = name_struct->mData;
6168 : }
6169 :
6170 : nsCOMPtr<nsIInterfaceInfoManager>
6171 0 : iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
6172 0 : if (!iim) {
6173 0 : NS_ERROR("nsDOMConstructor::HasInstance can't get interface info mgr.");
6174 0 : return NS_ERROR_UNEXPECTED;
6175 : }
6176 :
6177 0 : nsCOMPtr<nsIInterfaceInfo> if_info;
6178 0 : PRUint32 count = 0;
6179 : const nsIID* class_interface;
6180 0 : while ((class_interface = ci_data->mInterfaces[count++])) {
6181 0 : if (class_iid->Equals(*class_interface)) {
6182 0 : *bp = JS_TRUE;
6183 :
6184 0 : return NS_OK;
6185 : }
6186 :
6187 0 : iim->GetInfoForIID(class_interface, getter_AddRefs(if_info));
6188 0 : if (!if_info) {
6189 0 : NS_ERROR("nsDOMConstructor::HasInstance can't get interface info.");
6190 0 : return NS_ERROR_UNEXPECTED;
6191 : }
6192 :
6193 0 : if_info->HasAncestor(class_iid, bp);
6194 :
6195 0 : if (*bp) {
6196 0 : return NS_OK;
6197 : }
6198 : }
6199 :
6200 0 : return NS_OK;
6201 : }
6202 :
6203 : nsresult
6204 0 : nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JSObject *obj)
6205 : {
6206 0 : const nsGlobalNameStruct *class_name_struct = GetNameStruct();
6207 0 : if (!class_name_struct)
6208 0 : return NS_ERROR_UNEXPECTED;
6209 :
6210 : const nsIID *class_iid;
6211 0 : if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
6212 : class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
6213 0 : class_iid = &class_name_struct->mIID;
6214 0 : } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6215 : class_iid =
6216 0 : sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
6217 0 : } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6218 0 : class_iid = class_name_struct->mData->mProtoChainInterface;
6219 : } else {
6220 0 : return NS_OK;
6221 : }
6222 :
6223 0 : nsresult rv = DefineInterfaceConstants(cx, obj, class_iid);
6224 0 : NS_ENSURE_SUCCESS(rv, rv);
6225 :
6226 : // Special case for |Event|, Event needs constants from NSEvent
6227 : // too for backwards compatibility.
6228 0 : if (class_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
6229 : rv = DefineInterfaceConstants(cx, obj,
6230 0 : &NS_GET_IID(nsIDOMNSEvent));
6231 0 : NS_ENSURE_SUCCESS(rv, rv);
6232 : }
6233 :
6234 : // Special case for |IDBKeyRange| which gets funny "static" functions.
6235 0 : if (class_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
6236 0 : !indexedDB::IDBKeyRange::DefineConstructors(cx, obj)) {
6237 0 : return NS_ERROR_FAILURE;
6238 : }
6239 :
6240 : // Special case a few IDB interfaces which for now are getting transitional
6241 : // constants.
6242 0 : if (class_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
6243 0 : class_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
6244 0 : class_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
6245 0 : rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
6246 0 : NS_ENSURE_SUCCESS(rv, rv);
6247 : }
6248 :
6249 0 : return NS_OK;
6250 : }
6251 :
6252 : NS_IMETHODIMP
6253 0 : nsDOMConstructor::ToString(nsAString &aResult)
6254 : {
6255 0 : aResult.AssignLiteral("[object ");
6256 0 : aResult.Append(mClassName);
6257 0 : aResult.Append(PRUnichar(']'));
6258 :
6259 0 : return NS_OK;
6260 : }
6261 :
6262 :
6263 : static nsresult
6264 0 : GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
6265 : const nsGlobalNameStruct *aNameStruct,
6266 : nsIXPConnectJSObjectHolder **aProto)
6267 : {
6268 0 : NS_ASSERTION(aNameStruct->mType ==
6269 : nsGlobalNameStruct::eTypeClassConstructor ||
6270 : aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
6271 : "Wrong type!");
6272 :
6273 0 : nsCOMPtr<nsIClassInfo> ci;
6274 0 : if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6275 0 : PRInt32 id = aNameStruct->mDOMClassInfoID;
6276 0 : NS_ABORT_IF_FALSE(id >= 0, "Negative DOM classinfo?!?");
6277 :
6278 0 : nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
6279 :
6280 0 : ci = NS_GetDOMClassInfoInstance(ci_id);
6281 :
6282 : // In most cases we want to find the wrapped native prototype in
6283 : // aWin's scope and use that prototype for
6284 : // ClassName.prototype. But in the case where we're setting up
6285 : // "Window.prototype" or "ChromeWindow.prototype" we want to do
6286 : // the look up in aWin's outer window's scope since the inner
6287 : // window's wrapped native prototype comes from the outer
6288 : // window's scope.
6289 0 : if (ci_id == eDOMClassInfo_Window_id ||
6290 : ci_id == eDOMClassInfo_ModalContentWindow_id ||
6291 : ci_id == eDOMClassInfo_ChromeWindow_id) {
6292 0 : nsGlobalWindow *scopeWindow = aWin->GetOuterWindowInternal();
6293 :
6294 0 : if (scopeWindow) {
6295 0 : aWin = scopeWindow;
6296 : }
6297 : }
6298 : }
6299 : else {
6300 0 : ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
6301 : }
6302 0 : NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
6303 :
6304 : nsresult rv =
6305 0 : aXPConnect->GetWrappedNativePrototype(cx, aWin->GetGlobalJSObject(), ci,
6306 0 : aProto);
6307 0 : NS_ENSURE_SUCCESS(rv, rv);
6308 :
6309 : JSObject *proto_obj;
6310 0 : (*aProto)->GetJSObject(&proto_obj);
6311 0 : if (!JS_WrapObject(cx, &proto_obj)) {
6312 0 : return NS_ERROR_FAILURE;
6313 : }
6314 :
6315 0 : NS_IF_RELEASE(*aProto);
6316 0 : return aXPConnect->HoldObject(cx, proto_obj, aProto);
6317 : }
6318 :
6319 : // Either ci_data must be non-null or name_struct must be non-null and of type
6320 : // eTypeClassProto.
6321 : static nsresult
6322 0 : ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
6323 : JSObject *obj, const PRUnichar *name,
6324 : const nsDOMClassInfoData *ci_data,
6325 : const nsGlobalNameStruct *name_struct,
6326 : nsScriptNameSpaceManager *nameSpaceManager,
6327 : JSObject *dot_prototype, bool install, bool *did_resolve)
6328 : {
6329 0 : NS_ASSERTION(ci_data ||
6330 : (name_struct &&
6331 : name_struct->mType == nsGlobalNameStruct::eTypeClassProto),
6332 : "Wrong type or missing ci_data!");
6333 :
6334 0 : nsRefPtr<nsDOMConstructor> constructor;
6335 : nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin,
6336 0 : getter_AddRefs(constructor));
6337 0 : NS_ENSURE_SUCCESS(rv, rv);
6338 :
6339 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6340 : jsval v;
6341 :
6342 : rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
6343 0 : false, &v, getter_AddRefs(holder));
6344 0 : NS_ENSURE_SUCCESS(rv, rv);
6345 :
6346 0 : if (install) {
6347 0 : rv = constructor->Install(cx, obj, v);
6348 0 : NS_ENSURE_SUCCESS(rv, rv);
6349 : }
6350 :
6351 : JSObject *class_obj;
6352 0 : holder->GetJSObject(&class_obj);
6353 0 : NS_ASSERTION(class_obj, "The return value lied");
6354 :
6355 0 : const nsIID *primary_iid = &NS_GET_IID(nsISupports);
6356 :
6357 0 : if (!ci_data) {
6358 0 : primary_iid = &name_struct->mIID;
6359 : }
6360 0 : else if (ci_data->mProtoChainInterface) {
6361 0 : primary_iid = ci_data->mProtoChainInterface;
6362 : }
6363 :
6364 0 : nsCOMPtr<nsIInterfaceInfo> if_info;
6365 0 : nsCOMPtr<nsIInterfaceInfo> parent;
6366 0 : const char *class_parent_name = nsnull;
6367 :
6368 0 : if (!primary_iid->Equals(NS_GET_IID(nsISupports))) {
6369 0 : JSAutoEnterCompartment ac;
6370 :
6371 0 : if (!ac.enter(cx, class_obj)) {
6372 0 : return NS_ERROR_FAILURE;
6373 : }
6374 :
6375 0 : rv = DefineInterfaceConstants(cx, class_obj, primary_iid);
6376 0 : NS_ENSURE_SUCCESS(rv, rv);
6377 :
6378 : // Special case for |Event|, Event needs constants from NSEvent
6379 : // too for backwards compatibility.
6380 0 : if (primary_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
6381 : rv = DefineInterfaceConstants(cx, class_obj,
6382 0 : &NS_GET_IID(nsIDOMNSEvent));
6383 0 : NS_ENSURE_SUCCESS(rv, rv);
6384 : }
6385 :
6386 : // Special case for |IDBKeyRange| which gets funny "static" functions.
6387 0 : if (primary_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
6388 0 : !indexedDB::IDBKeyRange::DefineConstructors(cx, class_obj)) {
6389 0 : return NS_ERROR_FAILURE;
6390 : }
6391 :
6392 : // Special case a few IDB interfaces which for now are getting transitional
6393 : // constants.
6394 0 : if (primary_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
6395 0 : primary_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
6396 0 : primary_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
6397 0 : rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
6398 0 : NS_ENSURE_SUCCESS(rv, rv);
6399 : }
6400 :
6401 : nsCOMPtr<nsIInterfaceInfoManager>
6402 0 : iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
6403 0 : NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
6404 :
6405 0 : iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
6406 0 : NS_ENSURE_TRUE(if_info, NS_ERROR_UNEXPECTED);
6407 :
6408 0 : const nsIID *iid = nsnull;
6409 :
6410 0 : if (ci_data && !ci_data->mHasClassInterface) {
6411 0 : if_info->GetIIDShared(&iid);
6412 : } else {
6413 0 : if_info->GetParent(getter_AddRefs(parent));
6414 0 : NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
6415 :
6416 0 : parent->GetIIDShared(&iid);
6417 : }
6418 :
6419 0 : if (iid) {
6420 0 : if (!iid->Equals(NS_GET_IID(nsISupports))) {
6421 0 : if (ci_data && !ci_data->mHasClassInterface) {
6422 : // If the class doesn't have a class interface the primary
6423 : // interface is the interface that should be
6424 : // constructor.prototype.__proto__.
6425 :
6426 0 : if_info->GetNameShared(&class_parent_name);
6427 : } else {
6428 : // If the class does have a class interface (or there's no
6429 : // real class for this name) then the parent of the
6430 : // primary interface is what we want on
6431 : // constructor.prototype.__proto__.
6432 :
6433 0 : NS_ASSERTION(parent, "Whoa, this is bad, null parent here!");
6434 :
6435 0 : parent->GetNameShared(&class_parent_name);
6436 : }
6437 : }
6438 : }
6439 : }
6440 :
6441 : {
6442 0 : JSObject *winobj = aWin->FastGetGlobalJSObject();
6443 :
6444 0 : JSObject *proto = nsnull;
6445 :
6446 0 : if (class_parent_name) {
6447 : jsval val;
6448 :
6449 0 : JSAutoEnterCompartment ac;
6450 0 : if (!ac.enter(cx, winobj)) {
6451 0 : return NS_ERROR_UNEXPECTED;
6452 : }
6453 :
6454 0 : if (!::JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
6455 0 : return NS_ERROR_UNEXPECTED;
6456 : }
6457 :
6458 0 : JSObject *tmp = JSVAL_IS_OBJECT(val) ? JSVAL_TO_OBJECT(val) : nsnull;
6459 :
6460 0 : if (tmp) {
6461 0 : if (!::JS_LookupProperty(cx, tmp, "prototype", &val)) {
6462 0 : return NS_ERROR_UNEXPECTED;
6463 : }
6464 :
6465 0 : if (JSVAL_IS_OBJECT(val)) {
6466 0 : proto = JSVAL_TO_OBJECT(val);
6467 : }
6468 : }
6469 : }
6470 :
6471 0 : if (dot_prototype) {
6472 0 : JSAutoEnterCompartment ac;
6473 0 : if (!ac.enter(cx, dot_prototype)) {
6474 0 : return NS_ERROR_UNEXPECTED;
6475 : }
6476 :
6477 0 : JSObject *xpc_proto_proto = ::JS_GetPrototype(dot_prototype);
6478 :
6479 0 : if (proto &&
6480 : (!xpc_proto_proto ||
6481 0 : JS_GetClass(xpc_proto_proto) == sObjectClass)) {
6482 0 : if (!JS_WrapObject(cx, &proto) ||
6483 0 : !JS_SetPrototype(cx, dot_prototype, proto)) {
6484 0 : return NS_ERROR_UNEXPECTED;
6485 : }
6486 : }
6487 : } else {
6488 0 : JSAutoEnterCompartment ac;
6489 0 : if (!ac.enter(cx, winobj)) {
6490 0 : return NS_ERROR_UNEXPECTED;
6491 : }
6492 :
6493 : dot_prototype = ::JS_NewObject(cx, &sDOMConstructorProtoClass, proto,
6494 0 : winobj);
6495 0 : NS_ENSURE_TRUE(dot_prototype, NS_ERROR_OUT_OF_MEMORY);
6496 : }
6497 : }
6498 :
6499 0 : v = OBJECT_TO_JSVAL(dot_prototype);
6500 :
6501 0 : JSAutoEnterCompartment ac;
6502 0 : if (!ac.enter(cx, class_obj)) {
6503 0 : return NS_ERROR_UNEXPECTED;
6504 : }
6505 :
6506 : // Per ECMA, the prototype property is {DontEnum, DontDelete, ReadOnly}
6507 0 : if (!JS_WrapValue(cx, &v) ||
6508 : !JS_DefineProperty(cx, class_obj, "prototype", v, nsnull, nsnull,
6509 0 : JSPROP_PERMANENT | JSPROP_READONLY)) {
6510 0 : return NS_ERROR_UNEXPECTED;
6511 : }
6512 :
6513 0 : *did_resolve = true;
6514 :
6515 0 : return NS_OK;
6516 : }
6517 :
6518 :
6519 : // static
6520 : nsresult
6521 0 : nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
6522 : JSObject *obj, jsid id, bool *did_resolve)
6523 : {
6524 0 : *did_resolve = false;
6525 :
6526 : nsScriptNameSpaceManager *nameSpaceManager =
6527 0 : nsJSRuntime::GetNameSpaceManager();
6528 0 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
6529 :
6530 0 : nsDependentJSString name(id);
6531 :
6532 0 : const nsGlobalNameStruct *name_struct = nsnull;
6533 0 : const PRUnichar *class_name = nsnull;
6534 :
6535 0 : nameSpaceManager->LookupName(name, &name_struct, &class_name);
6536 :
6537 0 : if (!name_struct) {
6538 0 : return NS_OK;
6539 : }
6540 :
6541 0 : NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
6542 :
6543 0 : nsresult rv = NS_OK;
6544 :
6545 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
6546 : rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
6547 0 : &name_struct);
6548 0 : if (NS_FAILED(rv) || !name_struct) {
6549 0 : return rv;
6550 : }
6551 : }
6552 :
6553 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
6554 : // We're resolving a name of a DOM interface for which there is no
6555 : // direct DOM class, create a constructor object...
6556 :
6557 0 : nsRefPtr<nsDOMConstructor> constructor;
6558 : rv = nsDOMConstructor::Create(class_name,
6559 : nsnull,
6560 : name_struct,
6561 : static_cast<nsPIDOMWindow*>(aWin),
6562 0 : getter_AddRefs(constructor));
6563 0 : NS_ENSURE_SUCCESS(rv, rv);
6564 :
6565 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6566 : jsval v;
6567 : rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
6568 0 : false, &v, getter_AddRefs(holder));
6569 0 : NS_ENSURE_SUCCESS(rv, rv);
6570 :
6571 0 : rv = constructor->Install(cx, obj, v);
6572 0 : NS_ENSURE_SUCCESS(rv, rv);
6573 :
6574 : JSObject *class_obj;
6575 0 : holder->GetJSObject(&class_obj);
6576 0 : NS_ASSERTION(class_obj, "The return value lied");
6577 :
6578 : // ... and define the constants from the DOM interface on that
6579 : // constructor object.
6580 :
6581 0 : rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
6582 0 : NS_ENSURE_SUCCESS(rv, rv);
6583 :
6584 0 : *did_resolve = true;
6585 :
6586 0 : return NS_OK;
6587 : }
6588 :
6589 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
6590 : name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6591 : // Don't expose chrome only constructors to content windows.
6592 0 : if (name_struct->mChromeOnly &&
6593 0 : !nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal())) {
6594 0 : return NS_OK;
6595 : }
6596 :
6597 : // For now don't expose web sockets unless user has explicitly enabled them
6598 0 : if (name_struct->mDOMClassInfoID == eDOMClassInfo_WebSocket_id) {
6599 0 : if (!nsWebSocket::PrefEnabled()) {
6600 0 : return NS_OK;
6601 : }
6602 : }
6603 :
6604 : // For now don't expose server events unless user has explicitly enabled them
6605 0 : if (name_struct->mDOMClassInfoID == eDOMClassInfo_EventSource_id) {
6606 0 : if (!nsEventSource::PrefEnabled()) {
6607 0 : return NS_OK;
6608 : }
6609 : }
6610 :
6611 : // Lookup new DOM bindings.
6612 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6613 : mozilla::dom::binding::DefineInterface define =
6614 0 : sClassInfoData[name_struct->mDOMClassInfoID].mDefineDOMInterface;
6615 0 : if (define && mozilla::dom::binding::DefineConstructor(cx, obj, define, &rv)) {
6616 0 : *did_resolve = NS_SUCCEEDED(rv);
6617 :
6618 0 : return rv;
6619 : }
6620 : }
6621 :
6622 : // Create the XPConnect prototype for our classinfo, PostCreateProto will
6623 : // set up the prototype chain.
6624 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
6625 : rv = GetXPCProto(sXPConnect, cx, aWin, name_struct,
6626 0 : getter_AddRefs(proto_holder));
6627 :
6628 0 : if (NS_SUCCEEDED(rv) && obj != aWin->GetGlobalJSObject()) {
6629 : JSObject* dot_prototype;
6630 0 : rv = proto_holder->GetJSObject(&dot_prototype);
6631 0 : NS_ENSURE_SUCCESS(rv, rv);
6632 :
6633 : const nsDOMClassInfoData *ci_data;
6634 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6635 0 : ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
6636 : } else {
6637 0 : ci_data = name_struct->mData;
6638 : }
6639 :
6640 : return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
6641 : name_struct, nameSpaceManager, dot_prototype,
6642 0 : true, did_resolve);
6643 : }
6644 :
6645 0 : *did_resolve = NS_SUCCEEDED(rv);
6646 :
6647 0 : return rv;
6648 : }
6649 :
6650 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
6651 : // We don't have a XPConnect prototype object, let ResolvePrototype create
6652 : // one.
6653 : return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, nsnull,
6654 : name_struct, nameSpaceManager, nsnull, true,
6655 0 : did_resolve);
6656 : }
6657 :
6658 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
6659 : const nsGlobalNameStruct *alias_struct =
6660 0 : nameSpaceManager->GetConstructorProto(name_struct);
6661 0 : NS_ENSURE_TRUE(alias_struct, NS_ERROR_UNEXPECTED);
6662 :
6663 : // We need to use the XPConnect prototype for the DOM class that this
6664 : // constructor is an alias for (for example for Image we need the prototype
6665 : // for HTMLImageElement).
6666 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
6667 : rv = GetXPCProto(sXPConnect, cx, aWin, alias_struct,
6668 0 : getter_AddRefs(proto_holder));
6669 0 : NS_ENSURE_SUCCESS(rv, rv);
6670 :
6671 : JSObject* dot_prototype;
6672 0 : rv = proto_holder->GetJSObject(&dot_prototype);
6673 0 : NS_ENSURE_SUCCESS(rv, rv);
6674 :
6675 : const nsDOMClassInfoData *ci_data;
6676 0 : if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6677 0 : ci_data = &sClassInfoData[alias_struct->mDOMClassInfoID];
6678 0 : } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6679 0 : ci_data = alias_struct->mData;
6680 : } else {
6681 0 : return NS_ERROR_UNEXPECTED;
6682 : }
6683 :
6684 : return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
6685 : name_struct, nameSpaceManager, nsnull, true,
6686 0 : did_resolve);
6687 : }
6688 :
6689 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
6690 0 : nsRefPtr<nsDOMConstructor> constructor;
6691 : rv = nsDOMConstructor::Create(class_name, nsnull, name_struct,
6692 : static_cast<nsPIDOMWindow*>(aWin),
6693 0 : getter_AddRefs(constructor));
6694 0 : NS_ENSURE_SUCCESS(rv, rv);
6695 :
6696 : jsval val;
6697 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6698 : rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
6699 0 : false, &val, getter_AddRefs(holder));
6700 0 : NS_ENSURE_SUCCESS(rv, rv);
6701 :
6702 0 : rv = constructor->Install(cx, obj, val);
6703 0 : NS_ENSURE_SUCCESS(rv, rv);
6704 :
6705 : JSObject* class_obj;
6706 0 : holder->GetJSObject(&class_obj);
6707 0 : NS_ASSERTION(class_obj, "Why didn't we get a JSObject?");
6708 :
6709 0 : *did_resolve = true;
6710 :
6711 0 : return NS_OK;
6712 : }
6713 :
6714 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) {
6715 0 : if (name_struct->mChromeOnly && !nsContentUtils::IsCallerChrome())
6716 0 : return NS_OK;
6717 :
6718 0 : nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
6719 0 : NS_ENSURE_SUCCESS(rv, rv);
6720 :
6721 0 : jsval prop_val = JSVAL_VOID; // Property value.
6722 :
6723 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6724 0 : nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
6725 0 : if (owner) {
6726 0 : nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
6727 0 : NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
6728 :
6729 0 : JSObject *prop_obj = nsnull;
6730 0 : rv = owner->GetScriptObject(context, (void**)&prop_obj);
6731 0 : NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && prop_obj, NS_ERROR_UNEXPECTED);
6732 :
6733 0 : prop_val = OBJECT_TO_JSVAL(prop_obj);
6734 : } else {
6735 0 : nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
6736 :
6737 0 : if (gpi) {
6738 0 : rv = gpi->Init(aWin, &prop_val);
6739 0 : NS_ENSURE_SUCCESS(rv, rv);
6740 : }
6741 : }
6742 :
6743 0 : if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
6744 : JSObject *scope;
6745 :
6746 0 : if (aWin->IsOuterWindow()) {
6747 0 : nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
6748 0 : NS_ENSURE_TRUE(inner, NS_ERROR_UNEXPECTED);
6749 :
6750 0 : scope = inner->GetGlobalJSObject();
6751 : } else {
6752 0 : scope = aWin->GetGlobalJSObject();
6753 : }
6754 :
6755 : rv = WrapNative(cx, scope, native, true, &prop_val,
6756 0 : getter_AddRefs(holder));
6757 : }
6758 :
6759 0 : NS_ENSURE_SUCCESS(rv, rv);
6760 :
6761 0 : if (!JS_WrapValue(cx, &prop_val)) {
6762 0 : return NS_ERROR_UNEXPECTED;
6763 : }
6764 :
6765 : JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
6766 0 : JSPROP_ENUMERATE);
6767 :
6768 0 : *did_resolve = true;
6769 :
6770 0 : return ok ? NS_OK : NS_ERROR_FAILURE;
6771 : }
6772 :
6773 0 : if (name_struct->mType == nsGlobalNameStruct::eTypeDynamicNameSet) {
6774 : nsCOMPtr<nsIScriptExternalNameSet> nameset =
6775 0 : do_CreateInstance(name_struct->mCID, &rv);
6776 0 : NS_ENSURE_SUCCESS(rv, rv);
6777 :
6778 0 : nsIScriptContext *context = aWin->GetContext();
6779 0 : NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
6780 :
6781 0 : rv = nameset->InitializeNameSet(context);
6782 :
6783 0 : *did_resolve = true;
6784 : }
6785 :
6786 0 : return rv;
6787 : }
6788 :
6789 : // Native code for window._content getter, this simply maps
6790 : // window._content to window.content for backwards compatibility only.
6791 : static JSBool
6792 0 : ContentWindowGetter(JSContext *cx, unsigned argc, jsval *vp)
6793 : {
6794 0 : JSObject *obj = JS_THIS_OBJECT(cx, vp);
6795 0 : if (!obj)
6796 0 : return JS_FALSE;
6797 :
6798 0 : return ::JS_GetProperty(cx, obj, "content", vp);
6799 : }
6800 :
6801 : static JSNewResolveOp sOtherResolveFuncs[] = {
6802 : mozilla::dom::workers::ResolveWorkerClasses
6803 : };
6804 :
6805 : template<class Interface>
6806 : static nsresult
6807 0 : LocationSetterGuts(JSContext *cx, JSObject *obj, jsval *vp)
6808 : {
6809 : // This function duplicates some of the logic in XPC_WN_HelperSetProperty
6810 : XPCWrappedNative *wrapper =
6811 0 : XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
6812 :
6813 : // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
6814 0 : NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
6815 :
6816 0 : nsCOMPtr<Interface> xpcomObj = do_QueryWrappedNative(wrapper, obj);
6817 0 : NS_ENSURE_TRUE(xpcomObj, NS_ERROR_UNEXPECTED);
6818 :
6819 0 : nsCOMPtr<nsIDOMLocation> location;
6820 0 : nsresult rv = xpcomObj->GetLocation(getter_AddRefs(location));
6821 0 : NS_ENSURE_SUCCESS(rv, rv);
6822 :
6823 : // Grab the value we're being set to before we stomp on |vp|
6824 0 : JSString *val = ::JS_ValueToString(cx, *vp);
6825 0 : NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
6826 :
6827 : // Make sure |val| stays alive below
6828 0 : JS::Anchor<JSString *> anchor(val);
6829 :
6830 : // We have to wrap location into vp before null-checking location, to
6831 : // avoid assigning the wrong thing into the slot.
6832 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6833 0 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
6834 : &NS_GET_IID(nsIDOMLocation), true, vp,
6835 : getter_AddRefs(holder));
6836 0 : NS_ENSURE_SUCCESS(rv, rv);
6837 :
6838 0 : if (!location) {
6839 : // Make this a no-op
6840 0 : return NS_OK;
6841 : }
6842 :
6843 0 : nsDependentJSString depStr;
6844 0 : NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
6845 :
6846 0 : return location->SetHref(depStr);
6847 : }
6848 :
6849 : template<class Interface>
6850 : static JSBool
6851 0 : LocationSetter(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
6852 : jsval *vp)
6853 : {
6854 0 : nsresult rv = LocationSetterGuts<Interface>(cx, obj, vp);
6855 0 : if (NS_FAILED(rv)) {
6856 0 : if (!::JS_IsExceptionPending(cx)) {
6857 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
6858 : }
6859 0 : return JS_FALSE;
6860 : }
6861 :
6862 0 : return JS_TRUE;
6863 : }
6864 :
6865 : static JSBool
6866 0 : LocationSetterUnwrapper(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
6867 : jsval *vp)
6868 : {
6869 0 : JSObject *wrapped = XPCWrapper::UnsafeUnwrapSecurityWrapper(obj);
6870 0 : if (wrapped) {
6871 0 : obj = wrapped;
6872 : }
6873 :
6874 0 : return LocationSetter<nsIDOMWindow>(cx, obj, id, strict, vp);
6875 : }
6876 :
6877 : NS_IMETHODIMP
6878 0 : nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
6879 : JSObject *obj, jsid id, PRUint32 flags,
6880 : JSObject **objp, bool *_retval)
6881 : {
6882 0 : nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
6883 :
6884 0 : if (!JSID_IS_STRING(id)) {
6885 0 : if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0 && !(flags & JSRESOLVE_ASSIGNING)) {
6886 : // If we're resolving a numeric property, treat that as if
6887 : // window.frames[n] is resolved (since window.frames ===
6888 : // window), if window.frames[n] is a child frame, define a
6889 : // property for this index.
6890 0 : PRUint32 index = PRUint32(JSID_TO_INT(id));
6891 0 : if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
6892 : // A numeric property accessed and the numeric property is a
6893 : // child frame. Define a property for this index.
6894 :
6895 : *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID,
6896 0 : nsnull, nsnull, JSPROP_SHARED);
6897 :
6898 0 : if (*_retval) {
6899 0 : *objp = obj;
6900 : }
6901 : }
6902 : }
6903 :
6904 0 : return NS_OK;
6905 : }
6906 :
6907 0 : nsIScriptContext *my_context = win->GetContextInternal();
6908 :
6909 0 : nsresult rv = NS_OK;
6910 :
6911 : // Resolve standard classes on my_context's JSContext (or on cx,
6912 : // if we don't have a my_context yet), in case the two contexts
6913 : // have different origins. We want lazy standard class
6914 : // initialization to behave as if it were done eagerly, on each
6915 : // window's own context (not on some other window-caller's
6916 : // context).
6917 :
6918 0 : JSBool did_resolve = JS_FALSE;
6919 : JSContext *my_cx;
6920 :
6921 0 : JSBool ok = JS_TRUE;
6922 0 : jsval exn = JSVAL_VOID;
6923 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
6924 0 : JSAutoEnterCompartment ac;
6925 :
6926 0 : if (!my_context) {
6927 0 : my_cx = cx;
6928 : } else {
6929 0 : my_cx = my_context->GetNativeContext();
6930 :
6931 0 : if (my_cx != cx) {
6932 0 : if (!ac.enter(my_cx, obj)) {
6933 0 : return NS_ERROR_UNEXPECTED;
6934 : }
6935 : }
6936 : }
6937 :
6938 0 : JSAutoRequest transfer(my_cx);
6939 :
6940 : // Don't resolve standard classes on XPCNativeWrapper etc, only
6941 : // resolve them if we're resolving on the real global object.
6942 0 : ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
6943 :
6944 0 : if (!ok) {
6945 : // Trust the JS engine (or the script security manager) to set
6946 : // the exception in the JS engine.
6947 :
6948 0 : if (!JS_GetPendingException(my_cx, &exn)) {
6949 0 : return NS_ERROR_UNEXPECTED;
6950 : }
6951 :
6952 : // Return NS_OK to avoid stomping over the exception that was passed
6953 : // down from the ResolveStandardClass call.
6954 : // Note that the order of the JS_ClearPendingException and
6955 : // JS_SetPendingException is important in the case that my_cx == cx.
6956 :
6957 0 : JS_ClearPendingException(my_cx);
6958 : }
6959 : }
6960 :
6961 0 : if (!ok) {
6962 0 : JS_SetPendingException(cx, exn);
6963 0 : *_retval = JS_FALSE;
6964 0 : return NS_OK;
6965 : }
6966 :
6967 0 : if (did_resolve) {
6968 0 : *objp = obj;
6969 :
6970 0 : return NS_OK;
6971 : }
6972 :
6973 0 : if (!(flags & JSRESOLVE_ASSIGNING)) {
6974 : // We want this code to be before the child frame lookup code
6975 : // below so that a child frame named 'constructor' doesn't
6976 : // shadow the window's constructor property.
6977 0 : if (id == sConstructor_id) {
6978 0 : return ResolveConstructor(cx, obj, objp);
6979 : }
6980 : }
6981 :
6982 0 : if (!my_context || !my_context->IsContextInitialized()) {
6983 : // The context is not yet initialized so there's nothing we can do
6984 : // here yet.
6985 :
6986 0 : return NS_OK;
6987 : }
6988 :
6989 0 : if (id == sLocation_id) {
6990 : // This must be done even if we're just getting the value of
6991 : // window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
6992 : // here) since we must define window.location to prevent the
6993 : // getter from being overriden (for security reasons).
6994 :
6995 : // Note: Because we explicitly don't forward to the inner window
6996 : // above, we have to ensure here that our window has a current
6997 : // inner window so that the location object we return will work.
6998 :
6999 0 : if (win->IsOuterWindow()) {
7000 0 : win->EnsureInnerWindow();
7001 : }
7002 :
7003 0 : nsCOMPtr<nsIDOMLocation> location;
7004 0 : rv = win->GetLocation(getter_AddRefs(location));
7005 0 : NS_ENSURE_SUCCESS(rv, rv);
7006 :
7007 : // Make sure we wrap the location object in the inner window's
7008 : // scope if we've got an inner window.
7009 0 : JSObject *scope = nsnull;
7010 0 : if (win->IsOuterWindow()) {
7011 0 : nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
7012 :
7013 0 : if (innerWin) {
7014 0 : scope = innerWin->GetGlobalJSObject();
7015 : }
7016 : }
7017 :
7018 0 : if (!scope) {
7019 0 : wrapper->GetJSObject(&scope);
7020 : }
7021 :
7022 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7023 : jsval v;
7024 : rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), true,
7025 0 : &v, getter_AddRefs(holder));
7026 0 : NS_ENSURE_SUCCESS(rv, rv);
7027 :
7028 0 : JSBool ok = JS_WrapValue(cx, &v) &&
7029 : JS_DefinePropertyById(cx, obj, id, v, nsnull,
7030 : LocationSetterUnwrapper,
7031 0 : JSPROP_PERMANENT | JSPROP_ENUMERATE);
7032 :
7033 0 : if (!ok) {
7034 0 : return NS_ERROR_FAILURE;
7035 : }
7036 :
7037 0 : *objp = obj;
7038 :
7039 0 : return NS_OK;
7040 : }
7041 :
7042 : // Hmm, we do an awful lot of QIs here; maybe we should add a
7043 : // method on an interface that would let us just call into the
7044 : // window code directly...
7045 :
7046 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
7047 0 : nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
7048 :
7049 0 : PRInt32 count = 0;
7050 :
7051 0 : if (dsn) {
7052 0 : dsn->GetChildCount(&count);
7053 : }
7054 :
7055 0 : if (count > 0) {
7056 0 : nsCOMPtr<nsIDocShellTreeItem> child;
7057 :
7058 0 : const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
7059 :
7060 0 : dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
7061 : false, true, nsnull, nsnull,
7062 0 : getter_AddRefs(child));
7063 :
7064 0 : nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
7065 :
7066 0 : if (child_win) {
7067 : // We found a subframe of the right name, define the property
7068 : // on the wrapper so that ::NewResolve() doesn't get called
7069 : // again for this property name.
7070 :
7071 : JSObject *wrapperObj;
7072 0 : wrapper->GetJSObject(&wrapperObj);
7073 :
7074 : jsval v;
7075 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7076 : rv = WrapNative(cx, wrapperObj, child_win,
7077 : &NS_GET_IID(nsIDOMWindow), true, &v,
7078 0 : getter_AddRefs(holder));
7079 0 : NS_ENSURE_SUCCESS(rv, rv);
7080 :
7081 0 : JSAutoRequest ar(cx);
7082 :
7083 0 : bool ok = JS_WrapValue(cx, &v) &&
7084 0 : JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
7085 0 : if (!ok) {
7086 0 : return NS_ERROR_FAILURE;
7087 : }
7088 :
7089 0 : *objp = obj;
7090 :
7091 0 : return NS_OK;
7092 : }
7093 : }
7094 : }
7095 :
7096 : // It is not worth calling GlobalResolve() if we are resolving
7097 : // for assignment, since only read-write properties get dealt
7098 : // with there.
7099 0 : if (!(flags & JSRESOLVE_ASSIGNING)) {
7100 0 : JSAutoRequest ar(cx);
7101 :
7102 : // Resolve special classes.
7103 0 : for (PRUint32 i = 0; i < ArrayLength(sOtherResolveFuncs); i++) {
7104 0 : if (!sOtherResolveFuncs[i](cx, obj, id, flags, objp)) {
7105 0 : return NS_ERROR_FAILURE;
7106 : }
7107 0 : if (*objp) {
7108 0 : return NS_OK;
7109 : }
7110 : }
7111 :
7112 : // Call GlobalResolve() after we call FindChildWithName() so
7113 : // that named child frames will override external properties
7114 : // which have been registered with the script namespace manager.
7115 :
7116 0 : bool did_resolve = false;
7117 0 : rv = GlobalResolve(win, cx, obj, id, &did_resolve);
7118 0 : NS_ENSURE_SUCCESS(rv, rv);
7119 :
7120 0 : if (did_resolve) {
7121 : // GlobalResolve() resolved something, so we're done here.
7122 0 : *objp = obj;
7123 :
7124 0 : return NS_OK;
7125 : }
7126 : }
7127 :
7128 0 : if (id == s_content_id) {
7129 : // Map window._content to window.content for backwards
7130 : // compatibility, this should spit out an message on the JS
7131 : // console.
7132 :
7133 0 : JSObject *windowObj = win->GetGlobalJSObject();
7134 :
7135 0 : JSAutoRequest ar(cx);
7136 :
7137 : JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
7138 0 : windowObj, "_content");
7139 0 : if (!fun) {
7140 0 : return NS_ERROR_OUT_OF_MEMORY;
7141 : }
7142 :
7143 0 : JSObject *funObj = ::JS_GetFunctionObject(fun);
7144 :
7145 0 : if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
7146 : JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
7147 : nsnull,
7148 : JSPROP_ENUMERATE | JSPROP_GETTER |
7149 0 : JSPROP_SHARED)) {
7150 0 : return NS_ERROR_FAILURE;
7151 : }
7152 :
7153 0 : *objp = obj;
7154 :
7155 0 : return NS_OK;
7156 : }
7157 :
7158 0 : if (flags & JSRESOLVE_ASSIGNING) {
7159 0 : if (IsReadonlyReplaceable(id) ||
7160 0 : (!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) {
7161 : // A readonly "replaceable" property is being set, or a
7162 : // readwrite "replaceable" property is being set w/o being
7163 : // fully qualified. Define the property on obj with the value
7164 : // undefined to override the predefined property. This is done
7165 : // for compatibility with other browsers.
7166 0 : JSAutoRequest ar(cx);
7167 :
7168 0 : if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
7169 0 : JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
7170 0 : return NS_ERROR_FAILURE;
7171 : }
7172 0 : *objp = obj;
7173 :
7174 0 : return NS_OK;
7175 : }
7176 : } else {
7177 0 : if (id == sNavigator_id) {
7178 0 : nsCOMPtr<nsIDOMNavigator> navigator;
7179 0 : rv = win->GetNavigator(getter_AddRefs(navigator));
7180 0 : NS_ENSURE_SUCCESS(rv, rv);
7181 :
7182 : jsval v;
7183 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7184 : rv = WrapNative(cx, obj, navigator, &NS_GET_IID(nsIDOMNavigator), true,
7185 0 : &v, getter_AddRefs(holder));
7186 0 : NS_ENSURE_SUCCESS(rv, rv);
7187 :
7188 : // Hold on to the navigator object as a global property so we
7189 : // don't need to worry about losing expando properties etc.
7190 0 : if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
7191 : JSPROP_READONLY | JSPROP_PERMANENT |
7192 0 : JSPROP_ENUMERATE)) {
7193 0 : return NS_ERROR_FAILURE;
7194 : }
7195 0 : *objp = obj;
7196 :
7197 0 : return NS_OK;
7198 : }
7199 :
7200 0 : if (id == sDocument_id) {
7201 0 : nsCOMPtr<nsIDOMDocument> document;
7202 0 : rv = win->GetDocument(getter_AddRefs(document));
7203 0 : NS_ENSURE_SUCCESS(rv, rv);
7204 :
7205 : // FIXME Ideally we'd have an nsIDocument here and get nsWrapperCache
7206 : // from it.
7207 : jsval v;
7208 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7209 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), document,
7210 : &NS_GET_IID(nsIDOMDocument), false, &v,
7211 0 : getter_AddRefs(holder));
7212 0 : NS_ENSURE_SUCCESS(rv, rv);
7213 :
7214 : // The PostCreate hook for the document will handle defining the
7215 : // property
7216 0 : *objp = obj;
7217 :
7218 : // NB: We need to do this for any Xray wrapper.
7219 0 : if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
7220 : // Unless our object is a native wrapper, in which case we have to
7221 : // define it ourselves.
7222 :
7223 0 : *_retval = JS_WrapValue(cx, &v) &&
7224 : JS_DefineProperty(cx, obj, "document", v, NULL, NULL,
7225 0 : JSPROP_READONLY | JSPROP_ENUMERATE);
7226 0 : if (!*_retval) {
7227 0 : return NS_ERROR_UNEXPECTED;
7228 : }
7229 : }
7230 :
7231 0 : return NS_OK;
7232 : }
7233 :
7234 0 : if (id == sJava_id || id == sPackages_id) {
7235 : static bool isResolvingJavaProperties;
7236 :
7237 0 : if (!isResolvingJavaProperties) {
7238 0 : isResolvingJavaProperties = true;
7239 :
7240 : // Tell the window to initialize the Java properties. The
7241 : // window needs to do this as we need to do this only once,
7242 : // and detecting that reliably from here is hard.
7243 :
7244 0 : win->InitJavaProperties();
7245 :
7246 : JSBool hasProp;
7247 0 : bool ok = ::JS_HasPropertyById(cx, obj, id, &hasProp);
7248 :
7249 0 : isResolvingJavaProperties = false;
7250 :
7251 0 : if (!ok) {
7252 0 : return NS_ERROR_FAILURE;
7253 : }
7254 :
7255 0 : if (hasProp) {
7256 0 : *objp = obj;
7257 :
7258 0 : return NS_OK;
7259 : }
7260 : }
7261 0 : } else if (id == sDialogArguments_id && win->IsModalContentWindow()) {
7262 0 : nsCOMPtr<nsIArray> args;
7263 0 : ((nsGlobalModalWindow *)win)->GetDialogArguments(getter_AddRefs(args));
7264 :
7265 0 : nsIScriptContext *script_cx = win->GetContext();
7266 0 : if (script_cx) {
7267 0 : JSAutoSuspendRequest asr(cx);
7268 :
7269 : // Make nsJSContext::SetProperty()'s magic argument array
7270 : // handling happen.
7271 0 : rv = script_cx->SetProperty(obj, "dialogArguments", args);
7272 0 : NS_ENSURE_SUCCESS(rv, rv);
7273 :
7274 0 : *objp = obj;
7275 : }
7276 :
7277 0 : return NS_OK;
7278 : }
7279 : }
7280 :
7281 0 : JSObject *oldobj = *objp;
7282 : rv = nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
7283 0 : _retval);
7284 :
7285 0 : if (NS_FAILED(rv) || *objp != oldobj) {
7286 : // Something went wrong, or the property got resolved. Return.
7287 0 : return rv;
7288 : }
7289 :
7290 : // Make a fast expando if we're assigning to (not declaring or
7291 : // binding a name) a new undefined property that's not already
7292 : // defined on our prototype chain. This way we can access this
7293 : // expando w/o ever getting back into XPConnect.
7294 0 : if ((flags & JSRESOLVE_ASSIGNING) && !(flags & JSRESOLVE_WITH)) {
7295 : JSObject *realObj;
7296 0 : wrapper->GetJSObject(&realObj);
7297 :
7298 0 : if (obj == realObj) {
7299 0 : JSObject *proto = js::GetObjectProto(obj);
7300 0 : if (proto) {
7301 0 : JSObject *pobj = NULL;
7302 : jsval val;
7303 :
7304 0 : if (!::JS_LookupPropertyWithFlagsById(cx, proto, id, flags,
7305 0 : &pobj, &val)) {
7306 0 : *_retval = JS_FALSE;
7307 :
7308 0 : return NS_OK;
7309 : }
7310 :
7311 0 : if (pobj) {
7312 : // A property was found on the prototype chain.
7313 0 : *objp = pobj;
7314 0 : return NS_OK;
7315 : }
7316 : }
7317 :
7318 : // Define a fast expando, the key here is to use JS_PropertyStub
7319 : // as the getter/setter, which makes us stay out of XPConnect
7320 : // when using this property.
7321 : //
7322 : // We don't need to worry about property attributes here as we
7323 : // know here we're dealing with an undefined property set, so
7324 : // we're not declaring readonly or permanent properties.
7325 : //
7326 : // Since we always create the undeclared property here without given a
7327 : // chance for the interpreter to report applicable strict mode warnings,
7328 : // we must take care to check those warnings here.
7329 0 : JSString *str = JSID_TO_STRING(id);
7330 0 : if ((!(flags & JSRESOLVE_QUALIFIED) &&
7331 0 : !js::CheckUndeclaredVarAssignment(cx, str)) ||
7332 : !::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
7333 0 : JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
7334 0 : *_retval = JS_FALSE;
7335 :
7336 0 : return NS_OK;
7337 : }
7338 :
7339 0 : *objp = obj;
7340 : }
7341 : }
7342 :
7343 0 : return NS_OK;
7344 : }
7345 :
7346 : NS_IMETHODIMP
7347 0 : nsWindowSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7348 : JSObject *obj)
7349 : {
7350 0 : nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryWrappedNative(wrapper));
7351 0 : NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
7352 :
7353 0 : sgo->OnFinalize(obj);
7354 :
7355 0 : return NS_OK;
7356 : }
7357 :
7358 : NS_IMETHODIMP
7359 0 : nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
7360 : JSObject * obj, JSObject * *_retval)
7361 : {
7362 0 : nsGlobalWindow *origWin = nsGlobalWindow::FromWrapper(wrapper);
7363 0 : nsGlobalWindow *win = origWin->GetOuterWindowInternal();
7364 :
7365 0 : if (!win) {
7366 : // If we no longer have an outer window. No code should ever be
7367 : // running on a window w/o an outer, which means this hook should
7368 : // never be called when we have no outer. But just in case, return
7369 : // null to prevent leaking an inner window to code in a different
7370 : // window.
7371 0 : *_retval = nsnull;
7372 0 : return NS_ERROR_UNEXPECTED;
7373 : }
7374 :
7375 0 : JSObject *winObj = win->FastGetGlobalJSObject();
7376 0 : if (!winObj) {
7377 0 : NS_ASSERTION(origWin->IsOuterWindow(), "What window is this?");
7378 0 : *_retval = obj;
7379 0 : return NS_OK;
7380 : }
7381 :
7382 0 : if (!JS_WrapObject(cx, &winObj)) {
7383 0 : *_retval = nsnull;
7384 0 : return NS_ERROR_UNEXPECTED;
7385 : }
7386 :
7387 0 : *_retval = winObj;
7388 0 : return NS_OK;
7389 : }
7390 :
7391 : // DOM Location helper
7392 :
7393 : NS_IMETHODIMP
7394 0 : nsLocationSH::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7395 : JSObject *obj, jsid id, PRUint32 mode,
7396 : jsval *vp, bool *_retval)
7397 : {
7398 0 : if ((mode & JSACC_TYPEMASK) == JSACC_PROTO && (mode & JSACC_WRITE)) {
7399 : // No setting location.__proto__, ever!
7400 :
7401 : // Let XPConnect know that the access was not granted.
7402 0 : *_retval = false;
7403 :
7404 0 : return NS_ERROR_DOM_SECURITY_ERR;
7405 : }
7406 :
7407 0 : return nsDOMGenericSH::CheckAccess(wrapper, cx, obj, id, mode, vp, _retval);
7408 : }
7409 :
7410 : NS_IMETHODIMP
7411 0 : nsLocationSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7412 : JSObject *globalObj, JSObject **parentObj)
7413 : {
7414 : // window.location can be held onto by both evil pages that want to track the
7415 : // user's progress on the web and bookmarklets that want to use the location
7416 : // object. Parent it to the outer window so that access checks do the Right
7417 : // Thing.
7418 0 : *parentObj = globalObj;
7419 :
7420 0 : nsCOMPtr<nsIDOMLocation> safeLoc(do_QueryInterface(nativeObj));
7421 0 : if (!safeLoc) {
7422 : // Oops, this wasn't really a location object. This can happen if someone
7423 : // tries to use our scriptable helper as a real object and tries to wrap
7424 : // it, see bug 319296
7425 0 : return NS_OK;
7426 : }
7427 :
7428 0 : nsLocation *loc = (nsLocation *)safeLoc.get();
7429 0 : nsIDocShell *ds = loc->GetDocShell();
7430 0 : if (!ds) {
7431 0 : NS_WARNING("Refusing to create a location in the wrong scope");
7432 0 : return NS_ERROR_UNEXPECTED;
7433 : }
7434 :
7435 0 : nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
7436 0 : if (!sgo) {
7437 : NS_WARNING("Refusing to create a location in the wrong scope because the "
7438 0 : "docshell is being destroyed");
7439 0 : return NS_ERROR_UNEXPECTED;
7440 : }
7441 :
7442 0 : *parentObj = sgo->GetGlobalJSObject();
7443 0 : return NS_OK;
7444 : }
7445 :
7446 : // DOM Navigator helper
7447 :
7448 : NS_IMETHODIMP
7449 0 : nsNavigatorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7450 : JSObject *obj, jsid id, PRUint32 flags,
7451 : JSObject **objp, bool *_retval)
7452 : {
7453 0 : if (!JSID_IS_STRING(id) || (flags & JSRESOLVE_ASSIGNING)) {
7454 0 : return NS_OK;
7455 : }
7456 :
7457 : nsScriptNameSpaceManager *nameSpaceManager =
7458 0 : nsJSRuntime::GetNameSpaceManager();
7459 0 : NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
7460 :
7461 0 : nsDependentJSString name(id);
7462 :
7463 0 : const nsGlobalNameStruct *name_struct = nsnull;
7464 :
7465 0 : nameSpaceManager->LookupNavigatorName(name, &name_struct);
7466 :
7467 0 : if (!name_struct) {
7468 0 : return NS_OK;
7469 : }
7470 0 : NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeNavigatorProperty,
7471 : "unexpected type");
7472 :
7473 0 : nsresult rv = NS_OK;
7474 :
7475 0 : nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
7476 0 : NS_ENSURE_SUCCESS(rv, rv);
7477 :
7478 0 : jsval prop_val = JSVAL_VOID; // Property value.
7479 :
7480 0 : nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
7481 :
7482 0 : if (gpi) {
7483 0 : JSObject *global = JS_GetGlobalForObject(cx, obj);
7484 :
7485 0 : nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
7486 0 : nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(globalNative);
7487 :
7488 0 : if (!window) {
7489 0 : return NS_ERROR_UNEXPECTED;
7490 : }
7491 :
7492 0 : rv = gpi->Init(window, &prop_val);
7493 0 : NS_ENSURE_SUCCESS(rv, rv);
7494 : }
7495 :
7496 0 : if (JSVAL_IS_PRIMITIVE(prop_val) && !JSVAL_IS_NULL(prop_val)) {
7497 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7498 : rv = WrapNative(cx, obj, native, true, &prop_val,
7499 0 : getter_AddRefs(holder));
7500 :
7501 0 : NS_ENSURE_SUCCESS(rv, rv);
7502 : }
7503 :
7504 0 : if (!JS_WrapValue(cx, &prop_val)) {
7505 0 : return NS_ERROR_UNEXPECTED;
7506 : }
7507 :
7508 : JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
7509 0 : JSPROP_ENUMERATE);
7510 :
7511 0 : *_retval = true;
7512 0 : *objp = obj;
7513 :
7514 0 : return ok ? NS_OK : NS_ERROR_FAILURE;
7515 : }
7516 :
7517 : // static
7518 : nsresult
7519 0 : nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7520 : JSObject *globalObj, JSObject **parentObj)
7521 : {
7522 : // window.navigator can hold expandos and thus we need to only ever
7523 : // create one wrapper per navigator object so that expandos are
7524 : // visible independently of who's looking it up.
7525 0 : *parentObj = globalObj;
7526 :
7527 0 : nsCOMPtr<nsIDOMNavigator> safeNav(do_QueryInterface(nativeObj));
7528 0 : if (!safeNav) {
7529 : // Oops, this wasn't really a navigator object. This can happen if someone
7530 : // tries to use our scriptable helper as a real object and tries to wrap
7531 : // it, see bug 319296.
7532 0 : return NS_OK;
7533 : }
7534 :
7535 0 : Navigator *nav = static_cast<Navigator*>(safeNav.get());
7536 0 : nsGlobalWindow *win = static_cast<nsGlobalWindow*>(nav->GetWindow());
7537 0 : if (!win) {
7538 0 : NS_WARNING("Refusing to create a navigator in the wrong scope");
7539 :
7540 0 : return NS_ERROR_UNEXPECTED;
7541 : }
7542 :
7543 0 : JSObject *global = win->GetGlobalJSObject();
7544 :
7545 0 : if (global) {
7546 0 : *parentObj = global;
7547 : }
7548 :
7549 0 : return NS_OK;
7550 : }
7551 :
7552 : // DOM Node helper
7553 :
7554 : template<nsresult (*func)(JSContext *cx, JSObject *obj, jsval *vp)>
7555 : static JSBool
7556 0 : GetterShim(JSContext *cx, JSObject *obj, jsid /* unused */, jsval *vp)
7557 : {
7558 0 : nsresult rv = (*func)(cx, obj, vp);
7559 0 : if (NS_FAILED(rv)) {
7560 0 : if (!::JS_IsExceptionPending(cx)) {
7561 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
7562 : }
7563 0 : return JS_FALSE;
7564 : }
7565 :
7566 0 : return JS_TRUE;
7567 : }
7568 :
7569 : // Can't be static so GetterShim will compile
7570 : nsresult
7571 0 : BaseURIObjectGetter(JSContext *cx, JSObject *obj, jsval *vp)
7572 : {
7573 : // This function duplicates some of the logic in XPC_WN_HelperGetProperty
7574 : XPCWrappedNative *wrapper =
7575 0 : XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
7576 :
7577 : // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
7578 0 : NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
7579 :
7580 0 : nsCOMPtr<nsINode> node = do_QueryWrappedNative(wrapper, obj);
7581 0 : NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
7582 :
7583 0 : nsCOMPtr<nsIURI> uri = node->GetBaseURI();
7584 : return WrapNative(cx, JS_GetGlobalForScopeChain(cx), uri,
7585 0 : &NS_GET_IID(nsIURI), true, vp);
7586 : }
7587 :
7588 : // Can't be static so GetterShim will compile
7589 : nsresult
7590 0 : NodePrincipalGetter(JSContext *cx, JSObject *obj, jsval *vp)
7591 : {
7592 : // This function duplicates some of the logic in XPC_WN_HelperGetProperty
7593 : XPCWrappedNative *wrapper =
7594 0 : XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
7595 :
7596 : // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
7597 0 : NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
7598 :
7599 0 : nsCOMPtr<nsINode> node = do_QueryWrappedNative(wrapper, obj);
7600 0 : NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
7601 :
7602 0 : return WrapNative(cx, JS_GetGlobalForScopeChain(cx), node->NodePrincipal(),
7603 0 : &NS_GET_IID(nsIPrincipal), true, vp);
7604 : }
7605 :
7606 : NS_IMETHODIMP
7607 1487 : nsNodeSH::PostCreatePrototype(JSContext * cx, JSObject * proto)
7608 : {
7609 : // set up our proto first
7610 1487 : nsresult rv = nsDOMGenericSH::PostCreatePrototype(cx, proto);
7611 :
7612 1487 : if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto))) {
7613 : // Stick nodePrincipal and baseURIObject properties on there
7614 : JS_DefinePropertyById(cx, proto, sNodePrincipal_id,
7615 : JSVAL_VOID, GetterShim<NodePrincipalGetter>,
7616 : nsnull,
7617 1487 : JSPROP_READONLY | JSPROP_SHARED);
7618 : JS_DefinePropertyById(cx, proto, sBaseURIObject_id,
7619 : JSVAL_VOID, GetterShim<BaseURIObjectGetter>,
7620 : nsnull,
7621 1487 : JSPROP_READONLY | JSPROP_SHARED);
7622 : }
7623 :
7624 1487 : return rv;
7625 : }
7626 :
7627 : bool
7628 17061 : nsNodeSH::IsCapabilityEnabled(const char* aCapability)
7629 : {
7630 : bool enabled;
7631 : return sSecMan &&
7632 17061 : NS_SUCCEEDED(sSecMan->IsCapabilityEnabled(aCapability, &enabled)) &&
7633 34122 : enabled;
7634 : }
7635 :
7636 : NS_IMETHODIMP
7637 17061 : nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
7638 : JSObject **parentObj)
7639 : {
7640 17061 : nsINode *node = static_cast<nsINode*>(nativeObj);
7641 :
7642 : #ifdef DEBUG
7643 : {
7644 34122 : nsCOMPtr<nsINode> node_qi(do_QueryInterface(nativeObj));
7645 :
7646 : // If this assertion fires the QI implementation for the object in
7647 : // question doesn't use the nsINode pointer as the nsISupports
7648 : // pointer. That must be fixed, or we'll crash...
7649 17061 : NS_ABORT_IF_FALSE(node_qi == node, "Uh, fix QI!");
7650 : }
7651 : #endif
7652 :
7653 : // Make sure that we get the owner document of the content node, in case
7654 : // we're in document teardown. If we are, it's important to *not* use
7655 : // globalObj as the nodes parent since that would give the node the
7656 : // principal of globalObj (i.e. the principal of the document that's being
7657 : // loaded) and not the principal of the document that's being unloaded.
7658 : // See http://bugzilla.mozilla.org/show_bug.cgi?id=227417
7659 17061 : nsIDocument* doc = node->OwnerDoc();
7660 :
7661 : // If we have a document, make sure one of these is true
7662 : // (1) it has a script handling object,
7663 : // (2) has had one, or has been marked to have had one,
7664 : // (3) we are running a privileged script.
7665 : // Event handling is possible only if (1). If (2) event handling is prevented.
7666 : // If document has never had a script handling object,
7667 : // untrusted scripts (3) shouldn't touch it!
7668 17061 : bool hasHadScriptHandlingObject = false;
7669 17061 : NS_ENSURE_STATE(doc->GetScriptHandlingObject(hasHadScriptHandlingObject) ||
7670 : hasHadScriptHandlingObject ||
7671 : IsPrivilegedScript());
7672 :
7673 : nsINode *native_parent;
7674 :
7675 17061 : bool nodeIsElement = node->IsElement();
7676 17061 : if (nodeIsElement && node->AsElement()->IsXUL()) {
7677 : // For XUL elements, use the parent, if any.
7678 12 : native_parent = node->GetParent();
7679 :
7680 12 : if (!native_parent) {
7681 2 : native_parent = doc;
7682 : }
7683 17049 : } else if (!node->IsNodeOfType(nsINode::eDOCUMENT)) {
7684 15131 : NS_ASSERTION(node->IsNodeOfType(nsINode::eCONTENT) ||
7685 : node->IsNodeOfType(nsINode::eATTRIBUTE),
7686 : "Unexpected node type");
7687 :
7688 : // For attributes and non-XUL content, use the document as scope parent.
7689 15131 : native_parent = doc;
7690 :
7691 : // But for HTML form controls, use the form as scope parent.
7692 15131 : if (nodeIsElement) {
7693 8222 : if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
7694 2 : nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
7695 :
7696 1 : if (form_control) {
7697 1 : Element *form = form_control->GetFormElement();
7698 :
7699 1 : if (form) {
7700 : // Found a form, use it.
7701 0 : native_parent = form;
7702 : }
7703 : }
7704 : }
7705 : else {
7706 : // Legend isn't an HTML form control but should have its fieldset form
7707 : // as scope parent at least for backward compatibility.
7708 : nsHTMLLegendElement *legend =
7709 8221 : nsHTMLLegendElement::FromContent(node->AsElement());
7710 8221 : if (legend) {
7711 0 : Element *form = legend->GetFormElement();
7712 :
7713 0 : if (form) {
7714 0 : native_parent = form;
7715 : }
7716 : }
7717 : }
7718 : }
7719 : } else {
7720 : // We're called for a document object; set the parent to be the
7721 : // document's global object, if there is one
7722 :
7723 : // Get the scope object from the document.
7724 1918 : nsISupports *scope = doc->GetScopeObject();
7725 :
7726 1918 : if (scope) {
7727 : jsval v;
7728 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7729 : nsresult rv = WrapNative(cx, globalObj, scope, false, &v,
7730 0 : getter_AddRefs(holder));
7731 0 : NS_ENSURE_SUCCESS(rv, rv);
7732 :
7733 0 : holder->GetJSObject(parentObj);
7734 : }
7735 : else {
7736 : // No global object reachable from this document, use the
7737 : // global object that was passed to this method.
7738 :
7739 1918 : *parentObj = globalObj;
7740 : }
7741 :
7742 : // No slim wrappers for a document's scope object.
7743 1918 : return node->IsInNativeAnonymousSubtree() ?
7744 1918 : NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
7745 : }
7746 :
7747 : // XXXjst: Maybe we need to find the global to use from the
7748 : // nsIScriptGlobalObject that's reachable from the node we're about
7749 : // to wrap here? But that's not always reachable, let's use
7750 : // globalObj for now...
7751 :
7752 : nsresult rv = WrapNativeParent(cx, globalObj, native_parent, native_parent,
7753 15143 : parentObj);
7754 15143 : NS_ENSURE_SUCCESS(rv, rv);
7755 :
7756 15143 : return node->IsInNativeAnonymousSubtree() ?
7757 15143 : NS_SUCCESS_CHROME_ACCESS_ONLY : NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
7758 : }
7759 :
7760 : NS_IMETHODIMP
7761 2 : nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7762 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
7763 : {
7764 2 : nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
7765 2 : return NS_OK;
7766 : }
7767 :
7768 : NS_IMETHODIMP
7769 10932 : nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7770 : JSObject *obj, jsid id, PRUint32 flags,
7771 : JSObject **objp, bool *_retval)
7772 : {
7773 10932 : if (id == sOnload_id || id == sOnerror_id) {
7774 : // Make sure that this node can't go away while waiting for a
7775 : // network load that could fire an event handler.
7776 : // XXXbz won't this fail if the listener is added using
7777 : // addEventListener? On the other hand, even if I comment this
7778 : // code out I can't seem to reproduce the bug it was trying to
7779 : // fix....
7780 0 : nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
7781 : }
7782 :
7783 : return nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
7784 10932 : _retval);
7785 : }
7786 :
7787 : NS_IMETHODIMP
7788 14145 : nsNodeSH::GetFlags(PRUint32 *aFlags)
7789 : {
7790 14145 : *aFlags = DOMCLASSINFO_STANDARD_FLAGS | nsIClassInfo::CONTENT_NODE;
7791 :
7792 14145 : return NS_OK;
7793 : }
7794 :
7795 : void
7796 2 : nsNodeSH::PreserveWrapper(nsISupports *aNative)
7797 : {
7798 2 : nsINode *node = static_cast<nsINode*>(aNative);
7799 2 : nsContentUtils::PreserveWrapper(aNative, node);
7800 2 : }
7801 :
7802 : // EventTarget helper
7803 :
7804 : NS_IMETHODIMP
7805 1238 : nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7806 : JSObject *globalObj, JSObject **parentObj)
7807 : {
7808 : nsDOMEventTargetHelper *target =
7809 1238 : nsDOMEventTargetHelper::FromSupports(nativeObj);
7810 :
7811 2476 : nsCOMPtr<nsIScriptGlobalObject> native_parent;
7812 1238 : target->GetParentObject(getter_AddRefs(native_parent));
7813 :
7814 1238 : *parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;
7815 :
7816 1238 : return NS_OK;
7817 : }
7818 :
7819 : NS_IMETHODIMP
7820 1 : nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7821 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
7822 : {
7823 1 : if (id == sAddEventListener_id) {
7824 0 : return NS_OK;
7825 : }
7826 :
7827 1 : nsEventTargetSH::PreserveWrapper(GetNative(wrapper, obj));
7828 :
7829 1 : return NS_OK;
7830 : }
7831 :
7832 : void
7833 1 : nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
7834 : {
7835 : nsDOMEventTargetHelper *target =
7836 1 : nsDOMEventTargetHelper::FromSupports(aNative);
7837 1 : nsContentUtils::PreserveWrapper(aNative, target);
7838 1 : }
7839 :
7840 : // IDBEventTarget helper
7841 :
7842 : NS_IMETHODIMP
7843 6782 : IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
7844 : JSObject *aGlobalObj, JSObject **aParentObj)
7845 : {
7846 6782 : IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNativeObj);
7847 6782 : JSObject *parent = target->GetParentObject();
7848 6782 : *aParentObj = parent ? parent : aGlobalObj;
7849 6782 : return NS_OK;
7850 : }
7851 :
7852 : // Element helper
7853 :
7854 : static bool
7855 7954 : GetBindingURL(Element *aElement, nsIDocument *aDocument,
7856 : nsCSSValue::URL **aResult)
7857 : {
7858 : // If we have a frame the frame has already loaded the binding. And
7859 : // otherwise, don't do anything else here unless we're dealing with
7860 : // XUL.
7861 7954 : nsIPresShell *shell = aDocument->GetShell();
7862 7954 : if (!shell || aElement->GetPrimaryFrame() || !aElement->IsXUL()) {
7863 7954 : *aResult = nsnull;
7864 :
7865 7954 : return true;
7866 : }
7867 :
7868 : // Get the computed -moz-binding directly from the style context
7869 0 : nsPresContext *pctx = shell->GetPresContext();
7870 0 : NS_ENSURE_TRUE(pctx, false);
7871 :
7872 : nsRefPtr<nsStyleContext> sc = pctx->StyleSet()->ResolveStyleFor(aElement,
7873 0 : nsnull);
7874 0 : NS_ENSURE_TRUE(sc, false);
7875 :
7876 0 : *aResult = sc->GetStyleDisplay()->mBinding;
7877 :
7878 0 : return true;
7879 : }
7880 :
7881 : NS_IMETHODIMP
7882 8234 : nsElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7883 : JSObject *globalObj, JSObject **parentObj)
7884 : {
7885 8234 : nsresult rv = nsNodeSH::PreCreate(nativeObj, cx, globalObj, parentObj);
7886 8234 : NS_ENSURE_SUCCESS(rv, rv);
7887 :
7888 8234 : Element *element = static_cast<Element*>(nativeObj);
7889 :
7890 : #ifdef DEBUG
7891 : {
7892 16468 : nsCOMPtr<nsIContent> content_qi(do_QueryInterface(nativeObj));
7893 :
7894 : // If this assertion fires the QI implementation for the object in
7895 : // question doesn't use the nsIContent pointer as the nsISupports
7896 : // pointer. That must be fixed, or we'll crash...
7897 8234 : NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
7898 : }
7899 : #endif
7900 :
7901 8234 : nsIDocument *doc = element->HasFlag(NODE_FORCE_XBL_BINDINGS) ?
7902 0 : element->OwnerDoc() :
7903 8234 : element->GetCurrentDoc();
7904 :
7905 8234 : if (!doc) {
7906 280 : return rv;
7907 : }
7908 :
7909 7954 : if (element->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
7910 0 : doc->BindingManager()->GetBinding(element)) {
7911 : // Don't allow slim wrappers.
7912 0 : return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
7913 : }
7914 :
7915 : nsCSSValue::URL *bindingURL;
7916 7954 : bool ok = GetBindingURL(element, doc, &bindingURL);
7917 7954 : NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
7918 :
7919 : // Only allow slim wrappers if there's no binding.
7920 7954 : if (!bindingURL) {
7921 7954 : return rv;
7922 : }
7923 :
7924 0 : element->SetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
7925 :
7926 0 : return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
7927 : }
7928 :
7929 : NS_IMETHODIMP
7930 202 : nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7931 : JSObject *obj)
7932 : {
7933 202 : Element *element = static_cast<Element*>(wrapper->Native());
7934 :
7935 : #ifdef DEBUG
7936 : {
7937 404 : nsCOMPtr<nsIContent> content_qi(do_QueryWrappedNative(wrapper));
7938 :
7939 : // If this assertion fires the QI implementation for the object in
7940 : // question doesn't use the nsIContent pointer as the nsISupports
7941 : // pointer. That must be fixed, or we'll crash...
7942 202 : NS_ABORT_IF_FALSE(content_qi == element, "Uh, fix QI!");
7943 : }
7944 : #endif
7945 :
7946 : nsIDocument* doc;
7947 202 : if (element->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
7948 0 : doc = element->OwnerDoc();
7949 : }
7950 : else {
7951 202 : doc = element->GetCurrentDoc();
7952 : }
7953 :
7954 202 : if (!doc) {
7955 : // There's no baseclass that cares about this call so we just
7956 : // return here.
7957 :
7958 0 : return NS_OK;
7959 : }
7960 :
7961 : // We must ensure that the XBL Binding is installed before we hand
7962 : // back this object.
7963 :
7964 202 : if (!element->HasFlag(NODE_ATTACH_BINDING_ON_POSTCREATE)) {
7965 : // There's already a binding for this element so nothing left to
7966 : // be done here.
7967 :
7968 : // In theory we could call ExecuteAttachedHandler here when it's safe to
7969 : // run script if we also removed the binding from the PAQ queue, but that
7970 : // seems like a scary change that would mosly just add more
7971 : // inconsistencies.
7972 :
7973 202 : return NS_OK;
7974 : }
7975 :
7976 0 : element->UnsetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
7977 :
7978 : // Make sure the style context goes away _before_ we load the binding
7979 : // since that can destroy the relevant presshell.
7980 : nsCSSValue::URL *bindingURL;
7981 0 : bool ok = GetBindingURL(element, doc, &bindingURL);
7982 0 : NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
7983 :
7984 0 : if (!bindingURL) {
7985 : // No binding, nothing left to do here.
7986 0 : return NS_OK;
7987 : }
7988 :
7989 0 : nsCOMPtr<nsIURI> uri = bindingURL->GetURI();
7990 0 : nsCOMPtr<nsIPrincipal> principal = bindingURL->mOriginPrincipal;
7991 :
7992 : // We have a binding that must be installed.
7993 : bool dummy;
7994 :
7995 0 : nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
7996 0 : NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
7997 :
7998 0 : nsRefPtr<nsXBLBinding> binding;
7999 0 : xblService->LoadBindings(element, uri, principal, false,
8000 0 : getter_AddRefs(binding), &dummy);
8001 :
8002 0 : if (binding) {
8003 0 : if (nsContentUtils::IsSafeToRunScript()) {
8004 0 : binding->ExecuteAttachedHandler();
8005 : }
8006 : else {
8007 : nsContentUtils::AddScriptRunner(
8008 0 : NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
8009 : }
8010 : }
8011 :
8012 0 : return NS_OK;
8013 : }
8014 :
8015 : NS_IMETHODIMP
8016 0 : nsElementSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8017 : JSObject *obj, bool *_retval)
8018 : {
8019 : // Make sure to not call the superclass here!
8020 0 : nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
8021 0 : NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
8022 :
8023 0 : nsIDocument* doc = content->OwnerDoc();
8024 :
8025 0 : nsRefPtr<nsXBLBinding> binding = doc->BindingManager()->GetBinding(content);
8026 0 : if (!binding) {
8027 : // Nothing else to do here
8028 0 : return NS_OK;
8029 : }
8030 :
8031 0 : *_retval = binding->ResolveAllFields(cx, obj);
8032 :
8033 0 : return NS_OK;
8034 : }
8035 :
8036 :
8037 : // Generic array scriptable helper.
8038 :
8039 : NS_IMETHODIMP
8040 92 : nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8041 : JSObject *obj, jsid id, PRUint32 flags,
8042 : JSObject **objp, bool *_retval)
8043 : {
8044 92 : if (id == sLength_id) {
8045 : // Bail early; this isn't something we're interested in
8046 60 : return NS_OK;
8047 : }
8048 :
8049 32 : bool is_number = false;
8050 32 : PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
8051 :
8052 32 : if (is_number && n >= 0) {
8053 : // XXX The following is a cheap optimization to avoid hitting xpconnect to
8054 : // get the length. We may want to consider asking our concrete
8055 : // implementation for the length, and falling back onto the GetProperty if
8056 : // it doesn't provide one.
8057 :
8058 : PRUint32 length;
8059 2 : nsresult rv = GetLength(wrapper, cx, obj, &length);
8060 2 : NS_ENSURE_SUCCESS(rv, rv);
8061 :
8062 2 : PRUint32 index = PRUint32(n);
8063 2 : if (index < length) {
8064 : *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID, nsnull, nsnull,
8065 2 : JSPROP_ENUMERATE | JSPROP_SHARED);
8066 2 : *objp = obj;
8067 : }
8068 : }
8069 :
8070 32 : return NS_OK;
8071 : }
8072 :
8073 : nsresult
8074 2 : nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8075 : JSObject *obj, PRUint32 *length)
8076 : {
8077 2 : *length = 0;
8078 :
8079 : jsval lenval;
8080 2 : if (!JS_GetProperty(cx, obj, "length", &lenval)) {
8081 0 : return NS_ERROR_UNEXPECTED;
8082 : }
8083 :
8084 2 : if (!JSVAL_IS_INT(lenval)) {
8085 : // This can apparently happen with some sparse array impls falling back
8086 : // onto this code.
8087 0 : return NS_OK;
8088 : }
8089 :
8090 2 : PRInt32 slen = JSVAL_TO_INT(lenval);
8091 2 : if (slen < 0) {
8092 0 : return NS_OK;
8093 : }
8094 :
8095 2 : *length = (PRUint32)slen;
8096 :
8097 2 : return NS_OK;
8098 : }
8099 :
8100 : NS_IMETHODIMP
8101 0 : nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8102 : JSObject *obj, bool *_retval)
8103 : {
8104 : // Recursion protection in case someone tries to be smart and call
8105 : // the enumerate hook from a user defined .length getter, or
8106 : // somesuch.
8107 :
8108 : static bool sCurrentlyEnumerating;
8109 :
8110 0 : if (sCurrentlyEnumerating) {
8111 : // Don't recurse to death.
8112 0 : return NS_OK;
8113 : }
8114 :
8115 0 : sCurrentlyEnumerating = true;
8116 :
8117 : jsval len_val;
8118 0 : JSAutoRequest ar(cx);
8119 0 : JSBool ok = ::JS_GetProperty(cx, obj, "length", &len_val);
8120 :
8121 0 : if (ok && JSVAL_IS_INT(len_val)) {
8122 0 : PRInt32 length = JSVAL_TO_INT(len_val);
8123 :
8124 0 : for (PRInt32 i = 0; ok && i < length; ++i) {
8125 : ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nsnull, nsnull,
8126 0 : JSPROP_ENUMERATE | JSPROP_SHARED);
8127 : }
8128 : }
8129 :
8130 0 : sCurrentlyEnumerating = false;
8131 :
8132 0 : return ok ? NS_OK : NS_ERROR_UNEXPECTED;
8133 : }
8134 :
8135 : // Array scriptable helper
8136 :
8137 : NS_IMETHODIMP
8138 0 : nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8139 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
8140 : {
8141 0 : bool is_number = false;
8142 0 : PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
8143 :
8144 0 : nsresult rv = NS_OK;
8145 :
8146 0 : if (is_number) {
8147 0 : if (n < 0) {
8148 0 : return NS_ERROR_DOM_INDEX_SIZE_ERR;
8149 : }
8150 :
8151 : // Make sure rv == NS_OK here, so GetItemAt implementations that never fail
8152 : // don't have to set rv.
8153 0 : rv = NS_OK;
8154 0 : nsWrapperCache *cache = nsnull;
8155 : nsISupports* array_item =
8156 0 : GetItemAt(GetNative(wrapper, obj), n, &cache, &rv);
8157 0 : NS_ENSURE_SUCCESS(rv, rv);
8158 :
8159 0 : if (array_item) {
8160 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), array_item, cache,
8161 0 : true, vp);
8162 0 : NS_ENSURE_SUCCESS(rv, rv);
8163 :
8164 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
8165 : }
8166 : }
8167 :
8168 0 : return rv;
8169 : }
8170 :
8171 :
8172 : // StringList scriptable helper
8173 :
8174 : nsresult
8175 2 : nsStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
8176 : nsAString& aResult)
8177 : {
8178 4 : nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
8179 2 : NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
8180 :
8181 2 : nsresult rv = list->Item(aIndex, aResult);
8182 : #ifdef DEBUG
8183 2 : if (DOMStringIsNull(aResult)) {
8184 0 : PRUint32 length = 0;
8185 0 : list->GetLength(&length);
8186 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
8187 : }
8188 : #endif
8189 2 : return rv;
8190 : }
8191 :
8192 :
8193 : // DOMTokenList scriptable helper
8194 :
8195 : nsresult
8196 0 : nsDOMTokenListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
8197 : nsAString& aResult)
8198 : {
8199 0 : nsCOMPtr<nsIDOMDOMTokenList> list(do_QueryInterface(aNative));
8200 0 : NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
8201 :
8202 0 : nsresult rv = list->Item(aIndex, aResult);
8203 : #ifdef DEBUG
8204 0 : if (DOMStringIsNull(aResult)) {
8205 0 : PRUint32 length = 0;
8206 0 : list->GetLength(&length);
8207 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
8208 : }
8209 : #endif
8210 0 : return rv;
8211 : }
8212 :
8213 :
8214 : // Named Array helper
8215 :
8216 : NS_IMETHODIMP
8217 151 : nsNamedArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8218 : JSObject *obj, jsid id, PRUint32 flags,
8219 : JSObject **objp, bool *_retval)
8220 : {
8221 302 : if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
8222 151 : !ObjectIsNativeWrapper(cx, obj)) {
8223 :
8224 : {
8225 : JSObject *realObj;
8226 :
8227 151 : if (wrapper) {
8228 151 : wrapper->GetJSObject(&realObj);
8229 : } else {
8230 0 : realObj = obj;
8231 : }
8232 :
8233 302 : JSAutoEnterCompartment ac;
8234 :
8235 151 : if (!ac.enter(cx, realObj)) {
8236 0 : *_retval = false;
8237 0 : return NS_ERROR_FAILURE;
8238 : }
8239 :
8240 151 : JSObject *proto = ::JS_GetPrototype(realObj);
8241 :
8242 151 : if (proto) {
8243 : JSBool hasProp;
8244 151 : if (!::JS_HasPropertyById(cx, proto, id, &hasProp)) {
8245 0 : *_retval = false;
8246 0 : return NS_ERROR_FAILURE;
8247 : }
8248 :
8249 151 : if (hasProp) {
8250 : // We found the property we're resolving on the prototype,
8251 : // nothing left to do here then.
8252 151 : return NS_OK;
8253 : }
8254 : }
8255 : }
8256 :
8257 : // Make sure rv == NS_OK here, so GetNamedItem implementations
8258 : // that never fail don't have to set rv.
8259 0 : nsresult rv = NS_OK;
8260 : nsWrapperCache *cache;
8261 :
8262 : nsISupports* item = GetNamedItem(GetNative(wrapper, obj),
8263 0 : nsDependentJSString(id), &cache, &rv);
8264 0 : NS_ENSURE_SUCCESS(rv, rv);
8265 :
8266 0 : if (item) {
8267 : *_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull,
8268 0 : nsnull, JSPROP_ENUMERATE | JSPROP_SHARED);
8269 :
8270 0 : *objp = obj;
8271 :
8272 0 : return *_retval ? NS_OK : NS_ERROR_FAILURE;
8273 : }
8274 : }
8275 :
8276 0 : return nsArraySH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
8277 : }
8278 :
8279 : NS_IMETHODIMP
8280 0 : nsNamedArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8281 : JSObject *obj, jsid id, jsval *vp,
8282 : bool *_retval)
8283 : {
8284 0 : if (JSID_IS_STRING(id) && !ObjectIsNativeWrapper(cx, obj)) {
8285 0 : nsresult rv = NS_OK;
8286 0 : nsWrapperCache *cache = nsnull;
8287 : nsISupports* item = GetNamedItem(GetNative(wrapper, obj),
8288 0 : nsDependentJSString(id), &cache, &rv);
8289 0 : NS_ENSURE_SUCCESS(rv, rv);
8290 :
8291 0 : if (item) {
8292 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), item, cache,
8293 0 : true, vp);
8294 0 : NS_ENSURE_SUCCESS(rv, rv);
8295 :
8296 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
8297 : }
8298 :
8299 : // Don't fall through to nsArraySH::GetProperty() here
8300 0 : return rv;
8301 : }
8302 :
8303 0 : return nsArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
8304 : }
8305 :
8306 :
8307 : // NamedNodeMap helper
8308 :
8309 : nsISupports*
8310 0 : nsNamedNodeMapSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
8311 : nsWrapperCache **aCache, nsresult *aResult)
8312 : {
8313 0 : nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
8314 :
8315 : nsINode *attr;
8316 0 : *aCache = attr = map->GetItemAt(aIndex, aResult);
8317 0 : return attr;
8318 : }
8319 :
8320 : nsISupports*
8321 0 : nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
8322 : nsWrapperCache **aCache, nsresult *aResult)
8323 : {
8324 0 : nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
8325 :
8326 : nsINode *attr;
8327 0 : *aCache = attr = map->GetNamedItem(aName, aResult);
8328 0 : return attr;
8329 : }
8330 :
8331 :
8332 : NS_IMETHODIMP
8333 0 : nsDOMStringMapSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8334 : JSObject *obj, jsid id, PRUint32 flags,
8335 : JSObject **objp, bool *_retval)
8336 : {
8337 0 : nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
8338 0 : NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
8339 :
8340 0 : nsAutoString prop;
8341 0 : NS_ENSURE_TRUE(JSIDToProp(id, prop), NS_ERROR_UNEXPECTED);
8342 :
8343 0 : if (dataset->HasDataAttr(prop)) {
8344 : *_retval = JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
8345 : nsnull, nsnull,
8346 0 : JSPROP_ENUMERATE | JSPROP_SHARED);
8347 0 : *objp = obj;
8348 : }
8349 :
8350 0 : return NS_OK;
8351 : }
8352 :
8353 : NS_IMETHODIMP
8354 0 : nsDOMStringMapSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8355 : JSObject *obj, bool *_retval)
8356 : {
8357 0 : nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
8358 0 : NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
8359 :
8360 0 : nsDOMStringMap* stringMap = static_cast<nsDOMStringMap*>(dataset.get());
8361 0 : nsTArray<nsString> properties;
8362 0 : nsresult rv = stringMap->GetDataPropList(properties);
8363 0 : NS_ENSURE_SUCCESS(rv, rv);
8364 :
8365 0 : for (PRUint32 i = 0; i < properties.Length(); ++i) {
8366 0 : nsString& prop(properties[i]);
8367 : *_retval = JS_DefineUCProperty(cx, obj, prop.get(), prop.Length(),
8368 : JSVAL_VOID, nsnull, nsnull,
8369 0 : JSPROP_ENUMERATE | JSPROP_SHARED);
8370 0 : NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
8371 : }
8372 :
8373 0 : return NS_OK;
8374 : }
8375 :
8376 : NS_IMETHODIMP
8377 0 : nsDOMStringMapSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
8378 : JSObject *globalObj, JSObject **parentObj)
8379 : {
8380 0 : *parentObj = globalObj;
8381 :
8382 0 : nsDOMStringMap* dataset = static_cast<nsDOMStringMap*>(nativeObj);
8383 :
8384 0 : nsIDocument* document = dataset->GetElement()->OwnerDoc();
8385 :
8386 : nsCOMPtr<nsIScriptGlobalObject> sgo =
8387 0 : do_GetInterface(document->GetScopeObject());
8388 :
8389 0 : if (sgo) {
8390 0 : JSObject *global = sgo->GetGlobalJSObject();
8391 :
8392 0 : if (global) {
8393 0 : *parentObj = global;
8394 0 : return NS_OK;
8395 : }
8396 : }
8397 :
8398 0 : return NS_OK;
8399 : }
8400 :
8401 : NS_IMETHODIMP
8402 0 : nsDOMStringMapSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
8403 : JSContext *cx, JSObject *obj, jsid id,
8404 : jsval *vp, bool *_retval)
8405 : {
8406 0 : nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
8407 0 : NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
8408 :
8409 0 : nsAutoString prop;
8410 0 : NS_ENSURE_TRUE(JSIDToProp(id, prop), NS_ERROR_UNEXPECTED);
8411 :
8412 0 : dataset->RemoveDataAttr(prop);
8413 :
8414 0 : return NS_OK;
8415 : }
8416 :
8417 : NS_IMETHODIMP
8418 0 : nsDOMStringMapSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8419 : JSObject *obj, jsid id, jsval *vp,
8420 : bool *_retval)
8421 : {
8422 0 : nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
8423 0 : NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
8424 :
8425 0 : nsAutoString propName;
8426 0 : NS_ENSURE_TRUE(JSIDToProp(id, propName), NS_ERROR_UNEXPECTED);
8427 :
8428 0 : nsAutoString propVal;
8429 0 : nsresult rv = dataset->GetDataAttr(propName, propVal);
8430 0 : NS_ENSURE_SUCCESS(rv, rv);
8431 :
8432 0 : if (propVal.IsVoid()) {
8433 0 : *vp = JSVAL_VOID;
8434 0 : return NS_SUCCESS_I_DID_SOMETHING;
8435 : }
8436 :
8437 : nsStringBuffer* valBuf;
8438 0 : *vp = XPCStringConvert::ReadableToJSVal(cx, propVal, &valBuf);
8439 0 : if (valBuf) {
8440 0 : propVal.ForgetSharedBuffer();
8441 : }
8442 :
8443 0 : return NS_SUCCESS_I_DID_SOMETHING;
8444 : }
8445 :
8446 : NS_IMETHODIMP
8447 0 : nsDOMStringMapSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8448 : JSObject *obj, jsid id, jsval *vp,
8449 : bool *_retval)
8450 : {
8451 0 : nsCOMPtr<nsIDOMDOMStringMap> dataset(do_QueryWrappedNative(wrapper, obj));
8452 0 : NS_ENSURE_TRUE(dataset, NS_ERROR_UNEXPECTED);
8453 :
8454 0 : nsAutoString propName;
8455 0 : NS_ENSURE_TRUE(JSIDToProp(id, propName), NS_ERROR_UNEXPECTED);
8456 :
8457 0 : JSString *val = JS_ValueToString(cx, *vp);
8458 0 : NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
8459 :
8460 0 : nsDependentJSString propVal;
8461 0 : NS_ENSURE_TRUE(propVal.init(cx, val), NS_ERROR_UNEXPECTED);
8462 :
8463 0 : nsresult rv = dataset->SetDataAttr(propName, propVal);
8464 0 : NS_ENSURE_SUCCESS(rv, rv);
8465 :
8466 0 : return NS_SUCCESS_I_DID_SOMETHING;
8467 : }
8468 :
8469 : bool
8470 0 : nsDOMStringMapSH::JSIDToProp(const jsid& aId, nsAString& aResult)
8471 : {
8472 0 : if (JSID_IS_INT(aId)) {
8473 0 : aResult.AppendInt(JSID_TO_INT(aId));
8474 0 : } else if (JSID_IS_STRING(aId)) {
8475 0 : aResult = nsDependentJSString(aId);
8476 : } else {
8477 0 : return false;
8478 : }
8479 :
8480 0 : return true;
8481 : }
8482 :
8483 : // Can't be static so GetterShim will compile
8484 : nsresult
8485 0 : DocumentURIObjectGetter(JSContext *cx, JSObject *obj, jsval *vp)
8486 : {
8487 : // This function duplicates some of the logic in XPC_WN_HelperGetProperty
8488 : XPCWrappedNative *wrapper =
8489 0 : XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
8490 :
8491 : // The error checks duplicate code in THROW_AND_RETURN_IF_BAD_WRAPPER
8492 0 : NS_ENSURE_TRUE(!wrapper || wrapper->IsValid(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
8493 :
8494 0 : nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper, obj);
8495 0 : NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
8496 :
8497 0 : return WrapNative(cx, JS_GetGlobalForScopeChain(cx), doc->GetDocumentURI(),
8498 0 : &NS_GET_IID(nsIURI), true, vp);
8499 : }
8500 :
8501 : NS_IMETHODIMP
8502 565 : nsDocumentSH::PostCreatePrototype(JSContext * cx, JSObject * proto)
8503 : {
8504 : // set up our proto first
8505 565 : nsresult rv = nsNodeSH::PostCreatePrototype(cx, proto);
8506 :
8507 565 : if (xpc::AccessCheck::isChrome(js::GetObjectCompartment(proto))) {
8508 : // Stick a documentURIObject property on there
8509 : JS_DefinePropertyById(cx, proto, sDocumentURIObject_id,
8510 : JSVAL_VOID, GetterShim<DocumentURIObjectGetter>,
8511 : nsnull,
8512 565 : JSPROP_READONLY | JSPROP_SHARED);
8513 : }
8514 :
8515 565 : return rv;
8516 : }
8517 :
8518 : NS_IMETHODIMP
8519 1577 : nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8520 : JSObject *obj, jsid id, PRUint32 flags,
8521 : JSObject **objp, bool *_retval)
8522 : {
8523 : nsresult rv;
8524 :
8525 1577 : if (id == sLocation_id) {
8526 : // Define the location property on the document object itself so
8527 : // that we can intercept getting and setting of document.location.
8528 :
8529 0 : nsCOMPtr<nsIDOMDocument> doc = do_QueryWrappedNative(wrapper, obj);
8530 0 : NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
8531 :
8532 0 : nsCOMPtr<nsIDOMLocation> location;
8533 0 : rv = doc->GetLocation(getter_AddRefs(location));
8534 0 : NS_ENSURE_SUCCESS(rv, rv);
8535 :
8536 : jsval v;
8537 :
8538 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8539 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
8540 : &NS_GET_IID(nsIDOMLocation), true, &v,
8541 0 : getter_AddRefs(holder));
8542 0 : NS_ENSURE_SUCCESS(rv, rv);
8543 :
8544 : JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull,
8545 : LocationSetter<nsIDOMDocument>,
8546 0 : JSPROP_PERMANENT | JSPROP_ENUMERATE);
8547 :
8548 0 : if (!ok) {
8549 0 : return NS_ERROR_FAILURE;
8550 : }
8551 :
8552 0 : *objp = obj;
8553 :
8554 0 : return NS_OK;
8555 : }
8556 :
8557 1577 : return nsNodeSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
8558 : }
8559 :
8560 : NS_IMETHODIMP
8561 1467 : nsDocumentSH::GetFlags(PRUint32* aFlags)
8562 : {
8563 1467 : *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
8564 :
8565 1467 : return NS_OK;
8566 : }
8567 :
8568 : NS_IMETHODIMP
8569 959 : nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8570 : JSObject *obj)
8571 : {
8572 : // If this is the current document for the window that's the script global
8573 : // object of this document, then define this document object on the window.
8574 : // That will make sure that the document is referenced (via window.document)
8575 : // and prevent it from going away in GC.
8576 1918 : nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper);
8577 959 : if (!doc) {
8578 0 : return NS_ERROR_UNEXPECTED;
8579 : }
8580 :
8581 959 : nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
8582 1918 : nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(sgo);
8583 959 : if (!win) {
8584 : // No window, nothing else to do here
8585 959 : return NS_OK;
8586 : }
8587 :
8588 0 : nsIDOMDocument* currentDoc = win->GetExtantDocument();
8589 :
8590 0 : if (SameCOMIdentity(doc, currentDoc)) {
8591 : jsval winVal;
8592 :
8593 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8594 : nsresult rv = WrapNative(cx, obj, win, &NS_GET_IID(nsIDOMWindow), false,
8595 0 : &winVal, getter_AddRefs(holder));
8596 0 : NS_ENSURE_SUCCESS(rv, rv);
8597 :
8598 0 : NS_NAMED_LITERAL_STRING(doc_str, "document");
8599 :
8600 0 : if (!::JS_DefineUCProperty(cx, JSVAL_TO_OBJECT(winVal),
8601 : reinterpret_cast<const jschar *>
8602 0 : (doc_str.get()),
8603 : doc_str.Length(), OBJECT_TO_JSVAL(obj),
8604 : JS_PropertyStub, JS_StrictPropertyStub,
8605 0 : JSPROP_READONLY | JSPROP_ENUMERATE)) {
8606 0 : return NS_ERROR_FAILURE;
8607 : }
8608 : }
8609 0 : return NS_OK;
8610 : }
8611 :
8612 : // HTMLDocument helper
8613 :
8614 : static nsresult
8615 0 : ResolveImpl(JSContext *cx, nsIXPConnectWrappedNative *wrapper, jsid id,
8616 : nsISupports **result, nsWrapperCache **aCache)
8617 : {
8618 : nsHTMLDocument *doc =
8619 0 : static_cast<nsHTMLDocument*>(static_cast<nsINode*>(wrapper->Native()));
8620 :
8621 : // 'id' is not always a string, it can be a number since document.1
8622 : // should map to <input name="1">. Thus we can't use
8623 : // JSVAL_TO_STRING() here.
8624 0 : JSString *str = IdToString(cx, id);
8625 0 : NS_ENSURE_TRUE(str, NS_ERROR_UNEXPECTED);
8626 :
8627 0 : nsDependentJSString depStr;
8628 0 : NS_ENSURE_TRUE(depStr.init(cx, str), NS_ERROR_UNEXPECTED);
8629 :
8630 0 : return doc->ResolveName(depStr, nsnull, result, aCache);
8631 : }
8632 :
8633 :
8634 : static JSClass sHTMLDocumentAllClass = {
8635 : "HTML document.all class",
8636 : JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE |
8637 : JSCLASS_HAS_RESERVED_SLOTS(1),
8638 : JS_PropertyStub, JS_PropertyStub, nsHTMLDocumentSH::DocumentAllGetProperty,
8639 : JS_StrictPropertyStub, JS_EnumerateStub,
8640 : (JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve, JS_ConvertStub,
8641 : nsHTMLDocumentSH::ReleaseDocument, nsnull, nsnull,
8642 : nsHTMLDocumentSH::CallToGetPropMapper
8643 : };
8644 :
8645 :
8646 : static JSClass sHTMLDocumentAllHelperClass = {
8647 : "HTML document.all helper class", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
8648 : JS_PropertyStub, JS_PropertyStub,
8649 : nsHTMLDocumentSH::DocumentAllHelperGetProperty,
8650 : JS_StrictPropertyStub, JS_EnumerateStub,
8651 : (JSResolveOp)nsHTMLDocumentSH::DocumentAllHelperNewResolve, JS_ConvertStub,
8652 : nsnull
8653 : };
8654 :
8655 :
8656 : static JSClass sHTMLDocumentAllTagsClass = {
8657 : "HTML document.all.tags class",
8658 : JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
8659 : JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
8660 : JS_EnumerateStub, (JSResolveOp)nsHTMLDocumentSH::DocumentAllTagsNewResolve,
8661 : JS_ConvertStub, nsHTMLDocumentSH::ReleaseDocument, nsnull, nsnull,
8662 : nsHTMLDocumentSH::CallToGetPropMapper
8663 : };
8664 :
8665 : // static
8666 : JSBool
8667 0 : nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
8668 : nsDocument *domdoc,
8669 : nsContentList **nodeList)
8670 : {
8671 : // The document.all object is a mix of the node list returned by
8672 : // document.getElementsByTagName("*") and a map of elements in the
8673 : // document exposed by their id and/or name. To make access to the
8674 : // node list part (i.e. access to elements by index) not walk the
8675 : // document each time, we create a nsContentList and hold on to it
8676 : // in a reserved slot (0) on the document.all JSObject.
8677 0 : nsresult rv = NS_OK;
8678 :
8679 0 : jsval collection = JS_GetReservedSlot(obj, 0);
8680 :
8681 0 : if (!JSVAL_IS_PRIMITIVE(collection)) {
8682 : // We already have a node list in our reserved slot, use it.
8683 0 : JSObject *obj = JSVAL_TO_OBJECT(collection);
8684 0 : if (mozilla::dom::binding::HTMLCollection::objIsWrapper(obj)) {
8685 : nsIHTMLCollection *native =
8686 0 : mozilla::dom::binding::HTMLCollection::getNative(obj);
8687 0 : NS_ADDREF(*nodeList = static_cast<nsContentList*>(native));
8688 : }
8689 : else {
8690 0 : nsISupports *native = sXPConnect->GetNativeOfWrapper(cx, obj);
8691 0 : if (native) {
8692 0 : NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
8693 : }
8694 : else {
8695 0 : rv = NS_ERROR_FAILURE;
8696 : }
8697 : }
8698 : } else {
8699 : // No node list for this document.all yet, create one...
8700 :
8701 : nsRefPtr<nsContentList> list =
8702 0 : domdoc->GetElementsByTagName(NS_LITERAL_STRING("*"));
8703 0 : if (!list) {
8704 0 : rv |= NS_ERROR_OUT_OF_MEMORY;
8705 : }
8706 :
8707 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8708 : rv |= WrapNative(cx, JS_GetGlobalForScopeChain(cx),
8709 0 : static_cast<nsINodeList*>(list), list, false,
8710 0 : &collection, getter_AddRefs(holder));
8711 :
8712 0 : list.forget(nodeList);
8713 :
8714 : // ... and store it in our reserved slot.
8715 0 : JS_SetReservedSlot(obj, 0, collection);
8716 : }
8717 :
8718 0 : if (NS_FAILED(rv)) {
8719 0 : nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
8720 :
8721 0 : return JS_FALSE;
8722 : }
8723 :
8724 0 : return *nodeList != nsnull;
8725 : }
8726 :
8727 : JSBool
8728 0 : nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
8729 : jsid id, jsval *vp)
8730 : {
8731 : // document.all.item and .namedItem get their value in the
8732 : // newResolve hook, so nothing to do for those properties here. And
8733 : // we need to return early to prevent <div id="item"> from shadowing
8734 : // document.all.item(), etc.
8735 0 : if (id == sItem_id || id == sNamedItem_id) {
8736 0 : return JS_TRUE;
8737 : }
8738 :
8739 0 : while (js::GetObjectJSClass(obj) != &sHTMLDocumentAllClass) {
8740 0 : obj = js::GetObjectProto(obj);
8741 :
8742 0 : if (!obj) {
8743 0 : NS_ERROR("The JS engine lies!");
8744 :
8745 0 : return JS_TRUE;
8746 : }
8747 : }
8748 :
8749 0 : nsHTMLDocument *doc = GetDocument(obj);
8750 : nsISupports *result;
8751 : nsWrapperCache *cache;
8752 0 : nsresult rv = NS_OK;
8753 :
8754 0 : if (JSID_IS_STRING(id)) {
8755 0 : if (id == sLength_id) {
8756 : // Map document.all.length to the length of the collection
8757 : // document.getElementsByTagName("*"), and make sure <div
8758 : // id="length"> doesn't shadow document.all.length.
8759 :
8760 0 : nsRefPtr<nsContentList> nodeList;
8761 0 : if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
8762 0 : return JS_FALSE;
8763 : }
8764 :
8765 : PRUint32 length;
8766 0 : rv = nodeList->GetLength(&length);
8767 :
8768 0 : if (NS_FAILED(rv)) {
8769 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
8770 :
8771 0 : return JS_FALSE;
8772 : }
8773 :
8774 0 : *vp = INT_TO_JSVAL(length);
8775 :
8776 0 : return JS_TRUE;
8777 0 : } else if (id != sTags_id) {
8778 : // For all other strings, look for an element by id or name.
8779 :
8780 0 : nsDependentJSString str(id);
8781 :
8782 0 : result = doc->GetDocumentAllResult(str, &cache, &rv);
8783 :
8784 0 : if (NS_FAILED(rv)) {
8785 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
8786 :
8787 0 : return JS_FALSE;
8788 : }
8789 : }
8790 : else {
8791 0 : result = nsnull;
8792 : }
8793 0 : } else if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
8794 : // Map document.all[n] (where n is a number) to the n:th item in
8795 : // the document.all node list.
8796 :
8797 0 : nsRefPtr<nsContentList> nodeList;
8798 0 : if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
8799 0 : return JS_FALSE;
8800 : }
8801 :
8802 0 : nsIContent *node = nodeList->GetNodeAt(JSID_TO_INT(id));
8803 :
8804 0 : result = node;
8805 0 : cache = node;
8806 : } else {
8807 0 : result = nsnull;
8808 : }
8809 :
8810 0 : if (result) {
8811 0 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), result, cache, true, vp);
8812 0 : if (NS_FAILED(rv)) {
8813 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
8814 :
8815 0 : return JS_FALSE;
8816 : }
8817 : } else {
8818 0 : *vp = JSVAL_VOID;
8819 : }
8820 :
8821 0 : return JS_TRUE;
8822 : }
8823 :
8824 : JSBool
8825 0 : nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
8826 : unsigned flags, JSObject **objp)
8827 : {
8828 0 : if (flags & JSRESOLVE_ASSIGNING) {
8829 : // Nothing to do here if we're assigning
8830 :
8831 0 : return JS_TRUE;
8832 : }
8833 :
8834 0 : jsval v = JSVAL_VOID;
8835 :
8836 0 : if (id == sItem_id || id == sNamedItem_id) {
8837 : // Define the item() or namedItem() method.
8838 :
8839 : JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
8840 0 : 0, JSPROP_ENUMERATE);
8841 0 : *objp = obj;
8842 :
8843 0 : return fnc != nsnull;
8844 : }
8845 :
8846 0 : if (id == sLength_id) {
8847 : // document.all.length. Any jsval other than undefined would do
8848 : // here, all we need is to get into the code below that defines
8849 : // this propery on obj, the rest happens in
8850 : // DocumentAllGetProperty().
8851 :
8852 0 : v = JSVAL_ONE;
8853 0 : } else if (id == sTags_id) {
8854 0 : nsHTMLDocument *doc = GetDocument(obj);
8855 :
8856 : JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
8857 0 : ::JS_GetGlobalForObject(cx, obj));
8858 0 : if (!tags) {
8859 0 : return JS_FALSE;
8860 : }
8861 :
8862 0 : ::JS_SetPrivate(tags, doc);
8863 :
8864 : // The "tags" JSObject now also owns doc.
8865 0 : NS_ADDREF(doc);
8866 :
8867 0 : v = OBJECT_TO_JSVAL(tags);
8868 : } else {
8869 0 : if (!DocumentAllGetProperty(cx, obj, id, &v)) {
8870 0 : return JS_FALSE;
8871 : }
8872 : }
8873 :
8874 0 : JSBool ok = JS_TRUE;
8875 :
8876 0 : if (v != JSVAL_VOID) {
8877 0 : ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
8878 0 : *objp = obj;
8879 : }
8880 :
8881 0 : return ok;
8882 : }
8883 :
8884 : // Finalize hook used by document related JS objects, but also by
8885 : // sGlobalScopePolluterClass!
8886 :
8887 : void
8888 0 : nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
8889 : {
8890 0 : nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(obj);
8891 :
8892 0 : NS_IF_RELEASE(doc);
8893 0 : }
8894 :
8895 : JSBool
8896 0 : nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp)
8897 : {
8898 : // Handle document.all("foo") style access to document.all.
8899 :
8900 0 : if (argc != 1) {
8901 : // XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
8902 : // and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
8903 : // accepts nothing other than one arg.
8904 0 : nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_INVALID_ARG);
8905 :
8906 0 : return JS_FALSE;
8907 : }
8908 :
8909 : // Convert all types to string.
8910 0 : JSString *str = ::JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
8911 0 : if (!str) {
8912 0 : return JS_FALSE;
8913 : }
8914 :
8915 : // If we are called via document.all(id) instead of document.all.item(i) or
8916 : // another method, use the document.all callee object as self.
8917 : JSObject *self;
8918 0 : if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) &&
8919 0 : ::JS_GetClass(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) {
8920 0 : self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
8921 : } else {
8922 0 : self = JS_THIS_OBJECT(cx, vp);
8923 0 : if (!self)
8924 0 : return JS_FALSE;
8925 : }
8926 :
8927 : size_t length;
8928 0 : const jschar *chars = ::JS_GetStringCharsAndLength(cx, str, &length);
8929 0 : if (!chars) {
8930 0 : return JS_FALSE;
8931 : }
8932 :
8933 0 : return ::JS_GetUCProperty(cx, self, chars, length, vp);
8934 : }
8935 :
8936 :
8937 : static inline JSObject *
8938 0 : GetDocumentAllHelper(JSObject *obj)
8939 : {
8940 0 : while (obj && JS_GetClass(obj) != &sHTMLDocumentAllHelperClass) {
8941 0 : obj = ::JS_GetPrototype(obj);
8942 : }
8943 :
8944 0 : return obj;
8945 : }
8946 :
8947 : static inline void *
8948 0 : FlagsToPrivate(PRUint32 flags)
8949 : {
8950 0 : JS_ASSERT((flags & (1 << 31)) == 0);
8951 0 : return (void *)(flags << 1);
8952 : }
8953 :
8954 : static inline PRUint32
8955 0 : PrivateToFlags(void *priv)
8956 : {
8957 0 : JS_ASSERT(size_t(priv) <= PR_UINT32_MAX && (size_t(priv) & 1) == 0);
8958 0 : return (PRUint32)(size_t(priv) >> 1);
8959 : }
8960 :
8961 : JSBool
8962 0 : nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
8963 : jsid id, jsval *vp)
8964 : {
8965 0 : if (id != nsDOMClassInfo::sAll_id) {
8966 0 : return JS_TRUE;
8967 : }
8968 :
8969 0 : JSObject *helper = GetDocumentAllHelper(obj);
8970 :
8971 0 : if (!helper) {
8972 0 : NS_ERROR("Uh, how'd we get here?");
8973 :
8974 : // Let scripts continue, if we somehow did get here...
8975 :
8976 0 : return JS_TRUE;
8977 : }
8978 :
8979 0 : PRUint32 flags = PrivateToFlags(::JS_GetPrivate(helper));
8980 :
8981 0 : if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
8982 : // document.all is either being detected, e.g. if (document.all),
8983 : // or it was not being resolved with a qualified name. Claim that
8984 : // document.all is undefined.
8985 :
8986 0 : *vp = JSVAL_VOID;
8987 : } else {
8988 : // document.all is not being detected, and it resolved with a
8989 : // qualified name. Expose the document.all collection.
8990 :
8991 0 : if (!JSVAL_IS_OBJECT(*vp)) {
8992 : // First time through, create the collection, and set the
8993 : // document as its private nsISupports data.
8994 : nsresult rv;
8995 0 : nsCOMPtr<nsIHTMLDocument> doc = do_QueryWrapper(cx, obj, &rv);
8996 0 : if (NS_FAILED(rv)) {
8997 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
8998 :
8999 0 : return JS_FALSE;
9000 : }
9001 :
9002 : JSObject *all = ::JS_NewObject(cx, &sHTMLDocumentAllClass, nsnull,
9003 0 : ::JS_GetGlobalForObject(cx, obj));
9004 0 : if (!all) {
9005 0 : return JS_FALSE;
9006 : }
9007 :
9008 : // Let the JSObject take over ownership of doc.
9009 0 : ::JS_SetPrivate(all, doc);
9010 :
9011 0 : doc.forget();
9012 :
9013 0 : *vp = OBJECT_TO_JSVAL(all);
9014 : }
9015 : }
9016 :
9017 0 : return JS_TRUE;
9018 : }
9019 :
9020 : JSBool
9021 0 : nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
9022 : jsid id, unsigned flags,
9023 : JSObject **objp)
9024 : {
9025 0 : if (id == nsDOMClassInfo::sAll_id) {
9026 : // document.all is resolved for the first time. Define it.
9027 0 : JSObject *helper = GetDocumentAllHelper(obj);
9028 :
9029 0 : if (helper) {
9030 0 : if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
9031 0 : JSPROP_ENUMERATE)) {
9032 0 : return JS_FALSE;
9033 : }
9034 :
9035 0 : *objp = helper;
9036 : }
9037 : }
9038 :
9039 0 : return JS_TRUE;
9040 : }
9041 :
9042 :
9043 : JSBool
9044 0 : nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
9045 : jsid id, unsigned flags,
9046 : JSObject **objp)
9047 : {
9048 0 : if (JSID_IS_STRING(id)) {
9049 0 : nsDocument *doc = GetDocument(obj);
9050 :
9051 0 : JSObject *proto = ::JS_GetPrototype(obj);
9052 0 : if (NS_UNLIKELY(!proto)) {
9053 0 : return JS_TRUE;
9054 : }
9055 :
9056 : JSBool found;
9057 0 : if (!::JS_HasPropertyById(cx, proto, id, &found)) {
9058 0 : return JS_FALSE;
9059 : }
9060 :
9061 0 : if (found) {
9062 0 : return JS_TRUE;
9063 : }
9064 :
9065 : nsRefPtr<nsContentList> tags =
9066 0 : doc->GetElementsByTagName(nsDependentJSString(id));
9067 :
9068 0 : if (tags) {
9069 : jsval v;
9070 0 : nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
9071 : nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
9072 0 : static_cast<nsINodeList*>(tags), tags, true,
9073 0 : &v, getter_AddRefs(holder));
9074 0 : if (NS_FAILED(rv)) {
9075 0 : nsDOMClassInfo::ThrowJSException(cx, rv);
9076 :
9077 0 : return JS_FALSE;
9078 : }
9079 :
9080 0 : if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
9081 0 : return JS_FALSE;
9082 : }
9083 :
9084 0 : *objp = obj;
9085 : }
9086 : }
9087 :
9088 0 : return JS_TRUE;
9089 : }
9090 :
9091 :
9092 : NS_IMETHODIMP
9093 0 : nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9094 : JSObject *obj, jsid id, PRUint32 flags,
9095 : JSObject **objp, bool *_retval)
9096 : {
9097 : // nsDocumentSH::NewResolve() does a security check that we'd kinda
9098 : // want to do here too before doing anything else. But given that we
9099 : // only define dynamic properties here before the call to
9100 : // nsDocumentSH::NewResolve() we're ok, since once those properties
9101 : // are accessed, we'll do the necessary security check.
9102 :
9103 0 : if (!(flags & JSRESOLVE_ASSIGNING)) {
9104 : // For native wrappers, do not resolve random names on document
9105 :
9106 0 : JSAutoRequest ar(cx);
9107 :
9108 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
9109 0 : nsCOMPtr<nsISupports> result;
9110 : nsWrapperCache *cache;
9111 0 : nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result),
9112 0 : &cache);
9113 0 : NS_ENSURE_SUCCESS(rv, rv);
9114 :
9115 0 : if (result) {
9116 : JSBool ok = *_retval =
9117 0 : ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull, nsnull, 0);
9118 0 : *objp = obj;
9119 :
9120 0 : return ok ? NS_OK : NS_ERROR_FAILURE;
9121 : }
9122 : }
9123 :
9124 0 : if (id == sAll_id && !sDisableDocumentAllSupport &&
9125 0 : !ObjectIsNativeWrapper(cx, obj)) {
9126 0 : nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
9127 :
9128 0 : if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
9129 0 : JSObject *helper = GetDocumentAllHelper(::JS_GetPrototype(obj));
9130 :
9131 0 : JSObject *proto = ::JS_GetPrototype(helper ? helper : obj);
9132 :
9133 : // Check if the property all is defined on obj's (or helper's
9134 : // if obj doesn't exist) prototype, if it is, don't expose our
9135 : // document.all helper.
9136 :
9137 0 : JSBool hasAll = JS_FALSE;
9138 0 : if (proto && !JS_HasProperty(cx, proto, "all", &hasAll)) {
9139 0 : return NS_ERROR_UNEXPECTED;
9140 : }
9141 :
9142 0 : if (hasAll && helper) {
9143 : // Our helper's prototype now has an "all" property, remove
9144 : // the helper out of the prototype chain to prevent
9145 : // shadowing of the now defined "all" property.
9146 0 : JSObject *tmp = obj, *tmpProto;
9147 :
9148 0 : while ((tmpProto = ::JS_GetPrototype(tmp)) != helper) {
9149 0 : tmp = tmpProto;
9150 : }
9151 :
9152 0 : ::JS_SetPrototype(cx, tmp, proto);
9153 : }
9154 :
9155 : // If we don't already have a helper, and we're resolving
9156 : // document.all qualified, and we're *not* detecting
9157 : // document.all, e.g. if (document.all), and "all" isn't
9158 : // already defined on our prototype, create a helper.
9159 0 : if (!helper && flags & JSRESOLVE_QUALIFIED &&
9160 0 : !(flags & JSRESOLVE_DETECTING) && !hasAll) {
9161 : // Print a warning so developers can stop using document.all
9162 0 : PrintWarningOnConsole(cx, "DocumentAllUsed");
9163 :
9164 : helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
9165 : ::JS_GetPrototype(obj),
9166 0 : ::JS_GetGlobalForObject(cx, obj));
9167 :
9168 0 : if (!helper) {
9169 0 : return NS_ERROR_OUT_OF_MEMORY;
9170 : }
9171 :
9172 : // Insert the helper into our prototype chain. helper's prototype
9173 : // is already obj's current prototype.
9174 0 : if (!::JS_SetPrototype(cx, obj, helper)) {
9175 0 : nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
9176 :
9177 0 : return NS_ERROR_UNEXPECTED;
9178 : }
9179 : }
9180 :
9181 : // If we have (or just created) a helper, pass the resolve flags
9182 : // to the helper as its private data.
9183 0 : if (helper) {
9184 0 : ::JS_SetPrivate(helper, FlagsToPrivate(flags));
9185 : }
9186 : }
9187 :
9188 0 : return NS_OK;
9189 : }
9190 : }
9191 :
9192 0 : return nsDocumentSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
9193 : }
9194 :
9195 : NS_IMETHODIMP
9196 0 : nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9197 : JSContext *cx, JSObject *obj, jsid id,
9198 : jsval *vp, bool *_retval)
9199 : {
9200 : // For native wrappers, do not get random names on document
9201 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
9202 0 : nsCOMPtr<nsISupports> result;
9203 :
9204 0 : JSAutoRequest ar(cx);
9205 :
9206 : nsWrapperCache *cache;
9207 0 : nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result), &cache);
9208 0 : NS_ENSURE_SUCCESS(rv, rv);
9209 :
9210 0 : if (result) {
9211 0 : rv = WrapNative(cx, obj, result, cache, true, vp);
9212 0 : if (NS_SUCCEEDED(rv)) {
9213 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
9214 : }
9215 0 : return rv;
9216 : }
9217 : }
9218 :
9219 0 : return NS_OK;
9220 : }
9221 :
9222 : // HTMLFormElement helper
9223 :
9224 : // static
9225 : nsresult
9226 0 : nsHTMLFormElementSH::FindNamedItem(nsIForm *aForm, jsid id,
9227 : nsISupports **aResult,
9228 : nsWrapperCache **aCache)
9229 : {
9230 0 : nsDependentJSString name(id);
9231 :
9232 0 : *aResult = aForm->ResolveName(name).get();
9233 : // FIXME Get the wrapper cache from nsIForm::ResolveName
9234 0 : *aCache = nsnull;
9235 :
9236 0 : if (!*aResult) {
9237 0 : nsCOMPtr<nsIContent> content(do_QueryInterface(aForm));
9238 :
9239 : nsCOMPtr<nsIHTMLDocument> html_doc =
9240 0 : do_QueryInterface(content->GetDocument());
9241 :
9242 0 : if (html_doc && content) {
9243 0 : html_doc->ResolveName(name, content, aResult, aCache);
9244 : }
9245 : }
9246 :
9247 0 : return NS_OK;
9248 : }
9249 :
9250 : NS_IMETHODIMP
9251 0 : nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
9252 : JSContext *cx, JSObject *obj, jsid id,
9253 : PRUint32 flags, JSObject **objp,
9254 : bool *_retval)
9255 : {
9256 : // For native wrappers, do not resolve random names on form
9257 0 : if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
9258 0 : !ObjectIsNativeWrapper(cx, obj)) {
9259 0 : nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9260 0 : nsCOMPtr<nsISupports> result;
9261 : nsWrapperCache *cache;
9262 :
9263 0 : FindNamedItem(form, id, getter_AddRefs(result), &cache);
9264 :
9265 0 : if (result) {
9266 0 : JSAutoRequest ar(cx);
9267 : *_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull,
9268 0 : nsnull, JSPROP_ENUMERATE);
9269 :
9270 0 : *objp = obj;
9271 :
9272 0 : return *_retval ? NS_OK : NS_ERROR_FAILURE;
9273 : }
9274 : }
9275 :
9276 0 : return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
9277 : }
9278 :
9279 :
9280 : NS_IMETHODIMP
9281 0 : nsHTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9282 : JSContext *cx, JSObject *obj, jsid id,
9283 : jsval *vp, bool *_retval)
9284 : {
9285 0 : nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9286 :
9287 0 : if (JSID_IS_STRING(id)) {
9288 : // For native wrappers, do not get random names on form
9289 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
9290 0 : nsCOMPtr<nsISupports> result;
9291 : nsWrapperCache *cache;
9292 :
9293 0 : FindNamedItem(form, id, getter_AddRefs(result), &cache);
9294 :
9295 0 : if (result) {
9296 : // Wrap result, result can be either an element or a list of
9297 : // elements
9298 0 : nsresult rv = WrapNative(cx, obj, result, cache, true, vp);
9299 0 : return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9300 : }
9301 : }
9302 : } else {
9303 0 : PRInt32 n = GetArrayIndexFromId(cx, id);
9304 :
9305 0 : if (n >= 0) {
9306 0 : nsIFormControl* control = form->GetElementAt(n);
9307 :
9308 0 : if (control) {
9309 : Element *element =
9310 0 : static_cast<nsGenericHTMLFormElement*>(form->GetElementAt(n));
9311 : nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), element,
9312 0 : element, true, vp);
9313 0 : return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9314 : }
9315 : }
9316 : }
9317 :
9318 0 : return NS_OK;
9319 : }
9320 :
9321 : NS_IMETHODIMP
9322 0 : nsHTMLFormElementSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
9323 : JSContext *cx, JSObject *obj,
9324 : PRUint32 enum_op, jsval *statep,
9325 : jsid *idp, bool *_retval)
9326 : {
9327 0 : switch (enum_op) {
9328 : case JSENUMERATE_INIT:
9329 : case JSENUMERATE_INIT_ALL:
9330 : {
9331 0 : nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9332 :
9333 0 : if (!form) {
9334 0 : *statep = JSVAL_NULL;
9335 0 : return NS_ERROR_UNEXPECTED;
9336 : }
9337 :
9338 0 : *statep = INT_TO_JSVAL(0);
9339 :
9340 0 : if (idp) {
9341 0 : PRUint32 count = form->GetElementCount();
9342 :
9343 0 : *idp = INT_TO_JSID(count);
9344 : }
9345 :
9346 0 : break;
9347 : }
9348 : case JSENUMERATE_NEXT:
9349 : {
9350 0 : nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9351 0 : NS_ENSURE_TRUE(form, NS_ERROR_FAILURE);
9352 :
9353 0 : PRInt32 index = (PRInt32)JSVAL_TO_INT(*statep);
9354 :
9355 0 : PRUint32 count = form->GetElementCount();
9356 :
9357 0 : if ((PRUint32)index < count) {
9358 0 : nsIFormControl* controlNode = form->GetElementAt(index);
9359 0 : NS_ENSURE_TRUE(controlNode, NS_ERROR_FAILURE);
9360 :
9361 0 : nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(controlNode);
9362 0 : NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
9363 :
9364 0 : nsAutoString attr;
9365 0 : domElement->GetAttribute(NS_LITERAL_STRING("name"), attr);
9366 0 : if (attr.IsEmpty()) {
9367 : // If name is not there, use index instead
9368 0 : attr.AppendInt(index);
9369 : }
9370 :
9371 0 : JSAutoRequest ar(cx);
9372 :
9373 : JSString *jsname =
9374 : JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
9375 0 : (attr.get()),
9376 0 : attr.Length());
9377 0 : NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
9378 :
9379 0 : JS_ValueToId(cx, STRING_TO_JSVAL(jsname), idp);
9380 :
9381 0 : *statep = INT_TO_JSVAL(++index);
9382 : } else {
9383 0 : *statep = JSVAL_NULL;
9384 : }
9385 :
9386 0 : break;
9387 : }
9388 : case JSENUMERATE_DESTROY:
9389 0 : *statep = JSVAL_NULL;
9390 :
9391 0 : break;
9392 : }
9393 :
9394 0 : return NS_OK;
9395 : }
9396 :
9397 :
9398 : // HTMLSelectElement helper
9399 :
9400 : NS_IMETHODIMP
9401 0 : nsHTMLSelectElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9402 : JSObject *obj, jsid id, PRUint32 flags,
9403 : JSObject **objp, bool *_retval)
9404 : {
9405 0 : PRInt32 n = GetArrayIndexFromId(cx, id);
9406 0 : if (n >= 0) {
9407 : nsHTMLSelectElement *s =
9408 0 : nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
9409 :
9410 0 : nsHTMLOptionCollection *options = s->GetOptions();
9411 0 : if (options) {
9412 0 : nsISupports *node = options->GetNodeAt(n);
9413 0 : if (node) {
9414 0 : *objp = obj;
9415 : *_retval = JS_DefineElement(cx, obj, PRUint32(n), JSVAL_VOID, nsnull, nsnull,
9416 0 : JSPROP_ENUMERATE | JSPROP_SHARED);
9417 :
9418 0 : return NS_OK;
9419 : }
9420 : }
9421 : }
9422 :
9423 0 : return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
9424 : }
9425 :
9426 : NS_IMETHODIMP
9427 0 : nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9428 : JSContext *cx, JSObject *obj, jsid id,
9429 : jsval *vp, bool *_retval)
9430 : {
9431 0 : PRInt32 n = GetArrayIndexFromId(cx, id);
9432 :
9433 0 : nsresult rv = NS_OK;
9434 0 : if (n >= 0) {
9435 : nsHTMLSelectElement *s =
9436 0 : nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
9437 :
9438 0 : nsHTMLOptionCollection *options = s->GetOptions();
9439 :
9440 0 : if (options) {
9441 0 : nsISupports *node = options->GetNodeAt(n);
9442 :
9443 : rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), node,
9444 0 : &NS_GET_IID(nsIDOMNode), true, vp);
9445 0 : if (NS_SUCCEEDED(rv)) {
9446 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
9447 : }
9448 0 : return rv;
9449 : }
9450 : }
9451 :
9452 0 : return NS_OK;
9453 : }
9454 :
9455 : // static
9456 : nsresult
9457 0 : nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
9458 : nsIDOMHTMLOptionsCollection *aOptCollection)
9459 : {
9460 0 : JSAutoRequest ar(cx);
9461 :
9462 : // vp must refer to an object
9463 0 : if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) {
9464 0 : return NS_ERROR_UNEXPECTED;
9465 : }
9466 :
9467 0 : nsCOMPtr<nsIDOMHTMLOptionElement> new_option;
9468 :
9469 0 : if (!JSVAL_IS_NULL(*vp)) {
9470 0 : new_option = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
9471 0 : if (!new_option) {
9472 : // Someone is trying to set an option to a non-option object.
9473 :
9474 0 : return NS_ERROR_UNEXPECTED;
9475 : }
9476 : }
9477 :
9478 0 : return aOptCollection->SetOption(aIndex, new_option);
9479 : }
9480 :
9481 : NS_IMETHODIMP
9482 0 : nsHTMLSelectElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
9483 : JSContext *cx, JSObject *obj, jsid id,
9484 : jsval *vp, bool *_retval)
9485 : {
9486 0 : PRInt32 n = GetArrayIndexFromId(cx, id);
9487 :
9488 0 : if (n >= 0) {
9489 : nsCOMPtr<nsIDOMHTMLSelectElement> select =
9490 0 : do_QueryWrappedNative(wrapper, obj);
9491 0 : NS_ENSURE_TRUE(select, NS_ERROR_UNEXPECTED);
9492 :
9493 0 : nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
9494 0 : select->GetOptions(getter_AddRefs(options));
9495 :
9496 0 : nsresult rv = SetOption(cx, vp, n, options);
9497 0 : return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9498 : }
9499 :
9500 0 : return NS_OK;
9501 : }
9502 :
9503 :
9504 : // HTMLObject/EmbedElement helper
9505 : // Keep in mind that it is OK for this to fail to return an instance. Don't return a
9506 : // failure result unless something truly exceptional has happened.
9507 : // static
9508 : nsresult
9509 0 : nsHTMLPluginObjElementSH::GetPluginInstanceIfSafe(nsIXPConnectWrappedNative *wrapper,
9510 : JSObject *obj,
9511 : nsNPAPIPluginInstance **_result)
9512 : {
9513 0 : *_result = nsnull;
9514 :
9515 0 : nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
9516 0 : NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
9517 :
9518 0 : nsCOMPtr<nsIObjectLoadingContent> objlc(do_QueryInterface(content));
9519 0 : NS_ASSERTION(objlc, "Object nodes must implement nsIObjectLoadingContent");
9520 :
9521 0 : nsresult rv = objlc->GetPluginInstance(_result);
9522 0 : if (NS_SUCCEEDED(rv) && *_result) {
9523 0 : return rv;
9524 : }
9525 :
9526 : // If it's not safe to run script we'll only return the instance if it exists.
9527 0 : if (!nsContentUtils::IsSafeToRunScript()) {
9528 0 : return rv;
9529 : }
9530 :
9531 : // We don't care if this actually starts the plugin or not, we just want to
9532 : // try to start it now if possible.
9533 0 : objlc->SyncStartPluginInstance();
9534 :
9535 0 : return objlc->GetPluginInstance(_result);
9536 : }
9537 :
9538 : class nsPluginProtoChainInstallRunner : public nsIRunnable
9539 0 : {
9540 : public:
9541 : NS_DECL_ISUPPORTS
9542 :
9543 0 : nsPluginProtoChainInstallRunner(nsIXPConnectWrappedNative* wrapper,
9544 : nsIScriptContext* scriptContext)
9545 : : mWrapper(wrapper),
9546 0 : mContext(scriptContext)
9547 : {
9548 0 : }
9549 :
9550 0 : NS_IMETHOD Run()
9551 : {
9552 0 : JSContext* cx = nsnull;
9553 0 : if (mContext) {
9554 0 : cx = mContext->GetNativeContext();
9555 : } else {
9556 : nsCOMPtr<nsIThreadJSContextStack> stack =
9557 0 : do_GetService("@mozilla.org/js/xpc/ContextStack;1");
9558 0 : NS_ENSURE_TRUE(stack, NS_OK);
9559 :
9560 0 : stack->GetSafeJSContext(&cx);
9561 0 : NS_ENSURE_TRUE(cx, NS_OK);
9562 : }
9563 :
9564 0 : JSObject* obj = nsnull;
9565 0 : mWrapper->GetJSObject(&obj);
9566 0 : NS_ASSERTION(obj, "Should never be null");
9567 0 : nsHTMLPluginObjElementSH::SetupProtoChain(mWrapper, cx, obj);
9568 0 : return NS_OK;
9569 : }
9570 :
9571 : private:
9572 : nsCOMPtr<nsIXPConnectWrappedNative> mWrapper;
9573 : nsCOMPtr<nsIScriptContext> mContext;
9574 : };
9575 :
9576 0 : NS_IMPL_ISUPPORTS1(nsPluginProtoChainInstallRunner, nsIRunnable)
9577 :
9578 : // static
9579 : nsresult
9580 0 : nsHTMLPluginObjElementSH::SetupProtoChain(nsIXPConnectWrappedNative *wrapper,
9581 : JSContext *cx,
9582 : JSObject *obj)
9583 : {
9584 0 : NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
9585 : "Shouldn't have gotten in here");
9586 :
9587 0 : nsCxPusher cxPusher;
9588 0 : if (!cxPusher.Push(cx)) {
9589 0 : return NS_OK;
9590 : }
9591 :
9592 0 : JSAutoRequest ar(cx);
9593 :
9594 0 : JSAutoEnterCompartment ac;
9595 0 : if (!ac.enter(cx, obj)) {
9596 0 : return NS_ERROR_UNEXPECTED;
9597 : }
9598 :
9599 0 : nsRefPtr<nsNPAPIPluginInstance> pi;
9600 0 : nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9601 0 : NS_ENSURE_SUCCESS(rv, rv);
9602 :
9603 0 : if (!pi) {
9604 : // No plugin around for this object.
9605 :
9606 0 : return NS_OK;
9607 : }
9608 :
9609 0 : JSObject *pi_obj = nsnull; // XPConnect-wrapped peer object, when we get it.
9610 0 : JSObject *pi_proto = nsnull; // 'pi.__proto__'
9611 :
9612 0 : rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
9613 0 : NS_ENSURE_SUCCESS(rv, rv);
9614 :
9615 0 : if (!pi_obj) {
9616 : // Didn't get a plugin instance JSObject, nothing we can do then.
9617 0 : return NS_OK;
9618 : }
9619 :
9620 : // If we got an xpconnect-wrapped plugin object, set obj's
9621 : // prototype's prototype to the scriptable plugin.
9622 :
9623 0 : JSObject *my_proto = nsnull;
9624 :
9625 : // Get 'this.__proto__'
9626 0 : rv = wrapper->GetJSObjectPrototype(&my_proto);
9627 0 : NS_ENSURE_SUCCESS(rv, rv);
9628 :
9629 : // Set 'this.__proto__' to pi
9630 0 : if (!::JS_SetPrototype(cx, obj, pi_obj)) {
9631 0 : return NS_ERROR_UNEXPECTED;
9632 : }
9633 :
9634 0 : if (pi_proto && JS_GetClass(pi_proto) != sObjectClass) {
9635 : // The plugin wrapper has a proto that's not Object.prototype, set
9636 : // 'pi.__proto__.__proto__' to the original 'this.__proto__'
9637 0 : if (pi_proto != my_proto && !::JS_SetPrototype(cx, pi_proto, my_proto)) {
9638 0 : return NS_ERROR_UNEXPECTED;
9639 : }
9640 : } else {
9641 : // 'pi' didn't have a prototype, or pi's proto was
9642 : // 'Object.prototype' (i.e. pi is an NPRuntime wrapped JS object)
9643 : // set 'pi.__proto__' to the original 'this.__proto__'
9644 0 : if (!::JS_SetPrototype(cx, pi_obj, my_proto)) {
9645 0 : return NS_ERROR_UNEXPECTED;
9646 : }
9647 : }
9648 :
9649 : // Before this proto dance the objects involved looked like this:
9650 : //
9651 : // this.__proto__.__proto__
9652 : // ^ ^ ^
9653 : // | | |__ Object.prototype
9654 : // | |
9655 : // | |__ xpc embed wrapper proto (shared)
9656 : // |
9657 : // |__ xpc wrapped native embed node
9658 : //
9659 : // pi.__proto__
9660 : // ^ ^
9661 : // | |__ Object.prototype
9662 : // |
9663 : // |__ Plugin NPRuntime JS object wrapper
9664 : //
9665 : // Now, after the above prototype setup the prototype chain should
9666 : // look like this:
9667 : //
9668 : // this.__proto__.__proto__.__proto__
9669 : // ^ ^ ^ ^
9670 : // | | | |__ Object.prototype
9671 : // | | |
9672 : // | | |__ xpc embed wrapper proto (shared)
9673 : // | |
9674 : // | |__ Plugin NPRuntime JS object wrapper
9675 : // |
9676 : // |__ xpc wrapped native embed node
9677 : //
9678 :
9679 0 : return NS_OK;
9680 : }
9681 :
9682 : NS_IMETHODIMP
9683 0 : nsHTMLPluginObjElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
9684 : JSObject *globalObj, JSObject **parentObj)
9685 : {
9686 0 : nsresult rv = nsElementSH::PreCreate(nativeObj, cx, globalObj, parentObj);
9687 :
9688 : // For now we don't support slim wrappers for plugins.
9689 0 : return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
9690 : }
9691 :
9692 : NS_IMETHODIMP
9693 0 : nsHTMLPluginObjElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper,
9694 : JSContext *cx, JSObject *obj)
9695 : {
9696 0 : if (nsContentUtils::IsSafeToRunScript()) {
9697 : #ifdef DEBUG
9698 : nsresult rv =
9699 : #endif
9700 0 : SetupProtoChain(wrapper, cx, obj);
9701 :
9702 : // If SetupProtoChain failed then we're in real trouble. We're about to fail
9703 : // PostCreate but it's more than likely that we handed our (now invalid)
9704 : // wrapper to someone already. Bug 429442 is an example of the kind of crash
9705 : // that can result from such a situation. We'll return NS_OK for the time
9706 : // being and hope for the best.
9707 0 : NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "SetupProtoChain failed!");
9708 0 : return NS_OK;
9709 : }
9710 :
9711 : // This may be null if the JS context is not a DOM context. That's ok, we'll
9712 : // use the safe context from XPConnect in the runnable.
9713 0 : nsCOMPtr<nsIScriptContext> scriptContext = GetScriptContextFromJSContext(cx);
9714 :
9715 : nsRefPtr<nsPluginProtoChainInstallRunner> runner =
9716 0 : new nsPluginProtoChainInstallRunner(wrapper, scriptContext);
9717 0 : nsContentUtils::AddScriptRunner(runner);
9718 :
9719 0 : return NS_OK;
9720 : }
9721 :
9722 : NS_IMETHODIMP
9723 0 : nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9724 : JSContext *cx, JSObject *obj, jsid id,
9725 : jsval *vp, bool *_retval)
9726 : {
9727 0 : JSAutoRequest ar(cx);
9728 :
9729 0 : JSObject *pi_obj = ::JS_GetPrototype(obj);
9730 0 : if (NS_UNLIKELY(!pi_obj)) {
9731 0 : return NS_OK;
9732 : }
9733 :
9734 0 : JSBool found = false;
9735 :
9736 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
9737 0 : *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
9738 0 : if (!*_retval) {
9739 0 : return NS_ERROR_UNEXPECTED;
9740 : }
9741 : }
9742 :
9743 0 : if (found) {
9744 0 : *_retval = ::JS_GetPropertyById(cx, pi_obj, id, vp);
9745 0 : return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
9746 : }
9747 :
9748 0 : return NS_OK;
9749 : }
9750 :
9751 : NS_IMETHODIMP
9752 0 : nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
9753 : JSContext *cx, JSObject *obj, jsid id,
9754 : jsval *vp, bool *_retval)
9755 : {
9756 0 : JSAutoRequest ar(cx);
9757 :
9758 0 : JSObject *pi_obj = ::JS_GetPrototype(obj);
9759 0 : if (NS_UNLIKELY(!pi_obj)) {
9760 0 : return NS_OK;
9761 : }
9762 :
9763 0 : JSBool found = false;
9764 :
9765 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
9766 0 : *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
9767 0 : if (!*_retval) {
9768 0 : return NS_ERROR_UNEXPECTED;
9769 : }
9770 : }
9771 :
9772 0 : if (found) {
9773 0 : *_retval = ::JS_SetPropertyById(cx, pi_obj, id, vp);
9774 0 : return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
9775 : }
9776 :
9777 0 : return NS_OK;
9778 : }
9779 :
9780 : NS_IMETHODIMP
9781 0 : nsHTMLPluginObjElementSH::Call(nsIXPConnectWrappedNative *wrapper,
9782 : JSContext *cx, JSObject *obj, PRUint32 argc,
9783 : jsval *argv, jsval *vp, bool *_retval)
9784 : {
9785 0 : nsRefPtr<nsNPAPIPluginInstance> pi;
9786 0 : nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9787 0 : NS_ENSURE_SUCCESS(rv, rv);
9788 :
9789 : // If obj is a native wrapper, or if there's no plugin around for
9790 : // this object, throw.
9791 0 : if (ObjectIsNativeWrapper(cx, obj) || !pi) {
9792 0 : return NS_ERROR_NOT_AVAILABLE;
9793 : }
9794 :
9795 0 : JSObject *pi_obj = nsnull;
9796 0 : JSObject *pi_proto = nsnull;
9797 :
9798 0 : rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
9799 0 : NS_ENSURE_SUCCESS(rv, rv);
9800 :
9801 0 : if (!pi) {
9802 0 : return NS_ERROR_NOT_AVAILABLE;
9803 : }
9804 :
9805 : // XPConnect passes us the XPConnect wrapper JSObject as obj, and
9806 : // not the 'this' parameter that the JS engine passes in. Pass in
9807 : // the real this parameter from JS (argv[-1]) here.
9808 0 : JSAutoRequest ar(cx);
9809 0 : *_retval = ::JS::Call(cx, argv[-1], pi_obj, argc, argv, vp);
9810 :
9811 0 : return NS_OK;
9812 : }
9813 :
9814 :
9815 : nsresult
9816 0 : nsHTMLPluginObjElementSH::GetPluginJSObject(JSContext *cx, JSObject *obj,
9817 : nsNPAPIPluginInstance *plugin_inst,
9818 : JSObject **plugin_obj,
9819 : JSObject **plugin_proto)
9820 : {
9821 0 : *plugin_obj = nsnull;
9822 0 : *plugin_proto = nsnull;
9823 :
9824 0 : JSAutoRequest ar(cx);
9825 :
9826 : // NB: We need an AutoEnterCompartment because we can be called from
9827 : // nsObjectFrame when the plugin loads after the JS object for our content
9828 : // node has been created.
9829 0 : JSAutoEnterCompartment ac;
9830 0 : if (!ac.enter(cx, obj)) {
9831 0 : return NS_ERROR_UNEXPECTED;
9832 : }
9833 :
9834 0 : if (plugin_inst) {
9835 0 : plugin_inst->GetJSObject(cx, plugin_obj);
9836 0 : if (*plugin_obj) {
9837 0 : *plugin_proto = ::JS_GetPrototype(*plugin_obj);
9838 : }
9839 : }
9840 :
9841 0 : return NS_OK;
9842 : }
9843 :
9844 : NS_IMETHODIMP
9845 0 : nsHTMLPluginObjElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
9846 : JSContext *cx, JSObject *obj, jsid id,
9847 : PRUint32 flags, JSObject **objp,
9848 : bool *_retval)
9849 : {
9850 : // Make sure the plugin instance is loaded and instantiated, if
9851 : // possible.
9852 :
9853 0 : nsRefPtr<nsNPAPIPluginInstance> pi;
9854 0 : nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9855 0 : NS_ENSURE_SUCCESS(rv, rv);
9856 :
9857 : return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp,
9858 0 : _retval);
9859 : }
9860 :
9861 : // Plugin helper
9862 :
9863 : nsISupports*
9864 0 : nsPluginSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9865 : nsWrapperCache **aCache, nsresult *aResult)
9866 : {
9867 0 : nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
9868 :
9869 0 : return plugin->GetItemAt(aIndex, aResult);
9870 : }
9871 :
9872 : nsISupports*
9873 0 : nsPluginSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9874 : nsWrapperCache **aCache, nsresult *aResult)
9875 : {
9876 0 : nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
9877 :
9878 0 : return plugin->GetNamedItem(aName, aResult);
9879 : }
9880 :
9881 :
9882 : // PluginArray helper
9883 :
9884 : nsISupports*
9885 0 : nsPluginArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9886 : nsWrapperCache **aCache, nsresult *aResult)
9887 : {
9888 0 : nsPluginArray* array = nsPluginArray::FromSupports(aNative);
9889 :
9890 0 : return array->GetItemAt(aIndex, aResult);
9891 : }
9892 :
9893 : nsISupports*
9894 0 : nsPluginArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9895 : nsWrapperCache **aCache, nsresult *aResult)
9896 : {
9897 0 : nsPluginArray* array = nsPluginArray::FromSupports(aNative);
9898 :
9899 0 : return array->GetNamedItem(aName, aResult);
9900 : }
9901 :
9902 :
9903 : // MimeTypeArray helper
9904 :
9905 : nsISupports*
9906 0 : nsMimeTypeArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9907 : nsWrapperCache **aCache, nsresult *aResult)
9908 : {
9909 0 : nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
9910 :
9911 0 : return array->GetItemAt(aIndex, aResult);
9912 : }
9913 :
9914 : nsISupports*
9915 0 : nsMimeTypeArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9916 : nsWrapperCache **aCache, nsresult *aResult)
9917 : {
9918 0 : nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
9919 :
9920 0 : return array->GetNamedItem(aName, aResult);
9921 : }
9922 :
9923 :
9924 : // StringArray helper
9925 :
9926 : NS_IMETHODIMP
9927 2 : nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9928 : JSObject *obj, jsid id, jsval *vp,
9929 : bool *_retval)
9930 : {
9931 2 : bool is_number = false;
9932 2 : PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
9933 :
9934 2 : if (!is_number) {
9935 0 : return NS_OK;
9936 : }
9937 :
9938 4 : nsAutoString val;
9939 :
9940 2 : nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
9941 2 : NS_ENSURE_SUCCESS(rv, rv);
9942 :
9943 4 : JSAutoRequest ar(cx);
9944 :
9945 2 : if (DOMStringIsNull(val)) {
9946 0 : *vp = JSVAL_VOID;
9947 : } else {
9948 2 : nsStringBuffer* sharedBuffer = nsnull;
9949 2 : *vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer);
9950 2 : if (sharedBuffer) {
9951 2 : val.ForgetSharedBuffer();
9952 : }
9953 : }
9954 :
9955 2 : return NS_SUCCESS_I_DID_SOMETHING;
9956 : }
9957 :
9958 :
9959 : // History helper
9960 :
9961 : NS_IMETHODIMP
9962 0 : nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,
9963 : JSObject *globalObj, JSObject **parentObj)
9964 : {
9965 0 : nsHistory *history = (nsHistory *)((nsIDOMHistory*)nativeObj);
9966 0 : nsCOMPtr<nsPIDOMWindow> innerWindow;
9967 0 : history->GetWindow(getter_AddRefs(innerWindow));
9968 0 : if (!innerWindow) {
9969 0 : NS_WARNING("refusing to create history object in the wrong scope");
9970 0 : return NS_ERROR_FAILURE;
9971 : }
9972 :
9973 0 : *parentObj = static_cast<nsGlobalWindow *>(innerWindow.get())->FastGetGlobalJSObject();
9974 0 : return NS_OK;
9975 : }
9976 :
9977 : NS_IMETHODIMP
9978 0 : nsHistorySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9979 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
9980 : {
9981 0 : bool is_number = false;
9982 0 : GetArrayIndexFromId(cx, id, &is_number);
9983 :
9984 0 : if (!is_number) {
9985 0 : return NS_OK;
9986 : }
9987 :
9988 0 : return nsStringArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
9989 : }
9990 :
9991 : nsresult
9992 0 : nsHistorySH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
9993 : nsAString& aResult)
9994 : {
9995 0 : if (aIndex < 0) {
9996 0 : return NS_ERROR_DOM_INDEX_SIZE_ERR;
9997 : }
9998 :
9999 0 : nsCOMPtr<nsIDOMHistory> history(do_QueryInterface(aNative));
10000 :
10001 0 : nsresult rv = history->Item(aIndex, aResult);
10002 : #ifdef DEBUG
10003 0 : if (DOMStringIsNull(aResult)) {
10004 0 : PRInt32 length = 0;
10005 0 : history->GetLength(&length);
10006 0 : NS_ASSERTION(aIndex >= length, "Item should only return null for out-of-bounds access");
10007 : }
10008 : #endif
10009 0 : return rv;
10010 : }
10011 :
10012 :
10013 : // MediaList helper
10014 :
10015 : nsresult
10016 0 : nsMediaListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10017 : nsAString& aResult)
10018 : {
10019 0 : if (aIndex < 0) {
10020 0 : return NS_ERROR_DOM_INDEX_SIZE_ERR;
10021 : }
10022 :
10023 0 : nsCOMPtr<nsIDOMMediaList> media_list(do_QueryInterface(aNative));
10024 :
10025 0 : nsresult rv = media_list->Item(PRUint32(aIndex), aResult);
10026 : #ifdef DEBUG
10027 0 : if (DOMStringIsNull(aResult)) {
10028 0 : PRUint32 length = 0;
10029 0 : media_list->GetLength(&length);
10030 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
10031 : }
10032 : #endif
10033 0 : return rv;
10034 : }
10035 :
10036 :
10037 : // StyleSheetList helper
10038 :
10039 : nsISupports*
10040 0 : nsStyleSheetListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10041 : nsWrapperCache **aCache, nsresult *rv)
10042 : {
10043 0 : nsDOMStyleSheetList* list = nsDOMStyleSheetList::FromSupports(aNative);
10044 :
10045 0 : return list->GetItemAt(aIndex);
10046 : }
10047 :
10048 :
10049 : // CSSValueList helper
10050 :
10051 : nsISupports*
10052 0 : nsCSSValueListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10053 : nsWrapperCache **aCache, nsresult *aResult)
10054 : {
10055 0 : nsDOMCSSValueList* list = nsDOMCSSValueList::FromSupports(aNative);
10056 :
10057 0 : return list->GetItemAt(aIndex);
10058 : }
10059 :
10060 :
10061 : // CSSStyleDeclaration helper
10062 :
10063 : NS_IMETHODIMP
10064 0 : nsCSSStyleDeclSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
10065 : JSObject *globalObj, JSObject **parentObj)
10066 : {
10067 0 : nsWrapperCache* cache = nsnull;
10068 0 : CallQueryInterface(nativeObj, &cache);
10069 0 : if (!cache) {
10070 0 : return nsDOMClassInfo::PreCreate(nativeObj, cx, globalObj, parentObj);
10071 : }
10072 :
10073 0 : nsICSSDeclaration *declaration = static_cast<nsICSSDeclaration*>(nativeObj);
10074 0 : nsINode *native_parent = declaration->GetParentObject();
10075 0 : if (!native_parent) {
10076 0 : return NS_ERROR_FAILURE;
10077 : }
10078 :
10079 : nsresult rv =
10080 0 : WrapNativeParent(cx, globalObj, native_parent, native_parent, parentObj);
10081 0 : NS_ENSURE_SUCCESS(rv, rv);
10082 :
10083 0 : return NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
10084 : }
10085 :
10086 : nsresult
10087 0 : nsCSSStyleDeclSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10088 : nsAString& aResult)
10089 : {
10090 0 : if (aIndex < 0) {
10091 0 : return NS_ERROR_DOM_INDEX_SIZE_ERR;
10092 : }
10093 :
10094 0 : nsCOMPtr<nsIDOMCSSStyleDeclaration> style_decl(do_QueryInterface(aNative));
10095 :
10096 0 : nsresult rv = style_decl->Item(PRUint32(aIndex), aResult);
10097 : #ifdef DEBUG
10098 0 : if (DOMStringIsNull(aResult)) {
10099 0 : PRUint32 length = 0;
10100 0 : style_decl->GetLength(&length);
10101 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
10102 : }
10103 : #endif
10104 0 : return rv;
10105 : }
10106 :
10107 :
10108 : // CSSRuleList scriptable helper
10109 :
10110 : nsISupports*
10111 0 : nsCSSRuleListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10112 : nsWrapperCache **aCache, nsresult *aResult)
10113 : {
10114 0 : nsICSSRuleList* list = static_cast<nsICSSRuleList*>(aNative);
10115 : #ifdef DEBUG
10116 : {
10117 0 : nsCOMPtr<nsICSSRuleList> list_qi = do_QueryInterface(aNative);
10118 :
10119 : // If this assertion fires the QI implementation for the object in
10120 : // question doesn't use the nsICSSRuleList pointer as the nsISupports
10121 : // pointer. That must be fixed, or we'll crash...
10122 0 : NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
10123 : }
10124 : #endif
10125 :
10126 0 : return list->GetItemAt(aIndex, aResult);
10127 : }
10128 :
10129 : // ClientRectList scriptable helper
10130 :
10131 : nsISupports*
10132 0 : nsClientRectListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10133 : nsWrapperCache **aCache, nsresult *aResult)
10134 : {
10135 0 : nsClientRectList* list = nsClientRectList::FromSupports(aNative);
10136 :
10137 0 : return list->GetItemAt(aIndex);
10138 : }
10139 :
10140 : // PaintRequestList scriptable helper
10141 :
10142 : nsISupports*
10143 0 : nsPaintRequestListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10144 : nsWrapperCache **aCache, nsresult *aResult)
10145 : {
10146 0 : nsPaintRequestList* list = nsPaintRequestList::FromSupports(aNative);
10147 :
10148 0 : return list->GetItemAt(aIndex);
10149 : }
10150 :
10151 : nsISupports*
10152 0 : nsDOMTouchListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10153 : nsWrapperCache **aCache, nsresult *aResult)
10154 : {
10155 0 : nsDOMTouchList* list = static_cast<nsDOMTouchList*>(aNative);
10156 0 : return list->GetItemAt(aIndex);
10157 : }
10158 :
10159 : #ifdef MOZ_XUL
10160 : // TreeColumns helper
10161 :
10162 : nsISupports*
10163 0 : nsTreeColumnsSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10164 : nsWrapperCache **aCache, nsresult *aResult)
10165 : {
10166 0 : nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
10167 :
10168 0 : return columns->GetColumnAt(aIndex);
10169 : }
10170 :
10171 : nsISupports*
10172 0 : nsTreeColumnsSH::GetNamedItem(nsISupports *aNative,
10173 : const nsAString& aName,
10174 : nsWrapperCache **aCache,
10175 : nsresult *aResult)
10176 : {
10177 0 : nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
10178 :
10179 0 : return columns->GetNamedColumn(aName);
10180 : }
10181 : #endif
10182 :
10183 :
10184 : // Storage scriptable helper
10185 :
10186 : // One reason we need a newResolve hook is that in order for
10187 : // enumeration of storage object keys to work the keys we're
10188 : // enumerating need to exist on the storage object for the JS engine
10189 : // to find them.
10190 :
10191 : NS_IMETHODIMP
10192 0 : nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10193 : JSObject *obj, jsid id, PRUint32 flags,
10194 : JSObject **objp, bool *_retval)
10195 : {
10196 0 : if (ObjectIsNativeWrapper(cx, obj)) {
10197 0 : return NS_OK;
10198 : }
10199 :
10200 : JSObject *realObj;
10201 0 : wrapper->GetJSObject(&realObj);
10202 :
10203 0 : JSAutoEnterCompartment ac;
10204 0 : if (!ac.enter(cx, realObj)) {
10205 0 : *_retval = false;
10206 0 : return NS_ERROR_FAILURE;
10207 : }
10208 :
10209 : // First check to see if the property is defined on our prototype.
10210 :
10211 0 : JSObject *proto = ::JS_GetPrototype(realObj);
10212 : JSBool hasProp;
10213 :
10214 0 : if (proto &&
10215 0 : (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
10216 : hasProp)) {
10217 : // We found the property we're resolving on the prototype,
10218 : // nothing left to do here then.
10219 :
10220 0 : return NS_OK;
10221 : }
10222 :
10223 : // We're resolving property that doesn't exist on the prototype,
10224 : // check if the key exists in the storage object.
10225 :
10226 0 : nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10227 :
10228 0 : JSString *jsstr = IdToString(cx, id);
10229 0 : if (!jsstr)
10230 0 : return JS_FALSE;
10231 :
10232 0 : nsDependentJSString depStr;
10233 0 : if (!depStr.init(cx, jsstr))
10234 0 : return JS_FALSE;
10235 :
10236 : // GetItem() will return null if the caller can't access the session
10237 : // storage item.
10238 0 : nsCOMPtr<nsIDOMStorageItem> item;
10239 0 : nsresult rv = storage->GetItem(depStr, getter_AddRefs(item));
10240 0 : NS_ENSURE_SUCCESS(rv, rv);
10241 :
10242 0 : if (item) {
10243 0 : if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull, nsnull,
10244 0 : JSPROP_ENUMERATE)) {
10245 0 : return NS_ERROR_FAILURE;
10246 : }
10247 :
10248 0 : *objp = realObj;
10249 : }
10250 :
10251 0 : return NS_OK;
10252 : }
10253 :
10254 : nsISupports*
10255 0 : nsStorageSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
10256 : nsWrapperCache **aCache, nsresult *aResult)
10257 : {
10258 0 : nsDOMStorage* storage = nsDOMStorage::FromSupports(aNative);
10259 :
10260 0 : return storage->GetNamedItem(aName, aResult);
10261 : }
10262 :
10263 : NS_IMETHODIMP
10264 0 : nsStorageSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
10265 : JSContext *cx, JSObject *obj, jsid id,
10266 : jsval *vp, bool *_retval)
10267 : {
10268 0 : nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10269 0 : NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10270 :
10271 0 : JSString *key = IdToString(cx, id);
10272 0 : NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10273 :
10274 0 : nsDependentJSString keyStr;
10275 0 : NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10276 :
10277 0 : JSString *value = ::JS_ValueToString(cx, *vp);
10278 0 : NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
10279 :
10280 0 : nsDependentJSString valueStr;
10281 0 : NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
10282 :
10283 0 : nsresult rv = storage->SetItem(keyStr, valueStr);
10284 0 : if (NS_SUCCEEDED(rv)) {
10285 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
10286 : }
10287 :
10288 0 : return rv;
10289 : }
10290 :
10291 : NS_IMETHODIMP
10292 0 : nsStorageSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
10293 : JSContext *cx, JSObject *obj, jsid id,
10294 : jsval *vp, bool *_retval)
10295 : {
10296 0 : nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10297 0 : NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10298 :
10299 0 : JSString *key = IdToString(cx, id);
10300 0 : NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10301 :
10302 0 : nsDependentJSString keyStr;
10303 0 : NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10304 :
10305 0 : nsresult rv = storage->RemoveItem(keyStr);
10306 0 : if (NS_SUCCEEDED(rv)) {
10307 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
10308 : }
10309 :
10310 0 : return rv;
10311 : }
10312 :
10313 :
10314 : NS_IMETHODIMP
10315 0 : nsStorageSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10316 : JSObject *obj, PRUint32 enum_op, jsval *statep,
10317 : jsid *idp, bool *_retval)
10318 : {
10319 0 : if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
10320 0 : nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10321 :
10322 : // XXXndeakin need to free the keys afterwards
10323 0 : nsTArray<nsString> *keys = storage->GetKeys();
10324 0 : NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
10325 :
10326 0 : *statep = PRIVATE_TO_JSVAL(keys);
10327 :
10328 0 : if (idp) {
10329 0 : *idp = INT_TO_JSID(keys->Length());
10330 : }
10331 0 : return NS_OK;
10332 : }
10333 :
10334 : nsTArray<nsString> *keys =
10335 0 : (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
10336 :
10337 0 : if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
10338 0 : nsString& key = keys->ElementAt(0);
10339 : JSString *str =
10340 : JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
10341 0 : (key.get()),
10342 0 : key.Length());
10343 0 : NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10344 :
10345 0 : JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
10346 :
10347 0 : keys->RemoveElementAt(0);
10348 :
10349 0 : return NS_OK;
10350 : }
10351 :
10352 : // destroy the keys array if we have no keys or if we're done
10353 0 : NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
10354 : (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
10355 : "Bad call from the JS engine");
10356 0 : delete keys;
10357 :
10358 0 : *statep = JSVAL_NULL;
10359 :
10360 0 : return NS_OK;
10361 : }
10362 :
10363 :
10364 : // Storage2SH
10365 :
10366 : // One reason we need a newResolve hook is that in order for
10367 : // enumeration of storage object keys to work the keys we're
10368 : // enumerating need to exist on the storage object for the JS engine
10369 : // to find them.
10370 :
10371 : NS_IMETHODIMP
10372 73 : nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10373 : JSObject *obj, jsid id, PRUint32 flags,
10374 : JSObject **objp, bool *_retval)
10375 : {
10376 73 : if (ObjectIsNativeWrapper(cx, obj)) {
10377 0 : return NS_OK;
10378 : }
10379 :
10380 : JSObject *realObj;
10381 73 : wrapper->GetJSObject(&realObj);
10382 :
10383 146 : JSAutoEnterCompartment ac;
10384 73 : if (!ac.enter(cx, realObj)) {
10385 0 : *_retval = false;
10386 0 : return NS_ERROR_FAILURE;
10387 : }
10388 :
10389 : // First check to see if the property is defined on our prototype,
10390 : // after converting id to a string if it's an integer.
10391 :
10392 73 : JSString *jsstr = IdToString(cx, id);
10393 73 : if (!jsstr) {
10394 0 : return JS_FALSE;
10395 : }
10396 :
10397 73 : JSObject *proto = ::JS_GetPrototype(realObj);
10398 : JSBool hasProp;
10399 :
10400 146 : if (proto &&
10401 73 : (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
10402 : hasProp)) {
10403 : // We found the property we're resolving on the prototype,
10404 : // nothing left to do here then.
10405 :
10406 73 : return NS_OK;
10407 : }
10408 :
10409 : // We're resolving property that doesn't exist on the prototype,
10410 : // check if the key exists in the storage object.
10411 :
10412 0 : nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10413 :
10414 0 : nsDependentJSString depStr;
10415 0 : NS_ENSURE_TRUE(depStr.init(cx, jsstr), NS_ERROR_UNEXPECTED);
10416 :
10417 : // GetItem() will return null if the caller can't access the session
10418 : // storage item.
10419 0 : nsAutoString data;
10420 0 : nsresult rv = storage->GetItem(depStr, data);
10421 0 : NS_ENSURE_SUCCESS(rv, rv);
10422 :
10423 0 : if (!DOMStringIsNull(data)) {
10424 0 : if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull,
10425 0 : nsnull, JSPROP_ENUMERATE)) {
10426 0 : return NS_ERROR_FAILURE;
10427 : }
10428 :
10429 0 : *objp = realObj;
10430 : }
10431 :
10432 0 : return NS_OK;
10433 : }
10434 :
10435 : NS_IMETHODIMP
10436 0 : nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10437 : JSObject *obj, jsid id, jsval *vp, bool *_retval)
10438 : {
10439 0 : nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10440 0 : NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10441 :
10442 0 : nsAutoString val;
10443 0 : nsresult rv = NS_OK;
10444 :
10445 0 : if (JSID_IS_STRING(id)) {
10446 : // For native wrappers, do not get random names on storage objects.
10447 0 : if (ObjectIsNativeWrapper(cx, obj)) {
10448 0 : return NS_ERROR_NOT_AVAILABLE;
10449 : }
10450 :
10451 0 : rv = storage->GetItem(nsDependentJSString(id), val);
10452 0 : NS_ENSURE_SUCCESS(rv, rv);
10453 : } else {
10454 0 : PRInt32 n = GetArrayIndexFromId(cx, id);
10455 0 : NS_ENSURE_TRUE(n >= 0, NS_ERROR_NOT_AVAILABLE);
10456 :
10457 0 : rv = storage->Key(n, val);
10458 0 : NS_ENSURE_SUCCESS(rv, rv);
10459 : }
10460 :
10461 0 : JSAutoRequest ar(cx);
10462 :
10463 0 : if (DOMStringIsNull(val)) {
10464 0 : *vp = JSVAL_NULL;
10465 : }
10466 : else {
10467 : JSString *str =
10468 0 : ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(val.get()),
10469 0 : val.Length());
10470 0 : NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10471 :
10472 0 : *vp = STRING_TO_JSVAL(str);
10473 : }
10474 :
10475 0 : return NS_SUCCESS_I_DID_SOMETHING;
10476 : }
10477 :
10478 : NS_IMETHODIMP
10479 0 : nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
10480 : JSContext *cx, JSObject *obj, jsid id,
10481 : jsval *vp, bool *_retval)
10482 : {
10483 0 : nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10484 0 : NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10485 :
10486 0 : JSString *key = IdToString(cx, id);
10487 0 : NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10488 :
10489 0 : nsDependentJSString keyStr;
10490 0 : NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10491 :
10492 0 : JSString *value = ::JS_ValueToString(cx, *vp);
10493 0 : NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
10494 :
10495 0 : nsDependentJSString valueStr;
10496 0 : NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
10497 :
10498 0 : nsresult rv = storage->SetItem(keyStr, valueStr);
10499 0 : if (NS_SUCCEEDED(rv)) {
10500 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
10501 : }
10502 :
10503 0 : return rv;
10504 : }
10505 :
10506 : NS_IMETHODIMP
10507 0 : nsStorage2SH::DelProperty(nsIXPConnectWrappedNative *wrapper,
10508 : JSContext *cx, JSObject *obj, jsid id,
10509 : jsval *vp, bool *_retval)
10510 : {
10511 0 : nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10512 0 : NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10513 :
10514 0 : JSString *key = IdToString(cx, id);
10515 0 : NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10516 :
10517 0 : nsDependentJSString keyStr;
10518 0 : NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10519 :
10520 0 : nsresult rv = storage->RemoveItem(keyStr);
10521 0 : if (NS_SUCCEEDED(rv)) {
10522 0 : rv = NS_SUCCESS_I_DID_SOMETHING;
10523 : }
10524 :
10525 0 : return rv;
10526 : }
10527 :
10528 :
10529 : NS_IMETHODIMP
10530 0 : nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10531 : JSObject *obj, PRUint32 enum_op, jsval *statep,
10532 : jsid *idp, bool *_retval)
10533 : {
10534 0 : if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
10535 0 : nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10536 :
10537 : // XXXndeakin need to free the keys afterwards
10538 0 : nsTArray<nsString> *keys = storage->GetKeys();
10539 0 : NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
10540 :
10541 0 : *statep = PRIVATE_TO_JSVAL(keys);
10542 :
10543 0 : if (idp) {
10544 0 : *idp = INT_TO_JSID(keys->Length());
10545 : }
10546 0 : return NS_OK;
10547 : }
10548 :
10549 : nsTArray<nsString> *keys =
10550 0 : (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
10551 :
10552 0 : if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
10553 0 : nsString& key = keys->ElementAt(0);
10554 : JSString *str =
10555 : JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
10556 0 : (key.get()),
10557 0 : key.Length());
10558 0 : NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10559 :
10560 0 : JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
10561 :
10562 0 : keys->RemoveElementAt(0);
10563 :
10564 0 : return NS_OK;
10565 : }
10566 :
10567 : // destroy the keys array if we have no keys or if we're done
10568 0 : NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
10569 : (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
10570 : "Bad call from the JS engine");
10571 0 : delete keys;
10572 :
10573 0 : *statep = JSVAL_NULL;
10574 :
10575 0 : return NS_OK;
10576 : }
10577 :
10578 : // StorageList scriptable helper
10579 :
10580 : nsISupports*
10581 0 : nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
10582 : nsWrapperCache **aCache, nsresult *aResult)
10583 : {
10584 0 : nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
10585 :
10586 0 : return storagelist->GetNamedItem(aName, aResult);
10587 : }
10588 :
10589 :
10590 : // nsIDOMEventListener::HandleEvent() 'this' converter helper
10591 :
10592 305 : NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
10593 305 : NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
10594 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
10595 0 : NS_INTERFACE_MAP_END
10596 :
10597 :
10598 915 : NS_IMPL_ADDREF(nsEventListenerThisTranslator)
10599 914 : NS_IMPL_RELEASE(nsEventListenerThisTranslator)
10600 :
10601 :
10602 : NS_IMETHODIMP
10603 4144 : nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
10604 : nsIInterfaceInfo *aInterfaceInfo,
10605 : PRUint16 aMethodIndex,
10606 : bool *aHideFirstParamFromJS,
10607 : nsIID * *aIIDOfResult,
10608 : nsISupports **_retval)
10609 : {
10610 4144 : *aHideFirstParamFromJS = false;
10611 4144 : *aIIDOfResult = nsnull;
10612 :
10613 8288 : nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
10614 4144 : NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
10615 :
10616 8288 : nsCOMPtr<nsIDOMEventTarget> target;
10617 4144 : event->GetCurrentTarget(getter_AddRefs(target));
10618 :
10619 4144 : *_retval = target.forget().get();
10620 :
10621 4144 : return NS_OK;
10622 : }
10623 :
10624 : NS_IMETHODIMP
10625 0 : nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
10626 : JSObject *globalObj, JSObject **parentObj)
10627 : {
10628 0 : nsDOMConstructor *wrapped = static_cast<nsDOMConstructor *>(nativeObj);
10629 :
10630 : #ifdef DEBUG
10631 : {
10632 : nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10633 0 : do_QueryInterface(nativeObj);
10634 0 : NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10635 : }
10636 : #endif
10637 :
10638 0 : return wrapped->PreCreate(cx, globalObj, parentObj);
10639 : }
10640 :
10641 : NS_IMETHODIMP
10642 0 : nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10643 : JSObject *obj, jsid id, PRUint32 flags,
10644 : JSObject **objp, bool *_retval)
10645 : {
10646 : // For regular DOM constructors, we have our interface constants defined on
10647 : // us by nsWindowSH::GlobalResolve. However, XrayWrappers can't see these
10648 : // interface constants (as they look like expando properties) so we have to
10649 : // specially resolve those constants here, but only for Xray wrappers.
10650 0 : if (!ObjectIsNativeWrapper(cx, obj)) {
10651 0 : return NS_OK;
10652 : }
10653 :
10654 0 : JSObject *nativePropsObj = xpc::XrayUtils::GetNativePropertiesObject(cx, obj);
10655 : nsDOMConstructor *wrapped =
10656 0 : static_cast<nsDOMConstructor *>(wrapper->Native());
10657 0 : nsresult rv = wrapped->ResolveInterfaceConstants(cx, nativePropsObj);
10658 0 : NS_ENSURE_SUCCESS(rv, rv);
10659 :
10660 : // Now re-lookup the ID to see if we should report back that we resolved the
10661 : // looked-for constant. Note that we don't have to worry about infinitely
10662 : // recurring back here because the Xray wrapper's holder object doesn't call
10663 : // NewResolve hooks.
10664 : JSBool found;
10665 0 : if (!JS_HasPropertyById(cx, nativePropsObj, id, &found)) {
10666 0 : *_retval = PR_FALSE;
10667 0 : return NS_OK;
10668 : }
10669 :
10670 0 : if (found) {
10671 0 : *objp = obj;
10672 : }
10673 0 : return NS_OK;
10674 : }
10675 :
10676 : NS_IMETHODIMP
10677 0 : nsDOMConstructorSH::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10678 : JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
10679 : bool *_retval)
10680 : {
10681 : nsDOMConstructor *wrapped =
10682 0 : static_cast<nsDOMConstructor *>(wrapper->Native());
10683 :
10684 : #ifdef DEBUG
10685 : {
10686 : nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10687 0 : do_QueryWrappedNative(wrapper);
10688 0 : NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10689 : }
10690 : #endif
10691 :
10692 0 : return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
10693 : }
10694 :
10695 : NS_IMETHODIMP
10696 0 : nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10697 : JSObject *obj, PRUint32 argc, jsval *argv,
10698 : jsval *vp, bool *_retval)
10699 : {
10700 : nsDOMConstructor *wrapped =
10701 0 : static_cast<nsDOMConstructor *>(wrapper->Native());
10702 :
10703 : #ifdef DEBUG
10704 : {
10705 : nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10706 0 : do_QueryWrappedNative(wrapper);
10707 0 : NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10708 : }
10709 : #endif
10710 :
10711 0 : return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
10712 : }
10713 :
10714 : NS_IMETHODIMP
10715 0 : nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
10716 : JSContext *cx, JSObject *obj, const jsval &val,
10717 : bool *bp, bool *_retval)
10718 : {
10719 : nsDOMConstructor *wrapped =
10720 0 : static_cast<nsDOMConstructor *>(wrapper->Native());
10721 :
10722 : #ifdef DEBUG
10723 : {
10724 : nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10725 0 : do_QueryWrappedNative(wrapper);
10726 0 : NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10727 : }
10728 : #endif
10729 :
10730 0 : return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
10731 : }
10732 :
10733 : NS_IMETHODIMP
10734 0 : nsNonDOMObjectSH::GetFlags(PRUint32 *aFlags)
10735 : {
10736 : // This is NOT a DOM Object. Use this helper class for cases when you need
10737 : // to do something like implement nsISecurityCheckedComponent in a meaningful
10738 : // way.
10739 0 : *aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
10740 0 : return NS_OK;
10741 : }
10742 :
10743 : NS_IMETHODIMP
10744 996 : nsAttributeSH::GetFlags(PRUint32 *aFlags)
10745 : {
10746 : // Just like nsNodeSH, but without CONTENT_NODE
10747 996 : *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
10748 :
10749 996 : return NS_OK;
10750 : }
10751 :
10752 : // nsOfflineResourceListSH
10753 : nsresult
10754 0 : nsOfflineResourceListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10755 : nsAString& aResult)
10756 : {
10757 0 : nsCOMPtr<nsIDOMOfflineResourceList> list(do_QueryInterface(aNative));
10758 0 : NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
10759 :
10760 0 : nsresult rv = list->MozItem(aIndex, aResult);
10761 : #ifdef DEBUG
10762 0 : if (DOMStringIsNull(aResult)) {
10763 0 : PRUint32 length = 0;
10764 0 : list->GetMozLength(&length);
10765 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "MozItem should only return null for out-of-bounds access");
10766 : }
10767 : #endif
10768 0 : return rv;
10769 : }
10770 :
10771 : // nsFileListSH
10772 : nsISupports*
10773 0 : nsFileListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10774 : nsWrapperCache **aCache, nsresult *aResult)
10775 : {
10776 0 : nsDOMFileList* list = nsDOMFileList::FromSupports(aNative);
10777 :
10778 0 : return list->GetItemAt(aIndex);
10779 : }
10780 :
10781 : // Template for SVGXXXList helpers
10782 : template<class ListInterfaceType, class ListType> nsISupports*
10783 : nsSVGListSH<ListInterfaceType, ListType>::GetItemAt(nsISupports *aNative,
10784 : PRUint32 aIndex,
10785 : nsWrapperCache **aCache,
10786 : nsresult *aResult)
10787 : {
10788 0 : ListType* list = static_cast<ListType*>(static_cast<ListInterfaceType*>(aNative));
10789 : #ifdef DEBUG
10790 : {
10791 0 : nsCOMPtr<ListInterfaceType> list_qi = do_QueryInterface(aNative);
10792 :
10793 : // If this assertion fires the QI implementation for the object in
10794 : // question doesn't use the nsIDOMSVGXXXList pointer as the nsISupports
10795 : // pointer. That must be fixed, or we'll crash...
10796 0 : NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
10797 : }
10798 : #endif
10799 :
10800 0 : return list->GetItemAt(aIndex);
10801 : }
10802 :
10803 :
10804 : // SVGStringList helper
10805 :
10806 : nsresult
10807 0 : nsSVGStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10808 : nsAString& aResult)
10809 : {
10810 0 : if (aIndex < 0) {
10811 0 : SetDOMStringToNull(aResult);
10812 0 : return NS_OK;
10813 : }
10814 :
10815 : DOMSVGStringList* list = static_cast<DOMSVGStringList*>(
10816 0 : static_cast<nsIDOMSVGStringList*>(aNative));
10817 : #ifdef DEBUG
10818 : {
10819 0 : nsCOMPtr<nsIDOMSVGStringList> list_qi = do_QueryInterface(aNative);
10820 :
10821 : // If this assertion fires the QI implementation for the object in
10822 : // question doesn't use the nsIDOMDOMSVGStringList pointer as the
10823 : // nsISupports pointer. That must be fixed, or we'll crash...
10824 0 : NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
10825 : }
10826 : #endif
10827 :
10828 0 : nsresult rv = list->GetItem(aIndex, aResult);
10829 : #ifdef DEBUG
10830 0 : if (DOMStringIsNull(aResult)) {
10831 0 : PRUint32 length = 0;
10832 0 : list->GetLength(&length);
10833 0 : NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
10834 : }
10835 : #endif
10836 0 : if (rv == NS_ERROR_DOM_INDEX_SIZE_ERR) {
10837 0 : SetDOMStringToNull(aResult);
10838 0 : rv = NS_OK;
10839 : }
10840 0 : return rv;
10841 4188 : }
10842 :
10843 :
|