Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / dom / base / nsDOMClassInfo.cpp
bloba6432e6823b6825bbfe4249a37144c39b99ffe9b
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
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/
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.
16 * The Original Code is mozilla.org code.
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.
23 * Contributor(s):
24 * Johnny Stenback <jst@netscape.com> (original author)
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 // JavaScript includes
41 #include "jsapi.h"
42 #include "jsprvtd.h" // we are using private JS typedefs...
43 #include "jscntxt.h"
44 #include "jsobj.h"
45 #include "jsdbgapi.h"
46 #include "WrapperFactory.h"
47 #include "AccessCheck.h"
49 #include "nscore.h"
50 #include "nsDOMClassInfo.h"
51 #include "nsCRT.h"
52 #include "nsCRTGlue.h"
53 #include "nsIServiceManager.h"
54 #include "nsICategoryManager.h"
55 #include "nsIComponentRegistrar.h"
56 #include "nsXPCOM.h"
57 #include "nsISupportsPrimitives.h"
58 #include "nsIXPConnect.h"
59 #include "nsIJSContextStack.h"
60 #include "nsIXPCSecurityManager.h"
61 #include "nsIStringBundle.h"
62 #include "nsIConsoleService.h"
63 #include "nsIScriptError.h"
64 #include "nsXPIDLString.h"
65 #include "nsReadableUtils.h"
66 #include "nsUnicharUtils.h"
67 #include "xptcall.h"
68 #include "prprf.h"
69 #include "nsTArray.h"
70 #include "nsCSSValue.h"
71 #include "nsIRunnable.h"
72 #include "nsThreadUtils.h"
73 #include "nsDOMEventTargetWrapperCache.h"
74 #include "xpcpublic.h"
76 // General helper includes
77 #include "nsGlobalWindow.h"
78 #include "nsHistory.h"
79 #include "nsIContent.h"
80 #include "nsIAttribute.h"
81 #include "nsIDocument.h"
82 #include "nsIDOMDocument.h"
83 #include "nsIDOM3Document.h"
84 #include "nsIDOMXMLDocument.h"
85 #include "nsIDOMNSDocument.h"
86 #include "nsIDOMEvent.h"
87 #include "nsIDOMNSEvent.h"
88 #include "nsIDOMKeyEvent.h"
89 #include "nsIDOMEventListener.h"
90 #include "nsIDOMPopStateEvent.h"
91 #include "nsIDOMPopStateEvent_MOZILLA_2_BRANCH.h"
92 #include "nsContentUtils.h"
93 #include "nsDOMWindowUtils.h"
94 #include "nsIDOMGlobalPropertyInitializer.h"
96 // Window scriptable helper includes
97 #include "nsIDocShell.h"
98 #include "nsIDocShellTreeItem.h"
99 #include "nsIDocShellTreeNode.h"
100 #include "nsIScriptExternalNameSet.h"
101 #include "nsJSUtils.h"
102 #include "nsIInterfaceRequestor.h"
103 #include "nsIInterfaceRequestorUtils.h"
104 #include "nsScriptNameSpaceManager.h"
105 #include "nsIScriptObjectOwner.h"
106 #include "nsIJSNativeInitializer.h"
107 #include "nsJSEnvironment.h"
109 // DOM base includes
110 #include "nsIDOMPluginArray.h"
111 #include "nsIDOMPlugin.h"
112 #include "nsIDOMMimeTypeArray.h"
113 #include "nsIDOMMimeType.h"
114 #include "nsIDOMLocation.h"
115 #include "nsIDOMWindowInternal.h"
116 #include "nsPIDOMWindow.h"
117 #include "nsIDOMJSWindow.h"
118 #include "nsIDOMWindowCollection.h"
119 #include "nsIDOMHistory.h"
120 #include "nsIDOMMediaList.h"
121 #include "nsIDOMChromeWindow.h"
122 #include "nsIDOMConstructor.h"
123 #include "nsClientRect.h"
125 // DOM core includes
126 #include "nsDOMError.h"
127 #include "nsIDOMDOMException.h"
128 #include "nsIDOMNode.h"
129 #include "nsIDOM3Node.h"
130 #include "nsIDOM3Attr.h"
131 #include "nsIDOMNodeList.h"
132 #include "nsIDOMNamedNodeMap.h"
133 #include "nsIDOMDOMStringList.h"
134 #include "nsIDOMDOMTokenList.h"
135 #include "nsIDOMDOMSettableTokenList.h"
136 #include "nsIDOMNameList.h"
137 #include "nsIDOMNSElement.h"
139 // HTMLFormElement helper includes
140 #include "nsIForm.h"
141 #include "nsIFormControl.h"
142 #include "nsIDOMHTMLFormElement.h"
143 #include "nsIDOMHTMLCollection.h"
144 #include "nsIHTMLCollection.h"
145 #include "nsHTMLDocument.h"
147 // Constraint Validation API helper includes
148 #include "nsIDOMValidityState.h"
150 // HTMLSelectElement helper includes
151 #include "nsIDOMHTMLSelectElement.h"
153 // HTMLEmbed/ObjectElement helper includes
154 #include "nsIPluginInstance.h"
155 #include "nsIObjectFrame.h"
156 #include "nsIObjectLoadingContent.h"
157 #include "nsIPluginHost.h"
159 // Oh, did I mention that I hate Microsoft for doing this to me?
160 #ifdef XP_WIN
161 #undef GetClassName
162 #endif
164 // HTMLOptionsCollection includes
165 #include "nsIDOMHTMLOptionElement.h"
166 #include "nsIDOMHTMLOptionsCollection.h"
167 #include "nsIDOMNSHTMLOptionCollectn.h"
169 // ContentList includes
170 #include "nsContentList.h"
171 #include "nsGenericElement.h"
173 // Event related includes
174 #include "nsIEventListenerManager.h"
175 #include "nsIDOMEventTarget.h"
176 #include "nsIDOMNSEventTarget.h"
178 // CSS related includes
179 #include "nsIDOMStyleSheet.h"
180 #include "nsIDOMStyleSheetList.h"
181 #include "nsIDOMCSSStyleDeclaration.h"
182 #include "nsIDOMCSSRule.h"
183 #include "nsICSSRule.h"
184 #include "nsICSSRuleList.h"
185 #include "nsIDOMRect.h"
186 #include "nsIDOMRGBColor.h"
187 #include "nsIDOMNSRGBAColor.h"
188 #include "nsDOMCSSAttrDeclaration.h"
190 // XBL related includes.
191 #include "nsIXBLService.h"
192 #include "nsXBLBinding.h"
193 #include "nsBindingManager.h"
194 #include "nsIFrame.h"
195 #include "nsIPresShell.h"
196 #include "nsIDOMViewCSS.h"
197 #include "nsIDOMElement.h"
198 #include "nsIDOMCSSStyleDeclaration.h"
199 #include "nsStyleSet.h"
200 #include "nsStyleContext.h"
201 #include "nsAutoPtr.h"
202 #include "nsMemory.h"
204 // Tranformiix
205 #include "nsIDOMXPathEvaluator.h"
206 #include "nsIXSLTProcessor.h"
207 #include "nsIXSLTProcessorObsolete.h"
208 #include "nsIXSLTProcessorPrivate.h"
210 #include "nsIDOMLSProgressEvent.h"
211 #include "nsIDOMParser.h"
212 #include "nsIDOMSerializer.h"
213 #include "nsXMLHttpRequest.h"
214 #include "nsWebSocket.h"
215 #include "nsIDOMCloseEvent.h"
217 // includes needed for the prototype chain interfaces
218 #include "nsIDOMNavigator.h"
219 #include "nsIDOMBarProp.h"
220 #include "nsIDOMScreen.h"
221 #include "nsIDOMDocumentType.h"
222 #include "nsIDOMDOMImplementation.h"
223 #include "nsIDOMDocumentFragment.h"
224 #include "nsIDOMDocumentEvent.h"
225 #include "nsDOMAttribute.h"
226 #include "nsIDOMText.h"
227 #include "nsIDOM3Text.h"
228 #include "nsIDOMComment.h"
229 #include "nsIDOMCDATASection.h"
230 #include "nsIDOMProcessingInstruction.h"
231 #include "nsIDOMNotation.h"
232 #include "nsIDOMNSEvent.h"
233 #include "nsIDOMDataContainerEvent.h"
234 #include "nsIDOMKeyEvent.h"
235 #include "nsIDOMMouseEvent.h"
236 #include "nsIDOMMouseScrollEvent.h"
237 #include "nsIDOMDragEvent.h"
238 #include "nsIDOMCommandEvent.h"
239 #include "nsIDOMPopupBlockedEvent.h"
240 #include "nsIDOMBeforeUnloadEvent.h"
241 #include "nsIDOMMutationEvent.h"
242 #include "nsIDOMSmartCardEvent.h"
243 #include "nsIDOMXULCommandEvent.h"
244 #include "nsIDOMPageTransitionEvent.h"
245 #include "nsIDOMMessageEvent.h"
246 #include "nsPaintRequest.h"
247 #include "nsIDOMNotifyPaintEvent.h"
248 #include "nsIDOMNotifyAudioAvailableEvent.h"
249 #include "nsIDOMScrollAreaEvent.h"
250 #include "nsIDOMTransitionEvent.h"
251 #include "nsIDOMNSDocumentStyle.h"
252 #include "nsIDOMDocumentRange.h"
253 #include "nsIDOMDocumentTraversal.h"
254 #include "nsIDOMDocumentXBL.h"
255 #include "nsIDOMDocumentView.h"
256 #include "nsIDOMElementCSSInlineStyle.h"
257 #include "nsIDOMLinkStyle.h"
258 #include "nsIDOMHTMLDocument.h"
259 #include "nsIDOMNSHTMLDocument.h"
260 #include "nsIDOMHTMLElement.h"
261 #include "nsIDOMNSHTMLElement.h"
262 #include "nsIDOMHTMLAnchorElement.h"
263 #include "nsIDOMHTMLAppletElement.h"
264 #include "nsIDOMHTMLAreaElement.h"
265 #include "nsIDOMHTMLBRElement.h"
266 #include "nsIDOMHTMLBaseElement.h"
267 #include "nsIDOMHTMLBodyElement.h"
268 #include "nsIDOMHTMLButtonElement.h"
269 #include "nsIDOMHTMLCanvasElement.h"
270 #include "nsIDOMHTMLDataListElement.h"
271 #include "nsIDOMHTMLDListElement.h"
272 #include "nsIDOMHTMLDirectoryElement.h"
273 #include "nsIDOMHTMLDivElement.h"
274 #include "nsIDOMHTMLEmbedElement.h"
275 #include "nsIDOMHTMLFieldSetElement.h"
276 #include "nsIDOMHTMLFontElement.h"
277 #include "nsIDOMNSHTMLFormElement.h"
278 #include "nsIDOMHTMLFrameElement.h"
279 #include "nsIDOMHTMLFrameSetElement.h"
280 #include "nsIDOMNSHTMLFrameElement.h"
281 #include "nsIDOMHTMLHRElement.h"
282 #include "nsIDOMNSHTMLHRElement.h"
283 #include "nsIDOMHTMLHeadElement.h"
284 #include "nsIDOMHTMLHeadingElement.h"
285 #include "nsIDOMHTMLHtmlElement.h"
286 #include "nsIDOMHTMLIFrameElement.h"
287 #include "nsIDOMHTMLImageElement.h"
288 #include "nsIDOMHTMLInputElement.h"
289 #include "nsIDOMHTMLIsIndexElement.h"
290 #include "nsIDOMHTMLLIElement.h"
291 #include "nsIDOMHTMLLabelElement.h"
292 #include "nsIDOMHTMLLegendElement.h"
293 #include "nsIDOMHTMLLinkElement.h"
294 #include "nsIDOMHTMLMapElement.h"
295 #include "nsIDOMHTMLMenuElement.h"
296 #include "nsIDOMHTMLMetaElement.h"
297 #include "nsIDOMHTMLModElement.h"
298 #include "nsIDOMHTMLOListElement.h"
299 #include "nsIDOMHTMLObjectElement.h"
300 #include "nsIDOMHTMLOptGroupElement.h"
301 #include "nsIDOMHTMLOutputElement.h"
302 #include "nsIDOMHTMLParagraphElement.h"
303 #include "nsIDOMHTMLParamElement.h"
304 #include "nsIDOMHTMLPreElement.h"
305 #include "nsIDOMHTMLQuoteElement.h"
306 #include "nsIDOMHTMLScriptElement.h"
307 #include "nsIDOMHTMLStyleElement.h"
308 #include "nsIDOMHTMLTableCaptionElem.h"
309 #include "nsIDOMHTMLTableCellElement.h"
310 #include "nsIDOMHTMLTableColElement.h"
311 #include "nsIDOMHTMLTableElement.h"
312 #include "nsIDOMHTMLTableRowElement.h"
313 #include "nsIDOMHTMLTableSectionElem.h"
314 #include "nsIDOMHTMLTextAreaElement.h"
315 #include "nsIDOMNSHTMLTextAreaElement.h"
316 #include "nsIDOMHTMLTitleElement.h"
317 #include "nsIDOMHTMLUListElement.h"
318 #include "nsIDOMMediaError.h"
319 #include "nsIDOMTimeRanges.h"
320 #include "nsIDOMHTMLSourceElement.h"
321 #include "nsIDOMHTMLVideoElement.h"
322 #include "nsIDOMHTMLAudioElement.h"
323 #include "nsIDOMProgressEvent.h"
324 #include "nsIDOMNSUIEvent.h"
325 #include "nsIDOMCSS2Properties.h"
326 #include "nsIDOMCSSCharsetRule.h"
327 #include "nsIDOMCSSImportRule.h"
328 #include "nsIDOMCSSMediaRule.h"
329 #include "nsIDOMCSSFontFaceRule.h"
330 #include "nsIDOMCSSMozDocumentRule.h"
331 #include "nsIDOMCSSPrimitiveValue.h"
332 #include "nsIDOMCSSStyleRule.h"
333 #include "nsIDOMCSSStyleSheet.h"
334 #include "nsDOMCSSValueList.h"
335 #include "nsIDOMOrientationEvent.h"
336 #include "nsIDOMRange.h"
337 #include "nsIDOMNSRange.h"
338 #include "nsIDOMRangeException.h"
339 #include "nsIDOMNodeIterator.h"
340 #include "nsIDOMTreeWalker.h"
341 #include "nsIDOMXULDocument.h"
342 #include "nsIDOMXULElement.h"
343 #include "nsIDOMXULCommandDispatcher.h"
344 #include "nsIDOMCrypto.h"
345 #include "nsIDOMCRMFObject.h"
346 #include "nsIControllers.h"
347 #include "nsISelection.h"
348 #include "nsISelection3.h"
349 #include "nsIBoxObject.h"
350 #ifdef MOZ_XUL
351 #include "nsITreeSelection.h"
352 #include "nsITreeContentView.h"
353 #include "nsITreeView.h"
354 #include "nsIXULTemplateBuilder.h"
355 #include "nsTreeColumns.h"
356 #endif
357 #include "nsIDOMXPathException.h"
358 #include "nsIDOMXPathExpression.h"
359 #include "nsIDOMNSXPathExpression.h"
360 #include "nsIDOMXPathNSResolver.h"
361 #include "nsIDOMXPathResult.h"
363 #ifdef MOZ_SVG
364 #include "nsIDOMGetSVGDocument.h"
365 #include "nsIDOMSVGAElement.h"
366 #include "nsIDOMSVGAltGlyphElement.h"
367 #include "nsIDOMSVGAngle.h"
368 #include "nsIDOMSVGAnimatedAngle.h"
369 #include "nsIDOMSVGAnimatedBoolean.h"
370 #include "nsIDOMSVGAnimatedEnum.h"
371 #include "nsIDOMSVGAnimatedInteger.h"
372 #include "nsIDOMSVGAnimatedLength.h"
373 #include "nsIDOMSVGAnimatedLengthList.h"
374 #include "nsIDOMSVGAnimatedNumber.h"
375 #include "nsIDOMSVGAnimatedNumberList.h"
376 #include "nsIDOMSVGAnimatedPathData.h"
377 #include "nsIDOMSVGAnimatedPoints.h"
378 #include "nsIDOMSVGAnimPresAspRatio.h"
379 #include "nsIDOMSVGAnimatedRect.h"
380 #include "nsIDOMSVGAnimatedString.h"
381 #ifdef MOZ_SMIL
382 #include "nsIDOMSVGAnimateElement.h"
383 #include "nsIDOMSVGAnimateTransformElement.h"
384 #include "nsIDOMSVGAnimateMotionElement.h"
385 #include "nsIDOMSVGMpathElement.h"
386 #include "nsIDOMSVGSetElement.h"
387 #include "nsIDOMSVGAnimationElement.h"
388 #include "nsIDOMElementTimeControl.h"
389 #include "nsIDOMTimeEvent.h"
390 #endif // MOZ_SMIL
391 #include "nsIDOMSVGAnimTransformList.h"
392 #include "nsIDOMSVGCircleElement.h"
393 #include "nsIDOMSVGClipPathElement.h"
394 #include "nsIDOMSVGDefsElement.h"
395 #include "nsIDOMSVGDescElement.h"
396 #include "nsIDOMSVGDocument.h"
397 #include "nsIDOMSVGElement.h"
398 #include "nsIDOMSVGEllipseElement.h"
399 #include "nsIDOMSVGEvent.h"
400 #include "nsIDOMSVGException.h"
401 #include "nsIDOMSVGFilterElement.h"
402 #include "nsIDOMSVGFilters.h"
403 #include "nsIDOMSVGFitToViewBox.h"
404 #include "nsIDOMSVGForeignObjectElem.h"
405 #include "nsIDOMSVGGElement.h"
406 #include "nsIDOMSVGGradientElement.h"
407 #include "nsIDOMSVGImageElement.h"
408 #include "nsIDOMSVGLength.h"
409 #include "nsIDOMSVGLengthList.h"
410 #include "nsIDOMSVGLineElement.h"
411 #include "nsIDOMSVGLocatable.h"
412 #include "nsIDOMSVGMarkerElement.h"
413 #include "nsIDOMSVGMaskElement.h"
414 #include "nsIDOMSVGMatrix.h"
415 #include "nsIDOMSVGMetadataElement.h"
416 #include "nsIDOMSVGNumber.h"
417 #include "nsIDOMSVGNumberList.h"
418 #include "nsIDOMSVGPathElement.h"
419 #include "nsIDOMSVGPathSeg.h"
420 #include "nsIDOMSVGPathSegList.h"
421 #include "nsIDOMSVGPatternElement.h"
422 #include "nsIDOMSVGPoint.h"
423 #include "nsIDOMSVGPointList.h"
424 #include "nsIDOMSVGPolygonElement.h"
425 #include "nsIDOMSVGPolylineElement.h"
426 #include "nsIDOMSVGPresAspectRatio.h"
427 #include "nsIDOMSVGRect.h"
428 #include "nsIDOMSVGRectElement.h"
429 #include "nsIDOMSVGScriptElement.h"
430 #include "nsIDOMSVGStopElement.h"
431 #include "nsIDOMSVGStylable.h"
432 #include "nsIDOMSVGStyleElement.h"
433 #include "nsIDOMSVGSVGElement.h"
434 #include "nsIDOMSVGSwitchElement.h"
435 #include "nsIDOMSVGSymbolElement.h"
436 #include "nsIDOMSVGTextElement.h"
437 #include "nsIDOMSVGTextPathElement.h"
438 #include "nsIDOMSVGTitleElement.h"
439 #include "nsIDOMSVGTransform.h"
440 #include "nsIDOMSVGTransformable.h"
441 #include "nsIDOMSVGTransformList.h"
442 #include "nsIDOMSVGTSpanElement.h"
443 #include "nsIDOMSVGURIReference.h"
444 #include "nsIDOMSVGUseElement.h"
445 #include "nsIDOMSVGUnitTypes.h"
446 #include "nsIDOMSVGZoomAndPan.h"
447 #include "nsIDOMSVGZoomEvent.h"
448 #endif // MOZ_SVG
450 #include "nsIDOMCanvasRenderingContext2D.h"
451 #include "nsIDOMWebGLRenderingContext.h"
453 #include "nsIImageDocument.h"
455 // Storage includes
456 #include "nsDOMStorage.h"
458 // Drag and drop
459 #include "nsIDOMDataTransfer.h"
461 // Geolocation
462 #include "nsIDOMGeoGeolocation.h"
463 #include "nsIDOMGeoPosition.h"
464 #include "nsIDOMGeoPositionCoords.h"
465 #include "nsIDOMGeoPositionError.h"
467 // Workers
468 #include "nsDOMWorker.h"
470 #include "nsDOMFile.h"
471 #include "nsDOMFileReader.h"
472 #include "nsIDOMFileException.h"
473 #include "nsIDOMFileError.h"
474 #include "nsIDOMFormData.h"
476 #include "nsIDOMDesktopNotification.h"
477 #include "nsIDOMNavigatorDesktopNotification.h"
479 // Simple gestures include
480 #include "nsIDOMSimpleGestureEvent.h"
482 #include "nsIDOMNSMouseEvent.h"
484 #include "nsIDOMMozTouchEvent.h"
486 #include "nsIEventListenerService.h"
487 #include "nsIFrameMessageManager.h"
488 #include "mozilla/dom/Element.h"
489 #include "nsHTMLSelectElement.h"
490 #include "nsHTMLLegendElement.h"
492 using namespace mozilla::dom;
494 #include "mozilla/dom/indexedDB/IDBFactory.h"
495 #include "mozilla/dom/indexedDB/IDBRequest.h"
496 #include "mozilla/dom/indexedDB/IDBDatabase.h"
497 #include "mozilla/dom/indexedDB/IDBEvents.h"
498 #include "mozilla/dom/indexedDB/IDBObjectStore.h"
499 #include "mozilla/dom/indexedDB/IDBTransaction.h"
500 #include "mozilla/dom/indexedDB/IDBCursor.h"
501 #include "mozilla/dom/indexedDB/IDBKeyRange.h"
502 #include "mozilla/dom/indexedDB/IDBIndex.h"
503 #include "nsIIDBDatabaseException.h"
505 static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
507 static const char kDOMStringBundleURL[] =
508 "chrome://global/locale/dom/dom.properties";
510 // NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
511 // are defined in nsIDOMClassInfo.h.
513 #define WINDOW_SCRIPTABLE_FLAGS \
514 (nsIXPCScriptable::WANT_GETPROPERTY | \
515 nsIXPCScriptable::WANT_SETPROPERTY | \
516 nsIXPCScriptable::WANT_PRECREATE | \
517 nsIXPCScriptable::WANT_ADDPROPERTY | \
518 nsIXPCScriptable::WANT_FINALIZE | \
519 nsIXPCScriptable::WANT_EQUALITY | \
520 nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
521 nsIXPCScriptable::WANT_OUTER_OBJECT)
523 #define NODE_SCRIPTABLE_FLAGS \
524 ((DOM_DEFAULT_SCRIPTABLE_FLAGS | \
525 nsIXPCScriptable::WANT_GETPROPERTY | \
526 nsIXPCScriptable::WANT_ADDPROPERTY | \
527 nsIXPCScriptable::WANT_SETPROPERTY) & \
528 ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
530 // We need to let JavaScript QI elements to interfaces that are not in
531 // the classinfo since XBL can be used to dynamically implement new
532 // unknown interfaces on elements, accessibility relies on this being
533 // possible.
535 #define ELEMENT_SCRIPTABLE_FLAGS \
536 ((NODE_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY) | \
537 nsIXPCScriptable::WANT_POSTCREATE | \
538 nsIXPCScriptable::WANT_ENUMERATE)
540 #define EXTERNAL_OBJ_SCRIPTABLE_FLAGS \
541 ((ELEMENT_SCRIPTABLE_FLAGS & \
542 ~nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY) | \
543 nsIXPCScriptable::WANT_POSTCREATE | \
544 nsIXPCScriptable::WANT_GETPROPERTY | \
545 nsIXPCScriptable::WANT_SETPROPERTY | \
546 nsIXPCScriptable::WANT_CALL)
548 #define DOCUMENT_SCRIPTABLE_FLAGS \
549 (NODE_SCRIPTABLE_FLAGS | \
550 nsIXPCScriptable::WANT_POSTCREATE | \
551 nsIXPCScriptable::WANT_ADDPROPERTY | \
552 nsIXPCScriptable::WANT_GETPROPERTY | \
553 nsIXPCScriptable::WANT_ENUMERATE)
555 #define ARRAY_SCRIPTABLE_FLAGS \
556 (DOM_DEFAULT_SCRIPTABLE_FLAGS | \
557 nsIXPCScriptable::WANT_GETPROPERTY | \
558 nsIXPCScriptable::WANT_ENUMERATE)
560 #define EVENTTARGET_SCRIPTABLE_FLAGS \
561 (DOM_DEFAULT_SCRIPTABLE_FLAGS | \
562 nsIXPCScriptable::WANT_ADDPROPERTY)
564 #define DOMCLASSINFO_STANDARD_FLAGS \
565 (nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::DOM_OBJECT)
568 #ifdef NS_DEBUG
569 #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
570 eDOMClassInfo_##_class##_id,
571 #else
572 #define NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
573 // nothing
574 #endif
576 DOMCI_DATA(Crypto, void)
577 DOMCI_DATA(CRMFObject, void)
578 DOMCI_DATA(SmartCardEvent, void)
579 DOMCI_DATA(ContentFrameMessageManager, void)
581 DOMCI_DATA(DOMPrototype, void)
582 DOMCI_DATA(DOMConstructor, void)
584 DOMCI_DATA(Worker, void)
585 DOMCI_DATA(ChromeWorker, void)
587 DOMCI_DATA(Notation, void)
589 #define NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _name, _helper, \
590 _flags) \
591 { #_name, \
592 nsnull, \
593 { _helper::doCreate }, \
594 nsnull, \
595 nsnull, \
596 nsnull, \
597 _flags, \
598 PR_TRUE, \
599 0, \
600 PR_FALSE, \
601 NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
604 #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _name, \
605 _helper, _flags) \
606 { #_name, \
607 nsnull, \
608 { _helper::doCreate }, \
609 nsnull, \
610 nsnull, \
611 nsnull, \
612 _flags, \
613 PR_TRUE, \
614 0, \
615 PR_TRUE, \
616 NS_DEFINE_CLASSINFO_DATA_DEBUG(_class) \
619 #define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
620 NS_DEFINE_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, _flags)
622 #define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
623 NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
624 _flags)
626 // This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
627 // classes their correct behavior when used through XPConnect. The
628 // arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
630 // 1. Class name as it should appear in JavaScript, this name is also
631 // used to find the id of the class in nsDOMClassInfo
632 // (i.e. e<classname>_id)
633 // 2. Scriptable helper class
634 // 3. nsIClassInfo/nsIXPCScriptable flags (i.e. for GetScriptableFlags)
636 static nsDOMClassInfoData sClassInfoData[] = {
637 // Base classes
639 // The Window class lets you QI into interfaces that are not in the
640 // flattened set (i.e. nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY
641 // is not set), because of this make sure all scriptable interfaces
642 // that are implemented by nsGlobalWindow can securely be exposed
643 // to JS.
646 NS_DEFINE_CLASSINFO_DATA(Window, nsWindowSH,
647 DEFAULT_SCRIPTABLE_FLAGS |
648 WINDOW_SCRIPTABLE_FLAGS)
650 NS_DEFINE_CLASSINFO_DATA(Location, nsLocationSH,
651 (DOM_DEFAULT_SCRIPTABLE_FLAGS &
652 ~nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE))
654 NS_DEFINE_CLASSINFO_DATA(Navigator, nsNavigatorSH,
655 DOM_DEFAULT_SCRIPTABLE_FLAGS |
656 nsIXPCScriptable::WANT_PRECREATE)
657 NS_DEFINE_CLASSINFO_DATA(Plugin, nsPluginSH,
658 ARRAY_SCRIPTABLE_FLAGS)
659 NS_DEFINE_CLASSINFO_DATA(PluginArray, nsPluginArraySH,
660 ARRAY_SCRIPTABLE_FLAGS)
661 NS_DEFINE_CLASSINFO_DATA(MimeType, nsDOMGenericSH,
662 DOM_DEFAULT_SCRIPTABLE_FLAGS)
663 NS_DEFINE_CLASSINFO_DATA(MimeTypeArray, nsMimeTypeArraySH,
664 ARRAY_SCRIPTABLE_FLAGS)
665 NS_DEFINE_CLASSINFO_DATA(BarProp, nsDOMGenericSH,
666 DOM_DEFAULT_SCRIPTABLE_FLAGS)
667 NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
668 ARRAY_SCRIPTABLE_FLAGS |
669 nsIXPCScriptable::WANT_PRECREATE)
670 NS_DEFINE_CLASSINFO_DATA(Screen, nsDOMGenericSH,
671 DOM_DEFAULT_SCRIPTABLE_FLAGS)
672 NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
673 DOM_BASE_SCRIPTABLE_FLAGS |
674 nsIXPCScriptable::WANT_PRECREATE |
675 nsIXPCScriptable::WANT_HASINSTANCE |
676 nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
677 NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMConstructorSH,
678 DOM_BASE_SCRIPTABLE_FLAGS |
679 nsIXPCScriptable::WANT_PRECREATE |
680 nsIXPCScriptable::WANT_HASINSTANCE |
681 nsIXPCScriptable::WANT_CALL |
682 nsIXPCScriptable::WANT_CONSTRUCT |
683 nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
685 // Core classes
686 NS_DEFINE_CLASSINFO_DATA(XMLDocument, nsDocumentSH,
687 DOCUMENT_SCRIPTABLE_FLAGS)
688 NS_DEFINE_CLASSINFO_DATA(DocumentType, nsNodeSH,
689 NODE_SCRIPTABLE_FLAGS)
690 NS_DEFINE_CLASSINFO_DATA(DOMImplementation, nsDOMGenericSH,
691 DOM_DEFAULT_SCRIPTABLE_FLAGS)
692 NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
693 DOM_DEFAULT_SCRIPTABLE_FLAGS)
694 NS_DEFINE_CLASSINFO_DATA(DOMTokenList, nsDOMTokenListSH,
695 ARRAY_SCRIPTABLE_FLAGS)
696 NS_DEFINE_CLASSINFO_DATA(DOMSettableTokenList, nsDOMTokenListSH,
697 ARRAY_SCRIPTABLE_FLAGS)
698 NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
699 NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
700 ELEMENT_SCRIPTABLE_FLAGS)
701 NS_DEFINE_CLASSINFO_DATA(Attr, nsAttributeSH,
702 NODE_SCRIPTABLE_FLAGS)
703 NS_DEFINE_CLASSINFO_DATA(Text, nsNodeSH,
704 NODE_SCRIPTABLE_FLAGS)
705 NS_DEFINE_CLASSINFO_DATA(Comment, nsNodeSH,
706 NODE_SCRIPTABLE_FLAGS)
707 NS_DEFINE_CLASSINFO_DATA(CDATASection, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
708 NS_DEFINE_CLASSINFO_DATA(ProcessingInstruction, nsNodeSH,
709 NODE_SCRIPTABLE_FLAGS)
710 NS_DEFINE_CLASSINFO_DATA(Notation, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
711 NS_DEFINE_CLASSINFO_DATA(NodeList, nsNodeListSH, ARRAY_SCRIPTABLE_FLAGS)
712 NS_DEFINE_CLASSINFO_DATA(NamedNodeMap, nsNamedNodeMapSH,
713 ARRAY_SCRIPTABLE_FLAGS)
715 // Misc Core related classes
717 // Event
718 NS_DEFINE_CLASSINFO_DATA(Event, nsDOMGenericSH,
719 DOM_DEFAULT_SCRIPTABLE_FLAGS)
720 NS_DEFINE_CLASSINFO_DATA(MutationEvent, nsDOMGenericSH,
721 DOM_DEFAULT_SCRIPTABLE_FLAGS)
722 NS_DEFINE_CLASSINFO_DATA(UIEvent, nsDOMGenericSH,
723 DOM_DEFAULT_SCRIPTABLE_FLAGS)
724 NS_DEFINE_CLASSINFO_DATA(MouseEvent, nsDOMGenericSH,
725 DOM_DEFAULT_SCRIPTABLE_FLAGS)
726 NS_DEFINE_CLASSINFO_DATA(MouseScrollEvent, nsDOMGenericSH,
727 DOM_DEFAULT_SCRIPTABLE_FLAGS)
728 NS_DEFINE_CLASSINFO_DATA(DragEvent, nsDOMGenericSH,
729 DOM_DEFAULT_SCRIPTABLE_FLAGS)
730 NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
731 DOM_DEFAULT_SCRIPTABLE_FLAGS)
732 NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
733 DOM_DEFAULT_SCRIPTABLE_FLAGS)
734 NS_DEFINE_CLASSINFO_DATA(OrientationEvent, nsDOMGenericSH,
735 DOM_DEFAULT_SCRIPTABLE_FLAGS)
737 // Misc HTML classes
738 NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH,
739 DOCUMENT_SCRIPTABLE_FLAGS)
740 NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection,
741 nsHTMLOptionsCollectionSH,
742 ARRAY_SCRIPTABLE_FLAGS |
743 nsIXPCScriptable::WANT_SETPROPERTY)
744 NS_DEFINE_CLASSINFO_DATA(HTMLCollection,
745 nsHTMLCollectionSH,
746 ARRAY_SCRIPTABLE_FLAGS)
748 // HTML element classes
749 NS_DEFINE_CLASSINFO_DATA(HTMLElement, nsElementSH,
750 ELEMENT_SCRIPTABLE_FLAGS)
751 NS_DEFINE_CLASSINFO_DATA(HTMLAnchorElement, nsElementSH,
752 ELEMENT_SCRIPTABLE_FLAGS)
753 NS_DEFINE_CLASSINFO_DATA(HTMLAppletElement, nsHTMLPluginObjElementSH,
754 EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
755 NS_DEFINE_CLASSINFO_DATA(HTMLAreaElement, nsElementSH,
756 ELEMENT_SCRIPTABLE_FLAGS)
757 NS_DEFINE_CLASSINFO_DATA(HTMLBRElement, nsElementSH,
758 ELEMENT_SCRIPTABLE_FLAGS)
759 NS_DEFINE_CLASSINFO_DATA(HTMLBaseElement, nsElementSH,
760 ELEMENT_SCRIPTABLE_FLAGS)
761 NS_DEFINE_CLASSINFO_DATA(HTMLBodyElement, nsHTMLBodyElementSH,
762 ELEMENT_SCRIPTABLE_FLAGS)
763 NS_DEFINE_CLASSINFO_DATA(HTMLButtonElement, nsElementSH,
764 ELEMENT_SCRIPTABLE_FLAGS)
765 NS_DEFINE_CLASSINFO_DATA(HTMLDataListElement, nsElementSH,
766 ELEMENT_SCRIPTABLE_FLAGS)
767 NS_DEFINE_CLASSINFO_DATA(HTMLDListElement, nsElementSH,
768 ELEMENT_SCRIPTABLE_FLAGS)
769 NS_DEFINE_CLASSINFO_DATA(HTMLDelElement, nsElementSH,
770 ELEMENT_SCRIPTABLE_FLAGS)
771 NS_DEFINE_CLASSINFO_DATA(HTMLDirectoryElement, nsElementSH,
772 ELEMENT_SCRIPTABLE_FLAGS)
773 NS_DEFINE_CLASSINFO_DATA(HTMLDivElement, nsElementSH,
774 ELEMENT_SCRIPTABLE_FLAGS)
775 NS_DEFINE_CLASSINFO_DATA(HTMLEmbedElement, nsHTMLPluginObjElementSH,
776 EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
777 NS_DEFINE_CLASSINFO_DATA(HTMLFieldSetElement, nsElementSH,
778 ELEMENT_SCRIPTABLE_FLAGS)
779 NS_DEFINE_CLASSINFO_DATA(HTMLFontElement, nsElementSH,
780 ELEMENT_SCRIPTABLE_FLAGS)
781 NS_DEFINE_CLASSINFO_DATA(HTMLFormElement, nsHTMLFormElementSH,
782 ELEMENT_SCRIPTABLE_FLAGS |
783 nsIXPCScriptable::WANT_GETPROPERTY |
784 nsIXPCScriptable::WANT_NEWENUMERATE)
785 NS_DEFINE_CLASSINFO_DATA(HTMLFrameElement, nsElementSH,
786 ELEMENT_SCRIPTABLE_FLAGS)
787 NS_DEFINE_CLASSINFO_DATA(HTMLFrameSetElement, nsElementSH,
788 ELEMENT_SCRIPTABLE_FLAGS)
789 NS_DEFINE_CLASSINFO_DATA(HTMLHRElement, nsElementSH,
790 ELEMENT_SCRIPTABLE_FLAGS)
791 NS_DEFINE_CLASSINFO_DATA(HTMLHeadElement, nsElementSH,
792 ELEMENT_SCRIPTABLE_FLAGS)
793 NS_DEFINE_CLASSINFO_DATA(HTMLHeadingElement, nsElementSH,
794 ELEMENT_SCRIPTABLE_FLAGS)
795 NS_DEFINE_CLASSINFO_DATA(HTMLHtmlElement, nsElementSH,
796 ELEMENT_SCRIPTABLE_FLAGS)
797 NS_DEFINE_CLASSINFO_DATA(HTMLIFrameElement, nsElementSH,
798 ELEMENT_SCRIPTABLE_FLAGS)
799 NS_DEFINE_CLASSINFO_DATA(HTMLImageElement, nsElementSH,
800 ELEMENT_SCRIPTABLE_FLAGS)
801 NS_DEFINE_CLASSINFO_DATA(HTMLInputElement, nsElementSH,
802 ELEMENT_SCRIPTABLE_FLAGS)
803 NS_DEFINE_CLASSINFO_DATA(HTMLInsElement, nsElementSH,
804 ELEMENT_SCRIPTABLE_FLAGS)
805 NS_DEFINE_CLASSINFO_DATA(HTMLIsIndexElement, nsElementSH,
806 ELEMENT_SCRIPTABLE_FLAGS)
807 NS_DEFINE_CLASSINFO_DATA(HTMLLIElement, nsElementSH,
808 ELEMENT_SCRIPTABLE_FLAGS)
809 NS_DEFINE_CLASSINFO_DATA(HTMLLabelElement, nsElementSH,
810 ELEMENT_SCRIPTABLE_FLAGS)
811 NS_DEFINE_CLASSINFO_DATA(HTMLLegendElement, nsElementSH,
812 ELEMENT_SCRIPTABLE_FLAGS)
813 NS_DEFINE_CLASSINFO_DATA(HTMLLinkElement, nsElementSH,
814 ELEMENT_SCRIPTABLE_FLAGS)
815 NS_DEFINE_CLASSINFO_DATA(HTMLMapElement, nsElementSH,
816 ELEMENT_SCRIPTABLE_FLAGS)
817 NS_DEFINE_CLASSINFO_DATA(HTMLMenuElement, nsElementSH,
818 ELEMENT_SCRIPTABLE_FLAGS)
819 NS_DEFINE_CLASSINFO_DATA(HTMLMetaElement, nsElementSH,
820 ELEMENT_SCRIPTABLE_FLAGS)
821 NS_DEFINE_CLASSINFO_DATA(HTMLOListElement, nsElementSH,
822 ELEMENT_SCRIPTABLE_FLAGS)
823 NS_DEFINE_CLASSINFO_DATA(HTMLObjectElement, nsHTMLPluginObjElementSH,
824 EXTERNAL_OBJ_SCRIPTABLE_FLAGS)
825 NS_DEFINE_CLASSINFO_DATA(HTMLOptGroupElement, nsElementSH,
826 ELEMENT_SCRIPTABLE_FLAGS)
827 NS_DEFINE_CLASSINFO_DATA(HTMLOptionElement, nsElementSH,
828 ELEMENT_SCRIPTABLE_FLAGS)
829 NS_DEFINE_CLASSINFO_DATA(HTMLOutputElement, nsElementSH,
830 ELEMENT_SCRIPTABLE_FLAGS)
831 NS_DEFINE_CLASSINFO_DATA(HTMLParagraphElement, nsElementSH,
832 ELEMENT_SCRIPTABLE_FLAGS)
833 NS_DEFINE_CLASSINFO_DATA(HTMLParamElement, nsElementSH,
834 ELEMENT_SCRIPTABLE_FLAGS)
835 NS_DEFINE_CLASSINFO_DATA(HTMLPreElement, nsElementSH,
836 ELEMENT_SCRIPTABLE_FLAGS)
837 NS_DEFINE_CLASSINFO_DATA(HTMLQuoteElement, nsElementSH,
838 ELEMENT_SCRIPTABLE_FLAGS)
839 NS_DEFINE_CLASSINFO_DATA(HTMLScriptElement, nsElementSH,
840 ELEMENT_SCRIPTABLE_FLAGS)
841 NS_DEFINE_CLASSINFO_DATA(HTMLSelectElement, nsHTMLSelectElementSH,
842 ELEMENT_SCRIPTABLE_FLAGS |
843 nsIXPCScriptable::WANT_GETPROPERTY)
844 NS_DEFINE_CLASSINFO_DATA(HTMLSpanElement, nsElementSH,
845 ELEMENT_SCRIPTABLE_FLAGS)
846 NS_DEFINE_CLASSINFO_DATA(HTMLStyleElement, nsElementSH,
847 ELEMENT_SCRIPTABLE_FLAGS)
848 NS_DEFINE_CLASSINFO_DATA(HTMLTableCaptionElement, nsElementSH,
849 ELEMENT_SCRIPTABLE_FLAGS)
850 NS_DEFINE_CLASSINFO_DATA(HTMLTableCellElement, nsElementSH,
851 ELEMENT_SCRIPTABLE_FLAGS)
852 NS_DEFINE_CLASSINFO_DATA(HTMLTableColElement, nsElementSH,
853 ELEMENT_SCRIPTABLE_FLAGS)
854 NS_DEFINE_CLASSINFO_DATA(HTMLTableElement, nsElementSH,
855 ELEMENT_SCRIPTABLE_FLAGS)
856 NS_DEFINE_CLASSINFO_DATA(HTMLTableRowElement, nsElementSH,
857 ELEMENT_SCRIPTABLE_FLAGS)
858 NS_DEFINE_CLASSINFO_DATA(HTMLTableSectionElement, nsElementSH,
859 ELEMENT_SCRIPTABLE_FLAGS)
860 NS_DEFINE_CLASSINFO_DATA(HTMLTextAreaElement, nsElementSH,
861 ELEMENT_SCRIPTABLE_FLAGS)
862 NS_DEFINE_CLASSINFO_DATA(HTMLTitleElement, nsElementSH,
863 ELEMENT_SCRIPTABLE_FLAGS)
864 NS_DEFINE_CLASSINFO_DATA(HTMLUListElement, nsElementSH,
865 ELEMENT_SCRIPTABLE_FLAGS)
866 NS_DEFINE_CLASSINFO_DATA(HTMLUnknownElement, nsElementSH,
867 ELEMENT_SCRIPTABLE_FLAGS)
869 // Constraint Validation API classes
870 NS_DEFINE_CLASSINFO_DATA(ValidityState, nsDOMGenericSH,
871 DOM_DEFAULT_SCRIPTABLE_FLAGS)
873 // CSS classes
874 NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
875 DOM_DEFAULT_SCRIPTABLE_FLAGS)
876 NS_DEFINE_CLASSINFO_DATA(CSSCharsetRule, nsDOMGenericSH,
877 DOM_DEFAULT_SCRIPTABLE_FLAGS)
878 NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
879 DOM_DEFAULT_SCRIPTABLE_FLAGS)
880 NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
881 DOM_DEFAULT_SCRIPTABLE_FLAGS)
882 NS_DEFINE_CLASSINFO_DATA(CSSNameSpaceRule, nsDOMGenericSH,
883 DOM_DEFAULT_SCRIPTABLE_FLAGS)
884 NS_DEFINE_CLASSINFO_DATA(CSSRuleList, nsCSSRuleListSH,
885 ARRAY_SCRIPTABLE_FLAGS)
886 NS_DEFINE_CLASSINFO_DATA(CSSGroupRuleRuleList, nsCSSRuleListSH,
887 ARRAY_SCRIPTABLE_FLAGS)
888 NS_DEFINE_CLASSINFO_DATA(MediaList, nsMediaListSH,
889 ARRAY_SCRIPTABLE_FLAGS)
890 NS_DEFINE_CLASSINFO_DATA(StyleSheetList, nsStyleSheetListSH,
891 ARRAY_SCRIPTABLE_FLAGS)
892 NS_DEFINE_CLASSINFO_DATA(CSSStyleSheet, nsDOMGenericSH,
893 DOM_DEFAULT_SCRIPTABLE_FLAGS)
894 NS_DEFINE_CLASSINFO_DATA(CSSStyleDeclaration, nsCSSStyleDeclSH,
895 ARRAY_SCRIPTABLE_FLAGS)
896 NS_DEFINE_CLASSINFO_DATA(ComputedCSSStyleDeclaration, nsCSSStyleDeclSH,
897 ARRAY_SCRIPTABLE_FLAGS)
898 NS_DEFINE_CLASSINFO_DATA(ROCSSPrimitiveValue, nsDOMGenericSH,
899 DOM_DEFAULT_SCRIPTABLE_FLAGS)
901 // Range classes
902 NS_DEFINE_CLASSINFO_DATA(Range, nsDOMGenericSH,
903 DOM_DEFAULT_SCRIPTABLE_FLAGS)
904 NS_DEFINE_CLASSINFO_DATA(Selection, nsDOMGenericSH,
905 DEFAULT_SCRIPTABLE_FLAGS)
907 // XUL classes
908 #ifdef MOZ_XUL
909 NS_DEFINE_CLASSINFO_DATA(XULDocument, nsDocumentSH,
910 DOCUMENT_SCRIPTABLE_FLAGS)
911 NS_DEFINE_CLASSINFO_DATA(XULElement, nsElementSH,
912 ELEMENT_SCRIPTABLE_FLAGS)
913 NS_DEFINE_CLASSINFO_DATA(XULCommandDispatcher, nsDOMGenericSH,
914 DOM_DEFAULT_SCRIPTABLE_FLAGS)
915 #endif
916 NS_DEFINE_CLASSINFO_DATA(XULControllers, nsNonDOMObjectSH,
917 DEFAULT_SCRIPTABLE_FLAGS)
918 NS_DEFINE_CLASSINFO_DATA(BoxObject, nsDOMGenericSH,
919 DEFAULT_SCRIPTABLE_FLAGS)
920 #ifdef MOZ_XUL
921 NS_DEFINE_CLASSINFO_DATA(TreeSelection, nsDOMGenericSH,
922 DEFAULT_SCRIPTABLE_FLAGS)
923 NS_DEFINE_CLASSINFO_DATA(TreeContentView, nsDOMGenericSH,
924 DEFAULT_SCRIPTABLE_FLAGS)
925 #endif
927 // Crypto classes
928 NS_DEFINE_CLASSINFO_DATA(Crypto, nsDOMGenericSH,
929 DOM_DEFAULT_SCRIPTABLE_FLAGS)
930 NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH,
931 DOM_DEFAULT_SCRIPTABLE_FLAGS)
933 // DOM Traversal classes
934 NS_DEFINE_CLASSINFO_DATA(TreeWalker, nsDOMGenericSH,
935 DOM_DEFAULT_SCRIPTABLE_FLAGS)
937 // We are now trying to preserve binary compat in classinfo. No
938 // more putting things in those categories up there. New entries
939 // are to be added to the end of the list
940 NS_DEFINE_CLASSINFO_DATA(CSSRect, nsDOMGenericSH,
941 DOM_DEFAULT_SCRIPTABLE_FLAGS)
943 // DOM Chrome Window class.
944 NS_DEFINE_CLASSINFO_DATA(ChromeWindow, nsWindowSH,
945 DEFAULT_SCRIPTABLE_FLAGS |
946 WINDOW_SCRIPTABLE_FLAGS)
948 NS_DEFINE_CLASSINFO_DATA(CSSRGBColor, nsDOMGenericSH,
949 DOM_DEFAULT_SCRIPTABLE_FLAGS)
951 NS_DEFINE_CLASSINFO_DATA(RangeException, nsDOMGenericSH,
952 DOM_DEFAULT_SCRIPTABLE_FLAGS)
954 NS_DEFINE_CLASSINFO_DATA(CSSValueList, nsCSSValueListSH,
955 ARRAY_SCRIPTABLE_FLAGS)
957 NS_DEFINE_CLASSINFO_DATA_WITH_NAME(ContentList, HTMLCollection,
958 nsContentListSH, ARRAY_SCRIPTABLE_FLAGS)
960 NS_DEFINE_CLASSINFO_DATA(XMLStylesheetProcessingInstruction, nsNodeSH,
961 NODE_SCRIPTABLE_FLAGS)
963 NS_DEFINE_CLASSINFO_DATA(ImageDocument, nsHTMLDocumentSH,
964 DOCUMENT_SCRIPTABLE_FLAGS)
966 #ifdef MOZ_XUL
967 NS_DEFINE_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
968 DEFAULT_SCRIPTABLE_FLAGS)
970 NS_DEFINE_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
971 DEFAULT_SCRIPTABLE_FLAGS)
972 #endif
974 NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
975 ARRAY_SCRIPTABLE_FLAGS)
977 NS_DEFINE_CLASSINFO_DATA(NameList, nsDOMGenericSH,
978 DOM_DEFAULT_SCRIPTABLE_FLAGS)
980 #ifdef MOZ_XUL
981 NS_DEFINE_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
982 DEFAULT_SCRIPTABLE_FLAGS)
984 NS_DEFINE_CLASSINFO_DATA(TreeColumns, nsTreeColumnsSH,
985 ARRAY_SCRIPTABLE_FLAGS)
986 #endif
988 NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
989 DOM_DEFAULT_SCRIPTABLE_FLAGS)
991 NS_DEFINE_CLASSINFO_DATA(BeforeUnloadEvent, nsDOMGenericSH,
992 DOM_DEFAULT_SCRIPTABLE_FLAGS)
994 #ifdef MOZ_SVG
995 // SVG document
996 NS_DEFINE_CLASSINFO_DATA(SVGDocument, nsDocumentSH,
997 DOCUMENT_SCRIPTABLE_FLAGS)
999 // SVG element classes
1000 NS_DEFINE_CLASSINFO_DATA(SVGAElement, nsElementSH,
1001 ELEMENT_SCRIPTABLE_FLAGS)
1002 NS_DEFINE_CLASSINFO_DATA(SVGAltGlyphElement, nsElementSH,
1003 ELEMENT_SCRIPTABLE_FLAGS)
1004 #ifdef MOZ_SMIL
1005 NS_DEFINE_CLASSINFO_DATA(SVGAnimateElement, nsElementSH,
1006 ELEMENT_SCRIPTABLE_FLAGS)
1007 NS_DEFINE_CLASSINFO_DATA(SVGAnimateTransformElement, nsElementSH,
1008 ELEMENT_SCRIPTABLE_FLAGS)
1009 NS_DEFINE_CLASSINFO_DATA(SVGAnimateMotionElement, nsElementSH,
1010 ELEMENT_SCRIPTABLE_FLAGS)
1011 NS_DEFINE_CLASSINFO_DATA(SVGMpathElement, nsElementSH,
1012 ELEMENT_SCRIPTABLE_FLAGS)
1013 NS_DEFINE_CLASSINFO_DATA(SVGSetElement, nsElementSH,
1014 ELEMENT_SCRIPTABLE_FLAGS)
1015 NS_DEFINE_CLASSINFO_DATA(TimeEvent, nsDOMGenericSH,
1016 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1017 #endif // MOZ_SMIL
1018 NS_DEFINE_CLASSINFO_DATA(SVGCircleElement, nsElementSH,
1019 ELEMENT_SCRIPTABLE_FLAGS)
1020 NS_DEFINE_CLASSINFO_DATA(SVGClipPathElement, nsElementSH,
1021 ELEMENT_SCRIPTABLE_FLAGS)
1022 NS_DEFINE_CLASSINFO_DATA(SVGDefsElement, nsElementSH,
1023 ELEMENT_SCRIPTABLE_FLAGS)
1024 NS_DEFINE_CLASSINFO_DATA(SVGDescElement, nsElementSH,
1025 ELEMENT_SCRIPTABLE_FLAGS)
1026 NS_DEFINE_CLASSINFO_DATA(SVGEllipseElement, nsElementSH,
1027 ELEMENT_SCRIPTABLE_FLAGS)
1028 NS_DEFINE_CLASSINFO_DATA(SVGFEBlendElement, nsElementSH,
1029 ELEMENT_SCRIPTABLE_FLAGS)
1030 NS_DEFINE_CLASSINFO_DATA(SVGFEColorMatrixElement, nsElementSH,
1031 ELEMENT_SCRIPTABLE_FLAGS)
1032 NS_DEFINE_CLASSINFO_DATA(SVGFEComponentTransferElement, nsElementSH,
1033 ELEMENT_SCRIPTABLE_FLAGS)
1034 NS_DEFINE_CLASSINFO_DATA(SVGFECompositeElement, nsElementSH,
1035 ELEMENT_SCRIPTABLE_FLAGS)
1036 NS_DEFINE_CLASSINFO_DATA(SVGFEConvolveMatrixElement, nsElementSH,
1037 ELEMENT_SCRIPTABLE_FLAGS)
1038 NS_DEFINE_CLASSINFO_DATA(SVGFEDiffuseLightingElement, nsElementSH,
1039 ELEMENT_SCRIPTABLE_FLAGS)
1040 NS_DEFINE_CLASSINFO_DATA(SVGFEDisplacementMapElement, nsElementSH,
1041 ELEMENT_SCRIPTABLE_FLAGS)
1042 NS_DEFINE_CLASSINFO_DATA(SVGFEDistantLightElement, nsElementSH,
1043 ELEMENT_SCRIPTABLE_FLAGS)
1044 NS_DEFINE_CLASSINFO_DATA(SVGFEFloodElement, nsElementSH,
1045 ELEMENT_SCRIPTABLE_FLAGS)
1046 NS_DEFINE_CLASSINFO_DATA(SVGFEFuncAElement, nsElementSH,
1047 ELEMENT_SCRIPTABLE_FLAGS)
1048 NS_DEFINE_CLASSINFO_DATA(SVGFEFuncBElement, nsElementSH,
1049 ELEMENT_SCRIPTABLE_FLAGS)
1050 NS_DEFINE_CLASSINFO_DATA(SVGFEFuncGElement, nsElementSH,
1051 ELEMENT_SCRIPTABLE_FLAGS)
1052 NS_DEFINE_CLASSINFO_DATA(SVGFEFuncRElement, nsElementSH,
1053 ELEMENT_SCRIPTABLE_FLAGS)
1054 NS_DEFINE_CLASSINFO_DATA(SVGFEGaussianBlurElement, nsElementSH,
1055 ELEMENT_SCRIPTABLE_FLAGS)
1056 NS_DEFINE_CLASSINFO_DATA(SVGFEImageElement, nsElementSH,
1057 ELEMENT_SCRIPTABLE_FLAGS)
1058 NS_DEFINE_CLASSINFO_DATA(SVGFEMergeElement, nsElementSH,
1059 ELEMENT_SCRIPTABLE_FLAGS)
1060 NS_DEFINE_CLASSINFO_DATA(SVGFEMergeNodeElement, nsElementSH,
1061 ELEMENT_SCRIPTABLE_FLAGS)
1062 NS_DEFINE_CLASSINFO_DATA(SVGFEMorphologyElement, nsElementSH,
1063 ELEMENT_SCRIPTABLE_FLAGS)
1064 NS_DEFINE_CLASSINFO_DATA(SVGFEOffsetElement, nsElementSH,
1065 ELEMENT_SCRIPTABLE_FLAGS)
1066 NS_DEFINE_CLASSINFO_DATA(SVGFEPointLightElement, nsElementSH,
1067 ELEMENT_SCRIPTABLE_FLAGS)
1068 NS_DEFINE_CLASSINFO_DATA(SVGFESpecularLightingElement, nsElementSH,
1069 ELEMENT_SCRIPTABLE_FLAGS)
1070 NS_DEFINE_CLASSINFO_DATA(SVGFESpotLightElement, nsElementSH,
1071 ELEMENT_SCRIPTABLE_FLAGS)
1072 NS_DEFINE_CLASSINFO_DATA(SVGFETileElement, nsElementSH,
1073 ELEMENT_SCRIPTABLE_FLAGS)
1074 NS_DEFINE_CLASSINFO_DATA(SVGFETurbulenceElement, nsElementSH,
1075 ELEMENT_SCRIPTABLE_FLAGS)
1076 NS_DEFINE_CLASSINFO_DATA(SVGFilterElement, nsElementSH,
1077 ELEMENT_SCRIPTABLE_FLAGS)
1078 NS_DEFINE_CLASSINFO_DATA(SVGGElement, nsElementSH,
1079 ELEMENT_SCRIPTABLE_FLAGS)
1080 NS_DEFINE_CLASSINFO_DATA(SVGImageElement, nsElementSH,
1081 ELEMENT_SCRIPTABLE_FLAGS)
1082 NS_DEFINE_CLASSINFO_DATA(SVGLinearGradientElement, nsElementSH,
1083 ELEMENT_SCRIPTABLE_FLAGS)
1084 NS_DEFINE_CLASSINFO_DATA(SVGLineElement, nsElementSH,
1085 ELEMENT_SCRIPTABLE_FLAGS)
1086 NS_DEFINE_CLASSINFO_DATA(SVGMarkerElement, nsElementSH,
1087 ELEMENT_SCRIPTABLE_FLAGS)
1088 NS_DEFINE_CLASSINFO_DATA(SVGMaskElement, nsElementSH,
1089 ELEMENT_SCRIPTABLE_FLAGS)
1090 NS_DEFINE_CLASSINFO_DATA(SVGMetadataElement, nsElementSH,
1091 ELEMENT_SCRIPTABLE_FLAGS)
1092 NS_DEFINE_CLASSINFO_DATA(SVGPathElement, nsElementSH,
1093 ELEMENT_SCRIPTABLE_FLAGS)
1094 NS_DEFINE_CLASSINFO_DATA(SVGPatternElement, nsElementSH,
1095 ELEMENT_SCRIPTABLE_FLAGS)
1096 NS_DEFINE_CLASSINFO_DATA(SVGPolygonElement, nsElementSH,
1097 ELEMENT_SCRIPTABLE_FLAGS)
1098 NS_DEFINE_CLASSINFO_DATA(SVGPolylineElement, nsElementSH,
1099 ELEMENT_SCRIPTABLE_FLAGS)
1100 NS_DEFINE_CLASSINFO_DATA(SVGRadialGradientElement, nsElementSH,
1101 ELEMENT_SCRIPTABLE_FLAGS)
1102 NS_DEFINE_CLASSINFO_DATA(SVGRectElement, nsElementSH,
1103 ELEMENT_SCRIPTABLE_FLAGS)
1104 NS_DEFINE_CLASSINFO_DATA(SVGScriptElement, nsElementSH,
1105 ELEMENT_SCRIPTABLE_FLAGS)
1106 NS_DEFINE_CLASSINFO_DATA(SVGStopElement, nsElementSH,
1107 ELEMENT_SCRIPTABLE_FLAGS)
1108 NS_DEFINE_CLASSINFO_DATA(SVGStyleElement, nsElementSH,
1109 ELEMENT_SCRIPTABLE_FLAGS)
1110 NS_DEFINE_CLASSINFO_DATA(SVGSVGElement, nsElementSH,
1111 ELEMENT_SCRIPTABLE_FLAGS)
1112 NS_DEFINE_CLASSINFO_DATA(SVGSwitchElement, nsElementSH,
1113 ELEMENT_SCRIPTABLE_FLAGS)
1114 NS_DEFINE_CLASSINFO_DATA(SVGSymbolElement, nsElementSH,
1115 ELEMENT_SCRIPTABLE_FLAGS)
1116 NS_DEFINE_CLASSINFO_DATA(SVGTextElement, nsElementSH,
1117 ELEMENT_SCRIPTABLE_FLAGS)
1118 NS_DEFINE_CLASSINFO_DATA(SVGTextPathElement, nsElementSH,
1119 ELEMENT_SCRIPTABLE_FLAGS)
1120 NS_DEFINE_CLASSINFO_DATA(SVGTitleElement, nsElementSH,
1121 ELEMENT_SCRIPTABLE_FLAGS)
1122 NS_DEFINE_CLASSINFO_DATA(SVGTSpanElement, nsElementSH,
1123 ELEMENT_SCRIPTABLE_FLAGS)
1124 NS_DEFINE_CLASSINFO_DATA(SVGUseElement, nsElementSH,
1125 ELEMENT_SCRIPTABLE_FLAGS)
1127 // other SVG classes
1128 NS_DEFINE_CLASSINFO_DATA(SVGAngle, nsDOMGenericSH,
1129 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1130 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedAngle, nsDOMGenericSH,
1131 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1132 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedBoolean, nsDOMGenericSH,
1133 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1134 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedEnumeration, nsDOMGenericSH,
1135 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1136 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedInteger, nsDOMGenericSH,
1137 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1138 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLength, nsDOMGenericSH,
1139 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1140 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedLengthList, nsDOMGenericSH,
1141 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1142 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumber, nsDOMGenericSH,
1143 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1144 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedNumberList, nsDOMGenericSH,
1145 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1146 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedPreserveAspectRatio, nsDOMGenericSH,
1147 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1148 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedRect, nsDOMGenericSH,
1149 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1150 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedString, nsDOMGenericSH,
1151 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1152 NS_DEFINE_CLASSINFO_DATA(SVGAnimatedTransformList, nsDOMGenericSH,
1153 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1154 NS_DEFINE_CLASSINFO_DATA(SVGEvent, nsDOMGenericSH,
1155 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1156 NS_DEFINE_CLASSINFO_DATA(SVGException, nsDOMGenericSH,
1157 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1158 NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
1159 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1160 NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsDOMGenericSH,
1161 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1162 NS_DEFINE_CLASSINFO_DATA(SVGMatrix, nsDOMGenericSH,
1163 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1164 NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
1165 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1166 NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsDOMGenericSH,
1167 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1168 NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcAbs, nsDOMGenericSH,
1169 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1170 NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcRel, nsDOMGenericSH,
1171 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1172 NS_DEFINE_CLASSINFO_DATA(SVGPathSegClosePath, nsDOMGenericSH,
1173 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1174 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicAbs, nsDOMGenericSH,
1175 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1176 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicRel, nsDOMGenericSH,
1177 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1178 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothAbs, nsDOMGenericSH,
1179 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1180 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoCubicSmoothRel, nsDOMGenericSH,
1181 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1182 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticAbs, nsDOMGenericSH,
1183 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1184 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticRel, nsDOMGenericSH,
1185 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1186 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothAbs, nsDOMGenericSH,
1187 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1188 NS_DEFINE_CLASSINFO_DATA(SVGPathSegCurvetoQuadraticSmoothRel, nsDOMGenericSH,
1189 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1190 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoAbs, nsDOMGenericSH,
1191 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1192 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalAbs, nsDOMGenericSH,
1193 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1194 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoHorizontalRel, nsDOMGenericSH,
1195 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1196 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoRel, nsDOMGenericSH,
1197 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1198 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalAbs, nsDOMGenericSH,
1199 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1200 NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalRel, nsDOMGenericSH,
1201 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1202 NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsDOMGenericSH,
1203 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1204 NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoAbs, nsDOMGenericSH,
1205 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1206 NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoRel, nsDOMGenericSH,
1207 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1208 NS_DEFINE_CLASSINFO_DATA(SVGPoint, nsDOMGenericSH,
1209 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1210 NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsDOMGenericSH,
1211 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1212 NS_DEFINE_CLASSINFO_DATA(SVGPreserveAspectRatio, nsDOMGenericSH,
1213 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1214 NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH,
1215 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1216 NS_DEFINE_CLASSINFO_DATA(SVGTransform, nsDOMGenericSH,
1217 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1218 NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsDOMGenericSH,
1219 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1220 NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
1221 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1222 #endif // MOZ_SVG
1224 NS_DEFINE_CLASSINFO_DATA(HTMLCanvasElement, nsElementSH,
1225 ELEMENT_SCRIPTABLE_FLAGS)
1226 NS_DEFINE_CLASSINFO_DATA(CanvasRenderingContext2D, nsDOMGenericSH,
1227 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1228 NS_DEFINE_CLASSINFO_DATA(CanvasGradient, nsDOMGenericSH,
1229 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1230 NS_DEFINE_CLASSINFO_DATA(CanvasPattern, nsDOMGenericSH,
1231 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1232 NS_DEFINE_CLASSINFO_DATA(TextMetrics, nsDOMGenericSH,
1233 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1235 NS_DEFINE_CLASSINFO_DATA(SmartCardEvent, nsDOMGenericSH,
1236 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1237 NS_DEFINE_CLASSINFO_DATA(PageTransitionEvent, nsDOMGenericSH,
1238 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1239 NS_DEFINE_CLASSINFO_DATA(WindowUtils, nsDOMGenericSH,
1240 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1242 NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH,
1243 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1245 NS_DEFINE_CLASSINFO_DATA(XPathEvaluator, nsDOMGenericSH,
1246 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1247 NS_DEFINE_CLASSINFO_DATA(XPathException, nsDOMGenericSH,
1248 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1249 NS_DEFINE_CLASSINFO_DATA(XPathExpression, nsDOMGenericSH,
1250 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1251 NS_DEFINE_CLASSINFO_DATA(XPathNSResolver, nsDOMGenericSH,
1252 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1253 NS_DEFINE_CLASSINFO_DATA(XPathResult, nsDOMGenericSH,
1254 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1256 // WhatWG Storage
1258 // mrbkap says we don't need WANT_ADDPROPERTY on Storage objects
1259 // since a call to addProperty() is always followed by a call to
1260 // setProperty(), except in the case when a getter or setter is set
1261 // for a property. But we don't care about getters or setters here.
1262 NS_DEFINE_CLASSINFO_DATA(StorageObsolete, nsStorageSH,
1263 DOM_DEFAULT_SCRIPTABLE_FLAGS |
1264 nsIXPCScriptable::WANT_NEWRESOLVE |
1265 nsIXPCScriptable::WANT_GETPROPERTY |
1266 nsIXPCScriptable::WANT_SETPROPERTY |
1267 nsIXPCScriptable::WANT_DELPROPERTY |
1268 nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
1269 nsIXPCScriptable::WANT_NEWENUMERATE)
1271 NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
1272 DOM_DEFAULT_SCRIPTABLE_FLAGS |
1273 nsIXPCScriptable::WANT_NEWRESOLVE |
1274 nsIXPCScriptable::WANT_GETPROPERTY |
1275 nsIXPCScriptable::WANT_SETPROPERTY |
1276 nsIXPCScriptable::WANT_DELPROPERTY |
1277 nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
1278 nsIXPCScriptable::WANT_NEWENUMERATE)
1279 NS_DEFINE_CLASSINFO_DATA(StorageList, nsStorageListSH,
1280 ARRAY_SCRIPTABLE_FLAGS)
1281 NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
1282 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1283 NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
1284 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1285 NS_DEFINE_CLASSINFO_DATA(StorageEventObsolete, nsDOMGenericSH,
1286 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1288 NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
1289 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1290 NS_DEFINE_CLASSINFO_DATA(XMLSerializer, nsDOMGenericSH,
1291 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1293 NS_DEFINE_CLASSINFO_DATA(XMLHttpProgressEvent, nsDOMGenericSH,
1294 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1295 NS_DEFINE_CLASSINFO_DATA(XMLHttpRequest, nsEventTargetSH,
1296 EVENTTARGET_SCRIPTABLE_FLAGS)
1298 NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
1299 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1300 NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsClientRectListSH,
1301 ARRAY_SCRIPTABLE_FLAGS)
1303 #ifdef MOZ_SVG
1304 NS_DEFINE_CLASSINFO_DATA(SVGForeignObjectElement, nsElementSH,
1305 ELEMENT_SCRIPTABLE_FLAGS)
1306 #endif
1308 NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsDOMGenericSH,
1309 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1311 NS_DEFINE_CLASSINFO_DATA(CommandEvent, nsDOMGenericSH,
1312 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1313 NS_DEFINE_CLASSINFO_DATA(OfflineResourceList, nsOfflineResourceListSH,
1314 ARRAY_SCRIPTABLE_FLAGS)
1316 NS_DEFINE_CLASSINFO_DATA(FileList, nsFileListSH,
1317 ARRAY_SCRIPTABLE_FLAGS)
1318 NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
1319 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1320 NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
1321 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1322 NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
1323 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1324 NS_DEFINE_CLASSINFO_DATA(FileError, nsDOMGenericSH,
1325 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1326 NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
1327 EVENTTARGET_SCRIPTABLE_FLAGS)
1328 NS_DEFINE_CLASSINFO_DATA(MozURLProperty, nsDOMGenericSH,
1329 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1331 NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
1332 DEFAULT_SCRIPTABLE_FLAGS |
1333 WINDOW_SCRIPTABLE_FLAGS)
1335 NS_DEFINE_CLASSINFO_DATA(DataContainerEvent, nsDOMGenericSH,
1336 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1338 NS_DEFINE_CLASSINFO_DATA(MessageEvent, nsDOMGenericSH,
1339 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1341 NS_DEFINE_CLASSINFO_DATA(GeoGeolocation, nsDOMGenericSH,
1342 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1344 NS_DEFINE_CLASSINFO_DATA(GeoPosition, nsDOMGenericSH,
1345 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1347 NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsDOMGenericSH,
1348 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1350 NS_DEFINE_CLASSINFO_DATA(GeoPositionAddress, nsDOMGenericSH,
1351 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1353 NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH,
1354 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1356 NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
1357 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1358 NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
1359 ARRAY_SCRIPTABLE_FLAGS)
1361 #if defined(MOZ_MEDIA)
1362 NS_DEFINE_CLASSINFO_DATA(HTMLVideoElement, nsElementSH,
1363 ELEMENT_SCRIPTABLE_FLAGS)
1364 NS_DEFINE_CLASSINFO_DATA(HTMLSourceElement, nsElementSH,
1365 ELEMENT_SCRIPTABLE_FLAGS)
1366 NS_DEFINE_CLASSINFO_DATA(MediaError, nsDOMGenericSH,
1367 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1368 NS_DEFINE_CLASSINFO_DATA(HTMLAudioElement, nsElementSH,
1369 ELEMENT_SCRIPTABLE_FLAGS)
1370 NS_DEFINE_CLASSINFO_DATA(TimeRanges, nsDOMGenericSH,
1371 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1372 #endif
1374 NS_DEFINE_CLASSINFO_DATA(ProgressEvent, nsDOMGenericSH,
1375 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1377 NS_DEFINE_CLASSINFO_DATA(XMLHttpRequestUpload, nsEventTargetSH,
1378 EVENTTARGET_SCRIPTABLE_FLAGS)
1380 // DOM Traversal NodeIterator class
1381 NS_DEFINE_CLASSINFO_DATA(NodeIterator, nsDOMGenericSH,
1382 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1384 // data transfer for drag and drop
1385 NS_DEFINE_CLASSINFO_DATA(DataTransfer, nsDOMGenericSH,
1386 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1388 NS_DEFINE_CLASSINFO_DATA(NotifyPaintEvent, nsDOMGenericSH,
1389 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1391 NS_DEFINE_CLASSINFO_DATA(NotifyAudioAvailableEvent, nsDOMGenericSH,
1392 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1394 NS_DEFINE_CLASSINFO_DATA(SimpleGestureEvent, nsDOMGenericSH,
1395 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1397 NS_DEFINE_CLASSINFO_DATA(MozTouchEvent, nsDOMGenericSH,
1398 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1399 #ifdef MOZ_MATHML
1400 NS_DEFINE_CLASSINFO_DATA_WITH_NAME(MathMLElement, Element, nsElementSH,
1401 ELEMENT_SCRIPTABLE_FLAGS)
1402 #endif
1404 NS_DEFINE_CLASSINFO_DATA(Worker, nsDOMGenericSH,
1405 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1406 NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeWorker, nsDOMGenericSH,
1407 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1409 NS_DEFINE_CLASSINFO_DATA(WebGLRenderingContext, nsWebGLViewportHandlerSH,
1410 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1411 NS_DEFINE_CLASSINFO_DATA(WebGLBuffer, nsDOMGenericSH,
1412 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1413 NS_DEFINE_CLASSINFO_DATA(WebGLTexture, nsDOMGenericSH,
1414 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1415 NS_DEFINE_CLASSINFO_DATA(WebGLProgram, nsDOMGenericSH,
1416 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1417 NS_DEFINE_CLASSINFO_DATA(WebGLShader, nsDOMGenericSH,
1418 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1419 NS_DEFINE_CLASSINFO_DATA(WebGLFramebuffer, nsDOMGenericSH,
1420 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1421 NS_DEFINE_CLASSINFO_DATA(WebGLRenderbuffer, nsDOMGenericSH,
1422 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1423 NS_DEFINE_CLASSINFO_DATA(WebGLUniformLocation, nsDOMGenericSH,
1424 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1425 NS_DEFINE_CLASSINFO_DATA(WebGLActiveInfo, nsDOMGenericSH,
1426 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1428 NS_DEFINE_CLASSINFO_DATA(PaintRequest, nsDOMGenericSH,
1429 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1430 NS_DEFINE_CLASSINFO_DATA(PaintRequestList, nsPaintRequestListSH,
1431 ARRAY_SCRIPTABLE_FLAGS)
1433 NS_DEFINE_CLASSINFO_DATA(ScrollAreaEvent, nsDOMGenericSH,
1434 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1435 NS_DEFINE_CLASSINFO_DATA(PopStateEvent, nsDOMGenericSH,
1436 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1437 NS_DEFINE_CLASSINFO_DATA(EventListenerInfo, nsDOMGenericSH,
1438 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1439 NS_DEFINE_CLASSINFO_DATA(TransitionEvent, nsDOMGenericSH,
1440 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1441 NS_DEFINE_CLASSINFO_DATA(ContentFrameMessageManager, nsDOMGenericSH,
1442 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1444 NS_DEFINE_CLASSINFO_DATA(FormData, nsDOMGenericSH,
1445 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1447 NS_DEFINE_CLASSINFO_DATA(DesktopNotification, nsDOMGenericSH,
1448 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1449 NS_DEFINE_CLASSINFO_DATA(DesktopNotificationCenter, nsDOMGenericSH,
1450 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1452 NS_DEFINE_CLASSINFO_DATA(WebSocket, nsEventTargetSH,
1453 EVENTTARGET_SCRIPTABLE_FLAGS)
1455 NS_DEFINE_CLASSINFO_DATA(CloseEvent, nsDOMGenericSH,
1456 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1458 NS_DEFINE_CLASSINFO_DATA(IDBFactory, nsDOMGenericSH,
1459 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1460 NS_DEFINE_CLASSINFO_DATA(IDBRequest, nsDOMGenericSH,
1461 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1462 NS_DEFINE_CLASSINFO_DATA(IDBDatabase, nsDOMGenericSH,
1463 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1464 NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
1465 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1466 NS_DEFINE_CLASSINFO_DATA(IDBTransaction, nsDOMGenericSH,
1467 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1468 NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
1469 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1470 NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
1471 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1472 NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
1473 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1474 NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
1475 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1476 NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeEvent, nsDOMGenericSH,
1477 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1478 NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeRequest, nsDOMGenericSH,
1479 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1480 NS_DEFINE_CLASSINFO_DATA(IDBDatabaseException, nsDOMGenericSH,
1481 DOM_DEFAULT_SCRIPTABLE_FLAGS)
1484 // Objects that should be constructable through |new Name();|
1485 struct nsContractIDMapData
1487 PRInt32 mDOMClassInfoID;
1488 const char *mContractID;
1491 #define NS_DEFINE_CONSTRUCTOR_DATA(_class, _contract_id) \
1492 { eDOMClassInfo_##_class##_id, _contract_id },
1494 static const nsContractIDMapData kConstructorMap[] =
1496 NS_DEFINE_CONSTRUCTOR_DATA(DOMParser, NS_DOMPARSER_CONTRACTID)
1497 NS_DEFINE_CONSTRUCTOR_DATA(FileReader, NS_FILEREADER_CONTRACTID)
1498 NS_DEFINE_CONSTRUCTOR_DATA(FormData, NS_FORMDATA_CONTRACTID)
1499 NS_DEFINE_CONSTRUCTOR_DATA(XMLSerializer, NS_XMLSERIALIZER_CONTRACTID)
1500 NS_DEFINE_CONSTRUCTOR_DATA(XMLHttpRequest, NS_XMLHTTPREQUEST_CONTRACTID)
1501 NS_DEFINE_CONSTRUCTOR_DATA(WebSocket, NS_WEBSOCKET_CONTRACTID)
1502 NS_DEFINE_CONSTRUCTOR_DATA(XPathEvaluator, NS_XPATH_EVALUATOR_CONTRACTID)
1503 NS_DEFINE_CONSTRUCTOR_DATA(XSLTProcessor,
1504 "@mozilla.org/document-transformer;1?type=xslt")
1507 struct nsConstructorFuncMapData
1509 PRInt32 mDOMClassInfoID;
1510 nsDOMConstructorFunc mConstructorFunc;
1513 #define NS_DEFINE_CONSTRUCTOR_FUNC_DATA(_class, _func) \
1514 { eDOMClassInfo_##_class##_id, _func },
1516 static const nsConstructorFuncMapData kConstructorFuncMap[] =
1518 NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Worker, nsDOMWorker::NewWorker)
1519 NS_DEFINE_CONSTRUCTOR_FUNC_DATA(ChromeWorker, nsDOMWorker::NewChromeWorker)
1522 nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
1523 nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
1524 PRBool nsDOMClassInfo::sIsInitialized = PR_FALSE;
1525 PRBool nsDOMClassInfo::sDisableDocumentAllSupport = PR_FALSE;
1526 PRBool nsDOMClassInfo::sDisableGlobalScopePollutionSupport = PR_FALSE;
1529 jsid nsDOMClassInfo::sTop_id = JSID_VOID;
1530 jsid nsDOMClassInfo::sParent_id = JSID_VOID;
1531 jsid nsDOMClassInfo::sScrollbars_id = JSID_VOID;
1532 jsid nsDOMClassInfo::sLocation_id = JSID_VOID;
1533 jsid nsDOMClassInfo::sConstructor_id = JSID_VOID;
1534 jsid nsDOMClassInfo::s_content_id = JSID_VOID;
1535 jsid nsDOMClassInfo::sContent_id = JSID_VOID;
1536 jsid nsDOMClassInfo::sMenubar_id = JSID_VOID;
1537 jsid nsDOMClassInfo::sToolbar_id = JSID_VOID;
1538 jsid nsDOMClassInfo::sLocationbar_id = JSID_VOID;
1539 jsid nsDOMClassInfo::sPersonalbar_id = JSID_VOID;
1540 jsid nsDOMClassInfo::sStatusbar_id = JSID_VOID;
1541 jsid nsDOMClassInfo::sDialogArguments_id = JSID_VOID;
1542 jsid nsDOMClassInfo::sControllers_id = JSID_VOID;
1543 jsid nsDOMClassInfo::sLength_id = JSID_VOID;
1544 jsid nsDOMClassInfo::sInnerHeight_id = JSID_VOID;
1545 jsid nsDOMClassInfo::sInnerWidth_id = JSID_VOID;
1546 jsid nsDOMClassInfo::sOuterHeight_id = JSID_VOID;
1547 jsid nsDOMClassInfo::sOuterWidth_id = JSID_VOID;
1548 jsid nsDOMClassInfo::sScreenX_id = JSID_VOID;
1549 jsid nsDOMClassInfo::sScreenY_id = JSID_VOID;
1550 jsid nsDOMClassInfo::sStatus_id = JSID_VOID;
1551 jsid nsDOMClassInfo::sName_id = JSID_VOID;
1552 jsid nsDOMClassInfo::sOnmousedown_id = JSID_VOID;
1553 jsid nsDOMClassInfo::sOnmouseup_id = JSID_VOID;
1554 jsid nsDOMClassInfo::sOnclick_id = JSID_VOID;
1555 jsid nsDOMClassInfo::sOndblclick_id = JSID_VOID;
1556 jsid nsDOMClassInfo::sOncontextmenu_id = JSID_VOID;
1557 jsid nsDOMClassInfo::sOnmouseover_id = JSID_VOID;
1558 jsid nsDOMClassInfo::sOnmouseout_id = JSID_VOID;
1559 jsid nsDOMClassInfo::sOnkeydown_id = JSID_VOID;
1560 jsid nsDOMClassInfo::sOnkeyup_id = JSID_VOID;
1561 jsid nsDOMClassInfo::sOnkeypress_id = JSID_VOID;
1562 jsid nsDOMClassInfo::sOnmousemove_id = JSID_VOID;
1563 jsid nsDOMClassInfo::sOnfocus_id = JSID_VOID;
1564 jsid nsDOMClassInfo::sOnblur_id = JSID_VOID;
1565 jsid nsDOMClassInfo::sOnsubmit_id = JSID_VOID;
1566 jsid nsDOMClassInfo::sOnreset_id = JSID_VOID;
1567 jsid nsDOMClassInfo::sOnchange_id = JSID_VOID;
1568 jsid nsDOMClassInfo::sOninput_id = JSID_VOID;
1569 jsid nsDOMClassInfo::sOninvalid_id = JSID_VOID;
1570 jsid nsDOMClassInfo::sOnselect_id = JSID_VOID;
1571 jsid nsDOMClassInfo::sOnload_id = JSID_VOID;
1572 jsid nsDOMClassInfo::sOnpopstate_id = JSID_VOID;
1573 jsid nsDOMClassInfo::sOnbeforeunload_id = JSID_VOID;
1574 jsid nsDOMClassInfo::sOnunload_id = JSID_VOID;
1575 jsid nsDOMClassInfo::sOnhashchange_id = JSID_VOID;
1576 jsid nsDOMClassInfo::sOnreadystatechange_id = JSID_VOID;
1577 jsid nsDOMClassInfo::sOnpageshow_id = JSID_VOID;
1578 jsid nsDOMClassInfo::sOnpagehide_id = JSID_VOID;
1579 jsid nsDOMClassInfo::sOnabort_id = JSID_VOID;
1580 jsid nsDOMClassInfo::sOnerror_id = JSID_VOID;
1581 jsid nsDOMClassInfo::sOnpaint_id = JSID_VOID;
1582 jsid nsDOMClassInfo::sOnresize_id = JSID_VOID;
1583 jsid nsDOMClassInfo::sOnscroll_id = JSID_VOID;
1584 jsid nsDOMClassInfo::sOndrag_id = JSID_VOID;
1585 jsid nsDOMClassInfo::sOndragend_id = JSID_VOID;
1586 jsid nsDOMClassInfo::sOndragenter_id = JSID_VOID;
1587 jsid nsDOMClassInfo::sOndragleave_id = JSID_VOID;
1588 jsid nsDOMClassInfo::sOndragover_id = JSID_VOID;
1589 jsid nsDOMClassInfo::sOndragstart_id = JSID_VOID;
1590 jsid nsDOMClassInfo::sOndrop_id = JSID_VOID;
1591 jsid nsDOMClassInfo::sScrollX_id = JSID_VOID;
1592 jsid nsDOMClassInfo::sScrollY_id = JSID_VOID;
1593 jsid nsDOMClassInfo::sScrollMaxX_id = JSID_VOID;
1594 jsid nsDOMClassInfo::sScrollMaxY_id = JSID_VOID;
1595 jsid nsDOMClassInfo::sOpen_id = JSID_VOID;
1596 jsid nsDOMClassInfo::sItem_id = JSID_VOID;
1597 jsid nsDOMClassInfo::sNamedItem_id = JSID_VOID;
1598 jsid nsDOMClassInfo::sEnumerate_id = JSID_VOID;
1599 jsid nsDOMClassInfo::sNavigator_id = JSID_VOID;
1600 jsid nsDOMClassInfo::sDocument_id = JSID_VOID;
1601 jsid nsDOMClassInfo::sFrames_id = JSID_VOID;
1602 jsid nsDOMClassInfo::sSelf_id = JSID_VOID;
1603 jsid nsDOMClassInfo::sOpener_id = JSID_VOID;
1604 jsid nsDOMClassInfo::sAll_id = JSID_VOID;
1605 jsid nsDOMClassInfo::sTags_id = JSID_VOID;
1606 jsid nsDOMClassInfo::sAddEventListener_id= JSID_VOID;
1607 jsid nsDOMClassInfo::sBaseURIObject_id = JSID_VOID;
1608 jsid nsDOMClassInfo::sNodePrincipal_id = JSID_VOID;
1609 jsid nsDOMClassInfo::sDocumentURIObject_id=JSID_VOID;
1610 jsid nsDOMClassInfo::sOncopy_id = JSID_VOID;
1611 jsid nsDOMClassInfo::sOncut_id = JSID_VOID;
1612 jsid nsDOMClassInfo::sOnpaste_id = JSID_VOID;
1613 jsid nsDOMClassInfo::sJava_id = JSID_VOID;
1614 jsid nsDOMClassInfo::sPackages_id = JSID_VOID;
1615 jsid nsDOMClassInfo::sOnloadstart_id = JSID_VOID;
1616 jsid nsDOMClassInfo::sOnprogress_id = JSID_VOID;
1617 jsid nsDOMClassInfo::sOnsuspend_id = JSID_VOID;
1618 jsid nsDOMClassInfo::sOnemptied_id = JSID_VOID;
1619 jsid nsDOMClassInfo::sOnstalled_id = JSID_VOID;
1620 jsid nsDOMClassInfo::sOnplay_id = JSID_VOID;
1621 jsid nsDOMClassInfo::sOnpause_id = JSID_VOID;
1622 jsid nsDOMClassInfo::sOnloadedmetadata_id= JSID_VOID;
1623 jsid nsDOMClassInfo::sOnloadeddata_id = JSID_VOID;
1624 jsid nsDOMClassInfo::sOnwaiting_id = JSID_VOID;
1625 jsid nsDOMClassInfo::sOnplaying_id = JSID_VOID;
1626 jsid nsDOMClassInfo::sOncanplay_id = JSID_VOID;
1627 jsid nsDOMClassInfo::sOncanplaythrough_id= JSID_VOID;
1628 jsid nsDOMClassInfo::sOnseeking_id = JSID_VOID;
1629 jsid nsDOMClassInfo::sOnseeked_id = JSID_VOID;
1630 jsid nsDOMClassInfo::sOntimeupdate_id = JSID_VOID;
1631 jsid nsDOMClassInfo::sOnended_id = JSID_VOID;
1632 jsid nsDOMClassInfo::sOnratechange_id = JSID_VOID;
1633 jsid nsDOMClassInfo::sOndurationchange_id= JSID_VOID;
1634 jsid nsDOMClassInfo::sOnvolumechange_id = JSID_VOID;
1635 jsid nsDOMClassInfo::sOnmessage_id = JSID_VOID;
1636 jsid nsDOMClassInfo::sOnbeforescriptexecute_id = JSID_VOID;
1637 jsid nsDOMClassInfo::sOnafterscriptexecute_id = JSID_VOID;
1638 jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
1639 jsid nsDOMClassInfo::sURL_id = JSID_VOID;
1640 jsid nsDOMClassInfo::sKeyPath_id = JSID_VOID;
1641 jsid nsDOMClassInfo::sAutoIncrement_id = JSID_VOID;
1642 jsid nsDOMClassInfo::sUnique_id = JSID_VOID;
1644 static const JSClass *sObjectClass = nsnull;
1647 * Set our JSClass pointer for the Object class
1649 static void
1650 FindObjectClass(JSObject* aGlobalObject)
1652 NS_ASSERTION(!sObjectClass,
1653 "Double set of sObjectClass");
1654 JSObject *obj, *proto = aGlobalObject;
1655 do {
1656 obj = proto;
1657 proto = obj->getProto();
1658 } while (proto);
1660 sObjectClass = obj->getJSClass();
1663 static void
1664 PrintWarningOnConsole(JSContext *cx, const char *stringBundleProperty)
1666 nsCOMPtr<nsIStringBundleService> stringService =
1667 mozilla::services::GetStringBundleService();
1668 if (!stringService) {
1669 return;
1672 nsCOMPtr<nsIStringBundle> bundle;
1673 stringService->CreateBundle(kDOMStringBundleURL, getter_AddRefs(bundle));
1674 if (!bundle) {
1675 return;
1678 nsXPIDLString msg;
1679 bundle->GetStringFromName(NS_ConvertASCIItoUTF16(stringBundleProperty).get(),
1680 getter_Copies(msg));
1682 if (msg.IsEmpty()) {
1683 NS_ERROR("Failed to get strings from dom.properties!");
1684 return;
1687 nsCOMPtr<nsIConsoleService> consoleService
1688 (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
1689 if (!consoleService) {
1690 return;
1693 nsCOMPtr<nsIScriptError2> scriptError =
1694 do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
1695 if (!scriptError) {
1696 return;
1699 JSStackFrame *fp, *iterator = nsnull;
1700 fp = ::JS_FrameIterator(cx, &iterator);
1701 PRUint32 lineno = 0;
1702 nsAutoString sourcefile;
1703 if (fp) {
1704 JSScript* script = ::JS_GetFrameScript(cx, fp);
1705 if (script) {
1706 const char* filename = ::JS_GetScriptFilename(cx, script);
1707 if (filename) {
1708 CopyUTF8toUTF16(nsDependentCString(filename), sourcefile);
1710 jsbytecode* pc = ::JS_GetFramePC(cx, fp);
1711 if (pc) {
1712 lineno = ::JS_PCToLineNumber(cx, script, pc);
1717 nsresult rv = scriptError->InitWithWindowID(msg.get(),
1718 sourcefile.get(),
1719 EmptyString().get(),
1720 lineno,
1721 0, // column for error is not available
1722 nsIScriptError::warningFlag,
1723 "DOM:HTML",
1724 nsJSUtils::GetCurrentlyRunningCodeWindowID(cx));
1726 if (NS_SUCCEEDED(rv)){
1727 nsCOMPtr<nsIScriptError> logError = do_QueryInterface(scriptError);
1728 consoleService->LogMessage(logError);
1732 static inline JSString *
1733 IdToString(JSContext *cx, jsid id)
1735 if (JSID_IS_STRING(id))
1736 return JSID_TO_STRING(id);
1737 jsval idval;
1738 if (!::JS_IdToValue(cx, id, &idval))
1739 return nsnull;
1740 return JS_ValueToString(cx, idval);
1743 // static
1745 nsISupports *
1746 nsDOMClassInfo::GetNative(nsIXPConnectWrappedNative *wrapper, JSObject *obj)
1748 return wrapper ? wrapper->Native() : static_cast<nsISupports*>(obj->getPrivate());
1751 nsresult
1752 nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
1754 #define SET_JSID_TO_STRING(_id, _cx, _str) \
1755 if (JSString *str = ::JS_InternString(_cx, _str)) \
1756 _id = INTERNED_STRING_TO_JSID(str); \
1757 else \
1758 return NS_ERROR_OUT_OF_MEMORY;
1760 JSAutoRequest ar(cx);
1762 SET_JSID_TO_STRING(sTop_id, cx, "top");
1763 SET_JSID_TO_STRING(sParent_id, cx, "parent");
1764 SET_JSID_TO_STRING(sScrollbars_id, cx, "scrollbars");
1765 SET_JSID_TO_STRING(sLocation_id, cx, "location");
1766 SET_JSID_TO_STRING(sConstructor_id, cx, "constructor");
1767 SET_JSID_TO_STRING(s_content_id, cx, "_content");
1768 SET_JSID_TO_STRING(sContent_id, cx, "content");
1769 SET_JSID_TO_STRING(sMenubar_id, cx, "menubar");
1770 SET_JSID_TO_STRING(sToolbar_id, cx, "toolbar");
1771 SET_JSID_TO_STRING(sLocationbar_id, cx, "locationbar");
1772 SET_JSID_TO_STRING(sPersonalbar_id, cx, "personalbar");
1773 SET_JSID_TO_STRING(sStatusbar_id, cx, "statusbar");
1774 SET_JSID_TO_STRING(sDialogArguments_id, cx, "dialogArguments");
1775 SET_JSID_TO_STRING(sControllers_id, cx, "controllers");
1776 SET_JSID_TO_STRING(sLength_id, cx, "length");
1777 SET_JSID_TO_STRING(sInnerHeight_id, cx, "innerHeight");
1778 SET_JSID_TO_STRING(sInnerWidth_id, cx, "innerWidth");
1779 SET_JSID_TO_STRING(sOuterHeight_id, cx, "outerHeight");
1780 SET_JSID_TO_STRING(sOuterWidth_id, cx, "outerWidth");
1781 SET_JSID_TO_STRING(sScreenX_id, cx, "screenX");
1782 SET_JSID_TO_STRING(sScreenY_id, cx, "screenY");
1783 SET_JSID_TO_STRING(sStatus_id, cx, "status");
1784 SET_JSID_TO_STRING(sName_id, cx, "name");
1785 SET_JSID_TO_STRING(sOnmousedown_id, cx, "onmousedown");
1786 SET_JSID_TO_STRING(sOnmouseup_id, cx, "onmouseup");
1787 SET_JSID_TO_STRING(sOnclick_id, cx, "onclick");
1788 SET_JSID_TO_STRING(sOndblclick_id, cx, "ondblclick");
1789 SET_JSID_TO_STRING(sOncontextmenu_id, cx, "oncontextmenu");
1790 SET_JSID_TO_STRING(sOnmouseover_id, cx, "onmouseover");
1791 SET_JSID_TO_STRING(sOnmouseout_id, cx, "onmouseout");
1792 SET_JSID_TO_STRING(sOnkeydown_id, cx, "onkeydown");
1793 SET_JSID_TO_STRING(sOnkeyup_id, cx, "onkeyup");
1794 SET_JSID_TO_STRING(sOnkeypress_id, cx, "onkeypress");
1795 SET_JSID_TO_STRING(sOnmousemove_id, cx, "onmousemove");
1796 SET_JSID_TO_STRING(sOnfocus_id, cx, "onfocus");
1797 SET_JSID_TO_STRING(sOnblur_id, cx, "onblur");
1798 SET_JSID_TO_STRING(sOnsubmit_id, cx, "onsubmit");
1799 SET_JSID_TO_STRING(sOnreset_id, cx, "onreset");
1800 SET_JSID_TO_STRING(sOnchange_id, cx, "onchange");
1801 SET_JSID_TO_STRING(sOninput_id, cx, "oninput");
1802 SET_JSID_TO_STRING(sOninvalid_id, cx, "oninvalid");
1803 SET_JSID_TO_STRING(sOnselect_id, cx, "onselect");
1804 SET_JSID_TO_STRING(sOnload_id, cx, "onload");
1805 SET_JSID_TO_STRING(sOnpopstate_id, cx, "onpopstate");
1806 SET_JSID_TO_STRING(sOnbeforeunload_id, cx, "onbeforeunload");
1807 SET_JSID_TO_STRING(sOnunload_id, cx, "onunload");
1808 SET_JSID_TO_STRING(sOnhashchange_id, cx, "onhashchange");
1809 SET_JSID_TO_STRING(sOnreadystatechange_id, cx, "onreadystatechange");
1810 SET_JSID_TO_STRING(sOnpageshow_id, cx, "onpageshow");
1811 SET_JSID_TO_STRING(sOnpagehide_id, cx, "onpagehide");
1812 SET_JSID_TO_STRING(sOnabort_id, cx, "onabort");
1813 SET_JSID_TO_STRING(sOnerror_id, cx, "onerror");
1814 SET_JSID_TO_STRING(sOnpaint_id, cx, "onpaint");
1815 SET_JSID_TO_STRING(sOnresize_id, cx, "onresize");
1816 SET_JSID_TO_STRING(sOnscroll_id, cx, "onscroll");
1817 SET_JSID_TO_STRING(sOndrag_id, cx, "ondrag");
1818 SET_JSID_TO_STRING(sOndragend_id, cx, "ondragend");
1819 SET_JSID_TO_STRING(sOndragenter_id, cx, "ondragenter");
1820 SET_JSID_TO_STRING(sOndragleave_id, cx, "ondragleave");
1821 SET_JSID_TO_STRING(sOndragover_id, cx, "ondragover");
1822 SET_JSID_TO_STRING(sOndragstart_id, cx, "ondragstart");
1823 SET_JSID_TO_STRING(sOndrop_id, cx, "ondrop");
1824 SET_JSID_TO_STRING(sScrollX_id, cx, "scrollX");
1825 SET_JSID_TO_STRING(sScrollY_id, cx, "scrollY");
1826 SET_JSID_TO_STRING(sScrollMaxX_id, cx, "scrollMaxX");
1827 SET_JSID_TO_STRING(sScrollMaxY_id, cx, "scrollMaxY");
1828 SET_JSID_TO_STRING(sOpen_id, cx, "open");
1829 SET_JSID_TO_STRING(sItem_id, cx, "item");
1830 SET_JSID_TO_STRING(sNamedItem_id, cx, "namedItem");
1831 SET_JSID_TO_STRING(sEnumerate_id, cx, "enumerateProperties");
1832 SET_JSID_TO_STRING(sNavigator_id, cx, "navigator");
1833 SET_JSID_TO_STRING(sDocument_id, cx, "document");
1834 SET_JSID_TO_STRING(sFrames_id, cx, "frames");
1835 SET_JSID_TO_STRING(sSelf_id, cx, "self");
1836 SET_JSID_TO_STRING(sOpener_id, cx, "opener");
1837 SET_JSID_TO_STRING(sAll_id, cx, "all");
1838 SET_JSID_TO_STRING(sTags_id, cx, "tags");
1839 SET_JSID_TO_STRING(sAddEventListener_id,cx, "addEventListener");
1840 SET_JSID_TO_STRING(sBaseURIObject_id, cx, "baseURIObject");
1841 SET_JSID_TO_STRING(sNodePrincipal_id, cx, "nodePrincipal");
1842 SET_JSID_TO_STRING(sDocumentURIObject_id,cx,"documentURIObject");
1843 SET_JSID_TO_STRING(sOncopy_id, cx, "oncopy");
1844 SET_JSID_TO_STRING(sOncut_id, cx, "oncut");
1845 SET_JSID_TO_STRING(sOnpaste_id, cx, "onpaste");
1846 SET_JSID_TO_STRING(sJava_id, cx, "java");
1847 SET_JSID_TO_STRING(sPackages_id, cx, "Packages");
1848 #ifdef MOZ_MEDIA
1849 SET_JSID_TO_STRING(sOnloadstart_id, cx, "onloadstart");
1850 SET_JSID_TO_STRING(sOnprogress_id, cx, "onprogress");
1851 SET_JSID_TO_STRING(sOnsuspend_id, cx, "onsuspend");
1852 SET_JSID_TO_STRING(sOnemptied_id, cx, "onemptied");
1853 SET_JSID_TO_STRING(sOnstalled_id, cx, "onstalled");
1854 SET_JSID_TO_STRING(sOnplay_id, cx, "onplay");
1855 SET_JSID_TO_STRING(sOnpause_id, cx, "onpause");
1856 SET_JSID_TO_STRING(sOnloadedmetadata_id,cx, "onloadedmetadata");
1857 SET_JSID_TO_STRING(sOnloadeddata_id, cx, "onloadeddata");
1858 SET_JSID_TO_STRING(sOnwaiting_id, cx, "onwaiting");
1859 SET_JSID_TO_STRING(sOnplaying_id, cx, "onplaying");
1860 SET_JSID_TO_STRING(sOncanplay_id, cx, "oncanplay");
1861 SET_JSID_TO_STRING(sOncanplaythrough_id,cx, "oncanplaythrough");
1862 SET_JSID_TO_STRING(sOnseeking_id, cx, "onseeking");
1863 SET_JSID_TO_STRING(sOnseeked_id, cx, "onseeked");
1864 SET_JSID_TO_STRING(sOntimeupdate_id, cx, "ontimeupdate");
1865 SET_JSID_TO_STRING(sOnended_id, cx, "onended");
1866 SET_JSID_TO_STRING(sOnratechange_id, cx, "onratechange");
1867 SET_JSID_TO_STRING(sOndurationchange_id,cx, "ondurationchange");
1868 SET_JSID_TO_STRING(sOnvolumechange_id, cx, "onvolumechange");
1869 SET_JSID_TO_STRING(sOnmessage_id, cx, "onmessage");
1870 SET_JSID_TO_STRING(sOnbeforescriptexecute_id, cx, "onbeforescriptexecute");
1871 SET_JSID_TO_STRING(sOnafterscriptexecute_id, cx, "onafterscriptexecute");
1872 #endif // MOZ_MEDIA
1873 SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject");
1874 SET_JSID_TO_STRING(sURL_id, cx, "URL");
1875 SET_JSID_TO_STRING(sKeyPath_id, cx, "keyPath");
1876 SET_JSID_TO_STRING(sAutoIncrement_id, cx, "autoIncrement");
1877 SET_JSID_TO_STRING(sUnique_id, cx, "unique");
1879 return NS_OK;
1882 static nsresult
1883 CreateExceptionFromResult(JSContext *cx, nsresult aResult)
1885 nsCOMPtr<nsIExceptionService> xs =
1886 do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
1887 if (!xs) {
1888 return NS_ERROR_FAILURE;
1891 nsCOMPtr<nsIExceptionManager> xm;
1892 nsresult rv = xs->GetCurrentExceptionManager(getter_AddRefs(xm));
1893 if (NS_FAILED(rv)) {
1894 return NS_ERROR_FAILURE;
1897 nsCOMPtr<nsIException> exception;
1898 rv = xm->GetExceptionFromProvider(aResult, 0, getter_AddRefs(exception));
1899 if (NS_FAILED(rv) || !exception) {
1900 return NS_ERROR_FAILURE;
1903 jsval jv;
1904 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
1905 rv = nsDOMClassInfo::WrapNative(cx, ::JS_GetGlobalObject(cx), exception,
1906 &NS_GET_IID(nsIException), PR_FALSE, &jv,
1907 getter_AddRefs(holder));
1908 if (NS_FAILED(rv) || JSVAL_IS_NULL(jv)) {
1909 return NS_ERROR_FAILURE;
1912 JSAutoEnterCompartment ac;
1914 if (JSVAL_IS_OBJECT(jv)) {
1915 if (!ac.enter(cx, JSVAL_TO_OBJECT(jv))) {
1916 return NS_ERROR_UNEXPECTED;
1920 JS_SetPendingException(cx, jv);
1921 return NS_OK;
1924 // static
1925 nsresult
1926 nsDOMClassInfo::ThrowJSException(JSContext *cx, nsresult aResult)
1928 JSAutoRequest ar(cx);
1930 if (NS_SUCCEEDED(CreateExceptionFromResult(cx, aResult))) {
1931 return NS_OK;
1934 // XXX This probably wants to be localized, but that can fail in ways that
1935 // are hard to report correctly.
1936 JSString *str =
1937 JS_NewStringCopyZ(cx, "An error occurred throwing an exception");
1938 if (!str) {
1939 // JS_NewStringCopyZ reported the error for us.
1940 return NS_OK;
1942 JS_SetPendingException(cx, STRING_TO_JSVAL(str));
1943 return NS_OK;
1946 // static
1947 PRBool
1948 nsDOMClassInfo::ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
1950 return xpc::WrapperFactory::IsXrayWrapper(obj) &&
1951 !xpc::WrapperFactory::IsPartiallyTransparent(obj);
1954 nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
1958 nsDOMClassInfo::~nsDOMClassInfo()
1960 if (IS_EXTERNAL(mData->mCachedClassInfo)) {
1961 // Some compilers don't like delete'ing a const nsDOMClassInfo*
1962 nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
1963 delete static_cast<nsExternalDOMClassInfoData*>(data);
1967 NS_IMPL_ADDREF(nsDOMClassInfo)
1968 NS_IMPL_RELEASE(nsDOMClassInfo)
1970 NS_INTERFACE_MAP_BEGIN(nsDOMClassInfo)
1971 if (aIID.Equals(NS_GET_IID(nsXPCClassInfo)))
1972 foundInterface = static_cast<nsIClassInfo*>(
1973 static_cast<nsXPCClassInfo*>(this));
1974 else
1975 NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
1976 NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
1977 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIClassInfo)
1978 NS_INTERFACE_MAP_END
1981 static JSClass sDOMConstructorProtoClass = {
1982 "DOM Constructor.prototype", 0,
1983 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
1984 JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, nsnull
1988 static const char *
1989 CutPrefix(const char *aName) {
1990 static const char prefix_nsIDOM[] = "nsIDOM";
1991 static const char prefix_nsI[] = "nsI";
1993 if (strncmp(aName, prefix_nsIDOM, sizeof(prefix_nsIDOM) - 1) == 0) {
1994 return aName + sizeof(prefix_nsIDOM) - 1;
1997 if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
1998 return aName + sizeof(prefix_nsI) - 1;
2001 return aName;
2004 // static
2005 nsresult
2006 nsDOMClassInfo::RegisterClassName(PRInt32 aClassInfoID)
2008 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
2009 NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2011 nameSpaceManager->RegisterClassName(sClassInfoData[aClassInfoID].mName,
2012 aClassInfoID,
2013 sClassInfoData[aClassInfoID].mChromeOnly,
2014 &sClassInfoData[aClassInfoID].mNameUTF16);
2016 return NS_OK;
2019 // static
2020 nsresult
2021 nsDOMClassInfo::RegisterClassProtos(PRInt32 aClassInfoID)
2023 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
2024 NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2025 PRBool found_old;
2027 const nsIID *primary_iid = sClassInfoData[aClassInfoID].mProtoChainInterface;
2029 if (!primary_iid || primary_iid == &NS_GET_IID(nsISupports)) {
2030 return NS_OK;
2033 nsCOMPtr<nsIInterfaceInfoManager>
2034 iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
2035 NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
2037 nsCOMPtr<nsIInterfaceInfo> if_info;
2038 PRBool first = PR_TRUE;
2040 iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
2042 while (if_info) {
2043 const nsIID *iid = nsnull;
2045 if_info->GetIIDShared(&iid);
2046 NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
2048 if (iid->Equals(NS_GET_IID(nsISupports))) {
2049 break;
2052 const char *name = nsnull;
2053 if_info->GetNameShared(&name);
2054 NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
2056 nameSpaceManager->RegisterClassProto(CutPrefix(name), iid, &found_old);
2058 if (first) {
2059 first = PR_FALSE;
2060 } else if (found_old) {
2061 break;
2064 nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
2065 tmp->GetParent(getter_AddRefs(if_info));
2068 return NS_OK;
2071 // static
2072 nsresult
2073 nsDOMClassInfo::RegisterExternalClasses()
2075 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
2076 NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2078 nsCOMPtr<nsIComponentRegistrar> registrar;
2079 nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
2080 NS_ENSURE_SUCCESS(rv, rv);
2082 nsCOMPtr<nsICategoryManager> cm =
2083 do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
2084 NS_ENSURE_SUCCESS(rv, rv);
2086 nsCOMPtr<nsISimpleEnumerator> e;
2087 rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e));
2088 NS_ENSURE_SUCCESS(rv, rv);
2090 nsXPIDLCString contractId;
2091 nsCAutoString categoryEntry;
2092 nsCOMPtr<nsISupports> entry;
2094 while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
2095 nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
2097 if (!category) {
2098 NS_WARNING("Category entry not an nsISupportsCString!");
2099 continue;
2102 rv = category->GetData(categoryEntry);
2104 cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
2105 getter_Copies(contractId));
2106 NS_ENSURE_SUCCESS(rv, rv);
2108 nsCID *cid;
2109 rv = registrar->ContractIDToCID(contractId, &cid);
2110 if (NS_FAILED(rv)) {
2111 NS_WARNING("Bad contract id registered with the script namespace manager");
2112 continue;
2115 rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
2116 nsMemory::Free(cid);
2117 NS_ENSURE_SUCCESS(rv, rv);
2120 return nameSpaceManager->RegisterExternalInterfaces(PR_TRUE);
2123 // static
2124 inline nsresult
2125 nsDOMClassInfo::WrapNativeParent(JSContext *cx, JSObject *scope,
2126 nsISupports *native,
2127 nsWrapperCache *nativeWrapperCache,
2128 JSObject **parentObj)
2130 // In the common case, |native| is a wrapper cache with an existing wrapper
2131 #ifdef DEBUG
2132 nsWrapperCache* cache = nsnull;
2133 CallQueryInterface(native, &cache);
2134 NS_PRECONDITION(nativeWrapperCache &&
2135 cache == nativeWrapperCache, "What happened here?");
2136 #endif
2138 JSObject* obj = nativeWrapperCache->GetWrapper();
2139 if (obj) {
2140 #ifdef DEBUG
2141 jsval debugVal;
2142 nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, PR_FALSE,
2143 &debugVal);
2144 NS_ASSERTION(NS_SUCCEEDED(rv) && JSVAL_TO_OBJECT(debugVal) == obj,
2145 "Unexpected object in nsWrapperCache");
2146 #endif
2147 *parentObj = obj;
2148 return NS_OK;
2151 jsval v;
2152 nsresult rv = WrapNative(cx, scope, native, nativeWrapperCache, PR_FALSE, &v);
2153 NS_ENSURE_SUCCESS(rv, rv);
2154 *parentObj = JSVAL_TO_OBJECT(v);
2155 return NS_OK;
2158 #define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if) \
2160 nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
2161 d.mProtoChainInterface = _ifptr; \
2162 d.mHasClassInterface = _has_class_if; \
2163 d.mInterfacesBitmap = kDOMClassInfo_##_class##_interfaces; \
2164 static const nsIID *interface_list[] = {
2166 #define DOM_CLASSINFO_MAP_BEGIN(_class, _interface) \
2167 _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), PR_TRUE)
2169 #define DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(_class, _interface) \
2170 _DOM_CLASSINFO_MAP_BEGIN(_class, &NS_GET_IID(_interface), PR_FALSE)
2172 #define DOM_CLASSINFO_MAP_ENTRY(_if) \
2173 &NS_GET_IID(_if),
2175 #define DOM_CLASSINFO_MAP_END \
2176 nsnull \
2177 }; \
2179 d.mInterfaces = interface_list; \
2182 #define DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES \
2183 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocument) \
2184 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentEvent) \
2185 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentStyle) \
2186 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocumentStyle) \
2187 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentView) \
2188 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentRange) \
2189 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentTraversal) \
2190 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL) \
2191 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
2192 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
2193 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Document) \
2194 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
2195 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator) \
2196 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector) \
2197 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocument_MOZILLA_2_0_BRANCH)
2200 #define DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES \
2201 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLElement) \
2202 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle) \
2203 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
2204 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
2205 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
2206 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
2207 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2209 #define DOM_CLASSINFO_EVENT_MAP_ENTRIES \
2210 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent) \
2211 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEvent) \
2213 #define DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES \
2214 DOM_CLASSINFO_MAP_ENTRY(nsIDOMUIEvent) \
2215 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSUIEvent) \
2216 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2218 nsresult
2219 nsDOMClassInfo::Init()
2221 /* Errors that can trigger early returns are done first,
2222 otherwise nsDOMClassInfo is left in a half inited state. */
2223 NS_ASSERTION(sizeof(PtrBits) == sizeof(void*),
2224 "BAD! You'll need to adjust the size of PtrBits to the size "
2225 "of a pointer on your platform.");
2227 NS_ENSURE_TRUE(!sIsInitialized, NS_ERROR_ALREADY_INITIALIZED);
2229 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
2230 NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
2232 nsresult rv = CallGetService(nsIXPConnect::GetCID(), &sXPConnect);
2233 NS_ENSURE_SUCCESS(rv, rv);
2235 nsCOMPtr<nsIXPCFunctionThisTranslator> old;
2237 nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
2238 NS_ENSURE_TRUE(elt, NS_ERROR_OUT_OF_MEMORY);
2240 sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener),
2241 elt, getter_AddRefs(old));
2243 nsCOMPtr<nsIScriptSecurityManager> sm =
2244 do_GetService("@mozilla.org/scriptsecuritymanager;1", &rv);
2245 NS_ENSURE_SUCCESS(rv, rv);
2247 sSecMan = sm;
2248 NS_ADDREF(sSecMan);
2250 nsCOMPtr<nsIThreadJSContextStack> stack =
2251 do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
2252 NS_ENSURE_SUCCESS(rv, rv);
2254 JSContext *cx = nsnull;
2256 rv = stack->GetSafeJSContext(&cx);
2257 NS_ENSURE_SUCCESS(rv, rv);
2259 if (nsGlobalWindow::HasIndexedDBSupport()) {
2260 DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
2261 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
2262 DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
2263 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
2264 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2265 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2266 DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
2267 DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
2268 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
2269 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
2270 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
2271 DOM_CLASSINFO_MAP_END
2272 } else {
2273 DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
2274 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
2275 DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
2276 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
2277 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2278 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2279 DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
2280 DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
2281 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
2282 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
2283 DOM_CLASSINFO_MAP_END
2286 DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
2287 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
2288 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils_MOZILLA_2_0_BRANCH)
2289 DOM_CLASSINFO_MAP_END
2291 DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
2292 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
2293 DOM_CLASSINFO_MAP_END
2295 if (nsNavigator::HasDesktopNotificationSupport()) {
2296 DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
2297 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
2298 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
2299 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorDesktopNotification)
2300 DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
2301 DOM_CLASSINFO_MAP_END
2302 } else {
2303 DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
2304 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
2305 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation)
2306 DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
2307 DOM_CLASSINFO_MAP_END
2310 DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
2311 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin)
2312 DOM_CLASSINFO_MAP_END
2314 DOM_CLASSINFO_MAP_BEGIN(PluginArray, nsIDOMPluginArray)
2315 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPluginArray)
2316 DOM_CLASSINFO_MAP_END
2318 DOM_CLASSINFO_MAP_BEGIN(MimeType, nsIDOMMimeType)
2319 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeType)
2320 DOM_CLASSINFO_MAP_END
2322 DOM_CLASSINFO_MAP_BEGIN(MimeTypeArray, nsIDOMMimeTypeArray)
2323 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeTypeArray)
2324 DOM_CLASSINFO_MAP_END
2326 DOM_CLASSINFO_MAP_BEGIN(BarProp, nsIDOMBarProp)
2327 DOM_CLASSINFO_MAP_ENTRY(nsIDOMBarProp)
2328 DOM_CLASSINFO_MAP_END
2330 DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
2331 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
2332 DOM_CLASSINFO_MAP_END
2334 DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
2335 DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
2336 DOM_CLASSINFO_MAP_END
2338 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
2339 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
2340 DOM_CLASSINFO_MAP_END
2342 DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
2343 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
2344 DOM_CLASSINFO_MAP_END
2346 DOM_CLASSINFO_MAP_BEGIN(XMLDocument, nsIDOMXMLDocument)
2347 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
2348 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXMLDocument)
2349 DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
2350 DOM_CLASSINFO_MAP_END
2352 DOM_CLASSINFO_MAP_BEGIN(DocumentType, nsIDOMDocumentType)
2353 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentType)
2354 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2355 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2356 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2357 DOM_CLASSINFO_MAP_END
2359 DOM_CLASSINFO_MAP_BEGIN(DOMImplementation, nsIDOMDOMImplementation)
2360 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMImplementation)
2361 DOM_CLASSINFO_MAP_END
2363 DOM_CLASSINFO_MAP_BEGIN(DOMException, nsIDOMDOMException)
2364 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMException)
2365 DOM_CLASSINFO_MAP_ENTRY(nsIException)
2366 DOM_CLASSINFO_MAP_END
2368 DOM_CLASSINFO_MAP_BEGIN(DOMTokenList, nsIDOMDOMTokenList)
2369 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMTokenList)
2370 DOM_CLASSINFO_MAP_END
2372 DOM_CLASSINFO_MAP_BEGIN(DOMSettableTokenList, nsIDOMDOMSettableTokenList)
2373 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMSettableTokenList)
2374 DOM_CLASSINFO_MAP_END
2376 DOM_CLASSINFO_MAP_BEGIN(DocumentFragment, nsIDOMDocumentFragment)
2377 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentFragment)
2378 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2379 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2380 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2381 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2382 DOM_CLASSINFO_MAP_END
2384 DOM_CLASSINFO_MAP_BEGIN(Element, nsIDOMElement)
2385 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
2386 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
2387 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2388 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2389 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2390 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2391 DOM_CLASSINFO_MAP_END
2393 DOM_CLASSINFO_MAP_BEGIN(Attr, nsIDOMAttr)
2394 DOM_CLASSINFO_MAP_ENTRY(nsIDOMAttr)
2395 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2396 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Attr)
2397 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2398 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2399 DOM_CLASSINFO_MAP_END
2401 DOM_CLASSINFO_MAP_BEGIN(Text, nsIDOMText)
2402 DOM_CLASSINFO_MAP_ENTRY(nsIDOMText)
2403 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2404 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2405 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2406 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text)
2407 DOM_CLASSINFO_MAP_END
2409 DOM_CLASSINFO_MAP_BEGIN(Comment, nsIDOMComment)
2410 DOM_CLASSINFO_MAP_ENTRY(nsIDOMComment)
2411 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2412 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2413 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2414 DOM_CLASSINFO_MAP_END
2416 DOM_CLASSINFO_MAP_BEGIN(CDATASection, nsIDOMCDATASection)
2417 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCDATASection)
2418 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2419 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2420 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2421 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Text)
2422 DOM_CLASSINFO_MAP_END
2424 DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)
2425 DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
2426 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2427 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2428 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2429 DOM_CLASSINFO_MAP_END
2431 DOM_CLASSINFO_MAP_BEGIN(Notation, nsIDOMNotation)
2432 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotation)
2433 DOM_CLASSINFO_MAP_END
2435 DOM_CLASSINFO_MAP_BEGIN(NodeList, nsIDOMNodeList)
2436 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
2437 DOM_CLASSINFO_MAP_END
2439 DOM_CLASSINFO_MAP_BEGIN(NamedNodeMap, nsIDOMNamedNodeMap)
2440 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNamedNodeMap)
2441 DOM_CLASSINFO_MAP_END
2443 DOM_CLASSINFO_MAP_BEGIN(Event, nsIDOMEvent)
2444 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2445 DOM_CLASSINFO_MAP_END
2447 DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
2448 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
2449 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2450 DOM_CLASSINFO_MAP_END
2452 DOM_CLASSINFO_MAP_BEGIN(OrientationEvent, nsIDOMOrientationEvent)
2453 DOM_CLASSINFO_MAP_ENTRY(nsIDOMOrientationEvent)
2454 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2455 DOM_CLASSINFO_MAP_END
2457 DOM_CLASSINFO_MAP_BEGIN(SmartCardEvent, nsIDOMSmartCardEvent)
2458 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
2459 DOM_CLASSINFO_MAP_END
2461 DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
2462 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPageTransitionEvent)
2463 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2464 DOM_CLASSINFO_MAP_END
2466 DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
2467 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
2468 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2469 DOM_CLASSINFO_MAP_END
2471 DOM_CLASSINFO_MAP_BEGIN(UIEvent, nsIDOMUIEvent)
2472 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2473 DOM_CLASSINFO_MAP_END
2475 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(KeyboardEvent, nsIDOMKeyEvent)
2476 DOM_CLASSINFO_MAP_ENTRY(nsIDOMKeyEvent)
2477 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2478 DOM_CLASSINFO_MAP_END
2480 DOM_CLASSINFO_MAP_BEGIN(MouseEvent, nsIDOMMouseEvent)
2481 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2482 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
2483 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2484 DOM_CLASSINFO_MAP_END
2486 DOM_CLASSINFO_MAP_BEGIN(MouseScrollEvent, nsIDOMMouseScrollEvent)
2487 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseScrollEvent)
2488 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2489 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
2490 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2491 DOM_CLASSINFO_MAP_END
2493 DOM_CLASSINFO_MAP_BEGIN(DragEvent, nsIDOMDragEvent)
2494 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDragEvent)
2495 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
2496 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
2497 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
2498 DOM_CLASSINFO_MAP_END
2500 DOM_CLASSINFO_MAP_BEGIN(PopStateEvent, nsIDOMPopStateEvent)
2501 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopStateEvent)
2502 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopStateEvent_MOZILLA_2_BRANCH)
2503 DOM_CLASSINFO_EVENT_MAP_ENTRIES
2504 DOM_CLASSINFO_MAP_END
2506 DOM_CLASSINFO_MAP_BEGIN(HTMLDocument, nsIDOMHTMLDocument)
2507 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
2508 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLDocument)
2509 DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
2510 DOM_CLASSINFO_MAP_END
2512 DOM_CLASSINFO_MAP_BEGIN(HTMLOptionsCollection, nsIDOMHTMLOptionsCollection)
2513 // Order is significant. nsIDOMHTMLOptionsCollection.length shadows
2514 // nsIDOMHTMLCollection.length, which is readonly.
2515 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionsCollection)
2516 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLOptionCollection)
2517 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
2518 DOM_CLASSINFO_MAP_END
2520 DOM_CLASSINFO_MAP_BEGIN(HTMLCollection, nsIDOMHTMLCollection)
2521 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
2522 DOM_CLASSINFO_MAP_END
2524 DOM_CLASSINFO_MAP_BEGIN(HTMLElement, nsIDOMHTMLElement)
2525 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
2526 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLElement)
2527 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2528 DOM_CLASSINFO_MAP_END
2530 DOM_CLASSINFO_MAP_BEGIN(HTMLAnchorElement, nsIDOMHTMLAnchorElement)
2531 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAnchorElement)
2532 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2533 DOM_CLASSINFO_MAP_END
2535 DOM_CLASSINFO_MAP_BEGIN(HTMLAppletElement, nsIDOMHTMLAppletElement)
2536 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAppletElement)
2537 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2538 DOM_CLASSINFO_MAP_END
2540 DOM_CLASSINFO_MAP_BEGIN(HTMLAreaElement, nsIDOMHTMLAreaElement)
2541 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAreaElement)
2542 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2543 DOM_CLASSINFO_MAP_END
2545 DOM_CLASSINFO_MAP_BEGIN(HTMLBRElement, nsIDOMHTMLBRElement)
2546 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBRElement)
2547 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2548 DOM_CLASSINFO_MAP_END
2550 DOM_CLASSINFO_MAP_BEGIN(HTMLBaseElement, nsIDOMHTMLBaseElement)
2551 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBaseElement)
2552 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2553 DOM_CLASSINFO_MAP_END
2555 DOM_CLASSINFO_MAP_BEGIN(HTMLBodyElement, nsIDOMHTMLBodyElement)
2556 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLBodyElement)
2557 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2558 DOM_CLASSINFO_MAP_END
2560 DOM_CLASSINFO_MAP_BEGIN(HTMLButtonElement, nsIDOMHTMLButtonElement)
2561 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLButtonElement)
2562 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2563 DOM_CLASSINFO_MAP_END
2565 DOM_CLASSINFO_MAP_BEGIN(HTMLDataListElement, nsIDOMHTMLDataListElement)
2566 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDataListElement)
2567 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2568 DOM_CLASSINFO_MAP_END
2570 DOM_CLASSINFO_MAP_BEGIN(HTMLDListElement, nsIDOMHTMLDListElement)
2571 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDListElement)
2572 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2573 DOM_CLASSINFO_MAP_END
2575 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLDelElement, nsIDOMHTMLElement)
2576 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLModElement)
2577 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2578 DOM_CLASSINFO_MAP_END
2580 DOM_CLASSINFO_MAP_BEGIN(HTMLDirectoryElement, nsIDOMHTMLDirectoryElement)
2581 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDirectoryElement)
2582 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2583 DOM_CLASSINFO_MAP_END
2585 DOM_CLASSINFO_MAP_BEGIN(HTMLDivElement, nsIDOMHTMLDivElement)
2586 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDivElement)
2587 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2588 DOM_CLASSINFO_MAP_END
2590 DOM_CLASSINFO_MAP_BEGIN(HTMLEmbedElement, nsIDOMHTMLEmbedElement)
2591 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLEmbedElement)
2592 #ifdef MOZ_SVG
2593 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2594 #endif
2595 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2596 DOM_CLASSINFO_MAP_END
2598 DOM_CLASSINFO_MAP_BEGIN(HTMLFieldSetElement, nsIDOMHTMLFieldSetElement)
2599 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFieldSetElement)
2600 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2601 DOM_CLASSINFO_MAP_END
2603 DOM_CLASSINFO_MAP_BEGIN(HTMLFontElement, nsIDOMHTMLFontElement)
2604 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFontElement)
2605 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2606 DOM_CLASSINFO_MAP_END
2608 DOM_CLASSINFO_MAP_BEGIN(HTMLFormElement, nsIDOMHTMLFormElement)
2609 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFormElement)
2610 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLFormElement)
2611 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2612 DOM_CLASSINFO_MAP_END
2614 DOM_CLASSINFO_MAP_BEGIN(HTMLFrameElement, nsIDOMHTMLFrameElement)
2615 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameElement)
2616 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
2617 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2618 DOM_CLASSINFO_MAP_END
2620 DOM_CLASSINFO_MAP_BEGIN(HTMLFrameSetElement, nsIDOMHTMLFrameSetElement)
2621 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameSetElement)
2622 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2623 DOM_CLASSINFO_MAP_END
2625 DOM_CLASSINFO_MAP_BEGIN(HTMLHRElement, nsIDOMHTMLHRElement)
2626 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHRElement)
2627 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLHRElement)
2628 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2629 DOM_CLASSINFO_MAP_END
2631 DOM_CLASSINFO_MAP_BEGIN(HTMLHeadElement, nsIDOMHTMLHeadElement)
2632 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadElement)
2633 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2634 DOM_CLASSINFO_MAP_END
2636 DOM_CLASSINFO_MAP_BEGIN(HTMLHeadingElement, nsIDOMHTMLHeadingElement)
2637 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHeadingElement)
2638 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2639 DOM_CLASSINFO_MAP_END
2641 DOM_CLASSINFO_MAP_BEGIN(HTMLHtmlElement, nsIDOMHTMLHtmlElement)
2642 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLHtmlElement)
2643 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2644 DOM_CLASSINFO_MAP_END
2646 DOM_CLASSINFO_MAP_BEGIN(HTMLIFrameElement, nsIDOMHTMLIFrameElement)
2647 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIFrameElement)
2648 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
2649 #ifdef MOZ_SVG
2650 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2651 #endif
2652 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2653 DOM_CLASSINFO_MAP_END
2655 DOM_CLASSINFO_MAP_BEGIN(HTMLImageElement, nsIDOMHTMLImageElement)
2656 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLImageElement)
2657 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2658 DOM_CLASSINFO_MAP_END
2660 DOM_CLASSINFO_MAP_BEGIN(HTMLInputElement, nsIDOMHTMLInputElement)
2661 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLInputElement)
2662 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2663 DOM_CLASSINFO_MAP_END
2665 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLInsElement, nsIDOMHTMLElement)
2666 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLModElement)
2667 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2668 DOM_CLASSINFO_MAP_END
2670 DOM_CLASSINFO_MAP_BEGIN(HTMLIsIndexElement, nsIDOMHTMLIsIndexElement)
2671 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIsIndexElement)
2672 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2673 DOM_CLASSINFO_MAP_END
2675 DOM_CLASSINFO_MAP_BEGIN(HTMLLIElement, nsIDOMHTMLLIElement)
2676 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLIElement)
2677 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2678 DOM_CLASSINFO_MAP_END
2680 DOM_CLASSINFO_MAP_BEGIN(HTMLLabelElement, nsIDOMHTMLLabelElement)
2681 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLabelElement)
2682 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2683 DOM_CLASSINFO_MAP_END
2685 DOM_CLASSINFO_MAP_BEGIN(HTMLLegendElement, nsIDOMHTMLLegendElement)
2686 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLegendElement)
2687 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2688 DOM_CLASSINFO_MAP_END
2690 DOM_CLASSINFO_MAP_BEGIN(HTMLLinkElement, nsIDOMHTMLLinkElement)
2691 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLLinkElement)
2692 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
2693 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2694 DOM_CLASSINFO_MAP_END
2696 DOM_CLASSINFO_MAP_BEGIN(HTMLMapElement, nsIDOMHTMLMapElement)
2697 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMapElement)
2698 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2699 DOM_CLASSINFO_MAP_END
2701 DOM_CLASSINFO_MAP_BEGIN(HTMLMenuElement, nsIDOMHTMLMenuElement)
2702 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMenuElement)
2703 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2704 DOM_CLASSINFO_MAP_END
2706 DOM_CLASSINFO_MAP_BEGIN(HTMLMetaElement, nsIDOMHTMLMetaElement)
2707 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLMetaElement)
2708 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2709 DOM_CLASSINFO_MAP_END
2711 DOM_CLASSINFO_MAP_BEGIN(HTMLOListElement, nsIDOMHTMLOListElement)
2712 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOListElement)
2713 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2714 DOM_CLASSINFO_MAP_END
2716 DOM_CLASSINFO_MAP_BEGIN(HTMLObjectElement, nsIDOMHTMLObjectElement)
2717 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLObjectElement)
2718 #ifdef MOZ_SVG
2719 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
2720 #endif
2721 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2722 DOM_CLASSINFO_MAP_END
2724 DOM_CLASSINFO_MAP_BEGIN(HTMLOptGroupElement, nsIDOMHTMLOptGroupElement)
2725 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptGroupElement)
2726 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2727 DOM_CLASSINFO_MAP_END
2729 DOM_CLASSINFO_MAP_BEGIN(HTMLOptionElement, nsIDOMHTMLOptionElement)
2730 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionElement)
2731 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2732 DOM_CLASSINFO_MAP_END
2734 DOM_CLASSINFO_MAP_BEGIN(HTMLOutputElement, nsIDOMHTMLOutputElement)
2735 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOutputElement)
2736 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2737 DOM_CLASSINFO_MAP_END
2739 DOM_CLASSINFO_MAP_BEGIN(HTMLParagraphElement, nsIDOMHTMLParagraphElement)
2740 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParagraphElement)
2741 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2742 DOM_CLASSINFO_MAP_END
2744 DOM_CLASSINFO_MAP_BEGIN(HTMLParamElement, nsIDOMHTMLParamElement)
2745 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLParamElement)
2746 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2747 DOM_CLASSINFO_MAP_END
2749 DOM_CLASSINFO_MAP_BEGIN(HTMLPreElement, nsIDOMHTMLPreElement)
2750 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLPreElement)
2751 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2752 DOM_CLASSINFO_MAP_END
2754 DOM_CLASSINFO_MAP_BEGIN(HTMLQuoteElement, nsIDOMHTMLQuoteElement)
2755 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLQuoteElement)
2756 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2757 DOM_CLASSINFO_MAP_END
2759 DOM_CLASSINFO_MAP_BEGIN(HTMLScriptElement, nsIDOMHTMLScriptElement)
2760 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLScriptElement)
2761 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2762 DOM_CLASSINFO_MAP_END
2764 DOM_CLASSINFO_MAP_BEGIN(HTMLSelectElement, nsIDOMHTMLSelectElement)
2765 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement)
2766 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSelectElement_Mozilla_2_0_Branch)
2767 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2768 DOM_CLASSINFO_MAP_END
2770 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLSpanElement, nsIDOMHTMLElement)
2771 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
2772 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2773 DOM_CLASSINFO_MAP_END
2775 DOM_CLASSINFO_MAP_BEGIN(HTMLStyleElement, nsIDOMHTMLStyleElement)
2776 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLStyleElement)
2777 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
2778 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2779 DOM_CLASSINFO_MAP_END
2781 DOM_CLASSINFO_MAP_BEGIN(HTMLTableCaptionElement,
2782 nsIDOMHTMLTableCaptionElement)
2783 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCaptionElement)
2784 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2785 DOM_CLASSINFO_MAP_END
2787 DOM_CLASSINFO_MAP_BEGIN(HTMLTableCellElement, nsIDOMHTMLTableCellElement)
2788 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableCellElement)
2789 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2790 DOM_CLASSINFO_MAP_END
2792 DOM_CLASSINFO_MAP_BEGIN(HTMLTableColElement, nsIDOMHTMLTableColElement)
2793 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableColElement)
2794 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2795 DOM_CLASSINFO_MAP_END
2797 DOM_CLASSINFO_MAP_BEGIN(HTMLTableElement, nsIDOMHTMLTableElement)
2798 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableElement)
2799 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2800 DOM_CLASSINFO_MAP_END
2802 DOM_CLASSINFO_MAP_BEGIN(HTMLTableRowElement, nsIDOMHTMLTableRowElement)
2803 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableRowElement)
2804 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2805 DOM_CLASSINFO_MAP_END
2807 DOM_CLASSINFO_MAP_BEGIN(HTMLTableSectionElement,
2808 nsIDOMHTMLTableSectionElement)
2809 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTableSectionElement)
2810 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2811 DOM_CLASSINFO_MAP_END
2813 DOM_CLASSINFO_MAP_BEGIN(HTMLTextAreaElement, nsIDOMHTMLTextAreaElement)
2814 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
2815 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLTextAreaElement)
2816 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2817 DOM_CLASSINFO_MAP_END
2819 DOM_CLASSINFO_MAP_BEGIN(HTMLTitleElement, nsIDOMHTMLTitleElement)
2820 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTitleElement)
2821 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2822 DOM_CLASSINFO_MAP_END
2824 DOM_CLASSINFO_MAP_BEGIN(HTMLUListElement, nsIDOMHTMLUListElement)
2825 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLUListElement)
2826 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2827 DOM_CLASSINFO_MAP_END
2829 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLUnknownElement, nsIDOMHTMLElement)
2830 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement)
2831 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
2832 DOM_CLASSINFO_MAP_END
2834 DOM_CLASSINFO_MAP_BEGIN(ValidityState, nsIDOMValidityState)
2835 DOM_CLASSINFO_MAP_ENTRY(nsIDOMValidityState)
2836 DOM_CLASSINFO_MAP_END
2838 DOM_CLASSINFO_MAP_BEGIN(CSSStyleRule, nsIDOMCSSStyleRule)
2839 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleRule)
2840 DOM_CLASSINFO_MAP_END
2842 DOM_CLASSINFO_MAP_BEGIN(CSSCharsetRule, nsIDOMCSSCharsetRule)
2843 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSCharsetRule)
2844 DOM_CLASSINFO_MAP_END
2846 DOM_CLASSINFO_MAP_BEGIN(CSSImportRule, nsIDOMCSSImportRule)
2847 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSImportRule)
2848 DOM_CLASSINFO_MAP_END
2850 DOM_CLASSINFO_MAP_BEGIN(CSSMediaRule, nsIDOMCSSMediaRule)
2851 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMediaRule)
2852 DOM_CLASSINFO_MAP_END
2854 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSNameSpaceRule, nsIDOMCSSRule)
2855 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRule)
2856 DOM_CLASSINFO_MAP_END
2858 DOM_CLASSINFO_MAP_BEGIN(CSSRuleList, nsIDOMCSSRuleList)
2859 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
2860 DOM_CLASSINFO_MAP_END
2862 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSGroupRuleRuleList, nsIDOMCSSRuleList)
2863 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSRuleList)
2864 DOM_CLASSINFO_MAP_END
2866 DOM_CLASSINFO_MAP_BEGIN(MediaList, nsIDOMMediaList)
2867 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaList)
2868 DOM_CLASSINFO_MAP_END
2870 DOM_CLASSINFO_MAP_BEGIN(StyleSheetList, nsIDOMStyleSheetList)
2871 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStyleSheetList)
2872 DOM_CLASSINFO_MAP_END
2874 DOM_CLASSINFO_MAP_BEGIN(CSSStyleSheet, nsIDOMCSSStyleSheet)
2875 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleSheet)
2876 DOM_CLASSINFO_MAP_END
2878 DOM_CLASSINFO_MAP_BEGIN(CSSStyleDeclaration, nsIDOMCSSStyleDeclaration)
2879 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
2880 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
2881 DOM_CLASSINFO_MAP_END
2883 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ComputedCSSStyleDeclaration,
2884 nsIDOMCSSStyleDeclaration)
2885 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
2886 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
2887 DOM_CLASSINFO_MAP_END
2889 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ROCSSPrimitiveValue,
2890 nsIDOMCSSPrimitiveValue)
2891 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSPrimitiveValue)
2892 DOM_CLASSINFO_MAP_END
2894 DOM_CLASSINFO_MAP_BEGIN(CSSValueList, nsIDOMCSSValueList)
2895 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSValueList)
2896 DOM_CLASSINFO_MAP_END
2898 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRect, nsIDOMRect)
2899 DOM_CLASSINFO_MAP_ENTRY(nsIDOMRect)
2900 DOM_CLASSINFO_MAP_END
2902 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSRGBColor, nsIDOMRGBColor)
2903 DOM_CLASSINFO_MAP_ENTRY(nsIDOMRGBColor)
2904 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSRGBAColor)
2905 DOM_CLASSINFO_MAP_END
2907 DOM_CLASSINFO_MAP_BEGIN(Range, nsIDOMRange)
2908 DOM_CLASSINFO_MAP_ENTRY(nsIDOMRange)
2909 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSRange)
2910 DOM_CLASSINFO_MAP_END
2912 DOM_CLASSINFO_MAP_BEGIN(NodeIterator, nsIDOMNodeIterator)
2913 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeIterator)
2914 DOM_CLASSINFO_MAP_END
2916 DOM_CLASSINFO_MAP_BEGIN(TreeWalker, nsIDOMTreeWalker)
2917 DOM_CLASSINFO_MAP_ENTRY(nsIDOMTreeWalker)
2918 DOM_CLASSINFO_MAP_END
2920 DOM_CLASSINFO_MAP_BEGIN(Selection, nsISelection)
2921 DOM_CLASSINFO_MAP_ENTRY(nsISelection)
2922 DOM_CLASSINFO_MAP_ENTRY(nsISelection3)
2923 DOM_CLASSINFO_MAP_END
2925 #ifdef MOZ_XUL
2926 DOM_CLASSINFO_MAP_BEGIN(XULDocument, nsIDOMXULDocument)
2927 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
2928 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULDocument)
2929 DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
2930 DOM_CLASSINFO_MAP_END
2932 DOM_CLASSINFO_MAP_BEGIN(XULElement, nsIDOMXULElement)
2933 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULElement)
2934 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2935 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2936 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2937 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
2938 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementCSSInlineStyle)
2939 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
2940 DOM_CLASSINFO_MAP_END
2942 DOM_CLASSINFO_MAP_BEGIN(XULCommandDispatcher, nsIDOMXULCommandDispatcher)
2943 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandDispatcher)
2944 DOM_CLASSINFO_MAP_END
2945 #endif
2947 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControllers, nsIControllers)
2948 DOM_CLASSINFO_MAP_ENTRY(nsIControllers)
2949 DOM_CLASSINFO_MAP_END
2951 DOM_CLASSINFO_MAP_BEGIN(BoxObject, nsIBoxObject)
2952 DOM_CLASSINFO_MAP_ENTRY(nsIBoxObject)
2953 DOM_CLASSINFO_MAP_END
2955 #ifdef MOZ_XUL
2956 DOM_CLASSINFO_MAP_BEGIN(TreeSelection, nsITreeSelection)
2957 DOM_CLASSINFO_MAP_ENTRY(nsITreeSelection)
2958 DOM_CLASSINFO_MAP_END
2960 DOM_CLASSINFO_MAP_BEGIN(TreeContentView, nsITreeContentView)
2961 DOM_CLASSINFO_MAP_ENTRY(nsITreeContentView)
2962 DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
2963 DOM_CLASSINFO_MAP_END
2964 #endif
2966 DOM_CLASSINFO_MAP_BEGIN(Crypto, nsIDOMCrypto)
2967 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCrypto)
2968 DOM_CLASSINFO_MAP_END
2970 DOM_CLASSINFO_MAP_BEGIN(CRMFObject, nsIDOMCRMFObject)
2971 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject)
2972 DOM_CLASSINFO_MAP_END
2974 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLStylesheetProcessingInstruction, nsIDOMProcessingInstruction)
2975 DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
2976 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
2977 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2978 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2979 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
2980 DOM_CLASSINFO_MAP_END
2982 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow)
2983 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
2984 DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
2985 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
2986 DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
2987 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
2988 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
2989 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
2990 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
2991 DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
2992 DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
2993 DOM_CLASSINFO_MAP_END
2995 DOM_CLASSINFO_MAP_BEGIN(RangeException, nsIDOMRangeException)
2996 DOM_CLASSINFO_MAP_ENTRY(nsIDOMRangeException)
2997 DOM_CLASSINFO_MAP_ENTRY(nsIException)
2998 DOM_CLASSINFO_MAP_END
3000 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentList, nsIDOMHTMLCollection)
3001 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList)
3002 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
3003 DOM_CLASSINFO_MAP_END
3005 DOM_CLASSINFO_MAP_BEGIN(ImageDocument, nsIImageDocument)
3006 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLDocument)
3007 DOM_CLASSINFO_MAP_ENTRY(nsIImageDocument)
3008 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLDocument)
3009 DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
3010 DOM_CLASSINFO_MAP_END
3012 #ifdef MOZ_XUL
3013 DOM_CLASSINFO_MAP_BEGIN(XULTemplateBuilder, nsIXULTemplateBuilder)
3014 DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
3015 DOM_CLASSINFO_MAP_END
3017 DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
3018 DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
3019 DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
3020 DOM_CLASSINFO_MAP_END
3021 #endif
3023 DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
3024 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
3025 DOM_CLASSINFO_MAP_END
3027 DOM_CLASSINFO_MAP_BEGIN(NameList, nsIDOMNameList)
3028 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNameList)
3029 DOM_CLASSINFO_MAP_END
3031 #ifdef MOZ_XUL
3032 DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
3033 DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
3034 DOM_CLASSINFO_MAP_END
3036 DOM_CLASSINFO_MAP_BEGIN(TreeColumns, nsITreeColumns)
3037 DOM_CLASSINFO_MAP_ENTRY(nsITreeColumns)
3038 DOM_CLASSINFO_MAP_END
3039 #endif
3041 DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
3042 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
3043 DOM_CLASSINFO_MAP_END
3045 DOM_CLASSINFO_MAP_BEGIN(BeforeUnloadEvent, nsIDOMBeforeUnloadEvent)
3046 DOM_CLASSINFO_MAP_ENTRY(nsIDOMBeforeUnloadEvent)
3047 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3048 DOM_CLASSINFO_MAP_END
3050 #ifdef MOZ_SVG
3051 #define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES \
3052 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
3053 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
3054 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement) \
3055 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement) \
3056 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node) \
3057 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
3059 #define DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES \
3060 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable) \
3061 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable) \
3062 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable) \
3063 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3065 // XXX - the proto chain stuff is sort of hackish, because of the MI in
3066 // the SVG interfaces. I doubt that extending the proto on one interface
3067 // works properly on an element which inherits off multiple interfaces.
3068 // Tough luck. - bbaetz
3070 // The SVG document
3072 DOM_CLASSINFO_MAP_BEGIN(SVGDocument, nsIDOMSVGDocument)
3073 // Order is significant. nsIDOMDocument.title shadows
3074 // nsIDOMSVGDocument.title, which is readonly.
3075 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocument)
3076 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDocument)
3077 DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES
3078 DOM_CLASSINFO_MAP_END
3080 // SVG element classes
3082 DOM_CLASSINFO_MAP_BEGIN(SVGAElement, nsIDOMSVGAElement)
3083 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAElement)
3084 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3085 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3086 DOM_CLASSINFO_MAP_END
3088 DOM_CLASSINFO_MAP_BEGIN(SVGAltGlyphElement, nsIDOMSVGAltGlyphElement)
3089 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3090 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
3091 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3092 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3093 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3094 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3095 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3096 DOM_CLASSINFO_MAP_END
3098 #ifdef MOZ_SMIL
3099 DOM_CLASSINFO_MAP_BEGIN(SVGAnimateElement, nsIDOMSVGAnimateElement)
3100 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3101 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateElement)
3102 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3103 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3104 DOM_CLASSINFO_MAP_END
3106 DOM_CLASSINFO_MAP_BEGIN(SVGAnimateTransformElement,
3107 nsIDOMSVGAnimateTransformElement)
3108 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3109 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateTransformElement)
3110 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3111 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3112 DOM_CLASSINFO_MAP_END
3114 DOM_CLASSINFO_MAP_BEGIN(SVGAnimateMotionElement,
3115 nsIDOMSVGAnimateMotionElement)
3116 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3117 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimateMotionElement)
3118 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3119 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3120 DOM_CLASSINFO_MAP_END
3122 DOM_CLASSINFO_MAP_BEGIN(SVGSetElement,
3123 nsIDOMSVGSetElement)
3124 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimationElement)
3125 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSetElement)
3126 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElementTimeControl)
3127 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3128 DOM_CLASSINFO_MAP_END
3130 DOM_CLASSINFO_MAP_BEGIN(SVGMpathElement, nsIDOMSVGMpathElement)
3131 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3132 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3133 DOM_CLASSINFO_MAP_END
3135 DOM_CLASSINFO_MAP_BEGIN(TimeEvent, nsIDOMTimeEvent)
3136 DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeEvent)
3137 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3138 DOM_CLASSINFO_MAP_END
3139 #endif // MOZ_SMIL
3141 DOM_CLASSINFO_MAP_BEGIN(SVGCircleElement, nsIDOMSVGCircleElement)
3142 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGCircleElement)
3143 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3144 DOM_CLASSINFO_MAP_END
3146 DOM_CLASSINFO_MAP_BEGIN(SVGClipPathElement, nsIDOMSVGClipPathElement)
3147 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGClipPathElement)
3148 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
3149 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformable)
3150 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3151 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3152 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3153 DOM_CLASSINFO_MAP_END
3155 DOM_CLASSINFO_MAP_BEGIN(SVGDefsElement, nsIDOMSVGDefsElement)
3156 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDefsElement)
3157 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3158 DOM_CLASSINFO_MAP_END
3160 DOM_CLASSINFO_MAP_BEGIN(SVGDescElement, nsIDOMSVGDescElement)
3161 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGDescElement)
3162 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3163 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3164 DOM_CLASSINFO_MAP_END
3166 DOM_CLASSINFO_MAP_BEGIN(SVGEllipseElement, nsIDOMSVGEllipseElement)
3167 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEllipseElement)
3168 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3169 DOM_CLASSINFO_MAP_END
3171 DOM_CLASSINFO_MAP_BEGIN(SVGFEBlendElement, nsIDOMSVGFEBlendElement)
3172 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEBlendElement)
3173 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3174 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3175 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3176 DOM_CLASSINFO_MAP_END
3178 DOM_CLASSINFO_MAP_BEGIN(SVGFEColorMatrixElement, nsIDOMSVGFEColorMatrixElement)
3179 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEColorMatrixElement)
3180 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3181 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3182 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3183 DOM_CLASSINFO_MAP_END
3185 DOM_CLASSINFO_MAP_BEGIN(SVGFEComponentTransferElement, nsIDOMSVGFEComponentTransferElement)
3186 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEComponentTransferElement)
3187 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3188 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3189 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3190 DOM_CLASSINFO_MAP_END
3192 DOM_CLASSINFO_MAP_BEGIN(SVGFECompositeElement, nsIDOMSVGFECompositeElement)
3193 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFECompositeElement)
3194 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3195 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3196 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3197 DOM_CLASSINFO_MAP_END
3199 DOM_CLASSINFO_MAP_BEGIN(SVGFEConvolveMatrixElement, nsIDOMSVGFEConvolveMatrixElement)
3200 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEConvolveMatrixElement)
3201 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3202 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3203 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3204 DOM_CLASSINFO_MAP_END
3206 DOM_CLASSINFO_MAP_BEGIN(SVGFEDiffuseLightingElement, nsIDOMSVGFEDiffuseLightingElement)
3207 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement)
3208 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3209 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3210 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3211 DOM_CLASSINFO_MAP_END
3213 DOM_CLASSINFO_MAP_BEGIN(SVGFEDisplacementMapElement, nsIDOMSVGFEDisplacementMapElement)
3214 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement)
3215 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3216 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3217 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3218 DOM_CLASSINFO_MAP_END
3220 DOM_CLASSINFO_MAP_BEGIN(SVGFEDistantLightElement, nsIDOMSVGFEDistantLightElement)
3221 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEDistantLightElement)
3222 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3223 DOM_CLASSINFO_MAP_END
3225 DOM_CLASSINFO_MAP_BEGIN(SVGFEFloodElement, nsIDOMSVGFEFloodElement)
3226 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFloodElement)
3227 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3228 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3229 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3230 DOM_CLASSINFO_MAP_END
3232 DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncAElement, nsIDOMSVGFEFuncAElement)
3233 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncAElement)
3234 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3235 DOM_CLASSINFO_MAP_END
3237 DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncBElement, nsIDOMSVGFEFuncBElement)
3238 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncBElement)
3239 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3240 DOM_CLASSINFO_MAP_END
3242 DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncGElement, nsIDOMSVGFEFuncGElement)
3243 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncGElement)
3244 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3245 DOM_CLASSINFO_MAP_END
3247 DOM_CLASSINFO_MAP_BEGIN(SVGFEFuncRElement, nsIDOMSVGFEFuncRElement)
3248 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEFuncRElement)
3249 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3250 DOM_CLASSINFO_MAP_END
3252 DOM_CLASSINFO_MAP_BEGIN(SVGFEGaussianBlurElement, nsIDOMSVGFEGaussianBlurElement)
3253 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEGaussianBlurElement)
3254 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3255 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3256 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3257 DOM_CLASSINFO_MAP_END
3259 DOM_CLASSINFO_MAP_BEGIN(SVGFEImageElement, nsIDOMSVGFEImageElement)
3260 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEImageElement)
3261 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3262 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3263 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3264 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3265 DOM_CLASSINFO_MAP_END
3267 DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeElement, nsIDOMSVGFEMergeElement)
3268 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeElement)
3269 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3270 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3271 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3272 DOM_CLASSINFO_MAP_END
3274 DOM_CLASSINFO_MAP_BEGIN(SVGFEMorphologyElement, nsIDOMSVGFEMorphologyElement)
3275 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMorphologyElement)
3276 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3277 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3278 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3279 DOM_CLASSINFO_MAP_END
3281 DOM_CLASSINFO_MAP_BEGIN(SVGFEMergeNodeElement, nsIDOMSVGFEMergeNodeElement)
3282 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEMergeNodeElement)
3283 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3284 DOM_CLASSINFO_MAP_END
3286 DOM_CLASSINFO_MAP_BEGIN(SVGFEOffsetElement, nsIDOMSVGFEOffsetElement)
3287 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEOffsetElement)
3288 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3289 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3290 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3291 DOM_CLASSINFO_MAP_END
3293 DOM_CLASSINFO_MAP_BEGIN(SVGFEPointLightElement, nsIDOMSVGFEPointLightElement)
3294 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFEPointLightElement)
3295 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3296 DOM_CLASSINFO_MAP_END
3298 DOM_CLASSINFO_MAP_BEGIN(SVGFESpecularLightingElement, nsIDOMSVGFESpecularLightingElement)
3299 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement)
3300 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3301 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3302 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3303 DOM_CLASSINFO_MAP_END
3305 DOM_CLASSINFO_MAP_BEGIN(SVGFESpotLightElement, nsIDOMSVGFESpotLightElement)
3306 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFESpotLightElement)
3307 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3308 DOM_CLASSINFO_MAP_END
3310 DOM_CLASSINFO_MAP_BEGIN(SVGFETileElement, nsIDOMSVGFETileElement)
3311 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETileElement)
3312 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3313 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3314 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3315 DOM_CLASSINFO_MAP_END
3317 DOM_CLASSINFO_MAP_BEGIN(SVGFETurbulenceElement, nsIDOMSVGFETurbulenceElement)
3318 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
3319 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
3320 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3321 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3322 DOM_CLASSINFO_MAP_END
3324 DOM_CLASSINFO_MAP_BEGIN(SVGFilterElement, nsIDOMSVGFilterElement)
3325 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFilterElement)
3326 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3327 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3328 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3329 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3330 DOM_CLASSINFO_MAP_END
3332 DOM_CLASSINFO_MAP_BEGIN(SVGGElement, nsIDOMSVGGElement)
3333 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGElement)
3334 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3335 DOM_CLASSINFO_MAP_END
3337 DOM_CLASSINFO_MAP_BEGIN(SVGImageElement, nsIDOMSVGImageElement)
3338 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGImageElement)
3339 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3340 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3341 DOM_CLASSINFO_MAP_END
3343 DOM_CLASSINFO_MAP_BEGIN(SVGLinearGradientElement, nsIDOMSVGLinearGradientElement)
3344 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
3345 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
3346 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3347 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3348 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3349 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3350 DOM_CLASSINFO_MAP_END
3352 DOM_CLASSINFO_MAP_BEGIN(SVGLineElement, nsIDOMSVGLineElement)
3353 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLineElement)
3354 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3355 DOM_CLASSINFO_MAP_END
3357 DOM_CLASSINFO_MAP_BEGIN(SVGMarkerElement, nsIDOMSVGMarkerElement)
3358 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMarkerElement)
3359 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3360 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3361 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3362 DOM_CLASSINFO_MAP_END
3364 DOM_CLASSINFO_MAP_BEGIN(SVGMaskElement, nsIDOMSVGMaskElement)
3365 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMaskElement)
3366 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3367 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3368 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3369 DOM_CLASSINFO_MAP_END
3371 DOM_CLASSINFO_MAP_BEGIN(SVGMetadataElement, nsIDOMSVGMetadataElement)
3372 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMetadataElement)
3373 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3374 DOM_CLASSINFO_MAP_END
3376 DOM_CLASSINFO_MAP_BEGIN(SVGPathElement, nsIDOMSVGPathElement)
3377 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathElement)
3378 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
3379 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3380 DOM_CLASSINFO_MAP_END
3382 DOM_CLASSINFO_MAP_BEGIN(SVGPatternElement, nsIDOMSVGPatternElement)
3383 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPatternElement)
3384 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3385 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3386 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3387 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3388 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3389 DOM_CLASSINFO_MAP_END
3391 DOM_CLASSINFO_MAP_BEGIN(SVGPolygonElement, nsIDOMSVGPolygonElement)
3392 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolygonElement)
3393 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
3394 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3395 DOM_CLASSINFO_MAP_END
3397 DOM_CLASSINFO_MAP_BEGIN(SVGPolylineElement, nsIDOMSVGPolylineElement)
3398 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPolylineElement)
3399 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPoints)
3400 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3401 DOM_CLASSINFO_MAP_END
3403 DOM_CLASSINFO_MAP_BEGIN(SVGRadialGradientElement, nsIDOMSVGRadialGradientElement)
3404 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGGradientElement)
3405 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
3406 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3407 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3408 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUnitTypes)
3409 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3410 DOM_CLASSINFO_MAP_END
3412 DOM_CLASSINFO_MAP_BEGIN(SVGRectElement, nsIDOMSVGRectElement)
3413 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRectElement)
3414 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3415 DOM_CLASSINFO_MAP_END
3417 DOM_CLASSINFO_MAP_BEGIN(SVGScriptElement, nsIDOMSVGScriptElement)
3418 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGScriptElement)
3419 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3420 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3421 DOM_CLASSINFO_MAP_END
3423 DOM_CLASSINFO_MAP_BEGIN(SVGStopElement, nsIDOMSVGStopElement)
3424 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStopElement)
3425 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3426 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3427 DOM_CLASSINFO_MAP_END
3429 DOM_CLASSINFO_MAP_BEGIN(SVGStyleElement, nsIDOMSVGStyleElement)
3430 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStyleElement)
3431 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
3432 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3433 DOM_CLASSINFO_MAP_END
3435 DOM_CLASSINFO_MAP_BEGIN(SVGSVGElement, nsIDOMSVGSVGElement)
3436 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3437 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3438 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSVGElement)
3439 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3440 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLocatable)
3441 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3442 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomAndPan)
3443 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3444 DOM_CLASSINFO_MAP_END
3446 DOM_CLASSINFO_MAP_BEGIN(SVGSwitchElement, nsIDOMSVGSwitchElement)
3447 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSwitchElement)
3448 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3449 DOM_CLASSINFO_MAP_END
3451 DOM_CLASSINFO_MAP_BEGIN(SVGSymbolElement, nsIDOMSVGSymbolElement)
3452 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3453 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3454 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGSymbolElement)
3455 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGFitToViewBox)
3456 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3457 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3458 DOM_CLASSINFO_MAP_END
3460 DOM_CLASSINFO_MAP_BEGIN(SVGTextElement, nsIDOMSVGTextElement)
3461 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3462 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
3463 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3464 DOM_CLASSINFO_MAP_END
3466 DOM_CLASSINFO_MAP_BEGIN(SVGTextPathElement, nsIDOMSVGTextPathElement)
3467 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
3468 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3469 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3470 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3471 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3472 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3473 DOM_CLASSINFO_MAP_END
3475 DOM_CLASSINFO_MAP_BEGIN(SVGTitleElement, nsIDOMSVGTitleElement)
3476 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTitleElement)
3477 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3478 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3479 DOM_CLASSINFO_MAP_END
3481 DOM_CLASSINFO_MAP_BEGIN(SVGTSpanElement, nsIDOMSVGTSpanElement)
3482 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
3483 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTextContentElement)
3484 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3485 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3486 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGStylable)
3487 DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES
3488 DOM_CLASSINFO_MAP_END
3490 DOM_CLASSINFO_MAP_BEGIN(SVGUseElement, nsIDOMSVGUseElement)
3491 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGUseElement)
3492 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGURIReference)
3493 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3494 DOM_CLASSINFO_MAP_END
3496 // other SVG classes
3498 DOM_CLASSINFO_MAP_BEGIN(SVGAngle, nsIDOMSVGAngle)
3499 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAngle)
3500 DOM_CLASSINFO_MAP_END
3502 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedAngle, nsIDOMSVGAnimatedAngle)
3503 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedAngle)
3504 DOM_CLASSINFO_MAP_END
3506 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedBoolean, nsIDOMSVGAnimatedBoolean)
3507 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedBoolean)
3508 DOM_CLASSINFO_MAP_END
3510 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedEnumeration, nsIDOMSVGAnimatedEnumeration)
3511 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
3512 DOM_CLASSINFO_MAP_END
3514 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedInteger, nsIDOMSVGAnimatedInteger)
3515 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedInteger)
3516 DOM_CLASSINFO_MAP_END
3518 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLength, nsIDOMSVGAnimatedLength)
3519 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLength)
3520 DOM_CLASSINFO_MAP_END
3522 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedLengthList, nsIDOMSVGAnimatedLengthList)
3523 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedLengthList)
3524 DOM_CLASSINFO_MAP_END
3526 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumber, nsIDOMSVGAnimatedNumber)
3527 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumber)
3528 DOM_CLASSINFO_MAP_END
3530 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedNumberList, nsIDOMSVGAnimatedNumberList)
3531 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedNumberList)
3532 DOM_CLASSINFO_MAP_END
3534 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedPreserveAspectRatio, nsIDOMSVGAnimatedPreserveAspectRatio)
3535 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedPreserveAspectRatio)
3536 DOM_CLASSINFO_MAP_END
3538 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedRect, nsIDOMSVGAnimatedRect)
3539 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedRect)
3540 DOM_CLASSINFO_MAP_END
3542 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedString, nsIDOMSVGAnimatedString)
3543 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedString)
3544 DOM_CLASSINFO_MAP_END
3546 DOM_CLASSINFO_MAP_BEGIN(SVGAnimatedTransformList, nsIDOMSVGAnimatedTransformList)
3547 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGAnimatedTransformList)
3548 DOM_CLASSINFO_MAP_END
3550 DOM_CLASSINFO_MAP_BEGIN(SVGEvent, nsIDOMSVGEvent)
3551 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGEvent)
3552 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3553 DOM_CLASSINFO_MAP_END
3555 DOM_CLASSINFO_MAP_BEGIN(SVGException, nsIDOMSVGException)
3556 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGException)
3557 DOM_CLASSINFO_MAP_ENTRY(nsIException)
3558 DOM_CLASSINFO_MAP_END
3560 DOM_CLASSINFO_MAP_BEGIN(SVGLength, nsIDOMSVGLength)
3561 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLength)
3562 DOM_CLASSINFO_MAP_END
3564 DOM_CLASSINFO_MAP_BEGIN(SVGLengthList, nsIDOMSVGLengthList)
3565 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGLengthList)
3566 DOM_CLASSINFO_MAP_END
3568 DOM_CLASSINFO_MAP_BEGIN(SVGMatrix, nsIDOMSVGMatrix)
3569 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGMatrix)
3570 DOM_CLASSINFO_MAP_END
3572 DOM_CLASSINFO_MAP_BEGIN(SVGNumber, nsIDOMSVGNumber)
3573 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumber)
3574 DOM_CLASSINFO_MAP_END
3576 DOM_CLASSINFO_MAP_BEGIN(SVGNumberList, nsIDOMSVGNumberList)
3577 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGNumberList)
3578 DOM_CLASSINFO_MAP_END
3580 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcAbs, nsIDOMSVGPathSegArcAbs)
3581 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcAbs)
3582 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3583 DOM_CLASSINFO_MAP_END
3585 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegArcRel, nsIDOMSVGPathSegArcRel)
3586 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegArcRel)
3587 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3588 DOM_CLASSINFO_MAP_END
3590 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegClosePath, nsIDOMSVGPathSegClosePath)
3591 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegClosePath)
3592 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3593 DOM_CLASSINFO_MAP_END
3595 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicAbs, nsIDOMSVGPathSegCurvetoCubicAbs)
3596 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicAbs)
3597 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3598 DOM_CLASSINFO_MAP_END
3600 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicRel, nsIDOMSVGPathSegCurvetoCubicRel)
3601 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicRel)
3602 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3603 DOM_CLASSINFO_MAP_END
3605 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothAbs, nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
3606 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothAbs)
3607 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3608 DOM_CLASSINFO_MAP_END
3610 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoCubicSmoothRel, nsIDOMSVGPathSegCurvetoCubicSmoothRel)
3611 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoCubicSmoothRel)
3612 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3613 DOM_CLASSINFO_MAP_END
3615 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticAbs, nsIDOMSVGPathSegCurvetoQuadraticAbs)
3616 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticAbs)
3617 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3618 DOM_CLASSINFO_MAP_END
3620 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticRel, nsIDOMSVGPathSegCurvetoQuadraticRel)
3621 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticRel)
3622 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3623 DOM_CLASSINFO_MAP_END
3625 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothAbs, nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
3626 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothAbs)
3627 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3628 DOM_CLASSINFO_MAP_END
3630 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegCurvetoQuadraticSmoothRel, nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
3631 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegCurvetoQuadraticSmoothRel)
3632 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3633 DOM_CLASSINFO_MAP_END
3635 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoAbs, nsIDOMSVGPathSegLinetoAbs)
3636 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoAbs)
3637 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3638 DOM_CLASSINFO_MAP_END
3640 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalAbs, nsIDOMSVGPathSegLinetoHorizontalAbs)
3641 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalAbs)
3642 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3643 DOM_CLASSINFO_MAP_END
3645 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoHorizontalRel, nsIDOMSVGPathSegLinetoHorizontalRel)
3646 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoHorizontalRel)
3647 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3648 DOM_CLASSINFO_MAP_END
3650 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoRel, nsIDOMSVGPathSegLinetoRel)
3651 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoRel)
3652 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3653 DOM_CLASSINFO_MAP_END
3655 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalAbs, nsIDOMSVGPathSegLinetoVerticalAbs)
3656 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalAbs)
3657 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3658 DOM_CLASSINFO_MAP_END
3660 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegLinetoVerticalRel, nsIDOMSVGPathSegLinetoVerticalRel)
3661 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegLinetoVerticalRel)
3662 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3663 DOM_CLASSINFO_MAP_END
3665 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegList, nsIDOMSVGPathSegList)
3666 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegList)
3667 DOM_CLASSINFO_MAP_END
3669 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoAbs, nsIDOMSVGPathSegMovetoAbs)
3670 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoAbs)
3671 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3672 DOM_CLASSINFO_MAP_END
3674 DOM_CLASSINFO_MAP_BEGIN(SVGPathSegMovetoRel, nsIDOMSVGPathSegMovetoRel)
3675 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSegMovetoRel)
3676 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPathSeg)
3677 DOM_CLASSINFO_MAP_END
3679 DOM_CLASSINFO_MAP_BEGIN(SVGPoint, nsIDOMSVGPoint)
3680 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPoint)
3681 DOM_CLASSINFO_MAP_END
3683 DOM_CLASSINFO_MAP_BEGIN(SVGPointList, nsIDOMSVGPointList)
3684 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPointList)
3685 DOM_CLASSINFO_MAP_END
3687 DOM_CLASSINFO_MAP_BEGIN(SVGPreserveAspectRatio, nsIDOMSVGPreserveAspectRatio)
3688 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGPreserveAspectRatio)
3689 DOM_CLASSINFO_MAP_END
3691 DOM_CLASSINFO_MAP_BEGIN(SVGRect, nsIDOMSVGRect)
3692 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGRect)
3693 DOM_CLASSINFO_MAP_END
3695 DOM_CLASSINFO_MAP_BEGIN(SVGTransform, nsIDOMSVGTransform)
3696 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransform)
3697 DOM_CLASSINFO_MAP_END
3699 DOM_CLASSINFO_MAP_BEGIN(SVGTransformList, nsIDOMSVGTransformList)
3700 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGTransformList)
3701 DOM_CLASSINFO_MAP_END
3703 DOM_CLASSINFO_MAP_BEGIN(SVGZoomEvent, nsIDOMSVGZoomEvent)
3704 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGZoomEvent)
3705 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3706 DOM_CLASSINFO_MAP_END
3707 #endif // MOZ_SVG
3709 DOM_CLASSINFO_MAP_BEGIN(HTMLCanvasElement, nsIDOMHTMLCanvasElement)
3710 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCanvasElement)
3711 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
3712 DOM_CLASSINFO_MAP_END
3714 DOM_CLASSINFO_MAP_BEGIN(CanvasRenderingContext2D, nsIDOMCanvasRenderingContext2D)
3715 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasRenderingContext2D)
3716 DOM_CLASSINFO_MAP_END
3718 DOM_CLASSINFO_MAP_BEGIN(CanvasGradient, nsIDOMCanvasGradient)
3719 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasGradient)
3720 DOM_CLASSINFO_MAP_END
3722 DOM_CLASSINFO_MAP_BEGIN(CanvasPattern, nsIDOMCanvasPattern)
3723 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCanvasPattern)
3724 DOM_CLASSINFO_MAP_END
3726 DOM_CLASSINFO_MAP_BEGIN(TextMetrics, nsIDOMTextMetrics)
3727 DOM_CLASSINFO_MAP_ENTRY(nsIDOMTextMetrics)
3728 DOM_CLASSINFO_MAP_END
3730 DOM_CLASSINFO_MAP_BEGIN(XSLTProcessor, nsIXSLTProcessor)
3731 DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessor)
3732 DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorObsolete) // XXX DEPRECATED
3733 DOM_CLASSINFO_MAP_ENTRY(nsIXSLTProcessorPrivate)
3734 DOM_CLASSINFO_MAP_END
3736 DOM_CLASSINFO_MAP_BEGIN(XPathEvaluator, nsIDOMXPathEvaluator)
3737 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator)
3738 DOM_CLASSINFO_MAP_END
3740 DOM_CLASSINFO_MAP_BEGIN(XPathException, nsIDOMXPathException)
3741 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathException)
3742 DOM_CLASSINFO_MAP_ENTRY(nsIException)
3743 DOM_CLASSINFO_MAP_END
3745 DOM_CLASSINFO_MAP_BEGIN(XPathExpression, nsIDOMXPathExpression)
3746 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathExpression)
3747 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSXPathExpression)
3748 DOM_CLASSINFO_MAP_END
3750 DOM_CLASSINFO_MAP_BEGIN(XPathNSResolver, nsIDOMXPathNSResolver)
3751 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathNSResolver)
3752 DOM_CLASSINFO_MAP_END
3754 DOM_CLASSINFO_MAP_BEGIN(XPathResult, nsIDOMXPathResult)
3755 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathResult)
3756 DOM_CLASSINFO_MAP_END
3758 DOM_CLASSINFO_MAP_BEGIN(StorageObsolete, nsIDOMStorageObsolete)
3759 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageObsolete)
3760 DOM_CLASSINFO_MAP_END
3762 DOM_CLASSINFO_MAP_BEGIN(Storage, nsIDOMStorage)
3763 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
3764 DOM_CLASSINFO_MAP_END
3766 DOM_CLASSINFO_MAP_BEGIN(StorageList, nsIDOMStorageList)
3767 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageList)
3768 DOM_CLASSINFO_MAP_END
3770 DOM_CLASSINFO_MAP_BEGIN(StorageItem, nsIDOMStorageItem)
3771 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageItem)
3772 DOM_CLASSINFO_MAP_ENTRY(nsIDOMToString)
3773 DOM_CLASSINFO_MAP_END
3775 DOM_CLASSINFO_MAP_BEGIN(StorageEvent, nsIDOMStorageEvent)
3776 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEvent)
3777 DOM_CLASSINFO_MAP_END
3779 DOM_CLASSINFO_MAP_BEGIN(StorageEventObsolete, nsIDOMStorageEventObsolete)
3780 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEventObsolete)
3781 DOM_CLASSINFO_MAP_END
3783 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMParser, nsIDOMParser)
3784 DOM_CLASSINFO_MAP_ENTRY(nsIDOMParser)
3785 DOM_CLASSINFO_MAP_ENTRY(nsIDOMParserJS)
3786 DOM_CLASSINFO_MAP_END
3788 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLSerializer, nsIDOMSerializer)
3789 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSerializer)
3790 DOM_CLASSINFO_MAP_END
3792 DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequest, nsIXMLHttpRequest)
3793 DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequest)
3794 DOM_CLASSINFO_MAP_ENTRY(nsIJSXMLHttpRequest)
3795 DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
3796 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3797 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3798 DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
3799 DOM_CLASSINFO_MAP_END
3801 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLHttpProgressEvent, nsIDOMEvent)
3802 DOM_CLASSINFO_MAP_ENTRY(nsIDOMLSProgressEvent)
3803 DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
3804 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3805 DOM_CLASSINFO_MAP_END
3807 #ifdef MOZ_SVG
3808 DOM_CLASSINFO_MAP_BEGIN(SVGForeignObjectElement, nsIDOMSVGForeignObjectElement)
3809 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
3810 DOM_CLASSINFO_SVG_GRAPHIC_ELEMENT_MAP_ENTRIES
3811 DOM_CLASSINFO_MAP_END
3812 #endif
3814 DOM_CLASSINFO_MAP_BEGIN(XULCommandEvent, nsIDOMXULCommandEvent)
3815 DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULCommandEvent)
3816 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3817 DOM_CLASSINFO_MAP_END
3819 DOM_CLASSINFO_MAP_BEGIN(CommandEvent, nsIDOMCommandEvent)
3820 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCommandEvent)
3821 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3822 DOM_CLASSINFO_MAP_END
3824 DOM_CLASSINFO_MAP_BEGIN(OfflineResourceList, nsIDOMOfflineResourceList)
3825 DOM_CLASSINFO_MAP_ENTRY(nsIDOMOfflineResourceList)
3826 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3827 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3828 DOM_CLASSINFO_MAP_END
3830 DOM_CLASSINFO_MAP_BEGIN(ClientRect, nsIDOMClientRect)
3831 DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRect)
3832 DOM_CLASSINFO_MAP_END
3834 DOM_CLASSINFO_MAP_BEGIN(ClientRectList, nsIDOMClientRectList)
3835 DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRectList)
3836 DOM_CLASSINFO_MAP_END
3838 DOM_CLASSINFO_MAP_BEGIN(FileList, nsIDOMFileList)
3839 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileList)
3840 DOM_CLASSINFO_MAP_END
3842 DOM_CLASSINFO_MAP_BEGIN(FileError, nsIDOMFileError)
3843 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileError)
3844 DOM_CLASSINFO_MAP_END
3846 DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
3847 DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
3848 DOM_CLASSINFO_MAP_END
3850 DOM_CLASSINFO_MAP_BEGIN(File, nsIDOMFile)
3851 DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
3852 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFile)
3853 DOM_CLASSINFO_MAP_END
3855 DOM_CLASSINFO_MAP_BEGIN(FileException, nsIDOMFileException)
3856 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileException)
3857 DOM_CLASSINFO_MAP_ENTRY(nsIException)
3858 DOM_CLASSINFO_MAP_END
3860 DOM_CLASSINFO_MAP_BEGIN(FileReader, nsIDOMFileReader)
3861 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileReader)
3862 DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
3863 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3864 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3865 DOM_CLASSINFO_MAP_ENTRY(nsIInterfaceRequestor)
3866 DOM_CLASSINFO_MAP_END
3868 DOM_CLASSINFO_MAP_BEGIN(MozURLProperty, nsIDOMMozURLProperty)
3869 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozURLProperty)
3870 DOM_CLASSINFO_MAP_END
3872 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
3873 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
3874 DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
3875 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
3876 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3877 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3878 DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
3879 DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
3880 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
3881 DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
3882 DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
3883 DOM_CLASSINFO_MAP_END
3885 DOM_CLASSINFO_MAP_BEGIN(DataContainerEvent, nsIDOMDataContainerEvent)
3886 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataContainerEvent)
3887 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3888 DOM_CLASSINFO_MAP_END
3890 DOM_CLASSINFO_MAP_BEGIN(MessageEvent, nsIDOMMessageEvent)
3891 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMessageEvent)
3892 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3893 DOM_CLASSINFO_MAP_END
3895 DOM_CLASSINFO_MAP_BEGIN(GeoGeolocation, nsIDOMGeoGeolocation)
3896 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoGeolocation)
3897 DOM_CLASSINFO_MAP_END
3899 DOM_CLASSINFO_MAP_BEGIN(GeoPosition, nsIDOMGeoPosition)
3900 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPosition)
3901 DOM_CLASSINFO_MAP_END
3903 DOM_CLASSINFO_MAP_BEGIN(GeoPositionCoords, nsIDOMGeoPositionCoords)
3904 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionCoords)
3905 DOM_CLASSINFO_MAP_END
3907 DOM_CLASSINFO_MAP_BEGIN(GeoPositionAddress, nsIDOMGeoPositionAddress)
3908 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionAddress)
3909 DOM_CLASSINFO_MAP_END
3911 DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError)
3912 DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError)
3913 DOM_CLASSINFO_MAP_END
3915 DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
3916 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
3917 DOM_CLASSINFO_MAP_END
3919 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
3920 nsIDOMCSSStyleDeclaration)
3921 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
3922 DOM_CLASSINFO_MAP_END
3924 #if defined (MOZ_MEDIA)
3925 DOM_CLASSINFO_MAP_BEGIN(HTMLVideoElement, nsIDOMHTMLVideoElement)
3926 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLVideoElement)
3927 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
3928 DOM_CLASSINFO_MAP_END
3930 DOM_CLASSINFO_MAP_BEGIN(HTMLSourceElement, nsIDOMHTMLSourceElement)
3931 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLSourceElement)
3932 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
3933 DOM_CLASSINFO_MAP_END
3935 DOM_CLASSINFO_MAP_BEGIN(MediaError, nsIDOMMediaError)
3936 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaError)
3937 DOM_CLASSINFO_MAP_END
3939 DOM_CLASSINFO_MAP_BEGIN(HTMLAudioElement, nsIDOMHTMLAudioElement)
3940 DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLAudioElement)
3941 DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
3942 DOM_CLASSINFO_MAP_END
3944 DOM_CLASSINFO_MAP_BEGIN(TimeRanges, nsIDOMTimeRanges)
3945 DOM_CLASSINFO_MAP_ENTRY(nsIDOMTimeRanges)
3946 DOM_CLASSINFO_MAP_END
3947 #endif
3949 DOM_CLASSINFO_MAP_BEGIN(ProgressEvent, nsIDOMProgressEvent)
3950 DOM_CLASSINFO_MAP_ENTRY(nsIDOMProgressEvent)
3951 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3952 DOM_CLASSINFO_MAP_END
3954 DOM_CLASSINFO_MAP_BEGIN(XMLHttpRequestUpload, nsIXMLHttpRequestUpload)
3955 DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
3956 DOM_CLASSINFO_MAP_ENTRY(nsIXMLHttpRequestUpload)
3957 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3958 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3959 DOM_CLASSINFO_MAP_END
3961 DOM_CLASSINFO_MAP_BEGIN(DataTransfer, nsIDOMDataTransfer)
3962 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataTransfer)
3963 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDataTransfer)
3964 DOM_CLASSINFO_MAP_END
3966 DOM_CLASSINFO_MAP_BEGIN(NotifyPaintEvent, nsIDOMNotifyPaintEvent)
3967 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyPaintEvent)
3968 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3969 DOM_CLASSINFO_MAP_END
3971 DOM_CLASSINFO_MAP_BEGIN(NotifyAudioAvailableEvent, nsIDOMNotifyAudioAvailableEvent)
3972 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNotifyAudioAvailableEvent)
3973 DOM_CLASSINFO_EVENT_MAP_ENTRIES
3974 DOM_CLASSINFO_MAP_END
3976 DOM_CLASSINFO_MAP_BEGIN(SimpleGestureEvent, nsIDOMSimpleGestureEvent)
3977 DOM_CLASSINFO_MAP_ENTRY(nsIDOMSimpleGestureEvent)
3978 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
3979 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
3980 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3981 DOM_CLASSINFO_MAP_END
3983 DOM_CLASSINFO_MAP_BEGIN(MozTouchEvent, nsIDOMMozTouchEvent)
3984 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozTouchEvent)
3985 DOM_CLASSINFO_MAP_ENTRY(nsIDOMMouseEvent)
3986 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSMouseEvent)
3987 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
3988 DOM_CLASSINFO_MAP_END
3990 #ifdef MOZ_MATHML
3991 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(MathMLElement, nsIDOMElement)
3992 DOM_CLASSINFO_MAP_ENTRY(nsIDOMElement)
3993 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSElement)
3994 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
3995 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
3996 DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)
3997 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
3998 DOM_CLASSINFO_MAP_END
3999 #endif
4001 DOM_CLASSINFO_MAP_BEGIN(Worker, nsIWorker)
4002 DOM_CLASSINFO_MAP_ENTRY(nsIWorker)
4003 DOM_CLASSINFO_MAP_ENTRY(nsIAbstractWorker)
4004 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4005 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4006 DOM_CLASSINFO_MAP_END
4008 DOM_CLASSINFO_MAP_BEGIN(ChromeWorker, nsIWorker)
4009 DOM_CLASSINFO_MAP_ENTRY(nsIWorker)
4010 DOM_CLASSINFO_MAP_ENTRY(nsIAbstractWorker)
4011 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4012 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4013 DOM_CLASSINFO_MAP_END
4015 DOM_CLASSINFO_MAP_BEGIN(WebGLRenderingContext, nsIDOMWebGLRenderingContext)
4016 DOM_CLASSINFO_MAP_ENTRY(nsIDOMWebGLRenderingContext)
4017 DOM_CLASSINFO_MAP_END
4019 DOM_CLASSINFO_MAP_BEGIN(WebGLBuffer, nsIWebGLBuffer)
4020 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLBuffer)
4021 DOM_CLASSINFO_MAP_END
4023 DOM_CLASSINFO_MAP_BEGIN(WebGLTexture, nsIWebGLTexture)
4024 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLTexture)
4025 DOM_CLASSINFO_MAP_END
4027 DOM_CLASSINFO_MAP_BEGIN(WebGLProgram, nsIWebGLProgram)
4028 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLProgram)
4029 DOM_CLASSINFO_MAP_END
4031 DOM_CLASSINFO_MAP_BEGIN(WebGLShader, nsIWebGLShader)
4032 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLShader)
4033 DOM_CLASSINFO_MAP_END
4035 DOM_CLASSINFO_MAP_BEGIN(WebGLFramebuffer, nsIWebGLFramebuffer)
4036 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLFramebuffer)
4037 DOM_CLASSINFO_MAP_END
4039 DOM_CLASSINFO_MAP_BEGIN(WebGLRenderbuffer, nsIWebGLRenderbuffer)
4040 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLRenderbuffer)
4041 DOM_CLASSINFO_MAP_END
4043 DOM_CLASSINFO_MAP_BEGIN(WebGLUniformLocation, nsIWebGLUniformLocation)
4044 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLUniformLocation)
4045 DOM_CLASSINFO_MAP_END
4047 DOM_CLASSINFO_MAP_BEGIN(WebGLActiveInfo, nsIWebGLActiveInfo)
4048 DOM_CLASSINFO_MAP_ENTRY(nsIWebGLActiveInfo)
4049 DOM_CLASSINFO_MAP_END
4051 DOM_CLASSINFO_MAP_BEGIN(PaintRequest, nsIDOMPaintRequest)
4052 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequest)
4053 DOM_CLASSINFO_MAP_END
4055 DOM_CLASSINFO_MAP_BEGIN(PaintRequestList, nsIDOMPaintRequestList)
4056 DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequestList)
4057 DOM_CLASSINFO_MAP_END
4059 DOM_CLASSINFO_MAP_BEGIN(ScrollAreaEvent, nsIDOMScrollAreaEvent)
4060 DOM_CLASSINFO_MAP_ENTRY(nsIDOMScrollAreaEvent)
4061 DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
4062 DOM_CLASSINFO_MAP_END
4064 DOM_CLASSINFO_MAP_BEGIN(EventListenerInfo, nsIEventListenerInfo)
4065 DOM_CLASSINFO_MAP_ENTRY(nsIEventListenerInfo)
4066 DOM_CLASSINFO_MAP_END
4068 DOM_CLASSINFO_MAP_BEGIN(TransitionEvent, nsIDOMTransitionEvent)
4069 DOM_CLASSINFO_MAP_ENTRY(nsIDOMTransitionEvent)
4070 DOM_CLASSINFO_EVENT_MAP_ENTRIES
4071 DOM_CLASSINFO_MAP_END
4073 DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsIContentFrameMessageManager)
4074 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4075 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4076 DOM_CLASSINFO_MAP_ENTRY(nsIFrameMessageManager)
4077 DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
4078 DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
4079 DOM_CLASSINFO_MAP_END
4081 DOM_CLASSINFO_MAP_BEGIN(FormData, nsIDOMFormData)
4082 DOM_CLASSINFO_MAP_ENTRY(nsIDOMFormData)
4083 DOM_CLASSINFO_MAP_END
4085 DOM_CLASSINFO_MAP_BEGIN(DesktopNotification, nsIDOMDesktopNotification)
4086 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotification)
4087 DOM_CLASSINFO_MAP_END
4089 DOM_CLASSINFO_MAP_BEGIN(DesktopNotificationCenter, nsIDOMDesktopNotificationCenter)
4090 DOM_CLASSINFO_MAP_ENTRY(nsIDOMDesktopNotificationCenter)
4091 DOM_CLASSINFO_MAP_END
4093 DOM_CLASSINFO_MAP_BEGIN(WebSocket, nsIWebSocket)
4094 DOM_CLASSINFO_MAP_ENTRY(nsIWebSocket)
4095 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4096 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4097 DOM_CLASSINFO_MAP_END
4099 DOM_CLASSINFO_MAP_BEGIN(CloseEvent, nsIDOMCloseEvent)
4100 DOM_CLASSINFO_MAP_ENTRY(nsIDOMCloseEvent)
4101 DOM_CLASSINFO_EVENT_MAP_ENTRIES
4102 DOM_CLASSINFO_MAP_END
4104 DOM_CLASSINFO_MAP_BEGIN(IDBFactory, nsIIDBFactory)
4105 DOM_CLASSINFO_MAP_ENTRY(nsIIDBFactory)
4106 DOM_CLASSINFO_MAP_END
4108 DOM_CLASSINFO_MAP_BEGIN(IDBRequest, nsIIDBRequest)
4109 DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
4110 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4111 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4112 DOM_CLASSINFO_MAP_END
4114 DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase)
4115 DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase)
4116 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4117 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4118 DOM_CLASSINFO_MAP_END
4120 DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
4121 DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
4122 DOM_CLASSINFO_MAP_END
4124 DOM_CLASSINFO_MAP_BEGIN(IDBTransaction, nsIIDBTransaction)
4125 DOM_CLASSINFO_MAP_ENTRY(nsIIDBTransaction)
4126 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4127 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4128 DOM_CLASSINFO_MAP_END
4130 DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
4131 DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
4132 DOM_CLASSINFO_MAP_END
4134 DOM_CLASSINFO_MAP_BEGIN(IDBCursorWithValue, nsIIDBCursorWithValue)
4135 DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
4136 DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursorWithValue)
4137 DOM_CLASSINFO_MAP_END
4139 DOM_CLASSINFO_MAP_BEGIN(IDBKeyRange, nsIIDBKeyRange)
4140 DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
4141 DOM_CLASSINFO_MAP_END
4143 DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
4144 DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
4145 DOM_CLASSINFO_MAP_END
4147 DOM_CLASSINFO_MAP_BEGIN(IDBVersionChangeEvent, nsIIDBVersionChangeEvent)
4148 DOM_CLASSINFO_MAP_ENTRY(nsIIDBVersionChangeEvent)
4149 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
4150 DOM_CLASSINFO_MAP_END
4152 DOM_CLASSINFO_MAP_BEGIN(IDBVersionChangeRequest, nsIIDBVersionChangeRequest)
4153 DOM_CLASSINFO_MAP_ENTRY(nsIIDBVersionChangeRequest)
4154 DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
4155 DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
4156 DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
4157 DOM_CLASSINFO_MAP_END
4159 DOM_CLASSINFO_MAP_BEGIN(IDBDatabaseException, nsIIDBDatabaseException)
4160 DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabaseException)
4161 DOM_CLASSINFO_MAP_ENTRY(nsIException)
4162 DOM_CLASSINFO_MAP_END
4164 #ifdef NS_DEBUG
4166 PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
4168 if (i != eDOMClassInfoIDCount) {
4169 NS_ERROR("The number of items in sClassInfoData doesn't match the "
4170 "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
4172 return NS_ERROR_NOT_INITIALIZED;
4175 for (i = 0; i < eDOMClassInfoIDCount; i++) {
4176 if (!sClassInfoData[i].u.mConstructorFptr ||
4177 sClassInfoData[i].mDebugID != i) {
4178 NS_ERROR("Class info data out of sync, you forgot to update "
4179 "nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
4180 "mozilla will not work without this fixed!");
4182 return NS_ERROR_NOT_INITIALIZED;
4186 for (i = 0; i < eDOMClassInfoIDCount; i++) {
4187 if (!sClassInfoData[i].mInterfaces) {
4188 NS_ERROR("Class info data without an interface list! Fix this, "
4189 "mozilla will not work without this fixed!");
4191 return NS_ERROR_NOT_INITIALIZED;
4195 #endif
4197 // Initialize static JSString's
4198 DefineStaticJSVals(cx);
4200 PRInt32 i;
4202 for (i = 0; i < eDOMClassInfoIDCount; ++i) {
4203 RegisterClassName(i);
4206 for (i = 0; i < eDOMClassInfoIDCount; ++i) {
4207 RegisterClassProtos(i);
4210 RegisterExternalClasses();
4212 sDisableDocumentAllSupport =
4213 nsContentUtils::GetBoolPref("browser.dom.document.all.disabled");
4215 sDisableGlobalScopePollutionSupport =
4216 nsContentUtils::GetBoolPref("browser.dom.global_scope_pollution.disabled");
4218 sIsInitialized = PR_TRUE;
4220 return NS_OK;
4223 // static
4224 PRInt32
4225 nsDOMClassInfo::GetArrayIndexFromId(JSContext *cx, jsid id, PRBool *aIsNumber)
4227 if (aIsNumber) {
4228 *aIsNumber = PR_FALSE;
4231 jsint i;
4232 if (JSID_IS_INT(id)) {
4233 i = JSID_TO_INT(id);
4234 } else {
4235 JSAutoRequest ar(cx);
4237 jsval idval;
4238 jsdouble array_index;
4239 if (!::JS_IdToValue(cx, id, &idval) ||
4240 !::JS_ValueToNumber(cx, idval, &array_index) ||
4241 !::JS_DoubleIsInt32(array_index, &i)) {
4242 return -1;
4246 if (aIsNumber) {
4247 *aIsNumber = PR_TRUE;
4250 return i;
4253 // static
4254 nsresult
4255 nsDOMClassInfo::WrapNative(JSContext *cx, JSObject *scope,
4256 nsISupports *native, nsWrapperCache *cache,
4257 const nsIID* aIID, jsval *vp,
4258 nsIXPConnectJSObjectHolder** aHolder,
4259 PRBool aAllowWrapping)
4261 if (!native) {
4262 NS_ASSERTION(!aHolder || !*aHolder, "*aHolder should be null!");
4264 *vp = JSVAL_NULL;
4266 return NS_OK;
4269 JSObject *wrapper = xpc_GetCachedSlimWrapper(cache, scope, vp);
4270 if (wrapper) {
4271 return NS_OK;
4274 return sXPConnect->WrapNativeToJSVal(cx, scope, native, cache, aIID,
4275 aAllowWrapping, vp, aHolder);
4278 NS_IMETHODIMP
4279 nsDOMClassInfo::GetInterfaces(PRUint32 *aCount, nsIID ***aArray)
4281 PRUint32 count = 0;
4283 while (mData->mInterfaces[count]) {
4284 count++;
4287 *aCount = count;
4289 if (!count) {
4290 *aArray = nsnull;
4292 return NS_OK;
4295 *aArray = static_cast<nsIID **>(nsMemory::Alloc(count * sizeof(nsIID *)));
4296 NS_ENSURE_TRUE(*aArray, NS_ERROR_OUT_OF_MEMORY);
4298 PRUint32 i;
4299 for (i = 0; i < count; i++) {
4300 nsIID *iid = static_cast<nsIID *>(nsMemory::Clone(mData->mInterfaces[i],
4301 sizeof(nsIID)));
4303 if (!iid) {
4304 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, *aArray);
4306 return NS_ERROR_OUT_OF_MEMORY;
4309 *((*aArray) + i) = iid;
4312 return NS_OK;
4315 NS_IMETHODIMP
4316 nsDOMClassInfo::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
4318 if (language == nsIProgrammingLanguage::JAVASCRIPT) {
4319 *_retval = static_cast<nsIXPCScriptable *>(this);
4321 NS_ADDREF(*_retval);
4322 } else {
4323 *_retval = nsnull;
4326 return NS_OK;
4329 NS_IMETHODIMP
4330 nsDOMClassInfo::GetContractID(char **aContractID)
4332 *aContractID = nsnull;
4334 return NS_OK;
4337 NS_IMETHODIMP
4338 nsDOMClassInfo::GetClassDescription(char **aClassDescription)
4340 return GetClassName(aClassDescription);
4343 NS_IMETHODIMP
4344 nsDOMClassInfo::GetClassID(nsCID **aClassID)
4346 *aClassID = nsnull;
4347 return NS_OK;
4350 NS_IMETHODIMP
4351 nsDOMClassInfo::GetClassIDNoAlloc(nsCID *aClassID)
4353 return NS_ERROR_NOT_AVAILABLE;
4356 NS_IMETHODIMP
4357 nsDOMClassInfo::GetImplementationLanguage(PRUint32 *aImplLanguage)
4359 *aImplLanguage = nsIProgrammingLanguage::CPLUSPLUS;
4361 return NS_OK;
4364 NS_IMETHODIMP
4365 nsDOMClassInfo::GetFlags(PRUint32 *aFlags)
4367 *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
4369 return NS_OK;
4372 // nsIXPCScriptable
4374 NS_IMETHODIMP
4375 nsDOMClassInfo::GetClassName(char **aClassName)
4377 *aClassName = NS_strdup(mData->mName);
4379 return NS_OK;
4382 NS_IMETHODIMP
4383 nsDOMClassInfo::GetScriptableFlags(PRUint32 *aFlags)
4385 *aFlags = mData->mScriptableFlags;
4387 return NS_OK;
4390 NS_IMETHODIMP
4391 nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
4392 JSObject *globalObj, JSObject **parentObj)
4394 *parentObj = globalObj;
4396 nsCOMPtr<nsPIDOMWindow> piwin = do_QueryWrapper(cx, globalObj);
4398 if (!piwin) {
4399 return NS_OK;
4402 if (piwin->IsOuterWindow()) {
4403 *parentObj = ((nsGlobalWindow *)piwin.get())->
4404 GetCurrentInnerWindowInternal()->GetGlobalJSObject();
4407 return NS_OK;
4410 NS_IMETHODIMP
4411 nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
4412 JSContext *cx, JSObject *obj)
4414 NS_WARNING("nsDOMClassInfo::Create Don't call me!");
4416 return NS_ERROR_UNEXPECTED;
4419 NS_IMETHODIMP
4420 nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
4421 JSContext *cx, JSObject *obj)
4423 NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
4425 return NS_ERROR_UNEXPECTED;
4428 NS_IMETHODIMP
4429 nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4430 JSObject *obj, jsid id, jsval *vp,
4431 PRBool *_retval)
4433 NS_WARNING("nsDOMClassInfo::AddProperty Don't call me!");
4435 return NS_ERROR_UNEXPECTED;
4438 NS_IMETHODIMP
4439 nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4440 JSObject *obj, jsid id, jsval *vp,
4441 PRBool *_retval)
4443 NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
4445 return NS_ERROR_UNEXPECTED;
4448 NS_IMETHODIMP
4449 nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4450 JSObject *obj, jsid id, jsval *vp,
4451 PRBool *_retval)
4453 NS_WARNING("nsDOMClassInfo::GetProperty Don't call me!");
4455 return NS_OK;
4458 NS_IMETHODIMP
4459 nsDOMClassInfo::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4460 JSObject *obj, jsid id, jsval *vp,
4461 PRBool *_retval)
4463 NS_WARNING("nsDOMClassInfo::SetProperty Don't call me!");
4465 return NS_ERROR_UNEXPECTED;
4468 NS_IMETHODIMP
4469 nsDOMClassInfo::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4470 JSObject *obj, PRBool *_retval)
4472 #ifdef DEBUG
4473 if (!sSecMan) {
4474 NS_ERROR("No security manager!!!");
4475 return NS_OK;
4478 // Ask the security manager if it's OK to enumerate
4479 nsresult rv =
4480 sSecMan->CheckPropertyAccess(cx, obj, mData->mName, sEnumerate_id,
4481 nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
4483 NS_ASSERTION(NS_SUCCEEDED(rv),
4484 "XOWs should have stopped us from getting here!!!");
4485 #endif
4487 return NS_OK;
4490 NS_IMETHODIMP
4491 nsDOMClassInfo::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
4492 JSContext *cx, JSObject *obj, PRUint32 enum_op,
4493 jsval *statep, jsid *idp, PRBool *_retval)
4495 NS_WARNING("nsDOMClassInfo::NewEnumerate Don't call me!");
4497 return NS_ERROR_UNEXPECTED;
4500 nsresult
4501 nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *obj,
4502 JSObject **objp)
4504 JSObject *global = ::JS_GetGlobalForObject(cx, obj);
4506 jsval val;
4507 JSAutoRequest ar(cx);
4508 if (!::JS_LookupProperty(cx, global, mData->mName, &val)) {
4509 return NS_ERROR_UNEXPECTED;
4512 if (!JSVAL_IS_PRIMITIVE(val)) {
4513 // If val is not an (non-null) object there either is no
4514 // constructor for this class, or someone messed with
4515 // window.classname, just fall through and let the JS engine
4516 // return the Object constructor.
4518 if (!::JS_DefinePropertyById(cx, obj, sConstructor_id, val, nsnull, nsnull,
4519 JSPROP_ENUMERATE)) {
4520 return NS_ERROR_UNEXPECTED;
4523 *objp = obj;
4526 return NS_OK;
4529 NS_IMETHODIMP
4530 nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4531 JSObject *obj, jsid id, PRUint32 flags,
4532 JSObject **objp, PRBool *_retval)
4534 if (id == sConstructor_id && !(flags & JSRESOLVE_ASSIGNING)) {
4535 return ResolveConstructor(cx, obj, objp);
4538 return NS_OK;
4541 NS_IMETHODIMP
4542 nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4543 JSObject *obj, PRUint32 type, jsval *vp,
4544 PRBool *_retval)
4546 NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
4548 return NS_ERROR_UNEXPECTED;
4551 NS_IMETHODIMP
4552 nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4553 JSObject *obj)
4555 NS_WARNING("nsDOMClassInfo::Finalize Don't call me!");
4557 return NS_ERROR_UNEXPECTED;
4560 NS_IMETHODIMP
4561 nsDOMClassInfo::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4562 JSObject *obj, jsid id, PRUint32 mode,
4563 jsval *vp, PRBool *_retval)
4565 PRUint32 mode_type = mode & JSACC_TYPEMASK;
4567 if ((mode_type == JSACC_WATCH ||
4568 mode_type == JSACC_PROTO ||
4569 mode_type == JSACC_PARENT) &&
4570 sSecMan) {
4572 nsresult rv;
4573 JSObject *real_obj;
4574 if (wrapper) {
4575 rv = wrapper->GetJSObject(&real_obj);
4576 NS_ENSURE_SUCCESS(rv, rv);
4578 else {
4579 real_obj = obj;
4582 rv =
4583 sSecMan->CheckPropertyAccess(cx, real_obj, mData->mName, id,
4584 nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
4586 if (NS_FAILED(rv)) {
4587 // Let XPConnect know that the access was not granted.
4588 *_retval = PR_FALSE;
4592 return NS_OK;
4595 NS_IMETHODIMP
4596 nsDOMClassInfo::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4597 JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
4598 PRBool *_retval)
4600 NS_WARNING("nsDOMClassInfo::Call Don't call me!");
4602 return NS_ERROR_UNEXPECTED;
4605 NS_IMETHODIMP
4606 nsDOMClassInfo::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4607 JSObject *obj, PRUint32 argc, jsval *argv,
4608 jsval *vp, PRBool *_retval)
4610 NS_WARNING("nsDOMClassInfo::Construct Don't call me!");
4612 return NS_ERROR_UNEXPECTED;
4615 NS_IMETHODIMP
4616 nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
4617 JSObject *obj, const jsval &val, PRBool *bp,
4618 PRBool *_retval)
4620 NS_WARNING("nsDOMClassInfo::HasInstance Don't call me!");
4622 return NS_ERROR_UNEXPECTED;
4625 NS_IMETHODIMP
4626 nsDOMClassInfo::Trace(nsIXPConnectWrappedNative *wrapper, JSTracer *trc,
4627 JSObject *obj)
4629 NS_WARNING("nsDOMClassInfo::Trace Don't call me!");
4631 return NS_ERROR_UNEXPECTED;
4634 NS_IMETHODIMP
4635 nsDOMClassInfo::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
4636 JSObject * obj, const jsval &val, PRBool *bp)
4638 NS_WARNING("nsDOMClassInfo::Equality Don't call me!");
4640 return NS_ERROR_UNEXPECTED;
4643 NS_IMETHODIMP
4644 nsDOMClassInfo::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
4645 JSObject * obj, JSObject * *_retval)
4647 NS_WARNING("nsDOMClassInfo::OuterObject Don't call me!");
4649 return NS_ERROR_UNEXPECTED;
4652 static nsresult
4653 GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
4654 const nsString &aName,
4655 const nsGlobalNameStruct *aStruct,
4656 const nsGlobalNameStruct **aResult)
4658 NS_ASSERTION(aStruct->mType ==
4659 nsGlobalNameStruct::eTypeExternalClassInfoCreator,
4660 "Wrong type!");
4662 nsresult rv;
4663 nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->mCID, &rv));
4664 NS_ENSURE_SUCCESS(rv, rv);
4666 nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
4667 NS_ENSURE_TRUE(sof, NS_ERROR_FAILURE);
4669 rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), sof);
4670 NS_ENSURE_SUCCESS(rv, rv);
4672 const nsGlobalNameStruct *name_struct;
4673 rv = aNameSpaceManager->LookupName(aName, &name_struct);
4674 if (NS_SUCCEEDED(rv) && name_struct &&
4675 name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
4676 *aResult = name_struct;
4678 else {
4679 NS_ERROR("Couldn't get the DOM ClassInfo data.");
4681 *aResult = nsnull;
4684 return NS_OK;
4688 static nsresult
4689 ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
4690 JSObject *obj, const PRUnichar *name,
4691 const nsDOMClassInfoData *ci_data,
4692 const nsGlobalNameStruct *name_struct,
4693 nsScriptNameSpaceManager *nameSpaceManager,
4694 JSObject *dot_prototype, PRBool install, PRBool *did_resolve);
4697 NS_IMETHODIMP
4698 nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * proto)
4700 PRUint32 flags = (mData->mScriptableFlags & DONT_ENUM_STATIC_PROPS)
4702 : JSPROP_ENUMERATE;
4704 PRUint32 count = 0;
4705 while (mData->mInterfaces[count]) {
4706 count++;
4709 if (!sXPConnect->DefineDOMQuickStubs(cx, proto, flags,
4710 count, mData->mInterfaces)) {
4711 JS_ClearPendingException(cx);
4714 // This is called before any other location that requires
4715 // sObjectClass, so compute it here. We assume that nobody has had a
4716 // chance to monkey around with proto's prototype chain before this.
4717 if (!sObjectClass) {
4718 FindObjectClass(proto);
4719 NS_ASSERTION(sObjectClass && !strcmp(sObjectClass->name, "Object"),
4720 "Incorrect object class!");
4723 NS_ASSERTION(::JS_GetPrototype(cx, proto) &&
4724 JS_GET_CLASS(cx, ::JS_GetPrototype(cx, proto)) == sObjectClass,
4725 "Hmm, somebody did something evil?");
4727 #ifdef DEBUG
4728 if (mData->mHasClassInterface && mData->mProtoChainInterface &&
4729 mData->mProtoChainInterface != &NS_GET_IID(nsISupports)) {
4730 nsCOMPtr<nsIInterfaceInfoManager>
4731 iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
4733 if (iim) {
4734 nsCOMPtr<nsIInterfaceInfo> if_info;
4735 iim->GetInfoForIID(mData->mProtoChainInterface,
4736 getter_AddRefs(if_info));
4738 if (if_info) {
4739 nsXPIDLCString name;
4740 if_info->GetName(getter_Copies(name));
4741 NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mName) == 0,
4742 "Class name and proto chain interface name mismatch!");
4746 #endif
4748 // Make prototype delegation work correctly. Consider if a site sets
4749 // HTMLElement.prototype.foopy = function () { ... } Now, calling
4750 // document.body.foopy() needs to ensure that looking up foopy on
4751 // document.body's prototype will find the right function.
4752 JSObject *global = ::JS_GetGlobalForObject(cx, proto);
4754 // Only do this if the global object is a window.
4755 // XXX Is there a better way to check this?
4756 nsISupports *globalNative = XPConnect()->GetNativeOfWrapper(cx, global);
4757 nsCOMPtr<nsPIDOMWindow> piwin = do_QueryInterface(globalNative);
4758 if (!piwin) {
4759 return NS_OK;
4762 nsGlobalWindow *win = nsGlobalWindow::FromSupports(globalNative);
4763 if (win->IsClosedOrClosing()) {
4764 return NS_OK;
4767 // If the window is in a different compartment than the global object, then
4768 // it's likely that global is a sandbox object whose prototype is a window.
4769 // Don't do anything in this case.
4770 if (win->FastGetGlobalJSObject() &&
4771 global->compartment() != win->FastGetGlobalJSObject()->compartment()) {
4772 return NS_OK;
4775 if (win->IsOuterWindow()) {
4776 // XXXjst: Do security checks here when we remove the security
4777 // checks on the inner window.
4779 win = win->GetCurrentInnerWindowInternal();
4781 if (!win || !(global = win->GetGlobalJSObject()) ||
4782 win->IsClosedOrClosing()) {
4783 return NS_OK;
4787 // Don't overwrite a property set by content.
4788 JSBool found;
4789 if (!::JS_AlreadyHasOwnUCProperty(cx, global, reinterpret_cast<const jschar*>(mData->mNameUTF16),
4790 nsCRT::strlen(mData->mNameUTF16), &found)) {
4791 return NS_ERROR_FAILURE;
4794 nsScriptNameSpaceManager *nameSpaceManager =
4795 nsJSRuntime::GetNameSpaceManager();
4796 NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
4798 PRBool unused;
4799 return ResolvePrototype(sXPConnect, win, cx, global, mData->mNameUTF16,
4800 mData, nsnull, nameSpaceManager, proto, !found,
4801 &unused);
4804 // static
4805 nsIClassInfo *
4806 NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
4808 if (aID >= eDOMClassInfoIDCount) {
4809 NS_ERROR("Bad ID!");
4811 return nsnull;
4814 if (!nsDOMClassInfo::sIsInitialized) {
4815 nsresult rv = nsDOMClassInfo::Init();
4817 NS_ENSURE_SUCCESS(rv, nsnull);
4820 if (!sClassInfoData[aID].mCachedClassInfo) {
4821 nsDOMClassInfoData& data = sClassInfoData[aID];
4823 data.mCachedClassInfo = data.u.mConstructorFptr(&data);
4824 NS_ENSURE_TRUE(data.mCachedClassInfo, nsnull);
4826 NS_ADDREF(data.mCachedClassInfo);
4829 NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
4830 "This is bad, internal class marked as external!");
4832 return sClassInfoData[aID].mCachedClassInfo;
4835 // static
4836 nsIClassInfo *
4837 nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
4839 NS_ASSERTION(IS_EXTERNAL(aData->mCachedClassInfo)
4840 || !aData->mCachedClassInfo,
4841 "This is bad, external class marked as internal!");
4843 if (!aData->mCachedClassInfo) {
4844 if (aData->u.mExternalConstructorFptr) {
4845 aData->mCachedClassInfo =
4846 aData->u.mExternalConstructorFptr(aData->mName);
4847 } else {
4848 aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
4850 NS_ENSURE_TRUE(aData->mCachedClassInfo, nsnull);
4852 NS_ADDREF(aData->mCachedClassInfo);
4853 aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
4856 return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
4860 // static
4861 void
4862 nsDOMClassInfo::ShutDown()
4864 if (sClassInfoData[0].u.mConstructorFptr) {
4865 PRUint32 i;
4867 for (i = 0; i < eDOMClassInfoIDCount; i++) {
4868 NS_IF_RELEASE(sClassInfoData[i].mCachedClassInfo);
4872 sTop_id = JSID_VOID;
4873 sParent_id = JSID_VOID;
4874 sScrollbars_id = JSID_VOID;
4875 sLocation_id = JSID_VOID;
4876 sConstructor_id = JSID_VOID;
4877 s_content_id = JSID_VOID;
4878 sContent_id = JSID_VOID;
4879 sMenubar_id = JSID_VOID;
4880 sToolbar_id = JSID_VOID;
4881 sLocationbar_id = JSID_VOID;
4882 sPersonalbar_id = JSID_VOID;
4883 sStatusbar_id = JSID_VOID;
4884 sDialogArguments_id = JSID_VOID;
4885 sControllers_id = JSID_VOID;
4886 sLength_id = JSID_VOID;
4887 sInnerHeight_id = JSID_VOID;
4888 sInnerWidth_id = JSID_VOID;
4889 sOuterHeight_id = JSID_VOID;
4890 sOuterWidth_id = JSID_VOID;
4891 sScreenX_id = JSID_VOID;
4892 sScreenY_id = JSID_VOID;
4893 sStatus_id = JSID_VOID;
4894 sName_id = JSID_VOID;
4895 sOnmousedown_id = JSID_VOID;
4896 sOnmouseup_id = JSID_VOID;
4897 sOnclick_id = JSID_VOID;
4898 sOndblclick_id = JSID_VOID;
4899 sOncontextmenu_id = JSID_VOID;
4900 sOnmouseover_id = JSID_VOID;
4901 sOnmouseout_id = JSID_VOID;
4902 sOnkeydown_id = JSID_VOID;
4903 sOnkeyup_id = JSID_VOID;
4904 sOnkeypress_id = JSID_VOID;
4905 sOnmousemove_id = JSID_VOID;
4906 sOnfocus_id = JSID_VOID;
4907 sOnblur_id = JSID_VOID;
4908 sOnsubmit_id = JSID_VOID;
4909 sOnreset_id = JSID_VOID;
4910 sOnchange_id = JSID_VOID;
4911 sOninput_id = JSID_VOID;
4912 sOninvalid_id = JSID_VOID;
4913 sOnselect_id = JSID_VOID;
4914 sOnload_id = JSID_VOID;
4915 sOnbeforeunload_id = JSID_VOID;
4916 sOnunload_id = JSID_VOID;
4917 sOnhashchange_id = JSID_VOID;
4918 sOnreadystatechange_id = JSID_VOID;
4919 sOnpageshow_id = JSID_VOID;
4920 sOnpagehide_id = JSID_VOID;
4921 sOnabort_id = JSID_VOID;
4922 sOnerror_id = JSID_VOID;
4923 sOnpaint_id = JSID_VOID;
4924 sOnresize_id = JSID_VOID;
4925 sOnscroll_id = JSID_VOID;
4926 sOndrag_id = JSID_VOID;
4927 sOndragend_id = JSID_VOID;
4928 sOndragenter_id = JSID_VOID;
4929 sOndragleave_id = JSID_VOID;
4930 sOndragover_id = JSID_VOID;
4931 sOndragstart_id = JSID_VOID;
4932 sOndrop_id = JSID_VOID;
4933 sScrollX_id = JSID_VOID;
4934 sScrollY_id = JSID_VOID;
4935 sScrollMaxX_id = JSID_VOID;
4936 sScrollMaxY_id = JSID_VOID;
4937 sOpen_id = JSID_VOID;
4938 sItem_id = JSID_VOID;
4939 sEnumerate_id = JSID_VOID;
4940 sNavigator_id = JSID_VOID;
4941 sDocument_id = JSID_VOID;
4942 sFrames_id = JSID_VOID;
4943 sSelf_id = JSID_VOID;
4944 sOpener_id = JSID_VOID;
4945 sAll_id = JSID_VOID;
4946 sTags_id = JSID_VOID;
4947 sAddEventListener_id= JSID_VOID;
4948 sBaseURIObject_id = JSID_VOID;
4949 sNodePrincipal_id = JSID_VOID;
4950 sDocumentURIObject_id=JSID_VOID;
4951 sOncopy_id = JSID_VOID;
4952 sOncut_id = JSID_VOID;
4953 sOnpaste_id = JSID_VOID;
4954 sJava_id = JSID_VOID;
4955 sPackages_id = JSID_VOID;
4956 sOnloadstart_id = JSID_VOID;
4957 sOnprogress_id = JSID_VOID;
4958 sOnsuspend_id = JSID_VOID;
4959 sOnemptied_id = JSID_VOID;
4960 sOnstalled_id = JSID_VOID;
4961 sOnplay_id = JSID_VOID;
4962 sOnpause_id = JSID_VOID;
4963 sOnloadedmetadata_id= JSID_VOID;
4964 sOnloadeddata_id = JSID_VOID;
4965 sOnwaiting_id = JSID_VOID;
4966 sOnplaying_id = JSID_VOID;
4967 sOncanplay_id = JSID_VOID;
4968 sOncanplaythrough_id= JSID_VOID;
4969 sOnseeking_id = JSID_VOID;
4970 sOnseeked_id = JSID_VOID;
4971 sOntimeupdate_id = JSID_VOID;
4972 sOnended_id = JSID_VOID;
4973 sOnratechange_id = JSID_VOID;
4974 sOndurationchange_id= JSID_VOID;
4975 sOnvolumechange_id = JSID_VOID;
4976 sOnmessage_id = JSID_VOID;
4977 sOnbeforescriptexecute_id = JSID_VOID;
4978 sOnafterscriptexecute_id = JSID_VOID;
4979 sWrappedJSObject_id = JSID_VOID;
4980 sKeyPath_id = JSID_VOID;
4981 sAutoIncrement_id = JSID_VOID;
4982 sUnique_id = JSID_VOID;
4984 NS_IF_RELEASE(sXPConnect);
4985 NS_IF_RELEASE(sSecMan);
4986 sIsInitialized = PR_FALSE;
4989 // Window helper
4991 NS_IMETHODIMP
4992 nsWindowSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
4993 JSObject *globalObj, JSObject **parentObj)
4995 // Normally ::PreCreate() is used to give XPConnect the parent
4996 // object for the object that's being wrapped, this parent object is
4997 // set as the parent of the wrapper and it's also used to find the
4998 // right scope for the object being wrapped. Now, in the case of the
4999 // global object the wrapper shouldn't have a parent but we supply
5000 // one here anyway (the global object itself) and this will be used
5001 // by XPConnect only to find the right scope, once the scope is
5002 // found XPConnect will find the existing wrapper (which always
5003 // exists since it's created on window construction), since an
5004 // existing wrapper is found the parent we supply here is ignored
5005 // after the wrapper is found.
5007 nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeObj));
5008 NS_ASSERTION(sgo, "nativeObj not a global object!");
5010 nsGlobalWindow *win = nsGlobalWindow::FromSupports(nativeObj);
5011 if (win->IsOuterWindow()) {
5012 if (!win->EnsureInnerWindow()) {
5013 return NS_ERROR_FAILURE;
5016 *parentObj = win->GetCurrentInnerWindowInternal()->FastGetGlobalJSObject();
5017 return NS_OK;
5020 JSObject *winObj = win->FastGetGlobalJSObject();
5021 if (!winObj) {
5022 NS_ASSERTION(win->GetOuterWindowInternal()->IsCreatingInnerWindow(),
5023 "should have a JS object by this point");
5024 return NS_OK;
5027 *parentObj = winObj;
5028 return NS_OK;
5031 // This JS class piggybacks on nsHTMLDocumentSH::ReleaseDocument()...
5033 static JSClass sGlobalScopePolluterClass = {
5034 "Global Scope Polluter",
5035 JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE,
5036 nsWindowSH::SecurityCheckOnAddDelProp,
5037 nsWindowSH::SecurityCheckOnAddDelProp,
5038 nsWindowSH::GlobalScopePolluterGetProperty,
5039 nsWindowSH::SecurityCheckOnSetProp,
5040 JS_EnumerateStub,
5041 (JSResolveOp)nsWindowSH::GlobalScopePolluterNewResolve,
5042 JS_ConvertStub,
5043 nsHTMLDocumentSH::ReleaseDocument
5047 // static
5048 JSBool
5049 nsWindowSH::GlobalScopePolluterGetProperty(JSContext *cx, JSObject *obj,
5050 jsid id, jsval *vp)
5052 // Someone is accessing a element by referencing its name/id in the
5053 // global scope, do a security check to make sure that's ok.
5055 nsresult rv =
5056 sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
5057 "Window", id,
5058 nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
5060 if (NS_FAILED(rv)) {
5061 // The security check failed. The security manager set a JS
5062 // exception for us.
5064 return JS_FALSE;
5067 // Print a warning on the console so developers have a chance to
5068 // catch and fix these mistakes.
5069 PrintWarningOnConsole(cx, "GlobalScopeElementReference");
5071 return JS_TRUE;
5074 // static
5075 JSBool
5076 nsWindowSH::SecurityCheckOnAddDelProp(JSContext *cx, JSObject *obj, jsid id,
5077 jsval *vp)
5079 // Someone is accessing a element by referencing its name/id in the
5080 // global scope, do a security check to make sure that's ok.
5082 nsresult rv =
5083 sSecMan->CheckPropertyAccess(cx, ::JS_GetGlobalForObject(cx, obj),
5084 "Window", id,
5085 nsIXPCSecurityManager::ACCESS_SET_PROPERTY);
5087 // If !NS_SUCCEEDED(rv) the security check failed. The security
5088 // manager set a JS exception for us.
5089 return NS_SUCCEEDED(rv);
5092 // static
5093 JSBool
5094 nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
5095 jsval *vp)
5097 return SecurityCheckOnAddDelProp(cx, obj, id, vp);
5100 static nsHTMLDocument*
5101 GetDocument(JSContext *cx, JSObject *obj)
5103 return static_cast<nsHTMLDocument*>(
5104 static_cast<nsIHTMLDocument*>(::JS_GetPrivate(cx, obj)));
5107 // static
5108 JSBool
5109 nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
5110 jsid id, uintN flags,
5111 JSObject **objp)
5113 if (flags & (JSRESOLVE_ASSIGNING | JSRESOLVE_DECLARING |
5114 JSRESOLVE_CLASSNAME | JSRESOLVE_QUALIFIED) ||
5115 !JSID_IS_STRING(id)) {
5116 // Nothing to do here if we're either assigning or declaring,
5117 // resolving a class name, doing a qualified resolve, or
5118 // resolving a number.
5120 return JS_TRUE;
5123 nsHTMLDocument *document = GetDocument(cx, obj);
5125 if (!document ||
5126 document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
5127 // If we don't have a document, or if the document is not in
5128 // quirks mode, return early.
5130 return JS_TRUE;
5133 JSObject *proto = ::JS_GetPrototype(cx, obj);
5134 JSBool hasProp;
5136 if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
5137 hasProp) {
5138 // No prototype, or the property exists on the prototype. Do
5139 // nothing.
5141 return JS_TRUE;
5144 nsDependentJSString str(id);
5145 nsCOMPtr<nsISupports> result;
5146 nsWrapperCache *cache;
5148 Element *element = document->GetElementById(str);
5149 result = element;
5150 cache = element;
5153 if (!result) {
5154 document->ResolveName(str, nsnull, getter_AddRefs(result), &cache);
5157 if (result) {
5158 jsval v;
5159 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
5160 nsresult rv = WrapNative(cx, obj, result, cache, PR_TRUE, &v,
5161 getter_AddRefs(holder));
5162 NS_ENSURE_SUCCESS(rv, JS_FALSE);
5164 if (!JS_WrapValue(cx, &v) ||
5165 !JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
5166 return JS_FALSE;
5169 *objp = obj;
5172 return JS_TRUE;
5175 // static
5176 void
5177 nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj)
5179 JSObject *proto;
5181 JSAutoRequest ar(cx);
5183 while ((proto = ::JS_GetPrototype(cx, obj))) {
5184 if (JS_GET_CLASS(cx, proto) == &sGlobalScopePolluterClass) {
5185 nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, proto);
5187 NS_IF_RELEASE(doc);
5189 ::JS_SetPrivate(cx, proto, nsnull);
5191 // Pull the global scope polluter out of the prototype chain so
5192 // that it can be freed.
5193 ::JS_SetPrototype(cx, obj, ::JS_GetPrototype(cx, proto));
5195 break;
5198 obj = proto;
5202 // static
5203 nsresult
5204 nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
5205 nsIHTMLDocument *doc)
5207 // If global scope pollution is disabled, or if our document is not
5208 // a HTML document, do nothing
5209 if (sDisableGlobalScopePollutionSupport || !doc) {
5210 return NS_OK;
5213 JSAutoRequest ar(cx);
5215 JSObject *gsp = ::JS_NewObject(cx, &sGlobalScopePolluterClass, nsnull, obj);
5216 if (!gsp) {
5217 return NS_ERROR_OUT_OF_MEMORY;
5220 JSObject *o = obj, *proto;
5222 // Find the place in the prototype chain where we want this global
5223 // scope polluter (right before Object.prototype).
5225 while ((proto = ::JS_GetPrototype(cx, o))) {
5226 if (JS_GET_CLASS(cx, proto) == sObjectClass) {
5227 // Set the global scope polluters prototype to Object.prototype
5228 if (!::JS_SetPrototype(cx, gsp, proto)) {
5229 return NS_ERROR_UNEXPECTED;
5232 break;
5235 o = proto;
5238 // And then set the prototype of the object whose prototype was
5239 // Object.prototype to be the global scope polluter.
5240 if (!::JS_SetPrototype(cx, o, gsp)) {
5241 return NS_ERROR_UNEXPECTED;
5244 if (!::JS_SetPrivate(cx, gsp, doc)) {
5245 return NS_ERROR_UNEXPECTED;
5248 // The global scope polluter will release doc on destruction (or
5249 // invalidation).
5250 NS_ADDREF(doc);
5252 return NS_OK;
5255 static
5256 already_AddRefed<nsIDOMWindow>
5257 GetChildFrame(nsGlobalWindow *win, jsid id)
5259 nsCOMPtr<nsIDOMWindowCollection> frames;
5260 win->GetFrames(getter_AddRefs(frames));
5262 nsIDOMWindow *frame = nsnull;
5264 if (frames) {
5265 frames->Item(JSID_TO_INT(id), &frame);
5268 return frame;
5271 NS_IMETHODIMP
5272 nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5273 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
5275 nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
5277 JSAutoRequest ar(cx);
5279 #ifdef DEBUG_SH_FORWARDING
5281 JSString *jsstr = ::JS_ValueToString(cx, id);
5282 if (jsstr) {
5283 nsDependentJSString str(jsstr);
5285 if (win->IsInnerWindow()) {
5286 #ifdef DEBUG_PRINT_INNER
5287 printf("Property '%s' get on inner window %p\n",
5288 NS_ConvertUTF16toUTF8(str).get(), (void *)win);
5289 #endif
5290 } else {
5291 printf("Property '%s' get on outer window %p\n",
5292 NS_ConvertUTF16toUTF8(str).get(), (void *)win);
5296 #endif
5298 // The order in which things are done in this method are a bit
5299 // whacky, that's because this method is *extremely* performace
5300 // critical. Don't touch this unless you know what you're doing.
5302 if (JSID_IS_INT(id)) {
5303 // If we're accessing a numeric property we'll treat that as if
5304 // window.frames[n] is accessed (since window.frames === window),
5305 // if window.frames[n] is a child frame, wrap the frame and return
5306 // it without doing a security check.
5308 nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
5309 nsresult rv = NS_OK;
5311 if (frame) {
5312 // A numeric property accessed and the numeric property is a
5313 // child frame, wrap the child frame without doing a security
5314 // check and return.
5316 nsGlobalWindow *frameWin = (nsGlobalWindow *)frame.get();
5317 NS_ASSERTION(frameWin->IsOuterWindow(), "GetChildFrame gave us an inner?");
5319 frameWin->EnsureInnerWindow();
5321 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
5322 jsval v;
5323 rv = WrapNative(cx, frameWin->GetGlobalJSObject(), frame,
5324 &NS_GET_IID(nsIDOMWindow), PR_TRUE, &v,
5325 getter_AddRefs(holder));
5326 NS_ENSURE_SUCCESS(rv, rv);
5328 if (!JS_WrapValue(cx, &v)) {
5329 return NS_ERROR_FAILURE;
5332 *vp = v;
5335 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
5338 if (JSID_IS_STRING(id) && !JSVAL_IS_PRIMITIVE(*vp) &&
5339 ::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) {
5340 // A named property accessed which could have been resolved to a
5341 // child frame in nsWindowSH::NewResolve() (*vp will tell us if
5342 // that's the case). If *vp is a window object (i.e. a child
5343 // frame), return without doing a security check.
5345 // Calling GetWrappedNativeOfJSObject() is not all that cheap, so
5346 // only do that if the JSClass name is one that is likely to be a
5347 // window object.
5349 const char *name = JS_GET_CLASS(cx, JSVAL_TO_OBJECT(*vp))->name;
5351 // The list of Window class names here need to be kept in sync
5352 // with the actual class names! The class name
5353 // XPCCrossOriginWrapper needs to be handled here too as XOWs
5354 // define child frame names with a XOW as the value, and thus
5355 // we'll need to get through here with XOWs class name too.
5356 if ((*name == 'W' && strcmp(name, "Window") == 0) ||
5357 (*name == 'C' && strcmp(name, "ChromeWindow") == 0) ||
5358 (*name == 'M' && strcmp(name, "ModalContentWindow") == 0) ||
5359 (*name == 'I' &&
5360 (strcmp(name, "InnerWindow") == 0 ||
5361 strcmp(name, "InnerChromeWindow") == 0 ||
5362 strcmp(name, "InnerModalContentWindow") == 0)) ||
5363 (*name == 'X' && strcmp(name, "XPCCrossOriginWrapper") == 0)) {
5364 nsCOMPtr<nsIDOMWindow> window = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
5366 if (window) {
5367 // Yup, *vp is a window object, return early (*vp is already
5368 // the window, so no need to wrap it again).
5370 return NS_SUCCESS_I_DID_SOMETHING;
5375 if (id == sWrappedJSObject_id &&
5376 xpc::AccessCheck::isChrome(cx->compartment)) {
5377 OBJ_TO_OUTER_OBJECT(cx, obj);
5378 *vp = OBJECT_TO_JSVAL(obj);
5379 return NS_SUCCESS_I_DID_SOMETHING;
5382 return NS_OK;
5385 NS_IMETHODIMP
5386 nsWindowSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5387 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
5389 if (id == sLocation_id) {
5390 JSAutoRequest ar(cx);
5392 JSString *val = ::JS_ValueToString(cx, *vp);
5393 NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
5395 nsCOMPtr<nsIDOMWindowInternal> window(do_QueryWrappedNative(wrapper));
5396 NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
5398 nsCOMPtr<nsIDOMLocation> location;
5399 nsresult rv = window->GetLocation(getter_AddRefs(location));
5400 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && location, rv);
5402 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
5403 rv = WrapNative(cx, obj, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
5404 vp, getter_AddRefs(holder));
5405 NS_ENSURE_SUCCESS(rv, rv);
5407 nsDependentJSString depStr;
5408 NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
5410 rv = location->SetHref(depStr);
5412 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
5415 return nsEventReceiverSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
5418 static const char*
5419 FindConstructorContractID(const nsDOMClassInfoData *aDOMClassInfoData)
5421 PRUint32 i;
5422 for (i = 0; i < NS_ARRAY_LENGTH(kConstructorMap); ++i) {
5423 if (&sClassInfoData[kConstructorMap[i].mDOMClassInfoID] ==
5424 aDOMClassInfoData) {
5425 return kConstructorMap[i].mContractID;
5428 return nsnull;
5431 static nsDOMConstructorFunc
5432 FindConstructorFunc(const nsDOMClassInfoData *aDOMClassInfoData)
5434 for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kConstructorFuncMap); ++i) {
5435 if (&sClassInfoData[kConstructorFuncMap[i].mDOMClassInfoID] ==
5436 aDOMClassInfoData) {
5437 return kConstructorFuncMap[i].mConstructorFunc;
5440 return nsnull;
5443 static nsresult
5444 BaseStubConstructor(nsIWeakReference* aWeakOwner,
5445 const nsGlobalNameStruct *name_struct, JSContext *cx,
5446 JSObject *obj, uintN argc, jsval *argv, jsval *rval)
5448 nsresult rv;
5449 nsCOMPtr<nsISupports> native;
5450 if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
5451 const nsDOMClassInfoData* ci_data =
5452 &sClassInfoData[name_struct->mDOMClassInfoID];
5453 const char *contractid = FindConstructorContractID(ci_data);
5454 if (contractid) {
5455 native = do_CreateInstance(contractid, &rv);
5457 else {
5458 nsDOMConstructorFunc func = FindConstructorFunc(ci_data);
5459 if (func) {
5460 rv = func(getter_AddRefs(native));
5462 else {
5463 rv = NS_ERROR_NOT_AVAILABLE;
5466 } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
5467 native = do_CreateInstance(name_struct->mCID, &rv);
5468 } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
5469 native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
5470 } else {
5471 native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
5473 if (NS_FAILED(rv)) {
5474 NS_ERROR("Failed to create the object");
5475 return rv;
5478 nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
5479 if (initializer) {
5480 // Initialize object using the current inner window, but only if
5481 // the caller can access it.
5482 nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
5483 nsPIDOMWindow* outerWindow = owner ? owner->GetOuterWindow() : nsnull;
5484 nsPIDOMWindow* currentInner =
5485 outerWindow ? outerWindow->GetCurrentInnerWindow() : nsnull;
5486 if (!currentInner ||
5487 (owner != currentInner &&
5488 !nsContentUtils::CanCallerAccess(currentInner))) {
5489 return NS_ERROR_DOM_SECURITY_ERR;
5492 rv = initializer->Initialize(currentInner, cx, obj, argc, argv);
5493 if (NS_FAILED(rv)) {
5494 return rv;
5498 nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
5499 if (owner) {
5500 nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
5501 if (!context) {
5502 return NS_ERROR_UNEXPECTED;
5505 JSObject* new_obj;
5506 rv = owner->GetScriptObject(context, (void**)&new_obj);
5508 if (NS_SUCCEEDED(rv)) {
5509 *rval = OBJECT_TO_JSVAL(new_obj);
5512 return rv;
5515 rv = nsDOMGenericSH::WrapNative(cx, obj, native, PR_TRUE, rval);
5517 return rv;
5520 static nsresult
5521 DefineInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
5523 nsCOMPtr<nsIInterfaceInfoManager>
5524 iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
5525 NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
5527 nsCOMPtr<nsIInterfaceInfo> if_info;
5529 nsresult rv = iim->GetInfoForIID(aIID, getter_AddRefs(if_info));
5530 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && if_info, rv);
5532 PRUint16 constant_count;
5534 if_info->GetConstantCount(&constant_count);
5536 if (!constant_count) {
5537 return NS_OK;
5540 nsCOMPtr<nsIInterfaceInfo> parent_if_info;
5542 rv = if_info->GetParent(getter_AddRefs(parent_if_info));
5543 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && parent_if_info, rv);
5545 PRUint16 parent_constant_count, i;
5546 parent_if_info->GetConstantCount(&parent_constant_count);
5548 for (i = parent_constant_count; i < constant_count; i++) {
5549 const nsXPTConstant *c = nsnull;
5551 rv = if_info->GetConstant(i, &c);
5552 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && c, rv);
5554 PRUint16 type = c->GetType().TagPart();
5556 jsval v;
5557 switch (type) {
5558 case nsXPTType::T_I8:
5559 case nsXPTType::T_U8:
5561 v = INT_TO_JSVAL(c->GetValue()->val.u8);
5562 break;
5564 case nsXPTType::T_I16:
5565 case nsXPTType::T_U16:
5567 v = INT_TO_JSVAL(c->GetValue()->val.u16);
5568 break;
5570 case nsXPTType::T_I32:
5572 if (!JS_NewNumberValue(cx, c->GetValue()->val.i32, &v)) {
5573 return NS_ERROR_UNEXPECTED;
5575 break;
5577 case nsXPTType::T_U32:
5579 if (!JS_NewNumberValue(cx, c->GetValue()->val.u32, &v)) {
5580 return NS_ERROR_UNEXPECTED;
5582 break;
5584 default:
5586 #ifdef NS_DEBUG
5587 NS_ERROR("Non-numeric constant found in interface.");
5588 #endif
5589 continue;
5593 if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull,
5594 JSPROP_ENUMERATE)) {
5595 return NS_ERROR_UNEXPECTED;
5599 return NS_OK;
5602 NS_IMETHODIMP
5603 nsHTMLBodyElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext
5604 *cx, JSObject *obj, jsid id, PRUint32 flags,
5605 JSObject **objp, PRBool *_retval)
5607 if (id == sOnhashchange_id) {
5608 // Special handling so |"onhashchange" in document.body| returns true.
5609 if (!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
5610 nsnull, nsnull, JSPROP_ENUMERATE)) {
5611 *_retval = PR_FALSE;
5612 return NS_ERROR_FAILURE;
5615 *objp = obj;
5616 return NS_OK;
5619 return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
5622 NS_IMETHODIMP
5623 nsHTMLBodyElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
5624 JSContext *cx, JSObject *obj, jsid id,
5625 jsval *vp, PRBool *_retval)
5627 if (id == sOnhashchange_id) {
5628 // Forward the request to the Window.
5629 if (!JS_GetPropertyById(cx, JS_GetGlobalForObject(cx, obj), id, vp)) {
5630 *_retval = PR_FALSE;
5631 return NS_ERROR_FAILURE;
5634 return NS_OK;
5637 return nsElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
5640 NS_IMETHODIMP
5641 nsHTMLBodyElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
5642 JSContext *cx, JSObject *obj,
5643 jsid id, jsval *vp, PRBool *_retval)
5645 if (id == sOnhashchange_id) {
5646 // Forward the request to the Window.
5647 if (!JS_SetPropertyById(cx, JS_GetGlobalForObject(cx, obj), id, vp)) {
5648 *_retval = PR_FALSE;
5649 return NS_ERROR_FAILURE;
5652 return NS_OK;
5655 return nsElementSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
5658 class nsDOMConstructor : public nsIDOMDOMConstructor
5660 protected:
5661 nsDOMConstructor(const PRUnichar* aName,
5662 PRBool aIsConstructable,
5663 nsPIDOMWindow* aOwner)
5664 : mClassName(aName),
5665 mConstructable(aIsConstructable),
5666 mWeakOwner(do_GetWeakReference(aOwner))
5670 public:
5672 static nsresult Create(const PRUnichar* aName,
5673 const nsDOMClassInfoData* aData,
5674 const nsGlobalNameStruct* aNameStruct,
5675 nsPIDOMWindow* aOwner,
5676 nsDOMConstructor** aResult);
5678 NS_DECL_ISUPPORTS
5679 NS_DECL_NSIDOMDOMCONSTRUCTOR
5681 nsresult PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj);
5683 nsresult Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5684 JSObject *obj, PRUint32 argc, jsval *argv,
5685 jsval *vp, PRBool *_retval);
5687 nsresult HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
5688 JSObject *obj, const jsval &val, PRBool *bp,
5689 PRBool *_retval);
5691 nsresult Install(JSContext *cx, JSObject *target, jsval thisAsVal)
5693 // The 'attrs' argument used to be JSPROP_PERMANENT. See bug 628612.
5694 JSBool ok = JS_WrapValue(cx, &thisAsVal) &&
5695 ::JS_DefineUCProperty(cx, target,
5696 reinterpret_cast<const jschar *>(mClassName),
5697 nsCRT::strlen(mClassName), thisAsVal, nsnull,
5698 nsnull, 0);
5700 return ok ? NS_OK : NS_ERROR_UNEXPECTED;
5703 private:
5704 const nsGlobalNameStruct *GetNameStruct()
5706 if (!mClassName) {
5707 NS_ERROR("Can't get name");
5708 return nsnull;
5711 const nsGlobalNameStruct *nameStruct;
5712 #ifdef DEBUG
5713 nsresult rv =
5714 #endif
5715 GetNameStruct(nsDependentString(mClassName), &nameStruct);
5717 NS_ASSERTION(NS_FAILED(rv) || nameStruct, "Name isn't in hash.");
5719 return nameStruct;
5722 static nsresult GetNameStruct(const nsAString& aName,
5723 const nsGlobalNameStruct **aNameStruct)
5725 *aNameStruct = nsnull;
5727 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
5728 if (!nameSpaceManager) {
5729 NS_ERROR("Can't get namespace manager.");
5730 return NS_ERROR_UNEXPECTED;
5733 nameSpaceManager->LookupName(aName, aNameStruct);
5735 // Return NS_OK here, aName just isn't a DOM class but nothing failed.
5736 return NS_OK;
5739 static PRBool IsConstructable(const nsDOMClassInfoData *aData)
5741 if (IS_EXTERNAL(aData->mCachedClassInfo)) {
5742 const nsExternalDOMClassInfoData* data =
5743 static_cast<const nsExternalDOMClassInfoData*>(aData);
5744 return data->mConstructorCID != nsnull;
5747 return FindConstructorContractID(aData) || FindConstructorFunc(aData);
5749 static PRBool IsConstructable(const nsGlobalNameStruct *aNameStruct)
5751 return
5752 (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
5753 IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
5754 (aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
5755 IsConstructable(aNameStruct->mData)) ||
5756 aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor ||
5757 aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias;
5760 const PRUnichar* mClassName;
5761 const PRPackedBool mConstructable;
5762 nsWeakPtr mWeakOwner;
5765 //static
5766 nsresult
5767 nsDOMConstructor::Create(const PRUnichar* aName,
5768 const nsDOMClassInfoData* aData,
5769 const nsGlobalNameStruct* aNameStruct,
5770 nsPIDOMWindow* aOwner,
5771 nsDOMConstructor** aResult)
5773 *aResult = nsnull;
5774 // Prevent creating a constructor if aOwner is inner window which doesn't have
5775 // an outer window. If the outer window doesn't have an inner window or the
5776 // caller can't access the outer window's current inner window then try to use
5777 // the owner (so long as it is, in fact, an inner window). If that doesn't
5778 // work then prevent creation also.
5779 nsPIDOMWindow* outerWindow = aOwner->GetOuterWindow();
5780 nsPIDOMWindow* currentInner =
5781 outerWindow ? outerWindow->GetCurrentInnerWindow() : aOwner;
5782 if (!currentInner ||
5783 (aOwner != currentInner &&
5784 !nsContentUtils::CanCallerAccess(currentInner) &&
5785 !(currentInner = aOwner)->IsInnerWindow())) {
5786 return NS_ERROR_DOM_SECURITY_ERR;
5789 PRBool constructable = aNameStruct ?
5790 IsConstructable(aNameStruct) :
5791 IsConstructable(aData);
5793 *aResult = new nsDOMConstructor(aName, constructable, currentInner);
5794 NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
5795 NS_ADDREF(*aResult);
5796 return NS_OK;
5799 NS_IMPL_ADDREF(nsDOMConstructor)
5800 NS_IMPL_RELEASE(nsDOMConstructor)
5801 NS_INTERFACE_MAP_BEGIN(nsDOMConstructor)
5802 NS_INTERFACE_MAP_ENTRY(nsIDOMDOMConstructor)
5803 NS_INTERFACE_MAP_ENTRY(nsISupports)
5804 if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
5805 #ifdef DEBUG
5807 const nsGlobalNameStruct *name_struct = GetNameStruct();
5808 NS_ASSERTION(!name_struct ||
5809 mConstructable == IsConstructable(name_struct),
5810 "Can't change constructability dynamically!");
5812 #endif
5813 foundInterface =
5814 NS_GetDOMClassInfoInstance(mConstructable ?
5815 eDOMClassInfo_DOMConstructor_id :
5816 eDOMClassInfo_DOMPrototype_id);
5817 if (!foundInterface) {
5818 *aInstancePtr = nsnull;
5819 return NS_ERROR_OUT_OF_MEMORY;
5821 } else
5822 NS_INTERFACE_MAP_END
5824 nsresult
5825 nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
5827 nsCOMPtr<nsPIDOMWindow> owner(do_QueryReferent(mWeakOwner));
5828 if (!owner) {
5829 // Can't do anything.
5830 return NS_OK;
5833 nsGlobalWindow *win = static_cast<nsGlobalWindow *>(owner.get());
5834 *parentObj = win->FastGetGlobalJSObject();
5835 return NS_OK;
5838 nsresult
5839 nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
5840 JSObject * obj, PRUint32 argc, jsval * argv,
5841 jsval * vp, PRBool *_retval)
5843 JSObject* class_obj = JSVAL_TO_OBJECT(argv[-2]);
5844 if (!class_obj) {
5845 NS_ERROR("nsDOMConstructor::Construct couldn't get constructor object.");
5846 return NS_ERROR_UNEXPECTED;
5849 const nsGlobalNameStruct *name_struct = GetNameStruct();
5850 NS_ENSURE_TRUE(name_struct, NS_ERROR_FAILURE);
5852 if (!IsConstructable(name_struct)) {
5853 // ignore return value, we return JS_FALSE anyway
5854 return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
5857 return BaseStubConstructor(mWeakOwner, name_struct, cx, obj, argc, argv, vp);
5860 nsresult
5861 nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
5862 JSContext * cx, JSObject * obj,
5863 const jsval &v, PRBool *bp, PRBool *_retval)
5866 // No need to look these up in the hash.
5867 if (JSVAL_IS_PRIMITIVE(v)) {
5868 return NS_OK;
5871 JSObject *dom_obj = JSVAL_TO_OBJECT(v);
5872 NS_ASSERTION(dom_obj, "nsDOMConstructor::HasInstance couldn't get object");
5874 // This might not be the right object, if XPCNativeWrapping
5875 // happened. Get the wrapped native for this object, then get its
5876 // JS object.
5877 JSObject *wrapped_obj;
5878 nsresult rv = nsContentUtils::XPConnect()->GetJSObjectOfWrapper(cx, dom_obj,
5879 &wrapped_obj);
5880 if (NS_SUCCEEDED(rv)) {
5881 dom_obj = wrapped_obj;
5884 JSClass *dom_class = JS_GET_CLASS(cx, dom_obj);
5885 if (!dom_class) {
5886 NS_ERROR("nsDOMConstructor::HasInstance can't get class.");
5887 return NS_ERROR_UNEXPECTED;
5890 const nsGlobalNameStruct *name_struct;
5891 rv = GetNameStruct(NS_ConvertASCIItoUTF16(dom_class->name), &name_struct);
5892 if (!name_struct) {
5893 return rv;
5896 if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
5897 name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo &&
5898 name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructorAlias) {
5899 // Doesn't have DOM interfaces.
5900 return NS_OK;
5903 const nsGlobalNameStruct *class_name_struct = GetNameStruct();
5904 NS_ENSURE_TRUE(class_name_struct, NS_ERROR_FAILURE);
5906 if (name_struct == class_name_struct) {
5907 *bp = JS_TRUE;
5909 return NS_OK;
5912 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
5913 NS_ASSERTION(nameSpaceManager, "Can't get namespace manager?");
5915 const nsIID *class_iid;
5916 if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
5917 class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
5918 class_iid = &class_name_struct->mIID;
5919 } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
5920 class_iid =
5921 sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
5922 } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
5923 class_iid = class_name_struct->mData->mProtoChainInterface;
5924 } else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
5925 const nsGlobalNameStruct* alias_struct =
5926 nameSpaceManager->GetConstructorProto(class_name_struct);
5927 if (!alias_struct) {
5928 NS_ERROR("Couldn't get constructor prototype.");
5929 return NS_ERROR_UNEXPECTED;
5932 if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
5933 class_iid =
5934 sClassInfoData[alias_struct->mDOMClassInfoID].mProtoChainInterface;
5935 } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
5936 class_iid = alias_struct->mData->mProtoChainInterface;
5937 } else {
5938 NS_ERROR("Expected eTypeClassConstructor or eTypeExternalClassInfo.");
5939 return NS_ERROR_UNEXPECTED;
5941 } else {
5942 *bp = JS_FALSE;
5944 return NS_OK;
5947 if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
5948 name_struct = nameSpaceManager->GetConstructorProto(name_struct);
5949 if (!name_struct) {
5950 NS_ERROR("Couldn't get constructor prototype.");
5951 return NS_ERROR_UNEXPECTED;
5955 NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
5956 name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
5957 "The constructor was set up with a struct of the wrong type.");
5959 const nsDOMClassInfoData *ci_data = nsnull;
5960 if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
5961 name_struct->mDOMClassInfoID >= 0) {
5962 ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
5963 } else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
5964 ci_data = name_struct->mData;
5967 nsCOMPtr<nsIInterfaceInfoManager>
5968 iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
5969 if (!iim) {
5970 NS_ERROR("nsDOMConstructor::HasInstance can't get interface info mgr.");
5971 return NS_ERROR_UNEXPECTED;
5974 nsCOMPtr<nsIInterfaceInfo> if_info;
5975 PRUint32 count = 0;
5976 const nsIID* class_interface;
5977 while ((class_interface = ci_data->mInterfaces[count++])) {
5978 if (class_iid->Equals(*class_interface)) {
5979 *bp = JS_TRUE;
5981 return NS_OK;
5984 iim->GetInfoForIID(class_interface, getter_AddRefs(if_info));
5985 if (!if_info) {
5986 NS_ERROR("nsDOMConstructor::HasInstance can't get interface info.");
5987 return NS_ERROR_UNEXPECTED;
5990 if_info->HasAncestor(class_iid, bp);
5992 if (*bp) {
5993 return NS_OK;
5997 return NS_OK;
6000 NS_IMETHODIMP
6001 nsDOMConstructor::ToString(nsAString &aResult)
6003 aResult.AssignLiteral("[object ");
6004 aResult.Append(mClassName);
6005 aResult.Append(PRUnichar(']'));
6007 return NS_OK;
6011 static nsresult
6012 GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
6013 const nsGlobalNameStruct *aNameStruct,
6014 nsIXPConnectJSObjectHolder **aProto)
6016 NS_ASSERTION(aNameStruct->mType ==
6017 nsGlobalNameStruct::eTypeClassConstructor ||
6018 aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
6019 "Wrong type!");
6021 nsCOMPtr<nsIClassInfo> ci;
6022 if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6023 PRInt32 id = aNameStruct->mDOMClassInfoID;
6024 NS_ABORT_IF_FALSE(id >= 0, "Negative DOM classinfo?!?");
6026 nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
6028 ci = NS_GetDOMClassInfoInstance(ci_id);
6030 // In most cases we want to find the wrapped native prototype in
6031 // aWin's scope and use that prototype for
6032 // ClassName.prototype. But in the case where we're setting up
6033 // "Window.prototype" or "ChromeWindow.prototype" we want to do
6034 // the look up in aWin's outer window's scope since the inner
6035 // window's wrapped native prototype comes from the outer
6036 // window's scope.
6037 if (ci_id == eDOMClassInfo_Window_id ||
6038 ci_id == eDOMClassInfo_ModalContentWindow_id ||
6039 ci_id == eDOMClassInfo_ChromeWindow_id) {
6040 nsGlobalWindow *scopeWindow = aWin->GetOuterWindowInternal();
6042 if (scopeWindow) {
6043 aWin = scopeWindow;
6047 else {
6048 ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
6050 NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
6052 nsresult rv =
6053 aXPConnect->GetWrappedNativePrototype(cx, aWin->GetGlobalJSObject(), ci,
6054 aProto);
6055 NS_ENSURE_SUCCESS(rv, rv);
6057 JSObject *proto_obj;
6058 (*aProto)->GetJSObject(&proto_obj);
6059 if (!JS_WrapObject(cx, &proto_obj)) {
6060 return NS_ERROR_FAILURE;
6063 NS_IF_RELEASE(*aProto);
6064 return aXPConnect->HoldObject(cx, proto_obj, aProto);
6067 // Either ci_data must be non-null or name_struct must be non-null and of type
6068 // eTypeClassProto.
6069 static nsresult
6070 ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
6071 JSObject *obj, const PRUnichar *name,
6072 const nsDOMClassInfoData *ci_data,
6073 const nsGlobalNameStruct *name_struct,
6074 nsScriptNameSpaceManager *nameSpaceManager,
6075 JSObject *dot_prototype, PRBool install, PRBool *did_resolve)
6077 NS_ASSERTION(ci_data ||
6078 (name_struct &&
6079 name_struct->mType == nsGlobalNameStruct::eTypeClassProto),
6080 "Wrong type or missing ci_data!");
6082 nsRefPtr<nsDOMConstructor> constructor;
6083 nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct, aWin,
6084 getter_AddRefs(constructor));
6085 NS_ENSURE_SUCCESS(rv, rv);
6087 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6088 jsval v;
6090 rv = nsDOMClassInfo::WrapNative(cx, obj, constructor,
6091 &NS_GET_IID(nsIDOMDOMConstructor),
6092 PR_FALSE, &v, getter_AddRefs(holder));
6093 NS_ENSURE_SUCCESS(rv, rv);
6095 if (install) {
6096 rv = constructor->Install(cx, obj, v);
6097 NS_ENSURE_SUCCESS(rv, rv);
6100 JSObject *class_obj;
6101 holder->GetJSObject(&class_obj);
6102 NS_ASSERTION(class_obj, "The return value lied");
6104 const nsIID *primary_iid = &NS_GET_IID(nsISupports);
6106 if (!ci_data) {
6107 primary_iid = &name_struct->mIID;
6109 else if (ci_data->mProtoChainInterface) {
6110 primary_iid = ci_data->mProtoChainInterface;
6113 nsCOMPtr<nsIInterfaceInfo> if_info;
6114 nsCOMPtr<nsIInterfaceInfo> parent;
6115 const char *class_parent_name = nsnull;
6117 if (!primary_iid->Equals(NS_GET_IID(nsISupports))) {
6118 JSAutoEnterCompartment ac;
6120 if (!ac.enter(cx, class_obj)) {
6121 return NS_ERROR_FAILURE;
6124 rv = DefineInterfaceConstants(cx, class_obj, primary_iid);
6125 NS_ENSURE_SUCCESS(rv, rv);
6127 // Special case for |Node|, which needs constants from Node3
6128 // too for forwards compatibility.
6129 if (primary_iid->Equals(NS_GET_IID(nsIDOMNode))) {
6130 rv = DefineInterfaceConstants(cx, class_obj,
6131 &NS_GET_IID(nsIDOM3Node));
6132 NS_ENSURE_SUCCESS(rv, rv);
6135 // Special case for |Event|, Event needs constants from NSEvent
6136 // too for backwards compatibility.
6137 if (primary_iid->Equals(NS_GET_IID(nsIDOMEvent))) {
6138 rv = DefineInterfaceConstants(cx, class_obj,
6139 &NS_GET_IID(nsIDOMNSEvent));
6140 NS_ENSURE_SUCCESS(rv, rv);
6143 // Special case for |IDBKeyRange| which gets funny "static" functions.
6144 if (primary_iid->Equals(NS_GET_IID(nsIIDBKeyRange)) &&
6145 !indexedDB::IDBKeyRange::DefineConstructors(cx, class_obj)) {
6146 return NS_ERROR_FAILURE;
6149 nsCOMPtr<nsIInterfaceInfoManager>
6150 iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
6151 NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
6153 iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
6154 NS_ENSURE_TRUE(if_info, NS_ERROR_UNEXPECTED);
6156 const nsIID *iid = nsnull;
6158 if (ci_data && !ci_data->mHasClassInterface) {
6159 if_info->GetIIDShared(&iid);
6160 } else {
6161 if_info->GetParent(getter_AddRefs(parent));
6162 NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED);
6164 parent->GetIIDShared(&iid);
6167 if (iid) {
6168 if (!iid->Equals(NS_GET_IID(nsISupports))) {
6169 if (ci_data && !ci_data->mHasClassInterface) {
6170 // If the class doesn't have a class interface the primary
6171 // interface is the interface that should be
6172 // constructor.prototype.__proto__.
6174 if_info->GetNameShared(&class_parent_name);
6175 } else {
6176 // If the class does have a class interface (or there's no
6177 // real class for this name) then the parent of the
6178 // primary interface is what we want on
6179 // constructor.prototype.__proto__.
6181 NS_ASSERTION(parent, "Whoa, this is bad, null parent here!");
6183 parent->GetNameShared(&class_parent_name);
6190 JSObject *winobj = aWin->FastGetGlobalJSObject();
6192 JSObject *proto = nsnull;
6194 if (class_parent_name) {
6195 jsval val;
6197 JSAutoEnterCompartment ac;
6198 if (!ac.enter(cx, winobj)) {
6199 return NS_ERROR_UNEXPECTED;
6202 if (!::JS_LookupProperty(cx, winobj, CutPrefix(class_parent_name), &val)) {
6203 return NS_ERROR_UNEXPECTED;
6206 JSObject *tmp = JSVAL_IS_OBJECT(val) ? JSVAL_TO_OBJECT(val) : nsnull;
6208 if (tmp) {
6209 if (!::JS_LookupProperty(cx, tmp, "prototype", &val)) {
6210 return NS_ERROR_UNEXPECTED;
6213 if (JSVAL_IS_OBJECT(val)) {
6214 proto = JSVAL_TO_OBJECT(val);
6219 if (dot_prototype) {
6220 JSAutoEnterCompartment ac;
6221 if (!ac.enter(cx, dot_prototype)) {
6222 return NS_ERROR_UNEXPECTED;
6225 JSObject *xpc_proto_proto = ::JS_GetPrototype(cx, dot_prototype);
6227 if (proto &&
6228 (!xpc_proto_proto ||
6229 JS_GET_CLASS(cx, xpc_proto_proto) == sObjectClass)) {
6230 if (!JS_WrapObject(cx, &proto) ||
6231 !JS_SetPrototype(cx, dot_prototype, proto)) {
6232 return NS_ERROR_UNEXPECTED;
6235 } else {
6236 JSAutoEnterCompartment ac;
6237 if (!ac.enter(cx, winobj)) {
6238 return NS_ERROR_UNEXPECTED;
6241 dot_prototype = ::JS_NewObject(cx, &sDOMConstructorProtoClass, proto,
6242 winobj);
6243 NS_ENSURE_TRUE(dot_prototype, NS_ERROR_OUT_OF_MEMORY);
6247 v = OBJECT_TO_JSVAL(dot_prototype);
6249 JSAutoEnterCompartment ac;
6250 if (!ac.enter(cx, class_obj)) {
6251 return NS_ERROR_UNEXPECTED;
6254 // Per ECMA, the prototype property is {DontEnum, DontDelete, ReadOnly}
6255 if (!JS_WrapValue(cx, &v) ||
6256 !JS_DefineProperty(cx, class_obj, "prototype", v, nsnull, nsnull,
6257 JSPROP_PERMANENT | JSPROP_READONLY)) {
6258 return NS_ERROR_UNEXPECTED;
6261 *did_resolve = PR_TRUE;
6263 return NS_OK;
6267 // static
6268 nsresult
6269 nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
6270 JSObject *obj, jsid id, PRBool *did_resolve)
6272 *did_resolve = PR_FALSE;
6274 nsScriptNameSpaceManager *nameSpaceManager = nsJSRuntime::GetNameSpaceManager();
6275 NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
6277 nsDependentJSString name(id);
6279 const nsGlobalNameStruct *name_struct = nsnull;
6280 const PRUnichar *class_name = nsnull;
6282 nameSpaceManager->LookupName(name, &name_struct, &class_name);
6284 if (!name_struct) {
6285 return NS_OK;
6288 NS_ENSURE_TRUE(class_name, NS_ERROR_UNEXPECTED);
6290 nsresult rv = NS_OK;
6292 if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
6293 rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
6294 &name_struct);
6295 if (NS_FAILED(rv) || !name_struct) {
6296 return rv;
6300 if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
6301 // We're resolving a name of a DOM interface for which there is no
6302 // direct DOM class, create a constructor object...
6304 nsRefPtr<nsDOMConstructor> constructor;
6305 rv = nsDOMConstructor::Create(class_name,
6306 nsnull,
6307 name_struct,
6308 static_cast<nsPIDOMWindow*>(aWin),
6309 getter_AddRefs(constructor));
6310 NS_ENSURE_SUCCESS(rv, rv);
6312 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6313 jsval v;
6314 rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
6315 PR_FALSE, &v, getter_AddRefs(holder));
6316 NS_ENSURE_SUCCESS(rv, rv);
6318 rv = constructor->Install(cx, obj, v);
6319 NS_ENSURE_SUCCESS(rv, rv);
6321 JSObject *class_obj;
6322 holder->GetJSObject(&class_obj);
6323 NS_ASSERTION(class_obj, "The return value lied");
6325 // ... and define the constants from the DOM interface on that
6326 // constructor object.
6328 rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
6329 NS_ENSURE_SUCCESS(rv, rv);
6331 *did_resolve = PR_TRUE;
6333 return NS_OK;
6336 if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
6337 name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6338 // Don't expose chrome only constructors to content windows.
6339 if (name_struct->mChromeOnly &&
6340 !nsContentUtils::IsSystemPrincipal(aWin->GetPrincipal())) {
6341 return NS_OK;
6344 // For now don't expose web sockets unless user has explicitly enabled them
6345 if (name_struct->mDOMClassInfoID == eDOMClassInfo_WebSocket_id) {
6346 if (!nsWebSocket::PrefEnabled()) {
6347 return NS_OK;
6351 // Create the XPConnect prototype for our classinfo, PostCreateProto will
6352 // set up the prototype chain.
6353 nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
6354 rv = GetXPCProto(sXPConnect, cx, aWin, name_struct,
6355 getter_AddRefs(proto_holder));
6357 if (NS_SUCCEEDED(rv) && obj != aWin->GetGlobalJSObject()) {
6358 JSObject* dot_prototype;
6359 rv = proto_holder->GetJSObject(&dot_prototype);
6360 NS_ENSURE_SUCCESS(rv, rv);
6362 const nsDOMClassInfoData *ci_data;
6363 if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6364 ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
6365 } else {
6366 ci_data = name_struct->mData;
6369 return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
6370 name_struct, nameSpaceManager, dot_prototype,
6371 PR_TRUE, did_resolve);
6374 *did_resolve = NS_SUCCEEDED(rv);
6376 return rv;
6379 if (name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
6380 // We don't have a XPConnect prototype object, let ResolvePrototype create
6381 // one.
6382 return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, nsnull,
6383 name_struct, nameSpaceManager, nsnull, PR_TRUE,
6384 did_resolve);
6387 if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
6388 const nsGlobalNameStruct *alias_struct =
6389 nameSpaceManager->GetConstructorProto(name_struct);
6390 NS_ENSURE_TRUE(alias_struct, NS_ERROR_UNEXPECTED);
6392 // We need to use the XPConnect prototype for the DOM class that this
6393 // constructor is an alias for (for example for Image we need the prototype
6394 // for HTMLImageElement).
6395 nsCOMPtr<nsIXPConnectJSObjectHolder> proto_holder;
6396 rv = GetXPCProto(sXPConnect, cx, aWin, alias_struct,
6397 getter_AddRefs(proto_holder));
6398 NS_ENSURE_SUCCESS(rv, rv);
6400 JSObject* dot_prototype;
6401 rv = proto_holder->GetJSObject(&dot_prototype);
6402 NS_ENSURE_SUCCESS(rv, rv);
6404 const nsDOMClassInfoData *ci_data;
6405 if (alias_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
6406 ci_data = &sClassInfoData[alias_struct->mDOMClassInfoID];
6407 } else if (alias_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
6408 ci_data = alias_struct->mData;
6409 } else {
6410 return NS_ERROR_UNEXPECTED;
6413 return ResolvePrototype(sXPConnect, aWin, cx, obj, class_name, ci_data,
6414 name_struct, nameSpaceManager, nsnull, PR_TRUE,
6415 did_resolve);
6418 if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
6419 nsRefPtr<nsDOMConstructor> constructor;
6420 rv = nsDOMConstructor::Create(class_name, nsnull, name_struct,
6421 static_cast<nsPIDOMWindow*>(aWin),
6422 getter_AddRefs(constructor));
6423 NS_ENSURE_SUCCESS(rv, rv);
6425 jsval val;
6426 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6427 rv = WrapNative(cx, obj, constructor, &NS_GET_IID(nsIDOMDOMConstructor),
6428 PR_FALSE, &val, getter_AddRefs(holder));
6429 NS_ENSURE_SUCCESS(rv, rv);
6431 rv = constructor->Install(cx, obj, val);
6432 NS_ENSURE_SUCCESS(rv, rv);
6434 JSObject* class_obj;
6435 holder->GetJSObject(&class_obj);
6436 NS_ASSERTION(class_obj, "Why didn't we get a JSObject?");
6438 *did_resolve = PR_TRUE;
6440 return NS_OK;
6443 if (name_struct->mType == nsGlobalNameStruct::eTypeProperty) {
6444 if (name_struct->mChromeOnly && !nsContentUtils::IsCallerChrome())
6445 return NS_OK;
6447 nsCOMPtr<nsISupports> native(do_CreateInstance(name_struct->mCID, &rv));
6448 NS_ENSURE_SUCCESS(rv, rv);
6450 jsval prop_val = JSVAL_VOID; // Property value.
6452 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6453 nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));
6454 if (owner) {
6455 nsIScriptContext *context = nsJSUtils::GetStaticScriptContext(cx, obj);
6456 NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
6458 JSObject *prop_obj = nsnull;
6459 rv = owner->GetScriptObject(context, (void**)&prop_obj);
6460 NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && prop_obj, NS_ERROR_UNEXPECTED);
6462 prop_val = OBJECT_TO_JSVAL(prop_obj);
6463 } else {
6464 nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi(do_QueryInterface(native));
6466 if (gpi) {
6467 rv = gpi->Init(aWin, &prop_val);
6468 NS_ENSURE_SUCCESS(rv, rv);
6472 if (JSVAL_IS_PRIMITIVE(prop_val)) {
6473 JSObject *scope;
6475 if (aWin->IsOuterWindow()) {
6476 nsGlobalWindow *inner = aWin->GetCurrentInnerWindowInternal();
6477 NS_ENSURE_TRUE(inner, NS_ERROR_UNEXPECTED);
6479 scope = inner->GetGlobalJSObject();
6480 } else {
6481 scope = aWin->GetGlobalJSObject();
6484 rv = WrapNative(cx, scope, native, PR_TRUE, &prop_val,
6485 getter_AddRefs(holder));
6488 NS_ENSURE_SUCCESS(rv, rv);
6490 if (!JS_WrapValue(cx, &prop_val)) {
6491 return NS_ERROR_UNEXPECTED;
6494 JSBool ok = ::JS_DefinePropertyById(cx, obj, id, prop_val, nsnull, nsnull,
6495 JSPROP_ENUMERATE);
6497 *did_resolve = PR_TRUE;
6499 return ok ? NS_OK : NS_ERROR_FAILURE;
6502 if (name_struct->mType == nsGlobalNameStruct::eTypeDynamicNameSet) {
6503 nsCOMPtr<nsIScriptExternalNameSet> nameset =
6504 do_CreateInstance(name_struct->mCID, &rv);
6505 NS_ENSURE_SUCCESS(rv, rv);
6507 nsIScriptContext *context = aWin->GetContext();
6508 NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
6510 rv = nameset->InitializeNameSet(context);
6512 *did_resolve = PR_TRUE;
6515 return rv;
6518 // Native code for window._content getter, this simply maps
6519 // window._content to window.content for backwards compatibility only.
6520 static JSBool
6521 ContentWindowGetter(JSContext *cx, uintN argc, jsval *vp)
6523 JSObject *obj = JS_THIS_OBJECT(cx, vp);
6524 if (!obj)
6525 return JS_FALSE;
6527 return ::JS_GetProperty(cx, obj, "content", vp);
6530 NS_IMETHODIMP
6531 nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
6532 JSObject *obj, jsid id, PRUint32 flags,
6533 JSObject **objp, PRBool *_retval)
6535 nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
6537 if (!JSID_IS_STRING(id)) {
6538 if (JSID_IS_INT(id) && !(flags & JSRESOLVE_ASSIGNING)) {
6539 // If we're resolving a numeric property, treat that as if
6540 // window.frames[n] is resolved (since window.frames ===
6541 // window), if window.frames[n] is a child frame, define a
6542 // property for this index.
6544 nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
6546 if (frame) {
6547 // A numeric property accessed and the numeric property is a
6548 // child frame. Define a property for this index.
6550 *_retval = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), JSVAL_VOID,
6551 nsnull, nsnull, JSPROP_SHARED);
6553 if (*_retval) {
6554 *objp = obj;
6559 return NS_OK;
6562 nsIScriptContext *my_context = win->GetContextInternal();
6564 nsresult rv = NS_OK;
6566 // Resolve standard classes on my_context's JSContext (or on cx,
6567 // if we don't have a my_context yet), in case the two contexts
6568 // have different origins. We want lazy standard class
6569 // initialization to behave as if it were done eagerly, on each
6570 // window's own context (not on some other window-caller's
6571 // context).
6573 JSBool did_resolve = JS_FALSE;
6574 JSContext *my_cx;
6576 JSBool ok = JS_TRUE;
6577 jsval exn = JSVAL_VOID;
6578 if (!ObjectIsNativeWrapper(cx, obj)) {
6579 JSAutoEnterCompartment ac;
6581 if (!my_context) {
6582 my_cx = cx;
6583 } else {
6584 my_cx = (JSContext *)my_context->GetNativeContext();
6586 if (my_cx != cx) {
6587 if (!ac.enter(my_cx, obj)) {
6588 return NS_ERROR_UNEXPECTED;
6593 JSAutoRequest transfer(my_cx);
6595 // Don't resolve standard classes on XPCNativeWrapper etc, only
6596 // resolve them if we're resolving on the real global object.
6597 ok = JS_ResolveStandardClass(my_cx, obj, id, &did_resolve);
6599 if (!ok) {
6600 // Trust the JS engine (or the script security manager) to set
6601 // the exception in the JS engine.
6603 if (!JS_GetPendingException(my_cx, &exn)) {
6604 return NS_ERROR_UNEXPECTED;
6607 // Return NS_OK to avoid stomping over the exception that was passed
6608 // down from the ResolveStandardClass call.
6609 // Note that the order of the JS_ClearPendingException and
6610 // JS_SetPendingException is important in the case that my_cx == cx.
6612 JS_ClearPendingException(my_cx);
6616 if (!ok) {
6617 JS_SetPendingException(cx, exn);
6618 *_retval = JS_FALSE;
6619 return NS_OK;
6622 if (did_resolve) {
6623 *objp = obj;
6625 return NS_OK;
6628 if (!(flags & JSRESOLVE_ASSIGNING)) {
6629 // We want this code to be before the child frame lookup code
6630 // below so that a child frame named 'constructor' doesn't
6631 // shadow the window's constructor property.
6632 if (id == sConstructor_id) {
6633 return ResolveConstructor(cx, obj, objp);
6637 if (!my_context || !my_context->IsContextInitialized()) {
6638 // The context is not yet initialized so there's nothing we can do
6639 // here yet.
6641 return NS_OK;
6645 // Hmm, we do an awful lot of QIs here; maybe we should add a
6646 // method on an interface that would let us just call into the
6647 // window code directly...
6649 if (!ObjectIsNativeWrapper(cx, obj)) {
6650 nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
6652 PRInt32 count = 0;
6654 if (dsn) {
6655 dsn->GetChildCount(&count);
6658 if (count > 0) {
6659 nsCOMPtr<nsIDocShellTreeItem> child;
6661 const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
6663 dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
6664 PR_FALSE, PR_TRUE, nsnull, nsnull,
6665 getter_AddRefs(child));
6667 nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
6669 if (child_win) {
6670 // We found a subframe of the right name, define the property
6671 // on the wrapper so that ::NewResolve() doesn't get called
6672 // again for this property name.
6674 JSObject *wrapperObj;
6675 wrapper->GetJSObject(&wrapperObj);
6677 jsval v;
6678 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6679 rv = WrapNative(cx, wrapperObj, child_win,
6680 &NS_GET_IID(nsIDOMWindowInternal), PR_TRUE, &v,
6681 getter_AddRefs(holder));
6682 NS_ENSURE_SUCCESS(rv, rv);
6684 JSAutoRequest ar(cx);
6686 PRBool ok = JS_WrapValue(cx, &v) &&
6687 JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
6688 if (!ok) {
6689 return NS_ERROR_FAILURE;
6692 *objp = obj;
6694 return NS_OK;
6699 // It is not worth calling GlobalResolve() if we are resolving
6700 // for assignment, since only read-write properties get dealt
6701 // with there.
6702 if (!(flags & JSRESOLVE_ASSIGNING)) {
6703 JSAutoRequest ar(cx);
6705 // Call GlobalResolve() after we call FindChildWithName() so
6706 // that named child frames will override external properties
6707 // which have been registered with the script namespace manager.
6709 JSBool did_resolve = JS_FALSE;
6710 rv = GlobalResolve(win, cx, obj, id, &did_resolve);
6711 NS_ENSURE_SUCCESS(rv, rv);
6713 if (did_resolve) {
6714 // GlobalResolve() resolved something, so we're done here.
6715 *objp = obj;
6717 return NS_OK;
6721 if (id == s_content_id) {
6722 // Map window._content to window.content for backwards
6723 // compatibility, this should spit out an message on the JS
6724 // console.
6726 JSObject *windowObj = win->GetGlobalJSObject();
6728 JSAutoRequest ar(cx);
6730 JSFunction *fun = ::JS_NewFunction(cx, ContentWindowGetter, 0, 0,
6731 windowObj, "_content");
6732 if (!fun) {
6733 return NS_ERROR_OUT_OF_MEMORY;
6736 JSObject *funObj = ::JS_GetFunctionObject(fun);
6738 if (!::JS_DefinePropertyById(cx, windowObj, id, JSVAL_VOID,
6739 JS_DATA_TO_FUNC_PTR(JSPropertyOp, funObj),
6740 nsnull,
6741 JSPROP_ENUMERATE | JSPROP_GETTER |
6742 JSPROP_SHARED)) {
6743 return NS_ERROR_FAILURE;
6746 *objp = obj;
6748 return NS_OK;
6751 if (id == sLocation_id) {
6752 // This must be done even if we're just getting the value of
6753 // window.location (i.e. no checking flags & JSRESOLVE_ASSIGNING
6754 // here) since we must define window.location to prevent the
6755 // getter from being overriden (for security reasons).
6757 // Note: Because we explicitly don't forward to the inner window
6758 // above, we have to ensure here that our window has a current
6759 // inner window so that the location object we return will work.
6761 if (win->IsOuterWindow()) {
6762 win->EnsureInnerWindow();
6765 nsCOMPtr<nsIDOMLocation> location;
6766 rv = win->GetLocation(getter_AddRefs(location));
6767 NS_ENSURE_SUCCESS(rv, rv);
6769 // Make sure we wrap the location object in the inner window's
6770 // scope if we've got an inner window.
6771 JSObject *scope = nsnull;
6772 if (win->IsOuterWindow()) {
6773 nsGlobalWindow *innerWin = win->GetCurrentInnerWindowInternal();
6775 if (innerWin) {
6776 scope = innerWin->GetGlobalJSObject();
6780 if (!scope) {
6781 wrapper->GetJSObject(&scope);
6784 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6785 jsval v;
6786 rv = WrapNative(cx, scope, location, &NS_GET_IID(nsIDOMLocation), PR_TRUE,
6787 &v, getter_AddRefs(holder));
6788 NS_ENSURE_SUCCESS(rv, rv);
6790 JSBool ok = JS_WrapValue(cx, &v) &&
6791 JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
6792 JSPROP_PERMANENT | JSPROP_ENUMERATE);
6794 if (!ok) {
6795 return NS_ERROR_FAILURE;
6798 *objp = obj;
6800 return NS_OK;
6803 if (id == sOnhashchange_id) {
6804 // Special handling so |"onhashchange" in window| returns true
6805 if (!JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
6806 nsnull, nsnull, JSPROP_ENUMERATE)) {
6807 *_retval = PR_FALSE;
6808 return NS_ERROR_FAILURE;
6811 *objp = obj;
6812 return NS_OK;
6815 if (flags & JSRESOLVE_ASSIGNING) {
6816 if (IsReadonlyReplaceable(id) ||
6817 (!(flags & JSRESOLVE_QUALIFIED) && IsWritableReplaceable(id))) {
6818 // A readonly "replaceable" property is being set, or a
6819 // readwrite "replaceable" property is being set w/o being
6820 // fully qualified. Define the property on obj with the value
6821 // undefined to override the predefined property. This is done
6822 // for compatibility with other browsers.
6823 JSAutoRequest ar(cx);
6825 if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
6826 JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
6827 return NS_ERROR_FAILURE;
6829 *objp = obj;
6831 return NS_OK;
6833 } else {
6834 if (id == sNavigator_id) {
6835 nsCOMPtr<nsIDOMNavigator> navigator;
6836 rv = win->GetNavigator(getter_AddRefs(navigator));
6837 NS_ENSURE_SUCCESS(rv, rv);
6839 jsval v;
6840 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6841 rv = WrapNative(cx, obj, navigator, &NS_GET_IID(nsIDOMNavigator), PR_TRUE,
6842 &v, getter_AddRefs(holder));
6843 NS_ENSURE_SUCCESS(rv, rv);
6845 if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
6846 JSPROP_READONLY | JSPROP_PERMANENT |
6847 JSPROP_ENUMERATE)) {
6848 return NS_ERROR_FAILURE;
6850 *objp = obj;
6852 return NS_OK;
6855 if (id == sDocument_id) {
6856 nsCOMPtr<nsIDOMDocument> document;
6857 rv = win->GetDocument(getter_AddRefs(document));
6858 NS_ENSURE_SUCCESS(rv, rv);
6860 // FIXME Ideally we'd have an nsIDocument here and get nsWrapperCache
6861 // from it.
6862 jsval v;
6863 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
6864 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), document,
6865 &NS_GET_IID(nsIDOMDocument), PR_FALSE, &v,
6866 getter_AddRefs(holder));
6867 NS_ENSURE_SUCCESS(rv, rv);
6869 // The PostCreate hook for the document will handle defining the
6870 // property
6871 *objp = obj;
6873 // NB: We need to do this for any Xray wrapper.
6874 if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
6875 // Unless our object is a native wrapper, in which case we have to
6876 // define it ourselves.
6878 *_retval = JS_WrapValue(cx, &v) &&
6879 JS_DefineProperty(cx, obj, "document", v, NULL, NULL,
6880 JSPROP_READONLY | JSPROP_ENUMERATE);
6881 if (!*_retval) {
6882 return NS_ERROR_UNEXPECTED;
6886 return NS_OK;
6889 if (id == sJava_id || id == sPackages_id) {
6890 static PRBool isResolvingJavaProperties;
6892 if (!isResolvingJavaProperties) {
6893 isResolvingJavaProperties = PR_TRUE;
6895 // Tell the window to initialize the Java properties. The
6896 // window needs to do this as we need to do this only once,
6897 // and detecting that reliably from here is hard.
6899 win->InitJavaProperties();
6901 PRBool hasProp;
6902 PRBool ok = ::JS_HasPropertyById(cx, obj, id, &hasProp);
6904 isResolvingJavaProperties = PR_FALSE;
6906 if (!ok) {
6907 return NS_ERROR_FAILURE;
6910 if (hasProp) {
6911 *objp = obj;
6913 return NS_OK;
6916 } else if (id == sDialogArguments_id && win->IsModalContentWindow()) {
6917 nsCOMPtr<nsIArray> args;
6918 ((nsGlobalModalWindow *)win)->GetDialogArguments(getter_AddRefs(args));
6920 nsIScriptContext *script_cx = win->GetContext();
6921 if (script_cx) {
6922 JSAutoSuspendRequest asr(cx);
6924 // Make nsJSContext::SetProperty()'s magic argument array
6925 // handling happen.
6926 rv = script_cx->SetProperty(obj, "dialogArguments", args);
6927 NS_ENSURE_SUCCESS(rv, rv);
6929 *objp = obj;
6932 return NS_OK;
6936 JSObject *oldobj = *objp;
6937 rv = nsEventReceiverSH::NewResolve(wrapper, cx, obj, id, flags, objp,
6938 _retval);
6940 if (NS_FAILED(rv) || *objp != oldobj) {
6941 // Something went wrong, or the property got resolved. Return.
6942 return rv;
6945 // Make a fast expando if we're assigning to (not declaring or
6946 // binding a name) a new undefined property that's not already
6947 // defined on our prototype chain. This way we can access this
6948 // expando w/o ever getting back into XPConnect.
6949 if ((flags & JSRESOLVE_ASSIGNING) && !(flags & JSRESOLVE_WITH)) {
6950 JSObject *realObj;
6951 wrapper->GetJSObject(&realObj);
6953 if (obj == realObj) {
6954 JSObject *proto = obj->getProto();
6955 if (proto) {
6956 JSObject *pobj = NULL;
6957 jsval val;
6959 if (!::JS_LookupPropertyWithFlagsById(cx, proto, id, flags,
6960 &pobj, &val)) {
6961 *_retval = JS_FALSE;
6963 return NS_OK;
6966 if (pobj) {
6967 // A property was found on the prototype chain.
6968 *objp = pobj;
6969 return NS_OK;
6973 // Define a fast expando, the key here is to use JS_PropertyStub
6974 // as the getter/setter, which makes us stay out of XPConnect
6975 // when using this property.
6977 // We don't need to worry about property attributes here as we
6978 // know here we're dealing with an undefined property set, so
6979 // we're not declaring readonly or permanent properties.
6981 // Since we always create the undeclared property here without given a
6982 // chance for the interpreter to report applicable strict mode warnings,
6983 // we must take care to check those warnings here.
6984 JSString *str = JSID_TO_STRING(id);
6985 if ((!(flags & JSRESOLVE_QUALIFIED) &&
6986 !js_CheckUndeclaredVarAssignment(cx, str)) ||
6987 !::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, JS_PropertyStub,
6988 JS_StrictPropertyStub, JSPROP_ENUMERATE)) {
6989 *_retval = JS_FALSE;
6991 return NS_OK;
6994 *objp = obj;
6998 return NS_OK;
7001 NS_IMETHODIMP
7002 nsWindowSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7003 JSObject *obj)
7005 nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryWrappedNative(wrapper));
7006 NS_ENSURE_TRUE(sgo, NS_ERROR_UNEXPECTED);
7008 sgo->OnFinalize(nsIProgrammingLanguage::JAVASCRIPT, obj);
7010 return NS_OK;
7013 NS_IMETHODIMP
7014 nsWindowSH::Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
7015 JSObject * obj, const jsval &val, PRBool *bp)
7017 *bp = PR_FALSE;
7019 if (JSVAL_IS_PRIMITIVE(val)) {
7020 return NS_OK;
7023 nsCOMPtr<nsIXPConnectWrappedNative> other_wrapper;
7024 nsContentUtils::XPConnect()->
7025 GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(val),
7026 getter_AddRefs(other_wrapper));
7027 if (!other_wrapper) {
7028 // Not equal.
7030 return NS_OK;
7033 nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
7035 nsCOMPtr<nsPIDOMWindow> other = do_QueryWrappedNative(other_wrapper);
7037 if (other) {
7038 *bp = win->GetOuterWindow() == other->GetOuterWindow();
7041 return NS_OK;
7044 NS_IMETHODIMP
7045 nsWindowSH::OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
7046 JSObject * obj, JSObject * *_retval)
7048 nsGlobalWindow *origWin = nsGlobalWindow::FromWrapper(wrapper);
7049 nsGlobalWindow *win = origWin->GetOuterWindowInternal();
7051 if (!win) {
7052 // If we no longer have an outer window. No code should ever be
7053 // running on a window w/o an outer, which means this hook should
7054 // never be called when we have no outer. But just in case, return
7055 // null to prevent leaking an inner window to code in a different
7056 // window.
7057 *_retval = nsnull;
7058 return NS_ERROR_UNEXPECTED;
7061 JSObject *winObj = win->FastGetGlobalJSObject();
7062 if (!winObj) {
7063 NS_ASSERTION(origWin->IsOuterWindow(), "What window is this?");
7064 *_retval = obj;
7065 return NS_OK;
7068 if (!JS_WrapObject(cx, &winObj)) {
7069 *_retval = nsnull;
7070 return NS_ERROR_UNEXPECTED;
7073 *_retval = winObj;
7074 return NS_OK;
7077 // DOM Location helper
7079 NS_IMETHODIMP
7080 nsLocationSH::CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7081 JSObject *obj, jsid id, PRUint32 mode,
7082 jsval *vp, PRBool *_retval)
7084 if ((mode & JSACC_TYPEMASK) == JSACC_PROTO && (mode & JSACC_WRITE)) {
7085 // No setting location.__proto__, ever!
7087 // Let XPConnect know that the access was not granted.
7088 *_retval = PR_FALSE;
7090 return NS_ERROR_DOM_SECURITY_ERR;
7093 return nsDOMGenericSH::CheckAccess(wrapper, cx, obj, id, mode, vp, _retval);
7096 NS_IMETHODIMP
7097 nsLocationSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7098 JSObject *globalObj, JSObject **parentObj)
7100 // window.location can be held onto by both evil pages that want to track the
7101 // user's progress on the web and bookmarklets that want to use the location
7102 // object. Parent it to the outer window so that access checks do the Right
7103 // Thing.
7104 *parentObj = globalObj;
7106 nsCOMPtr<nsIDOMLocation> safeLoc(do_QueryInterface(nativeObj));
7107 if (!safeLoc) {
7108 // Oops, this wasn't really a location object. This can happen if someone
7109 // tries to use our scriptable helper as a real object and tries to wrap
7110 // it, see bug 319296
7111 return NS_OK;
7114 nsLocation *loc = (nsLocation *)safeLoc.get();
7115 nsIDocShell *ds = loc->GetDocShell();
7116 if (!ds) {
7117 NS_WARNING("Refusing to create a location in the wrong scope");
7118 return NS_ERROR_UNEXPECTED;
7121 nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
7122 if (!sgo) {
7123 NS_WARNING("Refusing to create a location in the wrong scope because the "
7124 "docshell is being destroyed");
7125 return NS_ERROR_UNEXPECTED;
7128 *parentObj = sgo->GetGlobalJSObject();
7129 return NS_OK;
7132 // DOM Navigator helper
7133 nsresult
7134 nsNavigatorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7135 JSObject *globalObj, JSObject **parentObj)
7137 // window.navigator is persisted across document transitions if
7138 // we're loading a page from the same origin. Because of that we
7139 // need to parent the navigator wrapper at the outer window to avoid
7140 // holding on to the inner window where the navigator was initially
7141 // created too long.
7142 *parentObj = globalObj;
7144 nsCOMPtr<nsIDOMNavigator> safeNav(do_QueryInterface(nativeObj));
7145 if (!safeNav) {
7146 // Oops, this wasn't really a navigator object. This can happen if someone
7147 // tries to use our scriptable helper as a real object and tries to wrap
7148 // it, see bug 319296.
7149 return NS_OK;
7152 nsNavigator *nav = (nsNavigator *)safeNav.get();
7153 nsIDocShell *ds = nav->GetDocShell();
7154 if (!ds) {
7155 NS_WARNING("Refusing to create a navigator in the wrong scope");
7156 return NS_ERROR_UNEXPECTED;
7159 nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(ds);
7161 if (sgo) {
7162 JSObject *global = sgo->GetGlobalJSObject();
7164 if (global) {
7165 *parentObj = global;
7169 return NS_OK;
7172 // DOM Node helper
7174 PRBool
7175 nsNodeSH::IsCapabilityEnabled(const char* aCapability)
7177 PRBool enabled;
7178 return sSecMan &&
7179 NS_SUCCEEDED(sSecMan->IsCapabilityEnabled(aCapability, &enabled)) &&
7180 enabled;
7183 nsresult
7184 nsNodeSH::DefineVoidProp(JSContext* cx, JSObject* obj, jsid id,
7185 JSObject** objp)
7187 NS_ASSERTION(JSID_IS_STRING(id), "id must be a string");
7189 // We want this to be as invisible to content script as possible. So
7190 // don't enumerate this, and set is as JSPROP_SHARED so it won't get
7191 // cached on the object.
7192 JSBool ok = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
7193 nsnull, nsnull, JSPROP_SHARED);
7195 if (!ok) {
7196 return NS_ERROR_FAILURE;
7199 *objp = obj;
7200 return NS_OK;
7203 NS_IMETHODIMP
7204 nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
7205 JSObject **parentObj)
7207 nsINode *node = static_cast<nsINode*>(nativeObj);
7209 #ifdef DEBUG
7211 nsCOMPtr<nsINode> node_qi(do_QueryInterface(nativeObj));
7213 // If this assertion fires the QI implementation for the object in
7214 // question doesn't use the nsINode pointer as the nsISupports
7215 // pointer. That must be fixed, or we'll crash...
7216 NS_ASSERTION(node_qi == node, "Uh, fix QI!");
7218 #endif
7220 // Make sure that we get the owner document of the content node, in case
7221 // we're in document teardown. If we are, it's important to *not* use
7222 // globalObj as the nodes parent since that would give the node the
7223 // principal of globalObj (i.e. the principal of the document that's being
7224 // loaded) and not the principal of the document that's being unloaded.
7225 // See http://bugzilla.mozilla.org/show_bug.cgi?id=227417
7226 nsIDocument* doc = node->GetOwnerDoc();
7228 if (!doc) {
7229 // No document reachable from nativeObj, use the global object
7230 // that was passed to this method.
7232 *parentObj = globalObj;
7234 return node->IsInNativeAnonymousSubtree() ?
7235 NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
7238 // If we have a document, make sure one of these is true
7239 // (1) it has a script handling object,
7240 // (2) has had one, or has been marked to have had one,
7241 // (3) we are running a privileged script.
7242 // Event handling is possible only if (1). If (2) event handling is prevented.
7243 // If document has never had a script handling object,
7244 // untrusted scripts (3) shouldn't touch it!
7245 PRBool hasHadScriptHandlingObject = PR_FALSE;
7246 NS_ENSURE_STATE(doc->GetScriptHandlingObject(hasHadScriptHandlingObject) ||
7247 hasHadScriptHandlingObject ||
7248 IsPrivilegedScript());
7250 nsINode *native_parent;
7252 PRBool nodeIsElement = node->IsElement();
7253 if (nodeIsElement && node->AsElement()->IsXUL()) {
7254 // For XUL elements, use the parent, if any.
7255 native_parent = node->GetParent();
7257 if (!native_parent) {
7258 native_parent = doc;
7260 } else if (!node->IsNodeOfType(nsINode::eDOCUMENT)) {
7261 NS_ASSERTION(node->IsNodeOfType(nsINode::eCONTENT) ||
7262 node->IsNodeOfType(nsINode::eATTRIBUTE),
7263 "Unexpected node type");
7265 // For attributes and non-XUL content, use the document as scope parent.
7266 native_parent = doc;
7268 // But for HTML form controls, use the form as scope parent.
7269 if (nodeIsElement) {
7270 if (node->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
7271 nsCOMPtr<nsIFormControl> form_control(do_QueryInterface(node));
7273 if (form_control) {
7274 Element *form = form_control->GetFormElement();
7276 if (form) {
7277 // Found a form, use it.
7278 native_parent = form;
7282 else {
7283 // Legend isn't an HTML form control but should have its fieldset form
7284 // as scope parent at least for backward compatibility.
7285 nsHTMLLegendElement *legend =
7286 nsHTMLLegendElement::FromContent(node->AsElement());
7287 if (legend) {
7288 Element *form = legend->GetFormElement();
7290 if (form) {
7291 native_parent = form;
7296 } else {
7297 // We're called for a document object; set the parent to be the
7298 // document's global object, if there is one
7300 // Get the scope object from the document.
7301 nsISupports *scope = doc->GetScopeObject();
7303 if (scope) {
7304 jsval v;
7305 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7306 nsresult rv = WrapNative(cx, globalObj, scope, PR_FALSE, &v,
7307 getter_AddRefs(holder));
7308 NS_ENSURE_SUCCESS(rv, rv);
7310 holder->GetJSObject(parentObj);
7312 else {
7313 // No global object reachable from this document, use the
7314 // global object that was passed to this method.
7316 *parentObj = globalObj;
7319 // No slim wrappers for a document's scope object.
7320 return node->IsInNativeAnonymousSubtree() ?
7321 NS_SUCCESS_CHROME_ACCESS_ONLY : NS_OK;
7324 // XXXjst: Maybe we need to find the global to use from the
7325 // nsIScriptGlobalObject that's reachable from the node we're about
7326 // to wrap here? But that's not always reachable, let's use
7327 // globalObj for now...
7329 nsresult rv = WrapNativeParent(cx, globalObj, native_parent, native_parent,
7330 parentObj);
7331 NS_ENSURE_SUCCESS(rv, rv);
7333 return node->IsInNativeAnonymousSubtree() ?
7334 NS_SUCCESS_CHROME_ACCESS_ONLY : NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
7337 NS_IMETHODIMP
7338 nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7339 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
7341 nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
7342 return nsEventReceiverSH::AddProperty(wrapper, cx, obj, id, vp, _retval);
7345 NS_IMETHODIMP
7346 nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7347 JSObject *obj, jsid id, PRUint32 flags,
7348 JSObject **objp, PRBool *_retval)
7350 if ((id == sBaseURIObject_id || id == sNodePrincipal_id) &&
7351 IsPrivilegedScript()) {
7352 return DefineVoidProp(cx, obj, id, objp);
7355 if (id == sOnload_id || id == sOnerror_id) {
7356 // Make sure that this node can't go away while waiting for a
7357 // network load that could fire an event handler.
7358 nsNodeSH::PreserveWrapper(GetNative(wrapper, obj));
7361 return nsEventReceiverSH::NewResolve(wrapper, cx, obj, id, flags, objp,
7362 _retval);
7365 NS_IMETHODIMP
7366 nsNodeSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7367 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
7369 if (id == sBaseURIObject_id && IsPrivilegedScript()) {
7370 // I wish GetBaseURI lived on nsINode
7371 nsCOMPtr<nsIURI> uri;
7372 nsCOMPtr<nsIContent> content = do_QueryWrappedNative(wrapper, obj);
7373 if (content) {
7374 uri = content->GetBaseURI();
7375 NS_ENSURE_TRUE(uri, NS_ERROR_OUT_OF_MEMORY);
7376 } else {
7377 nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper, obj);
7378 NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
7380 uri = doc->GetBaseURI();
7381 NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE);
7384 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7385 nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), uri,
7386 &NS_GET_IID(nsIURI), PR_TRUE, vp,
7387 getter_AddRefs(holder));
7388 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
7391 if (id == sNodePrincipal_id && IsPrivilegedScript()) {
7392 nsCOMPtr<nsINode> node = do_QueryWrappedNative(wrapper, obj);
7393 NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
7395 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
7396 nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx),
7397 node->NodePrincipal(), &NS_GET_IID(nsIPrincipal),
7398 PR_TRUE, vp, getter_AddRefs(holder));
7399 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
7402 // Note: none of our ancestors want GetProperty
7403 return NS_OK;
7406 NS_IMETHODIMP
7407 nsNodeSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7408 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
7410 if ((id == sBaseURIObject_id || id == sNodePrincipal_id) &&
7411 IsPrivilegedScript()) {
7412 // We don't want privileged script that can read this property to set it,
7413 // but _do_ want to allow everyone else to set a value they can then read.
7415 // XXXbz Is there a better error we could use here?
7416 return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
7419 return nsEventReceiverSH::SetProperty(wrapper, cx, obj, id, vp,_retval);
7422 NS_IMETHODIMP
7423 nsNodeSH::GetFlags(PRUint32 *aFlags)
7425 *aFlags = DOMCLASSINFO_STANDARD_FLAGS | nsIClassInfo::CONTENT_NODE;
7427 return NS_OK;
7430 void
7431 nsNodeSH::PreserveWrapper(nsISupports *aNative)
7433 nsINode *node = static_cast<nsINode*>(aNative);
7434 nsContentUtils::PreserveWrapper(aNative, node);
7437 // EventReceiver helper
7439 // static
7440 PRBool
7441 nsEventReceiverSH::ReallyIsEventName(jsid id, jschar aFirstChar)
7443 // I wonder if this is faster than using a hash...
7445 switch (aFirstChar) {
7446 case 'a' :
7447 return (id == sOnabort_id ||
7448 id == sOnafterscriptexecute_id);
7449 case 'b' :
7450 return (id == sOnbeforeunload_id ||
7451 id == sOnbeforescriptexecute_id ||
7452 id == sOnblur_id);
7453 case 'c' :
7454 return (id == sOnchange_id ||
7455 id == sOnclick_id ||
7456 id == sOncontextmenu_id ||
7457 id == sOncopy_id ||
7458 id == sOncut_id ||
7459 id == sOncanplay_id ||
7460 id == sOncanplaythrough_id);
7461 case 'd' :
7462 return (id == sOndblclick_id ||
7463 id == sOndrag_id ||
7464 id == sOndragend_id ||
7465 id == sOndragenter_id ||
7466 id == sOndragleave_id ||
7467 id == sOndragover_id ||
7468 id == sOndragstart_id ||
7469 id == sOndrop_id ||
7470 id == sOndurationchange_id);
7471 case 'e' :
7472 return (id == sOnerror_id ||
7473 id == sOnemptied_id ||
7474 id == sOnended_id);
7475 case 'f' :
7476 return id == sOnfocus_id;
7477 case 'h' :
7478 return id == sOnhashchange_id;
7479 case 'i' :
7480 return (id == sOninput_id ||
7481 id == sOninvalid_id);
7482 case 'k' :
7483 return (id == sOnkeydown_id ||
7484 id == sOnkeypress_id ||
7485 id == sOnkeyup_id);
7486 case 'l' :
7487 return (id == sOnload_id ||
7488 id == sOnloadeddata_id ||
7489 id == sOnloadedmetadata_id ||
7490 id == sOnloadstart_id);
7491 case 'm' :
7492 return (id == sOnmousemove_id ||
7493 id == sOnmouseout_id ||
7494 id == sOnmouseover_id ||
7495 id == sOnmouseup_id ||
7496 id == sOnmousedown_id ||
7497 id == sOnmessage_id);
7498 case 'p' :
7499 return (id == sOnpaint_id ||
7500 id == sOnpageshow_id ||
7501 id == sOnpagehide_id ||
7502 id == sOnpaste_id ||
7503 id == sOnpopstate_id ||
7504 id == sOnpause_id ||
7505 id == sOnplay_id ||
7506 id == sOnplaying_id ||
7507 id == sOnprogress_id);
7508 case 'r' :
7509 return (id == sOnreadystatechange_id ||
7510 id == sOnreset_id ||
7511 id == sOnresize_id ||
7512 id == sOnratechange_id);
7513 case 's' :
7514 return (id == sOnscroll_id ||
7515 id == sOnselect_id ||
7516 id == sOnsubmit_id ||
7517 id == sOnseeked_id ||
7518 id == sOnseeking_id ||
7519 id == sOnstalled_id ||
7520 id == sOnsuspend_id);
7521 case 't':
7522 return id == sOntimeupdate_id;
7523 case 'u' :
7524 return id == sOnunload_id;
7525 case 'v':
7526 return id == sOnvolumechange_id;
7527 case 'w':
7528 return id == sOnwaiting_id;
7531 return PR_FALSE;
7534 nsresult
7535 nsEventReceiverSH::RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
7536 JSContext *cx, JSObject *obj,
7537 jsid id, PRBool compile,
7538 PRBool remove,
7539 PRBool *did_define)
7541 NS_PRECONDITION(!compile || !remove,
7542 "Can't both compile and remove at the same time");
7543 *did_define = PR_FALSE;
7545 if (!IsEventName(id)) {
7546 return NS_OK;
7549 if (ObjectIsNativeWrapper(cx, obj)) {
7550 return NS_ERROR_NOT_AVAILABLE;
7553 nsIScriptContext *script_cx = nsJSUtils::GetStaticScriptContext(cx, obj);
7554 NS_ENSURE_TRUE(script_cx, NS_ERROR_UNEXPECTED);
7556 nsCOMPtr<nsPIDOMEventTarget> piTarget =
7557 do_QueryWrappedNative(wrapper, obj);
7558 if (!piTarget) {
7559 // Doesn't do events
7560 NS_WARNING("Doesn't QI to nsPIDOMEventTarget?");
7561 return NS_OK;
7564 nsIEventListenerManager* manager = piTarget->GetListenerManager(PR_TRUE);
7565 NS_ENSURE_TRUE(manager, NS_ERROR_UNEXPECTED);
7567 nsCOMPtr<nsIAtom> atom(do_GetAtom(nsDependentJSString(id)));
7568 NS_ENSURE_TRUE(atom, NS_ERROR_OUT_OF_MEMORY);
7570 nsresult rv;
7572 JSObject *scope = ::JS_GetGlobalForObject(cx, obj);
7574 if (compile) {
7575 rv = manager->CompileScriptEventListener(script_cx, scope, piTarget, atom,
7576 did_define);
7577 } else if (remove) {
7578 rv = manager->RemoveScriptEventListener(atom);
7579 } else {
7580 rv = manager->RegisterScriptEventListener(script_cx, scope, piTarget,
7581 atom);
7584 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
7587 NS_IMETHODIMP
7588 nsEventReceiverSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
7589 JSContext *cx, JSObject *obj, jsid id,
7590 PRUint32 flags, JSObject **objp, PRBool *_retval)
7592 if (!JSID_IS_STRING(id)) {
7593 return NS_OK;
7596 if (flags & JSRESOLVE_ASSIGNING) {
7597 if (!IsEventName(id)) {
7598 // Bail out. We don't care about this assignment.
7599 return NS_OK;
7602 // If we're assigning to an on* property, just resolve to null for
7603 // now; the assignment will then set the right value. Only do this
7604 // in the case where the property isn't already defined on the
7605 // object's prototype chain though.
7606 JSAutoRequest ar(cx);
7608 JSObject *proto = ::JS_GetPrototype(cx, obj);
7609 PRBool ok = PR_TRUE, hasProp = PR_FALSE;
7610 if (!proto || ((ok = ::JS_HasPropertyById(cx, proto, id, &hasProp)) &&
7611 !hasProp)) {
7612 // Make sure the flags here match those in
7613 // nsJSContext::BindCompiledEventHandler
7614 if (!::JS_DefinePropertyById(cx, obj, id, JSVAL_NULL, nsnull, nsnull,
7615 JSPROP_ENUMERATE | JSPROP_PERMANENT)) {
7616 return NS_ERROR_FAILURE;
7619 *objp = obj;
7620 return NS_OK;
7623 return ok ? NS_OK : NS_ERROR_FAILURE;
7626 if (id == sAddEventListener_id) {
7627 return NS_OK;
7630 PRBool did_define = PR_FALSE;
7631 nsresult rv = RegisterCompileHandler(wrapper, cx, obj, id, PR_TRUE, PR_FALSE,
7632 &did_define);
7633 NS_ENSURE_SUCCESS(rv, rv);
7635 if (did_define) {
7636 *objp = obj;
7639 return nsDOMGenericSH::NewResolve(wrapper, cx, obj, id, flags, objp,
7640 _retval);
7643 NS_IMETHODIMP
7644 nsEventReceiverSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
7645 JSContext *cx, JSObject *obj, jsid id,
7646 jsval *vp, PRBool *_retval)
7648 JSAutoRequest ar(cx);
7650 if ((::JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION && !JSVAL_IS_NULL(*vp)) ||
7651 !JSID_IS_STRING(id) || id == sAddEventListener_id) {
7652 return NS_OK;
7655 PRBool did_compile; // Ignored here.
7657 return RegisterCompileHandler(wrapper, cx, obj, id, PR_FALSE,
7658 JSVAL_IS_NULL(*vp), &did_compile);
7661 NS_IMETHODIMP
7662 nsEventReceiverSH::AddProperty(nsIXPConnectWrappedNative *wrapper,
7663 JSContext *cx, JSObject *obj, jsid id,
7664 jsval *vp, PRBool *_retval)
7666 return nsEventReceiverSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
7669 // EventTarget helper
7671 NS_IMETHODIMP
7672 nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7673 JSObject *globalObj, JSObject **parentObj)
7675 nsDOMEventTargetWrapperCache *target =
7676 nsDOMEventTargetWrapperCache::FromSupports(nativeObj);
7678 nsCOMPtr<nsIScriptGlobalObject> native_parent;
7679 target->GetParentObject(getter_AddRefs(native_parent));
7681 *parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;
7683 return NS_OK;
7686 NS_IMETHODIMP
7687 nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7688 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
7690 if (id == sAddEventListener_id) {
7691 return NS_OK;
7694 nsEventTargetSH::PreserveWrapper(GetNative(wrapper, obj));
7696 return NS_OK;
7699 void
7700 nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
7702 nsDOMEventTargetWrapperCache *target =
7703 nsDOMEventTargetWrapperCache::FromSupports(aNative);
7704 nsContentUtils::PreserveWrapper(aNative, target);
7708 // Element helper
7710 static PRBool
7711 GetBindingURL(Element *aElement, nsIDocument *aDocument,
7712 nsCSSValue::URL **aResult)
7714 // If we have a frame the frame has already loaded the binding. And
7715 // otherwise, don't do anything else here unless we're dealing with
7716 // XUL.
7717 nsIPresShell *shell = aDocument->GetShell();
7718 if (!shell || aElement->GetPrimaryFrame() || !aElement->IsXUL()) {
7719 *aResult = nsnull;
7721 return PR_TRUE;
7724 // Get the computed -moz-binding directly from the style context
7725 nsPresContext *pctx = shell->GetPresContext();
7726 NS_ENSURE_TRUE(pctx, PR_FALSE);
7728 nsRefPtr<nsStyleContext> sc = pctx->StyleSet()->ResolveStyleFor(aElement,
7729 nsnull);
7730 NS_ENSURE_TRUE(sc, PR_FALSE);
7732 *aResult = sc->GetStyleDisplay()->mBinding;
7734 return PR_TRUE;
7737 NS_IMETHODIMP
7738 nsElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
7739 JSObject *globalObj, JSObject **parentObj)
7741 nsresult rv = nsNodeSH::PreCreate(nativeObj, cx, globalObj, parentObj);
7742 NS_ENSURE_SUCCESS(rv, rv);
7744 Element *element = static_cast<Element*>(nativeObj);
7746 #ifdef DEBUG
7748 nsCOMPtr<nsIContent> content_qi(do_QueryInterface(nativeObj));
7750 // If this assertion fires the QI implementation for the object in
7751 // question doesn't use the nsIContent pointer as the nsISupports
7752 // pointer. That must be fixed, or we'll crash...
7753 NS_ASSERTION(content_qi == element, "Uh, fix QI!");
7755 #endif
7757 nsIDocument *doc = element->HasFlag(NODE_FORCE_XBL_BINDINGS) ?
7758 element->GetOwnerDoc() :
7759 element->GetCurrentDoc();
7761 if (!doc) {
7762 return rv;
7765 if (element->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) &&
7766 doc->BindingManager()->GetBinding(element)) {
7767 // Don't allow slim wrappers.
7768 return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
7771 nsCSSValue::URL *bindingURL;
7772 PRBool ok = GetBindingURL(element, doc, &bindingURL);
7773 NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
7775 // Only allow slim wrappers if there's no binding.
7776 if (!bindingURL) {
7777 return rv;
7780 element->SetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
7782 return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
7785 NS_IMETHODIMP
7786 nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7787 JSObject *obj)
7789 Element *element = static_cast<Element*>(wrapper->Native());
7791 #ifdef DEBUG
7793 nsCOMPtr<nsIContent> content_qi(do_QueryWrappedNative(wrapper));
7795 // If this assertion fires the QI implementation for the object in
7796 // question doesn't use the nsIContent pointer as the nsISupports
7797 // pointer. That must be fixed, or we'll crash...
7798 NS_ASSERTION(content_qi == element, "Uh, fix QI!");
7800 #endif
7802 nsIDocument* doc;
7803 if (element->HasFlag(NODE_FORCE_XBL_BINDINGS)) {
7804 doc = element->GetOwnerDoc();
7806 else {
7807 doc = element->GetCurrentDoc();
7810 if (!doc) {
7811 // There's no baseclass that cares about this call so we just
7812 // return here.
7814 return NS_OK;
7817 // We must ensure that the XBL Binding is installed before we hand
7818 // back this object.
7820 if (!element->HasFlag(NODE_ATTACH_BINDING_ON_POSTCREATE)) {
7821 // There's already a binding for this element so nothing left to
7822 // be done here.
7824 // In theory we could call ExecuteAttachedHandler here when it's safe to
7825 // run script if we also removed the binding from the PAQ queue, but that
7826 // seems like a scary change that would mosly just add more
7827 // inconsistencies.
7829 return NS_OK;
7832 element->UnsetFlags(NODE_ATTACH_BINDING_ON_POSTCREATE);
7834 // Make sure the style context goes away _before_ we load the binding
7835 // since that can destroy the relevant presshell.
7836 nsCSSValue::URL *bindingURL;
7837 PRBool ok = GetBindingURL(element, doc, &bindingURL);
7838 NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
7840 if (!bindingURL) {
7841 // No binding, nothing left to do here.
7842 return NS_OK;
7845 nsCOMPtr<nsIURI> uri = bindingURL->mURI;
7846 nsCOMPtr<nsIPrincipal> principal = bindingURL->mOriginPrincipal;
7848 // We have a binding that must be installed.
7849 PRBool dummy;
7851 nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
7852 NS_ENSURE_TRUE(xblService, NS_ERROR_NOT_AVAILABLE);
7854 nsRefPtr<nsXBLBinding> binding;
7855 xblService->LoadBindings(element, uri, principal, PR_FALSE,
7856 getter_AddRefs(binding), &dummy);
7858 if (binding) {
7859 if (nsContentUtils::IsSafeToRunScript()) {
7860 binding->ExecuteAttachedHandler();
7862 else {
7863 nsContentUtils::AddScriptRunner(
7864 NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
7868 return NS_OK;
7871 NS_IMETHODIMP
7872 nsElementSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7873 JSObject *obj, PRBool *_retval)
7875 // Make sure to not call the superclass here!
7876 nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
7877 NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
7879 nsIDocument* doc = content->GetOwnerDoc();
7880 if (!doc) {
7881 // Nothing else to do here
7882 return NS_OK;
7885 nsRefPtr<nsXBLBinding> binding = doc->BindingManager()->GetBinding(content);
7886 if (!binding) {
7887 // Nothing else to do here
7888 return NS_OK;
7891 *_retval = binding->ResolveAllFields(cx, obj);
7893 return NS_OK;
7897 // Generic array scriptable helper.
7899 NS_IMETHODIMP
7900 nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7901 JSObject *obj, jsid id, PRUint32 flags,
7902 JSObject **objp, PRBool *_retval)
7904 if (id == sLength_id) {
7905 // Bail early; this isn't something we're interested in
7906 return NS_OK;
7909 PRBool is_number = PR_FALSE;
7910 PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
7912 if (is_number && n >= 0) {
7913 // XXX The following is a cheap optimization to avoid hitting xpconnect to
7914 // get the length. We may want to consider asking our concrete
7915 // implementation for the length, and falling back onto the GetProperty if
7916 // it doesn't provide one.
7918 PRUint32 length;
7919 nsresult rv = GetLength(wrapper, cx, obj, &length);
7920 NS_ENSURE_SUCCESS(rv, rv);
7922 if ((PRUint32)n < length) {
7923 *_retval = ::JS_DefineElement(cx, obj, n, JSVAL_VOID, nsnull, nsnull,
7924 JSPROP_ENUMERATE | JSPROP_SHARED);
7925 *objp = obj;
7929 return NS_OK;
7932 nsresult
7933 nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7934 JSObject *obj, PRUint32 *length)
7936 *length = 0;
7938 jsval lenval;
7939 if (!JS_GetProperty(cx, obj, "length", &lenval)) {
7940 return NS_ERROR_UNEXPECTED;
7943 if (!JSVAL_IS_INT(lenval)) {
7944 // This can apparently happen with some sparse array impls falling back
7945 // onto this code.
7946 return NS_OK;
7949 PRInt32 slen = JSVAL_TO_INT(lenval);
7950 if (slen < 0) {
7951 return NS_OK;
7954 *length = (PRUint32)slen;
7956 return NS_OK;
7959 NS_IMETHODIMP
7960 nsGenericArraySH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7961 JSObject *obj, PRBool *_retval)
7963 // Recursion protection in case someone tries to be smart and call
7964 // the enumerate hook from a user defined .length getter, or
7965 // somesuch.
7967 static PRBool sCurrentlyEnumerating;
7969 if (sCurrentlyEnumerating) {
7970 // Don't recurse to death.
7971 return NS_OK;
7974 sCurrentlyEnumerating = PR_TRUE;
7976 jsval len_val;
7977 JSAutoRequest ar(cx);
7978 JSBool ok = ::JS_GetProperty(cx, obj, "length", &len_val);
7980 if (ok && JSVAL_IS_INT(len_val)) {
7981 PRInt32 length = JSVAL_TO_INT(len_val);
7983 for (PRInt32 i = 0; ok && i < length; ++i) {
7984 ok = ::JS_DefineElement(cx, obj, i, JSVAL_VOID, nsnull, nsnull,
7985 JSPROP_ENUMERATE | JSPROP_SHARED);
7989 sCurrentlyEnumerating = PR_FALSE;
7991 return ok ? NS_OK : NS_ERROR_UNEXPECTED;
7994 // Array scriptable helper
7996 NS_IMETHODIMP
7997 nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
7998 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
8000 PRBool is_number = PR_FALSE;
8001 PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
8003 nsresult rv = NS_OK;
8005 if (is_number) {
8006 if (n < 0) {
8007 return NS_ERROR_DOM_INDEX_SIZE_ERR;
8010 // Make sure rv == NS_OK here, so GetItemAt implementations that never fail
8011 // don't have to set rv.
8012 rv = NS_OK;
8013 nsWrapperCache *cache = nsnull;
8014 nsISupports* array_item =
8015 GetItemAt(GetNative(wrapper, obj), n, &cache, &rv);
8016 NS_ENSURE_SUCCESS(rv, rv);
8018 if (array_item) {
8019 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), array_item, cache,
8020 PR_TRUE, vp);
8021 NS_ENSURE_SUCCESS(rv, rv);
8023 rv = NS_SUCCESS_I_DID_SOMETHING;
8027 return rv;
8031 // NodeList scriptable helper
8033 nsresult
8034 nsNodeListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
8035 JSObject *globalObj, JSObject **parentObj)
8037 nsWrapperCache* cache = nsnull;
8038 CallQueryInterface(nativeObj, &cache);
8039 if (!cache) {
8040 return nsDOMClassInfo::PreCreate(nativeObj, cx, globalObj, parentObj);
8043 // nsChildContentList is the only class that uses nsNodeListSH and has a
8044 // cached wrapper.
8045 nsChildContentList *list = nsChildContentList::FromSupports(nativeObj);
8046 nsINode *native_parent = list->GetParentObject();
8047 if (!native_parent) {
8048 return NS_ERROR_FAILURE;
8051 nsresult rv =
8052 WrapNativeParent(cx, globalObj, native_parent, native_parent, parentObj);
8053 NS_ENSURE_SUCCESS(rv, rv);
8055 return NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
8058 nsresult
8059 nsNodeListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8060 JSObject *obj, PRUint32 *length)
8062 nsINodeList* list = static_cast<nsINodeList*>(GetNative(wrapper, obj));
8063 #ifdef DEBUG
8065 nsCOMPtr<nsINodeList> list_qi = do_QueryWrappedNative(wrapper, obj);
8067 // If this assertion fires the QI implementation for the object in
8068 // question doesn't use the nsINodeList pointer as the nsISupports
8069 // pointer. That must be fixed, or we'll crash...
8070 NS_ASSERTION(list_qi == list, "Uh, fix QI!");
8072 #endif
8074 return list->GetLength(length);
8077 nsISupports*
8078 nsNodeListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
8079 nsWrapperCache **aCache, nsresult *aResult)
8081 nsINodeList* list = static_cast<nsINodeList*>(aNative);
8082 #ifdef DEBUG
8084 nsCOMPtr<nsINodeList> list_qi = do_QueryInterface(aNative);
8086 // If this assertion fires the QI implementation for the object in
8087 // question doesn't use the nsINodeList pointer as the nsISupports
8088 // pointer. That must be fixed, or we'll crash...
8089 NS_ASSERTION(list_qi == list, "Uh, fix QI!");
8091 #endif
8093 nsINode *node;
8094 *aCache = node = list->GetNodeAt(aIndex);
8095 return node;
8099 // StringList scriptable helper
8101 nsresult
8102 nsStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
8103 nsAString& aResult)
8105 nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
8106 NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
8108 return list->Item(aIndex, aResult);
8112 // DOMTokenList scriptable helper
8114 nsresult
8115 nsDOMTokenListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
8116 nsAString& aResult)
8118 nsCOMPtr<nsIDOMDOMTokenList> list(do_QueryInterface(aNative));
8119 NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
8121 return list->Item(aIndex, aResult);
8125 // Named Array helper
8127 NS_IMETHODIMP
8128 nsNamedArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8129 JSObject *obj, jsid id, jsval *vp,
8130 PRBool *_retval)
8132 if (JSID_IS_STRING(id) && !ObjectIsNativeWrapper(cx, obj)) {
8133 nsresult rv = NS_OK;
8134 nsWrapperCache *cache = nsnull;
8135 nsISupports* item = GetNamedItem(GetNative(wrapper, obj),
8136 nsDependentJSString(id), &cache, &rv);
8137 NS_ENSURE_SUCCESS(rv, rv);
8139 if (item) {
8140 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), item, cache,
8141 PR_TRUE, vp);
8142 NS_ENSURE_SUCCESS(rv, rv);
8144 rv = NS_SUCCESS_I_DID_SOMETHING;
8147 // Don't fall through to nsArraySH::GetProperty() here
8148 return rv;
8151 return nsArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
8155 // NamedNodeMap helper
8157 nsISupports*
8158 nsNamedNodeMapSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
8159 nsWrapperCache **aCache, nsresult *aResult)
8161 nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
8163 nsINode *attr;
8164 *aCache = attr = map->GetItemAt(aIndex, aResult);
8165 return attr;
8168 nsISupports*
8169 nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
8170 nsWrapperCache **aCache, nsresult *aResult)
8172 nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
8174 nsINode *attr;
8175 *aCache = attr = map->GetNamedItem(aName, aResult);
8176 return attr;
8180 // HTMLCollection helper
8182 nsresult
8183 nsHTMLCollectionSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8184 JSObject *obj, PRUint32 *length)
8186 nsIHTMLCollection* collection =
8187 static_cast<nsIHTMLCollection*>(GetNative(wrapper, obj));
8188 #ifdef DEBUG
8190 nsCOMPtr<nsIHTMLCollection> collection_qi =
8191 do_QueryWrappedNative(wrapper, obj);
8193 // If this assertion fires the QI implementation for the object in
8194 // question doesn't use the nsIHTMLCollection pointer as the nsISupports
8195 // pointer. That must be fixed, or we'll crash...
8196 NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
8198 #endif
8200 return collection->GetLength(length);
8203 nsISupports*
8204 nsHTMLCollectionSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
8205 nsWrapperCache **aCache, nsresult *aResult)
8207 nsIHTMLCollection* collection = static_cast<nsIHTMLCollection*>(aNative);
8208 #ifdef DEBUG
8210 nsCOMPtr<nsIHTMLCollection> collection_qi = do_QueryInterface(aNative);
8212 // If this assertion fires the QI implementation for the object in
8213 // question doesn't use the nsIHTMLCollection pointer as the nsISupports
8214 // pointer. That must be fixed, or we'll crash...
8215 NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
8217 #endif
8219 nsINode *item;
8220 *aCache = item = collection->GetNodeAt(aIndex, aResult);
8221 return item;
8224 nsISupports*
8225 nsHTMLCollectionSH::GetNamedItem(nsISupports *aNative,
8226 const nsAString& aName,
8227 nsWrapperCache **aCache,
8228 nsresult *aResult)
8230 nsIHTMLCollection* collection = static_cast<nsIHTMLCollection*>(aNative);
8231 #ifdef DEBUG
8233 nsCOMPtr<nsIHTMLCollection> collection_qi = do_QueryInterface(aNative);
8235 // If this assertion fires the QI implementation for the object in
8236 // question doesn't use the nsIHTMLCollection pointer as the nsISupports
8237 // pointer. That must be fixed, or we'll crash...
8238 NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
8240 #endif
8242 return collection->GetNamedItem(aName, aCache, aResult);
8246 // ContentList helper
8247 nsresult
8248 nsContentListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
8249 JSObject *globalObj, JSObject **parentObj)
8251 nsContentList *contentList = nsContentList::FromSupports(nativeObj);
8252 nsINode *native_parent = contentList->GetParentObject();
8254 if (!native_parent) {
8255 return NS_ERROR_FAILURE;
8258 nsresult rv =
8259 WrapNativeParent(cx, globalObj, native_parent, native_parent, parentObj);
8260 NS_ENSURE_SUCCESS(rv, rv);
8262 return NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
8265 nsresult
8266 nsContentListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8267 JSObject *obj, PRUint32 *length)
8269 nsContentList *list =
8270 nsContentList::FromSupports(GetNative(wrapper, obj));
8272 return list->GetLength(length);
8275 nsISupports*
8276 nsContentListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
8277 nsWrapperCache **aCache, nsresult *aResult)
8279 nsContentList *list = nsContentList::FromSupports(aNative);
8281 nsIContent *item;
8282 *aCache = item = list->GetNodeAt(aIndex, aResult);
8283 return item;
8286 nsISupports*
8287 nsContentListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
8288 nsWrapperCache **aCache, nsresult *aResult)
8290 nsContentList *list = nsContentList::FromSupports(aNative);
8292 return list->GetNamedItem(aName, aCache, aResult);
8295 NS_IMETHODIMP
8296 nsDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8297 JSObject *obj, jsid id, PRUint32 flags,
8298 JSObject **objp, PRBool *_retval)
8300 nsresult rv;
8302 if (id == sLocation_id) {
8303 // Define the location property on the document object itself so
8304 // that we can intercept getting and setting of document.location.
8306 nsCOMPtr<nsIDOMNSDocument> doc(do_QueryWrappedNative(wrapper, obj));
8307 NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
8309 nsCOMPtr<nsIDOMLocation> location;
8310 rv = doc->GetLocation(getter_AddRefs(location));
8311 NS_ENSURE_SUCCESS(rv, rv);
8313 jsval v;
8315 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8316 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
8317 &NS_GET_IID(nsIDOMLocation), PR_TRUE, &v,
8318 getter_AddRefs(holder));
8319 NS_ENSURE_SUCCESS(rv, rv);
8321 JSAutoRequest ar(cx);
8323 JSBool ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull,
8324 JSPROP_PERMANENT | JSPROP_ENUMERATE);
8326 if (!ok) {
8327 return NS_ERROR_FAILURE;
8330 *objp = obj;
8332 return NS_OK;
8335 if (id == sDocumentURIObject_id && IsPrivilegedScript()) {
8336 return DefineVoidProp(cx, obj, id, objp);
8339 return nsNodeSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
8342 NS_IMETHODIMP
8343 nsDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8344 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
8346 if (id == sDocumentURIObject_id && IsPrivilegedScript()) {
8347 nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper);
8348 NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
8350 nsIURI* uri = doc->GetDocumentURI();
8351 NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE);
8353 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8354 nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), uri,
8355 &NS_GET_IID(nsIURI), PR_TRUE, vp,
8356 getter_AddRefs(holder));
8358 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
8361 return nsNodeSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
8364 NS_IMETHODIMP
8365 nsDocumentSH::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8366 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
8368 if (id == sLocation_id) {
8369 nsCOMPtr<nsIDOMNSDocument> doc(do_QueryWrappedNative(wrapper));
8370 NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
8372 nsCOMPtr<nsIDOMLocation> location;
8374 nsresult rv = doc->GetLocation(getter_AddRefs(location));
8375 NS_ENSURE_SUCCESS(rv, rv);
8377 if (location) {
8378 JSAutoRequest ar(cx);
8380 JSString *val = ::JS_ValueToString(cx, *vp);
8381 NS_ENSURE_TRUE(val, NS_ERROR_UNEXPECTED);
8383 nsDependentJSString depStr;
8384 NS_ENSURE_TRUE(depStr.init(cx, val), NS_ERROR_UNEXPECTED);
8386 rv = location->SetHref(depStr);
8387 NS_ENSURE_SUCCESS(rv, rv);
8389 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8390 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), location,
8391 &NS_GET_IID(nsIDOMLocation), PR_TRUE, vp,
8392 getter_AddRefs(holder));
8393 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
8397 if (id == sDocumentURIObject_id && IsPrivilegedScript()) {
8398 // We don't want privileged script that can read this property to set it,
8399 // but _do_ want to allow everyone else to set a value they can then read.
8401 // XXXbz Is there a better error we could use here?
8402 return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
8405 return nsNodeSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
8408 NS_IMETHODIMP
8409 nsDocumentSH::GetFlags(PRUint32* aFlags)
8411 *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
8413 return NS_OK;
8416 NS_IMETHODIMP
8417 nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
8418 JSObject *obj)
8420 // If this is the current document for the window that's the script global
8421 // object of this document, then define this document object on the window.
8422 // That will make sure that the document is referenced (via window.document)
8423 // and prevent it from going away in GC.
8424 nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper);
8425 if (!doc) {
8426 return NS_ERROR_UNEXPECTED;
8429 nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
8430 nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(sgo);
8431 if (!win) {
8432 // No window, nothing else to do here
8433 return NS_OK;
8436 nsIDOMDocument* currentDoc = win->GetExtantDocument();
8438 if (SameCOMIdentity(doc, currentDoc)) {
8439 jsval winVal;
8441 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8442 nsresult rv = WrapNative(cx, obj, win, &NS_GET_IID(nsIDOMWindow), PR_FALSE,
8443 &winVal, getter_AddRefs(holder));
8444 NS_ENSURE_SUCCESS(rv, rv);
8446 NS_NAMED_LITERAL_STRING(doc_str, "document");
8448 if (!::JS_DefineUCProperty(cx, JSVAL_TO_OBJECT(winVal),
8449 reinterpret_cast<const jschar *>
8450 (doc_str.get()),
8451 doc_str.Length(), OBJECT_TO_JSVAL(obj),
8452 JS_PropertyStub, JS_StrictPropertyStub,
8453 JSPROP_READONLY | JSPROP_ENUMERATE)) {
8454 return NS_ERROR_FAILURE;
8457 return NS_OK;
8460 // HTMLDocument helper
8462 static nsresult
8463 ResolveImpl(JSContext *cx, nsIXPConnectWrappedNative *wrapper, jsid id,
8464 nsISupports **result, nsWrapperCache **aCache)
8466 nsHTMLDocument *doc =
8467 static_cast<nsHTMLDocument*>(static_cast<nsINode*>(wrapper->Native()));
8469 // 'id' is not always a string, it can be a number since document.1
8470 // should map to <input name="1">. Thus we can't use
8471 // JSVAL_TO_STRING() here.
8472 JSString *str = IdToString(cx, id);
8473 NS_ENSURE_TRUE(str, NS_ERROR_UNEXPECTED);
8475 nsDependentJSString depStr;
8476 NS_ENSURE_TRUE(depStr.init(cx, str), NS_ERROR_UNEXPECTED);
8478 return doc->ResolveName(depStr, nsnull, result, aCache);
8481 // static
8482 JSBool
8483 nsHTMLDocumentSH::DocumentOpen(JSContext *cx, uintN argc, jsval *vp)
8485 JSObject *obj = JS_THIS_OBJECT(cx, vp);
8486 if (!obj)
8487 return JS_FALSE;
8489 jsval *argv = JS_ARGV(cx, vp);
8490 if (argc > 2) {
8491 JSObject *global = ::JS_GetGlobalForObject(cx, obj);
8493 // DOM0 quirk that makes document.open() call window.open() if
8494 // called with 3 or more arguments.
8496 return ::JS_CallFunctionName(cx, global, "open", argc, JS_ARGV(cx, vp), vp);
8499 nsCOMPtr<nsISupports> native = do_QueryWrapper(cx, obj);
8500 if (!native) {
8501 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
8503 return JS_FALSE;
8506 nsCOMPtr<nsIDOMNSHTMLDocument> doc = do_QueryInterface(native);
8507 NS_ENSURE_TRUE(doc, JS_FALSE);
8509 nsCAutoString contentType("text/html");
8510 if (argc > 0) {
8511 JSString* jsstr = JS_ValueToString(cx, argv[0]);
8512 if (!jsstr) {
8513 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_OUT_OF_MEMORY);
8514 return JS_FALSE;
8516 nsDependentJSString depStr;
8517 if (!depStr.init(cx, jsstr)) {
8518 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_OUT_OF_MEMORY);
8519 return JS_FALSE;
8521 nsAutoString type;
8522 type.Assign(depStr);
8523 ToLowerCase(type);
8524 nsCAutoString actualType, dummy;
8525 NS_ParseContentType(NS_ConvertUTF16toUTF8(type), actualType, dummy);
8526 if (!actualType.EqualsLiteral("text/html") &&
8527 !type.EqualsLiteral("replace")) {
8528 contentType = "text/plain";
8532 PRBool replace = PR_FALSE;
8533 if (argc > 1) {
8534 JSString* jsstr = JS_ValueToString(cx, argv[1]);
8535 if (!jsstr) {
8536 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_OUT_OF_MEMORY);
8537 return JS_FALSE;
8540 const jschar *chars = ::JS_GetStringCharsZ(cx, jsstr);
8541 if (!chars) {
8542 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_OUT_OF_MEMORY);
8543 return JS_FALSE;
8546 replace = NS_LITERAL_STRING("replace").Equals(chars);
8549 nsCOMPtr<nsIDOMDocument> retval;
8550 nsresult rv = doc->Open(contentType, replace, getter_AddRefs(retval));
8551 if (NS_FAILED(rv)) {
8552 nsDOMClassInfo::ThrowJSException(cx, rv);
8554 return JS_FALSE;
8557 *vp = OBJECT_TO_JSVAL(obj);
8558 return NS_SUCCEEDED(rv);
8562 static JSClass sHTMLDocumentAllClass = {
8563 "HTML document.all class",
8564 JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_NEW_RESOLVE |
8565 JSCLASS_HAS_RESERVED_SLOTS(1),
8566 JS_PropertyStub, JS_PropertyStub, nsHTMLDocumentSH::DocumentAllGetProperty,
8567 JS_StrictPropertyStub, JS_EnumerateStub,
8568 (JSResolveOp)nsHTMLDocumentSH::DocumentAllNewResolve, JS_ConvertStub,
8569 nsHTMLDocumentSH::ReleaseDocument, nsnull, nsnull,
8570 nsHTMLDocumentSH::CallToGetPropMapper
8574 static JSClass sHTMLDocumentAllHelperClass = {
8575 "HTML document.all helper class", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
8576 JS_PropertyStub, JS_PropertyStub,
8577 nsHTMLDocumentSH::DocumentAllHelperGetProperty,
8578 JS_StrictPropertyStub, JS_EnumerateStub,
8579 (JSResolveOp)nsHTMLDocumentSH::DocumentAllHelperNewResolve, JS_ConvertStub,
8580 nsnull
8584 static JSClass sHTMLDocumentAllTagsClass = {
8585 "HTML document.all.tags class",
8586 JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
8587 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
8588 JS_EnumerateStub, (JSResolveOp)nsHTMLDocumentSH::DocumentAllTagsNewResolve,
8589 JS_ConvertStub, nsHTMLDocumentSH::ReleaseDocument, nsnull, nsnull,
8590 nsHTMLDocumentSH::CallToGetPropMapper
8593 // static
8594 JSBool
8595 nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
8596 nsDocument *domdoc,
8597 nsContentList **nodeList)
8599 // The document.all object is a mix of the node list returned by
8600 // document.getElementsByTagName("*") and a map of elements in the
8601 // document exposed by their id and/or name. To make access to the
8602 // node list part (i.e. access to elements by index) not walk the
8603 // document each time, we create a nsContentList and hold on to it
8604 // in a reserved slot (0) on the document.all JSObject.
8605 jsval collection;
8606 nsresult rv = NS_OK;
8608 if (!JS_GetReservedSlot(cx, obj, 0, &collection)) {
8609 return JS_FALSE;
8612 if (!JSVAL_IS_PRIMITIVE(collection)) {
8613 // We already have a node list in our reserved slot, use it.
8615 nsISupports *native =
8616 sXPConnect->GetNativeOfWrapper(cx, JSVAL_TO_OBJECT(collection));
8617 if (native) {
8618 NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
8620 else {
8621 rv = NS_ERROR_FAILURE;
8623 } else {
8624 // No node list for this document.all yet, create one...
8626 nsRefPtr<nsContentList> list =
8627 domdoc->GetElementsByTagName(NS_LITERAL_STRING("*"));
8628 if (!list) {
8629 rv |= NS_ERROR_OUT_OF_MEMORY;
8632 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
8633 rv |= nsDOMClassInfo::WrapNative(cx, JS_GetGlobalForScopeChain(cx),
8634 static_cast<nsINodeList*>(list),
8635 list, PR_FALSE, &collection,
8636 getter_AddRefs(holder));
8638 list.forget(nodeList);
8640 // ... and store it in our reserved slot.
8641 if (!JS_SetReservedSlot(cx, obj, 0, collection)) {
8642 return JS_FALSE;
8646 if (NS_FAILED(rv)) {
8647 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
8649 return JS_FALSE;
8652 return *nodeList != nsnull;
8655 JSBool
8656 nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSObject *obj,
8657 jsid id, jsval *vp)
8659 // document.all.item and .namedItem get their value in the
8660 // newResolve hook, so nothing to do for those properties here. And
8661 // we need to return early to prevent <div id="item"> from shadowing
8662 // document.all.item(), etc.
8663 if (id == sItem_id || id == sNamedItem_id) {
8664 return JS_TRUE;
8667 while (obj->getJSClass() != &sHTMLDocumentAllClass) {
8668 obj = obj->getProto();
8670 if (!obj) {
8671 NS_ERROR("The JS engine lies!");
8673 return JS_TRUE;
8677 nsHTMLDocument *doc = GetDocument(cx, obj);
8678 nsISupports *result;
8679 nsWrapperCache *cache;
8680 nsresult rv = NS_OK;
8682 if (JSID_IS_STRING(id)) {
8683 if (id == sLength_id) {
8684 // Map document.all.length to the length of the collection
8685 // document.getElementsByTagName("*"), and make sure <div
8686 // id="length"> doesn't shadow document.all.length.
8688 nsRefPtr<nsContentList> nodeList;
8689 if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
8690 return JS_FALSE;
8693 PRUint32 length;
8694 rv = nodeList->GetLength(&length);
8696 if (NS_FAILED(rv)) {
8697 nsDOMClassInfo::ThrowJSException(cx, rv);
8699 return JS_FALSE;
8702 *vp = INT_TO_JSVAL(length);
8704 return JS_TRUE;
8705 } else if (id != sTags_id) {
8706 // For all other strings, look for an element by id or name.
8708 nsDependentJSString str(id);
8710 result = doc->GetDocumentAllResult(str, &cache, &rv);
8712 if (NS_FAILED(rv)) {
8713 nsDOMClassInfo::ThrowJSException(cx, rv);
8715 return JS_FALSE;
8718 else {
8719 result = nsnull;
8721 } else if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
8722 // Map document.all[n] (where n is a number) to the n:th item in
8723 // the document.all node list.
8725 nsRefPtr<nsContentList> nodeList;
8726 if (!GetDocumentAllNodeList(cx, obj, doc, getter_AddRefs(nodeList))) {
8727 return JS_FALSE;
8730 nsIContent *node = nodeList->GetNodeAt(JSID_TO_INT(id));
8732 result = node;
8733 cache = node;
8734 } else {
8735 result = nsnull;
8738 if (result) {
8739 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), result, cache, PR_TRUE, vp);
8740 if (NS_FAILED(rv)) {
8741 nsDOMClassInfo::ThrowJSException(cx, rv);
8743 return JS_FALSE;
8745 } else {
8746 *vp = JSVAL_VOID;
8749 return JS_TRUE;
8752 JSBool
8753 nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSObject *obj, jsid id,
8754 uintN flags, JSObject **objp)
8756 if (flags & JSRESOLVE_ASSIGNING) {
8757 // Nothing to do here if we're assigning
8759 return JS_TRUE;
8762 jsval v = JSVAL_VOID;
8764 if (id == sItem_id || id == sNamedItem_id) {
8765 // Define the item() or namedItem() method.
8767 JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
8768 0, JSPROP_ENUMERATE);
8769 *objp = obj;
8771 return fnc != nsnull;
8774 if (id == sLength_id) {
8775 // document.all.length. Any jsval other than undefined would do
8776 // here, all we need is to get into the code below that defines
8777 // this propery on obj, the rest happens in
8778 // DocumentAllGetProperty().
8780 v = JSVAL_ONE;
8781 } else if (id == sTags_id) {
8782 nsHTMLDocument *doc = GetDocument(cx, obj);
8784 JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
8785 ::JS_GetGlobalForObject(cx, obj));
8786 if (!tags) {
8787 return JS_FALSE;
8790 if (!::JS_SetPrivate(cx, tags, doc)) {
8791 return JS_FALSE;
8794 // The "tags" JSObject now also owns doc.
8795 NS_ADDREF(doc);
8797 v = OBJECT_TO_JSVAL(tags);
8798 } else {
8799 if (!DocumentAllGetProperty(cx, obj, id, &v)) {
8800 return JS_FALSE;
8804 JSBool ok = JS_TRUE;
8806 if (v != JSVAL_VOID) {
8807 if (JSID_IS_STRING(id)) {
8808 ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
8809 } else {
8810 ok = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), v, nsnull, nsnull, 0);
8813 *objp = obj;
8816 return ok;
8819 // Finalize hook used by document related JS objects, but also by
8820 // sGlobalScopePolluterClass!
8822 void
8823 nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
8825 nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, obj);
8827 NS_IF_RELEASE(doc);
8830 JSBool
8831 nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, uintN argc, jsval *vp)
8833 // Handle document.all("foo") style access to document.all.
8835 if (argc != 1) {
8836 // XXX: Should throw NS_ERROR_XPC_NOT_ENOUGH_ARGS for argc < 1,
8837 // and create a new NS_ERROR_XPC_TOO_MANY_ARGS for argc > 1? IE
8838 // accepts nothing other than one arg.
8839 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_INVALID_ARG);
8841 return JS_FALSE;
8844 // Convert all types to string.
8845 JSString *str = ::JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
8846 if (!str) {
8847 return JS_FALSE;
8850 // If we are called via document.all(id) instead of document.all.item(i) or
8851 // another method, use the document.all callee object as self.
8852 JSObject *self;
8853 if (JSVAL_IS_OBJECT(JS_CALLEE(cx, vp)) &&
8854 ::JS_GetClass(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp))) == &sHTMLDocumentAllClass) {
8855 self = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
8856 } else {
8857 self = JS_THIS_OBJECT(cx, vp);
8858 if (!self)
8859 return JS_FALSE;
8862 size_t length;
8863 const jschar *chars = ::JS_GetStringCharsAndLength(cx, str, &length);
8864 if (!chars) {
8865 return JS_FALSE;
8868 return ::JS_GetUCProperty(cx, self, chars, length, vp);
8872 static inline JSObject *
8873 GetDocumentAllHelper(JSContext *cx, JSObject *obj)
8875 while (obj && JS_GET_CLASS(cx, obj) != &sHTMLDocumentAllHelperClass) {
8876 obj = ::JS_GetPrototype(cx, obj);
8879 return obj;
8882 static inline void *
8883 FlagsToPrivate(PRUint32 flags)
8885 JS_ASSERT((flags & (1 << 31)) == 0);
8886 return (void *)(flags << 1);
8889 static inline PRUint32
8890 PrivateToFlags(void *priv)
8892 JS_ASSERT(size_t(priv) <= PR_UINT32_MAX && (size_t(priv) & 1) == 0);
8893 return (PRUint32)(size_t(priv) >> 1);
8896 JSBool
8897 nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
8898 jsid id, jsval *vp)
8900 if (id != nsDOMClassInfo::sAll_id) {
8901 return JS_TRUE;
8904 JSObject *helper = GetDocumentAllHelper(cx, obj);
8906 if (!helper) {
8907 NS_ERROR("Uh, how'd we get here?");
8909 // Let scripts continue, if we somehow did get here...
8911 return JS_TRUE;
8914 PRUint32 flags = PrivateToFlags(::JS_GetPrivate(cx, helper));
8916 if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
8917 // document.all is either being detected, e.g. if (document.all),
8918 // or it was not being resolved with a qualified name. Claim that
8919 // document.all is undefined.
8921 *vp = JSVAL_VOID;
8922 } else {
8923 // document.all is not being detected, and it resolved with a
8924 // qualified name. Expose the document.all collection.
8926 if (!JSVAL_IS_OBJECT(*vp)) {
8927 // First time through, create the collection, and set the
8928 // document as its private nsISupports data.
8929 nsresult rv;
8930 nsCOMPtr<nsIHTMLDocument> doc = do_QueryWrapper(cx, obj, &rv);
8931 if (NS_FAILED(rv)) {
8932 nsDOMClassInfo::ThrowJSException(cx, rv);
8934 return JS_FALSE;
8937 JSObject *all = ::JS_NewObject(cx, &sHTMLDocumentAllClass, nsnull,
8938 ::JS_GetGlobalForObject(cx, obj));
8939 if (!all) {
8940 return JS_FALSE;
8943 // Let the JSObject take over ownership of doc.
8944 if (!::JS_SetPrivate(cx, all, doc)) {
8945 return JS_FALSE;
8948 doc.forget();
8950 *vp = OBJECT_TO_JSVAL(all);
8954 return JS_TRUE;
8957 JSBool
8958 nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
8959 jsid id, uintN flags,
8960 JSObject **objp)
8962 if (id == nsDOMClassInfo::sAll_id) {
8963 // document.all is resolved for the first time. Define it.
8964 JSObject *helper = GetDocumentAllHelper(cx, obj);
8966 if (helper) {
8967 if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
8968 JSPROP_ENUMERATE)) {
8969 return JS_FALSE;
8972 *objp = helper;
8976 return JS_TRUE;
8980 JSBool
8981 nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
8982 jsid id, uintN flags,
8983 JSObject **objp)
8985 if (JSID_IS_STRING(id)) {
8986 nsDocument *doc = GetDocument(cx, obj);
8988 JSObject *proto = ::JS_GetPrototype(cx, obj);
8989 if (NS_UNLIKELY(!proto)) {
8990 return JS_TRUE;
8993 JSBool found;
8994 if (!::JS_HasPropertyById(cx, proto, id, &found)) {
8995 return JS_FALSE;
8998 if (found) {
8999 return JS_TRUE;
9002 nsRefPtr<nsContentList> tags =
9003 doc->GetElementsByTagName(nsDependentJSString(id));
9005 if (tags) {
9006 jsval v;
9007 nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
9008 nsresult rv = nsDOMClassInfo::WrapNative(cx, JS_GetGlobalForScopeChain(cx),
9009 static_cast<nsINodeList*>(tags),
9010 tags, PR_TRUE, &v,
9011 getter_AddRefs(holder));
9012 if (NS_FAILED(rv)) {
9013 nsDOMClassInfo::ThrowJSException(cx, rv);
9015 return JS_FALSE;
9018 if (!::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0)) {
9019 return JS_FALSE;
9022 *objp = obj;
9026 return JS_TRUE;
9030 NS_IMETHODIMP
9031 nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9032 JSObject *obj, jsid id, PRUint32 flags,
9033 JSObject **objp, PRBool *_retval)
9035 // nsDocumentSH::NewResolve() does a security check that we'd kinda
9036 // want to do here too before doing anything else. But given that we
9037 // only define dynamic properties here before the call to
9038 // nsDocumentSH::NewResolve() we're ok, since once those properties
9039 // are accessed, we'll do the necessary security check.
9041 if (!(flags & JSRESOLVE_ASSIGNING)) {
9042 // For native wrappers, do not resolve random names on document
9044 JSAutoRequest ar(cx);
9046 if (!ObjectIsNativeWrapper(cx, obj)) {
9047 nsCOMPtr<nsISupports> result;
9048 nsWrapperCache *cache;
9049 nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result),
9050 &cache);
9051 NS_ENSURE_SUCCESS(rv, rv);
9053 if (result) {
9054 JSBool ok = *_retval =
9055 ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull, nsnull, 0);
9056 *objp = obj;
9058 return ok ? NS_OK : NS_ERROR_FAILURE;
9062 if (id == sOpen_id) {
9063 JSFunction *fnc =::JS_DefineFunctionById(cx, obj, id, DocumentOpen, 0,
9064 JSPROP_ENUMERATE);
9065 *objp = obj;
9067 return fnc ? NS_OK : NS_ERROR_UNEXPECTED;
9070 if (id == sAll_id && !sDisableDocumentAllSupport &&
9071 !ObjectIsNativeWrapper(cx, obj)) {
9072 nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
9074 if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
9075 JSObject *helper =
9076 GetDocumentAllHelper(cx, ::JS_GetPrototype(cx, obj));
9078 JSObject *proto = ::JS_GetPrototype(cx, helper ? helper : obj);
9080 // Check if the property all is defined on obj's (or helper's
9081 // if obj doesn't exist) prototype, if it is, don't expose our
9082 // document.all helper.
9084 JSBool hasAll = JS_FALSE;
9085 if (proto && !JS_HasProperty(cx, proto, "all", &hasAll)) {
9086 return NS_ERROR_UNEXPECTED;
9089 if (hasAll && helper) {
9090 // Our helper's prototype now has an "all" property, remove
9091 // the helper out of the prototype chain to prevent
9092 // shadowing of the now defined "all" property.
9093 JSObject *tmp = obj, *tmpProto;
9095 while ((tmpProto = ::JS_GetPrototype(cx, tmp)) != helper) {
9096 tmp = tmpProto;
9099 ::JS_SetPrototype(cx, tmp, proto);
9102 // If we don't already have a helper, and we're resolving
9103 // document.all qualified, and we're *not* detecting
9104 // document.all, e.g. if (document.all), and "all" isn't
9105 // already defined on our prototype, create a helper.
9106 if (!helper && flags & JSRESOLVE_QUALIFIED &&
9107 !(flags & JSRESOLVE_DETECTING) && !hasAll) {
9108 // Print a warning so developers can stop using document.all
9109 PrintWarningOnConsole(cx, "DocumentAllUsed");
9111 helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
9112 ::JS_GetPrototype(cx, obj),
9113 ::JS_GetGlobalForObject(cx, obj));
9115 if (!helper) {
9116 return NS_ERROR_OUT_OF_MEMORY;
9119 // Insert the helper into our prototype chain. helper's prototype
9120 // is already obj's current prototype.
9121 if (!::JS_SetPrototype(cx, obj, helper)) {
9122 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
9124 return NS_ERROR_UNEXPECTED;
9128 // If we have (or just created) a helper, pass the resolve flags
9129 // to the helper as its private data.
9130 if (helper && !::JS_SetPrivate(cx, helper, FlagsToPrivate(flags))) {
9131 nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
9133 return NS_ERROR_UNEXPECTED;
9137 return NS_OK;
9141 return nsDocumentSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
9144 NS_IMETHODIMP
9145 nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9146 JSContext *cx, JSObject *obj, jsid id,
9147 jsval *vp, PRBool *_retval)
9149 // For native wrappers, do not get random names on document
9150 if (!ObjectIsNativeWrapper(cx, obj)) {
9151 nsCOMPtr<nsISupports> result;
9153 JSAutoRequest ar(cx);
9155 nsWrapperCache *cache;
9156 nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result), &cache);
9157 NS_ENSURE_SUCCESS(rv, rv);
9159 if (result) {
9160 rv = WrapNative(cx, obj, result, cache, PR_TRUE, vp);
9161 if (NS_SUCCEEDED(rv)) {
9162 rv = NS_SUCCESS_I_DID_SOMETHING;
9164 return rv;
9168 return nsDocumentSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
9171 // HTMLFormElement helper
9173 // static
9174 nsresult
9175 nsHTMLFormElementSH::FindNamedItem(nsIForm *aForm, jsid id,
9176 nsISupports **aResult,
9177 nsWrapperCache **aCache)
9179 nsDependentJSString name(id);
9181 *aResult = aForm->ResolveName(name).get();
9182 // FIXME Get the wrapper cache from nsIForm::ResolveName
9183 *aCache = nsnull;
9185 if (!*aResult) {
9186 nsCOMPtr<nsIContent> content(do_QueryInterface(aForm));
9187 nsCOMPtr<nsIDOMHTMLFormElement> form_element(do_QueryInterface(aForm));
9189 nsCOMPtr<nsIHTMLDocument> html_doc =
9190 do_QueryInterface(content->GetDocument());
9192 if (html_doc && form_element) {
9193 html_doc->ResolveName(name, form_element, aResult, aCache);
9197 return NS_OK;
9200 NS_IMETHODIMP
9201 nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
9202 JSContext *cx, JSObject *obj, jsid id,
9203 PRUint32 flags, JSObject **objp,
9204 PRBool *_retval)
9206 // For native wrappers, do not resolve random names on form
9207 if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
9208 !ObjectIsNativeWrapper(cx, obj)) {
9209 nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9210 nsCOMPtr<nsISupports> result;
9211 nsWrapperCache *cache;
9213 FindNamedItem(form, id, getter_AddRefs(result), &cache);
9215 if (result) {
9216 JSAutoRequest ar(cx);
9217 *_retval = ::JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, nsnull,
9218 nsnull, JSPROP_ENUMERATE);
9220 *objp = obj;
9222 return *_retval ? NS_OK : NS_ERROR_FAILURE;
9226 return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
9230 NS_IMETHODIMP
9231 nsHTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9232 JSContext *cx, JSObject *obj, jsid id,
9233 jsval *vp, PRBool *_retval)
9235 nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9237 if (JSID_IS_STRING(id)) {
9238 // For native wrappers, do not get random names on form
9239 if (!ObjectIsNativeWrapper(cx, obj)) {
9240 nsCOMPtr<nsISupports> result;
9241 nsWrapperCache *cache;
9243 FindNamedItem(form, id, getter_AddRefs(result), &cache);
9245 if (result) {
9246 // Wrap result, result can be either an element or a list of
9247 // elements
9248 nsresult rv = WrapNative(cx, obj, result, cache, PR_TRUE, vp);
9249 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9252 } else {
9253 PRInt32 n = GetArrayIndexFromId(cx, id);
9255 if (n >= 0) {
9256 nsIFormControl* control = form->GetElementAt(n);
9258 if (control) {
9259 Element *element =
9260 static_cast<nsGenericHTMLFormElement*>(form->GetElementAt(n));
9261 nsresult rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), element,
9262 element, PR_TRUE, vp);
9263 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9268 return nsElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);;
9271 NS_IMETHODIMP
9272 nsHTMLFormElementSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
9273 JSContext *cx, JSObject *obj,
9274 PRUint32 enum_op, jsval *statep,
9275 jsid *idp, PRBool *_retval)
9277 switch (enum_op) {
9278 case JSENUMERATE_INIT:
9279 case JSENUMERATE_INIT_ALL:
9281 nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9283 if (!form) {
9284 *statep = JSVAL_NULL;
9285 return NS_ERROR_UNEXPECTED;
9288 *statep = INT_TO_JSVAL(0);
9290 if (idp) {
9291 PRUint32 count = form->GetElementCount();
9293 *idp = INT_TO_JSID(count);
9296 break;
9298 case JSENUMERATE_NEXT:
9300 nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
9301 NS_ENSURE_TRUE(form, NS_ERROR_FAILURE);
9303 PRInt32 index = (PRInt32)JSVAL_TO_INT(*statep);
9305 PRUint32 count = form->GetElementCount();
9307 if ((PRUint32)index < count) {
9308 nsIFormControl* controlNode = form->GetElementAt(index);
9309 NS_ENSURE_TRUE(controlNode, NS_ERROR_FAILURE);
9311 nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(controlNode);
9312 NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
9314 nsAutoString attr;
9315 domElement->GetAttribute(NS_LITERAL_STRING("name"), attr);
9316 if (attr.IsEmpty()) {
9317 // If name is not there, use index instead
9318 attr.AppendInt(index);
9321 JSAutoRequest ar(cx);
9323 JSString *jsname =
9324 JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
9325 (attr.get()),
9326 attr.Length());
9327 NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
9329 JS_ValueToId(cx, STRING_TO_JSVAL(jsname), idp);
9331 *statep = INT_TO_JSVAL(++index);
9332 } else {
9333 *statep = JSVAL_NULL;
9336 break;
9338 case JSENUMERATE_DESTROY:
9339 *statep = JSVAL_NULL;
9341 break;
9344 return NS_OK;
9348 // HTMLSelectElement helper
9350 NS_IMETHODIMP
9351 nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9352 JSContext *cx, JSObject *obj, jsid id,
9353 jsval *vp, PRBool *_retval)
9355 PRInt32 n = GetArrayIndexFromId(cx, id);
9357 nsresult rv = NS_OK;
9358 if (n >= 0) {
9359 nsHTMLSelectElement *s =
9360 nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
9362 nsHTMLOptionCollection *options = s->GetOptions();
9364 if (options) {
9365 nsISupports *node = options->GetNodeAt(n, &rv);
9367 rv = WrapNative(cx, JS_GetGlobalForScopeChain(cx), node,
9368 &NS_GET_IID(nsIDOMNode), PR_TRUE, vp);
9369 if (NS_SUCCEEDED(rv)) {
9370 rv = NS_SUCCESS_I_DID_SOMETHING;
9372 return rv;
9376 return nsElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);;
9379 // static
9380 nsresult
9381 nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
9382 nsIDOMNSHTMLOptionCollection *aOptCollection)
9384 JSAutoRequest ar(cx);
9386 // vp must refer to an object
9387 if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) {
9388 return NS_ERROR_UNEXPECTED;
9391 nsCOMPtr<nsIDOMHTMLOptionElement> new_option;
9393 if (!JSVAL_IS_NULL(*vp)) {
9394 new_option = do_QueryWrapper(cx, JSVAL_TO_OBJECT(*vp));
9395 if (!new_option) {
9396 // Someone is trying to set an option to a non-option object.
9398 return NS_ERROR_UNEXPECTED;
9402 return aOptCollection->SetOption(aIndex, new_option);
9405 NS_IMETHODIMP
9406 nsHTMLSelectElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
9407 JSContext *cx, JSObject *obj, jsid id,
9408 jsval *vp, PRBool *_retval)
9410 PRInt32 n = GetArrayIndexFromId(cx, id);
9412 if (n >= 0) {
9413 nsCOMPtr<nsIDOMHTMLSelectElement> select =
9414 do_QueryWrappedNative(wrapper, obj);
9415 NS_ENSURE_TRUE(select, NS_ERROR_UNEXPECTED);
9417 nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
9418 select->GetOptions(getter_AddRefs(options));
9420 nsCOMPtr<nsIDOMNSHTMLOptionCollection> oc(do_QueryInterface(options));
9421 NS_ENSURE_TRUE(oc, NS_ERROR_UNEXPECTED);
9423 nsresult rv = SetOption(cx, vp, n, oc);
9424 return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
9427 return nsElementSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
9431 // HTMLObject/EmbedElement helper
9433 // static
9434 nsresult
9435 nsHTMLPluginObjElementSH::GetPluginInstanceIfSafe(nsIXPConnectWrappedNative *wrapper,
9436 JSObject *obj,
9437 nsIPluginInstance **_result)
9439 *_result = nsnull;
9441 nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper, obj));
9442 NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
9444 nsCOMPtr<nsIObjectLoadingContent> objlc(do_QueryInterface(content));
9445 NS_ASSERTION(objlc, "Object nodes must implement nsIObjectLoadingContent");
9447 // If it's not safe to run script we'll only return the instance if it
9448 // exists.
9449 if (!nsContentUtils::IsSafeToRunScript()) {
9450 return objlc->GetPluginInstance(_result);
9453 // Make sure that there is a plugin
9454 return objlc->EnsureInstantiation(_result);
9457 // Check if proto is already in obj's prototype chain.
9459 static PRBool
9460 IsObjInProtoChain(JSContext *cx, JSObject *obj, JSObject *proto)
9462 JSObject *o = obj;
9464 JSAutoRequest ar(cx);
9466 while (o) {
9467 JSObject *p = ::JS_GetPrototype(cx, o);
9469 if (p == proto) {
9470 return PR_TRUE;
9473 o = p;
9476 return PR_FALSE;
9479 class nsPluginProtoChainInstallRunner : public nsIRunnable
9481 public:
9482 NS_DECL_ISUPPORTS
9484 nsPluginProtoChainInstallRunner(nsIXPConnectWrappedNative* wrapper,
9485 nsIScriptContext* scriptContext)
9486 : mWrapper(wrapper),
9487 mContext(scriptContext)
9491 NS_IMETHOD Run()
9493 JSContext* cx = nsnull;
9494 if (mContext) {
9495 cx = (JSContext*)mContext->GetNativeContext();
9496 } else {
9497 nsCOMPtr<nsIThreadJSContextStack> stack =
9498 do_GetService("@mozilla.org/js/xpc/ContextStack;1");
9499 NS_ENSURE_TRUE(stack, NS_OK);
9501 stack->GetSafeJSContext(&cx);
9502 NS_ENSURE_TRUE(cx, NS_OK);
9505 JSObject* obj = nsnull;
9506 mWrapper->GetJSObject(&obj);
9507 NS_ASSERTION(obj, "Should never be null");
9508 nsHTMLPluginObjElementSH::SetupProtoChain(mWrapper, cx, obj);
9509 return NS_OK;
9512 private:
9513 nsCOMPtr<nsIXPConnectWrappedNative> mWrapper;
9514 nsCOMPtr<nsIScriptContext> mContext;
9517 NS_IMPL_ISUPPORTS1(nsPluginProtoChainInstallRunner, nsIRunnable)
9519 // static
9520 nsresult
9521 nsHTMLPluginObjElementSH::SetupProtoChain(nsIXPConnectWrappedNative *wrapper,
9522 JSContext *cx,
9523 JSObject *obj)
9525 NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
9526 "Shouldn't have gotten in here");
9528 nsCxPusher cxPusher;
9529 if (!cxPusher.Push(cx)) {
9530 return NS_OK;
9533 JSAutoRequest ar(cx);
9535 JSAutoEnterCompartment ac;
9536 if (!ac.enter(cx, obj)) {
9537 return NS_ERROR_UNEXPECTED;
9540 nsCOMPtr<nsIPluginInstance> pi;
9541 nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9542 NS_ENSURE_SUCCESS(rv, rv);
9544 if (!pi) {
9545 // No plugin around for this object.
9547 return NS_OK;
9550 JSObject *pi_obj = nsnull; // XPConnect-wrapped peer object, when we get it.
9551 JSObject *pi_proto = nsnull; // 'pi.__proto__'
9553 rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
9554 NS_ENSURE_SUCCESS(rv, rv);
9556 if (!pi_obj) {
9557 // Didn't get a plugin instance JSObject, nothing we can do then.
9559 return NS_OK;
9562 if (IsObjInProtoChain(cx, obj, pi_obj)) {
9563 // We must have re-entered ::PostCreate() from nsObjectFrame()
9564 // (through the EnsureInstantiation() call in
9565 // GetPluginInstanceIfSafe()), this means that we've already done what
9566 // we're about to do in this function so we can just return here.
9568 return NS_OK;
9572 // If we got an xpconnect-wrapped plugin object, set obj's
9573 // prototype's prototype to the scriptable plugin.
9575 JSObject *my_proto = nsnull;
9577 // Get 'this.__proto__'
9578 rv = wrapper->GetJSObjectPrototype(&my_proto);
9579 NS_ENSURE_SUCCESS(rv, rv);
9581 // Set 'this.__proto__' to pi
9582 if (!::JS_SetPrototype(cx, obj, pi_obj)) {
9583 return NS_ERROR_UNEXPECTED;
9586 if (pi_proto && JS_GET_CLASS(cx, pi_proto) != sObjectClass) {
9587 // The plugin wrapper has a proto that's not Object.prototype, set
9588 // 'pi.__proto__.__proto__' to the original 'this.__proto__'
9589 if (pi_proto != my_proto && !::JS_SetPrototype(cx, pi_proto, my_proto)) {
9590 return NS_ERROR_UNEXPECTED;
9592 } else {
9593 // 'pi' didn't have a prototype, or pi's proto was
9594 // 'Object.prototype' (i.e. pi is an NPRuntime wrapped JS object)
9595 // set 'pi.__proto__' to the original 'this.__proto__'
9596 if (!::JS_SetPrototype(cx, pi_obj, my_proto)) {
9597 return NS_ERROR_UNEXPECTED;
9601 // Before this proto dance the objects involved looked like this:
9603 // this.__proto__.__proto__
9604 // ^ ^ ^
9605 // | | |__ Object.prototype
9606 // | |
9607 // | |__ xpc embed wrapper proto (shared)
9608 // |
9609 // |__ xpc wrapped native embed node
9611 // pi.__proto__
9612 // ^ ^
9613 // | |__ Object.prototype
9614 // |
9615 // |__ Plugin NPRuntime JS object wrapper
9617 // Now, after the above prototype setup the prototype chain should
9618 // look like this:
9620 // this.__proto__.__proto__.__proto__
9621 // ^ ^ ^ ^
9622 // | | | |__ Object.prototype
9623 // | | |
9624 // | | |__ xpc embed wrapper proto (shared)
9625 // | |
9626 // | |__ Plugin NPRuntime JS object wrapper
9627 // |
9628 // |__ xpc wrapped native embed node
9631 return NS_OK;
9634 NS_IMETHODIMP
9635 nsHTMLPluginObjElementSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
9636 JSObject *globalObj, JSObject **parentObj)
9638 nsresult rv = nsElementSH::PreCreate(nativeObj, cx, globalObj, parentObj);
9640 // For now we don't support slim wrappers for plugins.
9641 return rv == NS_SUCCESS_ALLOW_SLIM_WRAPPERS ? NS_OK : rv;
9644 NS_IMETHODIMP
9645 nsHTMLPluginObjElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper,
9646 JSContext *cx, JSObject *obj)
9648 if (nsContentUtils::IsSafeToRunScript()) {
9649 #ifdef DEBUG
9650 nsresult rv =
9651 #endif
9652 SetupProtoChain(wrapper, cx, obj);
9654 // If SetupProtoChain failed then we're in real trouble. We're about to fail
9655 // PostCreate but it's more than likely that we handed our (now invalid)
9656 // wrapper to someone already. Bug 429442 is an example of the kind of crash
9657 // that can result from such a situation. We'll return NS_OK for the time
9658 // being and hope for the best.
9659 NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "SetupProtoChain failed!");
9660 return NS_OK;
9663 // This may be null if the JS context is not a DOM context. That's ok, we'll
9664 // use the safe context from XPConnect in the runnable.
9665 nsCOMPtr<nsIScriptContext> scriptContext = GetScriptContextFromJSContext(cx);
9667 nsRefPtr<nsPluginProtoChainInstallRunner> runner =
9668 new nsPluginProtoChainInstallRunner(wrapper, scriptContext);
9669 nsContentUtils::AddScriptRunner(runner);
9671 return NS_OK;
9674 NS_IMETHODIMP
9675 nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
9676 JSContext *cx, JSObject *obj, jsid id,
9677 jsval *vp, PRBool *_retval)
9679 JSAutoRequest ar(cx);
9681 JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
9682 if (NS_UNLIKELY(!pi_obj)) {
9683 return NS_OK;
9686 JSBool found = PR_FALSE;
9688 if (!ObjectIsNativeWrapper(cx, obj)) {
9689 if (JSID_IS_STRING(id)) {
9690 *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
9691 } else {
9692 *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found);
9695 if (!*_retval) {
9696 return NS_ERROR_UNEXPECTED;
9700 if (found) {
9701 if (JSID_IS_STRING(id)) {
9702 *_retval = ::JS_GetPropertyById(cx, pi_obj, id, vp);
9703 } else {
9704 *_retval = ::JS_GetElement(cx, pi_obj, JSID_TO_INT(id), vp);
9707 return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
9710 return nsElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
9713 NS_IMETHODIMP
9714 nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
9715 JSContext *cx, JSObject *obj, jsid id,
9716 jsval *vp, PRBool *_retval)
9718 JSAutoRequest ar(cx);
9720 JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
9721 if (NS_UNLIKELY(!pi_obj)) {
9722 return NS_OK;
9725 JSBool found = PR_FALSE;
9727 if (!ObjectIsNativeWrapper(cx, obj)) {
9728 if (JSID_IS_STRING(id)) {
9729 *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
9730 } else {
9731 *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found);
9734 if (!*_retval) {
9735 return NS_ERROR_UNEXPECTED;
9739 if (found) {
9740 if (JSID_IS_STRING(id)) {
9741 *_retval = ::JS_SetPropertyById(cx, pi_obj, id, vp);
9742 } else {
9743 *_retval = ::JS_SetElement(cx, pi_obj, JSID_TO_INT(id), vp);
9746 return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
9749 return nsElementSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
9752 NS_IMETHODIMP
9753 nsHTMLPluginObjElementSH::Call(nsIXPConnectWrappedNative *wrapper,
9754 JSContext *cx, JSObject *obj, PRUint32 argc,
9755 jsval *argv, jsval *vp, PRBool *_retval)
9757 nsCOMPtr<nsIPluginInstance> pi;
9758 nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9759 NS_ENSURE_SUCCESS(rv, rv);
9761 // If obj is a native wrapper, or if there's no plugin around for
9762 // this object, throw.
9763 if (ObjectIsNativeWrapper(cx, obj) || !pi) {
9764 return NS_ERROR_NOT_AVAILABLE;
9767 JSObject *pi_obj = nsnull;
9768 JSObject *pi_proto = nsnull;
9770 rv = GetPluginJSObject(cx, obj, pi, &pi_obj, &pi_proto);
9771 NS_ENSURE_SUCCESS(rv, rv);
9773 if (!pi) {
9774 return NS_ERROR_NOT_AVAILABLE;
9777 // XPConnect passes us the XPConnect wrapper JSObject as obj, and
9778 // not the 'this' parameter that the JS engine passes in. Pass in
9779 // the real this parameter from JS (argv[-1]) here.
9780 JSAutoRequest ar(cx);
9781 *_retval = ::JS::Call(cx, argv[-1], pi_obj, argc, argv, vp);
9783 return NS_OK;
9787 nsresult
9788 nsHTMLPluginObjElementSH::GetPluginJSObject(JSContext *cx, JSObject *obj,
9789 nsIPluginInstance *plugin_inst,
9790 JSObject **plugin_obj,
9791 JSObject **plugin_proto)
9793 *plugin_obj = nsnull;
9794 *plugin_proto = nsnull;
9796 JSAutoRequest ar(cx);
9798 // NB: We need an AutoEnterCompartment because we can be called from
9799 // nsObjectFrame when the plugin loads after the JS object for our content
9800 // node has been created.
9801 JSAutoEnterCompartment ac;
9802 if (!ac.enter(cx, obj)) {
9803 return NS_ERROR_UNEXPECTED;
9806 if (plugin_inst) {
9807 plugin_inst->GetJSObject(cx, plugin_obj);
9808 if (*plugin_obj) {
9809 *plugin_proto = ::JS_GetPrototype(cx, *plugin_obj);
9813 return NS_OK;
9816 NS_IMETHODIMP
9817 nsHTMLPluginObjElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
9818 JSContext *cx, JSObject *obj, jsid id,
9819 PRUint32 flags, JSObject **objp,
9820 PRBool *_retval)
9822 // Make sure the plugin instance is loaded and instantiated, if
9823 // possible.
9825 nsCOMPtr<nsIPluginInstance> pi;
9826 nsresult rv = GetPluginInstanceIfSafe(wrapper, obj, getter_AddRefs(pi));
9827 NS_ENSURE_SUCCESS(rv, rv);
9829 return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp,
9830 _retval);
9833 // HTMLOptionsCollection helper
9835 NS_IMETHODIMP
9836 nsHTMLOptionsCollectionSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
9837 JSContext *cx, JSObject *obj, jsid id,
9838 jsval *vp, PRBool *_retval)
9840 PRInt32 n = GetArrayIndexFromId(cx, id);
9842 if (n < 0) {
9843 return NS_OK;
9846 nsCOMPtr<nsIDOMNSHTMLOptionCollection> oc =
9847 do_QueryWrappedNative(wrapper, obj);
9848 NS_ENSURE_TRUE(oc, NS_ERROR_UNEXPECTED);
9850 nsresult rv = nsHTMLSelectElementSH::SetOption(cx, vp, n, oc);
9851 if (NS_SUCCEEDED(rv)) {
9852 rv = NS_SUCCESS_I_DID_SOMETHING;
9854 return rv;
9858 // Plugin helper
9860 nsISupports*
9861 nsPluginSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9862 nsWrapperCache **aCache, nsresult *aResult)
9864 nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
9866 return plugin->GetItemAt(aIndex, aResult);
9869 nsISupports*
9870 nsPluginSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9871 nsWrapperCache **aCache, nsresult *aResult)
9873 nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
9875 return plugin->GetNamedItem(aName, aResult);
9879 // PluginArray helper
9881 nsISupports*
9882 nsPluginArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9883 nsWrapperCache **aCache, nsresult *aResult)
9885 nsPluginArray* array = nsPluginArray::FromSupports(aNative);
9887 return array->GetItemAt(aIndex, aResult);
9890 nsISupports*
9891 nsPluginArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9892 nsWrapperCache **aCache, nsresult *aResult)
9894 nsPluginArray* array = nsPluginArray::FromSupports(aNative);
9896 return array->GetNamedItem(aName, aResult);
9900 // MimeTypeArray helper
9902 nsISupports*
9903 nsMimeTypeArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
9904 nsWrapperCache **aCache, nsresult *aResult)
9906 nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
9908 return array->GetItemAt(aIndex, aResult);
9911 nsISupports*
9912 nsMimeTypeArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
9913 nsWrapperCache **aCache, nsresult *aResult)
9915 nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
9917 return array->GetNamedItem(aName, aResult);
9921 // StringArray helper
9923 NS_IMETHODIMP
9924 nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9925 JSObject *obj, jsid id, jsval *vp,
9926 PRBool *_retval)
9928 PRBool is_number = PR_FALSE;
9929 PRInt32 n = GetArrayIndexFromId(cx, id, &is_number);
9931 if (!is_number) {
9932 return NS_OK;
9935 nsAutoString val;
9937 nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
9938 NS_ENSURE_SUCCESS(rv, rv);
9940 // XXX: Null strings?
9942 JSAutoRequest ar(cx);
9944 JSString *str =
9945 ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(val.get()),
9946 val.Length());
9947 NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
9949 *vp = STRING_TO_JSVAL(str);
9951 return NS_SUCCESS_I_DID_SOMETHING;
9955 // History helper
9957 NS_IMETHODIMP
9958 nsHistorySH::PreCreate(nsISupports *nativeObj, JSContext *cx,
9959 JSObject *globalObj, JSObject **parentObj)
9961 nsHistory *history = (nsHistory *)nativeObj;
9962 nsCOMPtr<nsPIDOMWindow> innerWindow;
9963 history->GetWindow(getter_AddRefs(innerWindow));
9964 if (!innerWindow) {
9965 NS_WARNING("refusing to create history object in the wrong scope");
9966 return NS_ERROR_FAILURE;
9969 *parentObj = static_cast<nsGlobalWindow *>(innerWindow.get())->FastGetGlobalJSObject();
9970 return NS_OK;
9973 NS_IMETHODIMP
9974 nsHistorySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
9975 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
9977 PRBool is_number = PR_FALSE;
9978 GetArrayIndexFromId(cx, id, &is_number);
9980 if (!is_number) {
9981 return NS_OK;
9984 return nsStringArraySH::GetProperty(wrapper, cx, obj, id, vp, _retval);
9987 nsresult
9988 nsHistorySH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
9989 nsAString& aResult)
9991 if (aIndex < 0) {
9992 return NS_ERROR_DOM_INDEX_SIZE_ERR;
9995 nsCOMPtr<nsIDOMHistory> history(do_QueryInterface(aNative));
9997 return history->Item(aIndex, aResult);
10001 // MediaList helper
10003 nsresult
10004 nsMediaListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10005 nsAString& aResult)
10007 if (aIndex < 0) {
10008 return NS_ERROR_DOM_INDEX_SIZE_ERR;
10011 nsCOMPtr<nsIDOMMediaList> media_list(do_QueryInterface(aNative));
10013 return media_list->Item(PRUint32(aIndex), aResult);
10017 // StyleSheetList helper
10019 nsISupports*
10020 nsStyleSheetListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10021 nsWrapperCache **aCache, nsresult *rv)
10023 nsDOMStyleSheetList* list = nsDOMStyleSheetList::FromSupports(aNative);
10025 return list->GetItemAt(aIndex);
10029 // CSSValueList helper
10031 nsISupports*
10032 nsCSSValueListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10033 nsWrapperCache **aCache, nsresult *aResult)
10035 nsDOMCSSValueList* list = nsDOMCSSValueList::FromSupports(aNative);
10037 return list->GetItemAt(aIndex);
10041 // CSSStyleDeclaration helper
10043 NS_IMETHODIMP
10044 nsCSSStyleDeclSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
10045 JSObject *globalObj, JSObject **parentObj)
10047 nsWrapperCache* cache = nsnull;
10048 CallQueryInterface(nativeObj, &cache);
10049 if (!cache) {
10050 return nsDOMClassInfo::PreCreate(nativeObj, cx, globalObj, parentObj);
10053 nsICSSDeclaration *declaration = static_cast<nsICSSDeclaration*>(nativeObj);
10054 nsINode *native_parent = declaration->GetParentObject();
10055 if (!native_parent) {
10056 return NS_ERROR_FAILURE;
10059 nsresult rv =
10060 WrapNativeParent(cx, globalObj, native_parent, native_parent, parentObj);
10061 NS_ENSURE_SUCCESS(rv, rv);
10063 return NS_SUCCESS_ALLOW_SLIM_WRAPPERS;
10066 nsresult
10067 nsCSSStyleDeclSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10068 nsAString& aResult)
10070 if (aIndex < 0) {
10071 return NS_ERROR_DOM_INDEX_SIZE_ERR;
10074 nsCOMPtr<nsIDOMCSSStyleDeclaration> style_decl(do_QueryInterface(aNative));
10076 return style_decl->Item(PRUint32(aIndex), aResult);
10080 // CSSRuleList scriptable helper
10082 nsISupports*
10083 nsCSSRuleListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10084 nsWrapperCache **aCache, nsresult *aResult)
10086 nsICSSRuleList* list = static_cast<nsICSSRuleList*>(aNative);
10087 #ifdef DEBUG
10089 nsCOMPtr<nsICSSRuleList> list_qi = do_QueryInterface(aNative);
10091 // If this assertion fires the QI implementation for the object in
10092 // question doesn't use the nsICSSRuleList pointer as the nsISupports
10093 // pointer. That must be fixed, or we'll crash...
10094 NS_ASSERTION(list_qi == list, "Uh, fix QI!");
10096 #endif
10098 return list->GetItemAt(aIndex, aResult);
10101 // ClientRectList scriptable helper
10103 nsISupports*
10104 nsClientRectListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10105 nsWrapperCache **aCache, nsresult *aResult)
10107 nsClientRectList* list = nsClientRectList::FromSupports(aNative);
10109 return list->GetItemAt(aIndex);
10112 // PaintRequestList scriptable helper
10114 nsISupports*
10115 nsPaintRequestListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10116 nsWrapperCache **aCache, nsresult *aResult)
10118 nsPaintRequestList* list = nsPaintRequestList::FromSupports(aNative);
10120 return list->GetItemAt(aIndex);
10123 #ifdef MOZ_XUL
10124 // TreeColumns helper
10126 nsISupports*
10127 nsTreeColumnsSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10128 nsWrapperCache **aCache, nsresult *aResult)
10130 nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
10132 return columns->GetColumnAt(aIndex);
10135 nsISupports*
10136 nsTreeColumnsSH::GetNamedItem(nsISupports *aNative,
10137 const nsAString& aName,
10138 nsWrapperCache **aCache,
10139 nsresult *aResult)
10141 nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
10143 return columns->GetNamedColumn(aName);
10145 #endif
10148 // Storage scriptable helper
10150 // One reason we need a newResolve hook is that in order for
10151 // enumeration of storage object keys to work the keys we're
10152 // enumerating need to exist on the storage object for the JS engine
10153 // to find them.
10155 NS_IMETHODIMP
10156 nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10157 JSObject *obj, jsid id, PRUint32 flags,
10158 JSObject **objp, PRBool *_retval)
10160 if (ObjectIsNativeWrapper(cx, obj)) {
10161 return NS_OK;
10164 JSObject *realObj;
10165 wrapper->GetJSObject(&realObj);
10167 JSAutoEnterCompartment ac;
10168 if (!ac.enter(cx, realObj)) {
10169 *_retval = PR_FALSE;
10170 return NS_ERROR_FAILURE;
10173 // First check to see if the property is defined on our prototype.
10175 JSObject *proto = ::JS_GetPrototype(cx, realObj);
10176 JSBool hasProp;
10178 if (proto &&
10179 (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
10180 hasProp)) {
10181 // We found the property we're resolving on the prototype,
10182 // nothing left to do here then.
10184 return NS_OK;
10187 // We're resolving property that doesn't exist on the prototype,
10188 // check if the key exists in the storage object.
10190 nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10192 JSString *jsstr = IdToString(cx, id);
10193 if (!jsstr)
10194 return JS_FALSE;
10196 nsDependentJSString depStr;
10197 if (!depStr.init(cx, jsstr))
10198 return JS_FALSE;
10200 // GetItem() will return null if the caller can't access the session
10201 // storage item.
10202 nsCOMPtr<nsIDOMStorageItem> item;
10203 nsresult rv = storage->GetItem(depStr, getter_AddRefs(item));
10204 NS_ENSURE_SUCCESS(rv, rv);
10206 if (item) {
10207 if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull, nsnull,
10208 JSPROP_ENUMERATE)) {
10209 return NS_ERROR_FAILURE;
10212 *objp = realObj;
10215 return NS_OK;
10218 nsISupports*
10219 nsStorageSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
10220 nsWrapperCache **aCache, nsresult *aResult)
10222 nsDOMStorage* storage = nsDOMStorage::FromSupports(aNative);
10224 return storage->GetNamedItem(aName, aResult);
10227 NS_IMETHODIMP
10228 nsStorageSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
10229 JSContext *cx, JSObject *obj, jsid id,
10230 jsval *vp, PRBool *_retval)
10232 nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10233 NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10235 JSString *key = IdToString(cx, id);
10236 NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10238 nsDependentJSString keyStr;
10239 NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10241 JSString *value = ::JS_ValueToString(cx, *vp);
10242 NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
10244 nsDependentJSString valueStr;
10245 NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
10247 nsresult rv = storage->SetItem(keyStr, valueStr);
10248 if (NS_SUCCEEDED(rv)) {
10249 rv = NS_SUCCESS_I_DID_SOMETHING;
10252 return rv;
10255 NS_IMETHODIMP
10256 nsStorageSH::DelProperty(nsIXPConnectWrappedNative *wrapper,
10257 JSContext *cx, JSObject *obj, jsid id,
10258 jsval *vp, PRBool *_retval)
10260 nsCOMPtr<nsIDOMStorageObsolete> storage(do_QueryWrappedNative(wrapper));
10261 NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10263 JSString *key = IdToString(cx, id);
10264 NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10266 nsDependentJSString keyStr;
10267 NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10269 nsresult rv = storage->RemoveItem(keyStr);
10270 if (NS_SUCCEEDED(rv)) {
10271 rv = NS_SUCCESS_I_DID_SOMETHING;
10274 return rv;
10278 NS_IMETHODIMP
10279 nsStorageSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10280 JSObject *obj, PRUint32 enum_op, jsval *statep,
10281 jsid *idp, PRBool *_retval)
10283 if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
10284 nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10286 // XXXndeakin need to free the keys afterwards
10287 nsTArray<nsString> *keys = storage->GetKeys();
10288 NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
10290 *statep = PRIVATE_TO_JSVAL(keys);
10292 if (idp) {
10293 *idp = INT_TO_JSID(keys->Length());
10295 return NS_OK;
10298 nsTArray<nsString> *keys =
10299 (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
10301 if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
10302 nsString& key = keys->ElementAt(0);
10303 JSString *str =
10304 JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
10305 (key.get()),
10306 key.Length());
10307 NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10309 JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
10311 keys->RemoveElementAt(0);
10313 return NS_OK;
10316 // destroy the keys array if we have no keys or if we're done
10317 NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
10318 (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
10319 "Bad call from the JS engine");
10320 delete keys;
10322 *statep = JSVAL_NULL;
10324 return NS_OK;
10328 // Storage2SH
10330 // One reason we need a newResolve hook is that in order for
10331 // enumeration of storage object keys to work the keys we're
10332 // enumerating need to exist on the storage object for the JS engine
10333 // to find them.
10335 NS_IMETHODIMP
10336 nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10337 JSObject *obj, jsid id, PRUint32 flags,
10338 JSObject **objp, PRBool *_retval)
10340 if (ObjectIsNativeWrapper(cx, obj)) {
10341 return NS_OK;
10344 JSObject *realObj;
10345 wrapper->GetJSObject(&realObj);
10347 JSAutoEnterCompartment ac;
10348 if (!ac.enter(cx, realObj)) {
10349 *_retval = PR_FALSE;
10350 return NS_ERROR_FAILURE;
10353 // First check to see if the property is defined on our prototype,
10354 // after converting id to a string if it's an integer.
10356 JSString *jsstr = IdToString(cx, id);
10357 if (!jsstr) {
10358 return JS_FALSE;
10361 JSObject *proto = ::JS_GetPrototype(cx, realObj);
10362 JSBool hasProp;
10364 if (proto &&
10365 (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
10366 hasProp)) {
10367 // We found the property we're resolving on the prototype,
10368 // nothing left to do here then.
10370 return NS_OK;
10373 // We're resolving property that doesn't exist on the prototype,
10374 // check if the key exists in the storage object.
10376 nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10378 nsDependentJSString depStr;
10379 NS_ENSURE_TRUE(depStr.init(cx, jsstr), NS_ERROR_UNEXPECTED);
10381 // GetItem() will return null if the caller can't access the session
10382 // storage item.
10383 nsAutoString data;
10384 nsresult rv = storage->GetItem(depStr, data);
10385 NS_ENSURE_SUCCESS(rv, rv);
10387 if (!DOMStringIsNull(data)) {
10388 if (!::JS_DefinePropertyById(cx, realObj, id, JSVAL_VOID, nsnull,
10389 nsnull, JSPROP_ENUMERATE)) {
10390 return NS_ERROR_FAILURE;
10393 *objp = realObj;
10396 return NS_OK;
10399 NS_IMETHODIMP
10400 nsStorage2SH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10401 JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
10403 nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10404 NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10406 nsAutoString val;
10407 nsresult rv = NS_OK;
10409 if (JSID_IS_STRING(id)) {
10410 // For native wrappers, do not get random names on storage objects.
10411 if (ObjectIsNativeWrapper(cx, obj)) {
10412 return NS_ERROR_NOT_AVAILABLE;
10415 rv = storage->GetItem(nsDependentJSString(id), val);
10416 NS_ENSURE_SUCCESS(rv, rv);
10417 } else {
10418 PRInt32 n = GetArrayIndexFromId(cx, id);
10419 NS_ENSURE_TRUE(n >= 0, NS_ERROR_NOT_AVAILABLE);
10421 rv = storage->Key(n, val);
10422 NS_ENSURE_SUCCESS(rv, rv);
10425 JSAutoRequest ar(cx);
10427 if (DOMStringIsNull(val)) {
10428 *vp = JSVAL_NULL;
10430 else {
10431 JSString *str =
10432 ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(val.get()),
10433 val.Length());
10434 NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10436 *vp = STRING_TO_JSVAL(str);
10439 return NS_SUCCESS_I_DID_SOMETHING;
10442 NS_IMETHODIMP
10443 nsStorage2SH::SetProperty(nsIXPConnectWrappedNative *wrapper,
10444 JSContext *cx, JSObject *obj, jsid id,
10445 jsval *vp, PRBool *_retval)
10447 nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10448 NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10450 JSString *key = IdToString(cx, id);
10451 NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10453 nsDependentJSString keyStr;
10454 NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10456 JSString *value = ::JS_ValueToString(cx, *vp);
10457 NS_ENSURE_TRUE(value, NS_ERROR_UNEXPECTED);
10459 nsDependentJSString valueStr;
10460 NS_ENSURE_TRUE(valueStr.init(cx, value), NS_ERROR_UNEXPECTED);
10462 nsresult rv = storage->SetItem(keyStr, valueStr);
10463 if (NS_SUCCEEDED(rv)) {
10464 rv = NS_SUCCESS_I_DID_SOMETHING;
10467 return rv;
10470 NS_IMETHODIMP
10471 nsStorage2SH::DelProperty(nsIXPConnectWrappedNative *wrapper,
10472 JSContext *cx, JSObject *obj, jsid id,
10473 jsval *vp, PRBool *_retval)
10475 nsCOMPtr<nsIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10476 NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
10478 JSString *key = IdToString(cx, id);
10479 NS_ENSURE_TRUE(key, NS_ERROR_UNEXPECTED);
10481 nsDependentJSString keyStr;
10482 NS_ENSURE_TRUE(keyStr.init(cx, key), NS_ERROR_UNEXPECTED);
10484 nsresult rv = storage->RemoveItem(keyStr);
10485 if (NS_SUCCEEDED(rv)) {
10486 rv = NS_SUCCESS_I_DID_SOMETHING;
10489 return rv;
10493 NS_IMETHODIMP
10494 nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10495 JSObject *obj, PRUint32 enum_op, jsval *statep,
10496 jsid *idp, PRBool *_retval)
10498 if (enum_op == JSENUMERATE_INIT || enum_op == JSENUMERATE_INIT_ALL) {
10499 nsCOMPtr<nsPIDOMStorage> storage(do_QueryWrappedNative(wrapper));
10501 // XXXndeakin need to free the keys afterwards
10502 nsTArray<nsString> *keys = storage->GetKeys();
10503 NS_ENSURE_TRUE(keys, NS_ERROR_OUT_OF_MEMORY);
10505 *statep = PRIVATE_TO_JSVAL(keys);
10507 if (idp) {
10508 *idp = INT_TO_JSID(keys->Length());
10510 return NS_OK;
10513 nsTArray<nsString> *keys =
10514 (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
10516 if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
10517 nsString& key = keys->ElementAt(0);
10518 JSString *str =
10519 JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
10520 (key.get()),
10521 key.Length());
10522 NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
10524 JS_ValueToId(cx, STRING_TO_JSVAL(str), idp);
10526 keys->RemoveElementAt(0);
10528 return NS_OK;
10531 // destroy the keys array if we have no keys or if we're done
10532 NS_ABORT_IF_FALSE(enum_op == JSENUMERATE_DESTROY ||
10533 (enum_op == JSENUMERATE_NEXT && keys->Length() == 0),
10534 "Bad call from the JS engine");
10535 delete keys;
10537 *statep = JSVAL_NULL;
10539 return NS_OK;
10542 // StorageList scriptable helper
10544 nsISupports*
10545 nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
10546 nsWrapperCache **aCache, nsresult *aResult)
10548 nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
10550 return storagelist->GetNamedItem(aName, aResult);
10554 // nsIDOMEventListener::HandleEvent() 'this' converter helper
10556 NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
10557 NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
10558 NS_INTERFACE_MAP_ENTRY(nsISupports)
10559 NS_INTERFACE_MAP_END
10562 NS_IMPL_ADDREF(nsEventListenerThisTranslator)
10563 NS_IMPL_RELEASE(nsEventListenerThisTranslator)
10566 NS_IMETHODIMP
10567 nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
10568 nsIInterfaceInfo *aInterfaceInfo,
10569 PRUint16 aMethodIndex,
10570 PRBool *aHideFirstParamFromJS,
10571 nsIID * *aIIDOfResult,
10572 nsISupports **_retval)
10574 *aHideFirstParamFromJS = PR_FALSE;
10575 *aIIDOfResult = nsnull;
10577 nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
10578 NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
10580 nsCOMPtr<nsIDOMEventTarget> target;
10581 event->GetCurrentTarget(getter_AddRefs(target));
10583 *_retval = target.forget().get();
10585 return NS_OK;
10588 NS_IMETHODIMP
10589 nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
10590 JSObject *globalObj, JSObject **parentObj)
10592 nsDOMConstructor *wrapped = static_cast<nsDOMConstructor *>(nativeObj);
10594 #ifdef DEBUG
10596 nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10597 do_QueryInterface(nativeObj);
10598 NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10600 #endif
10602 return wrapped->PreCreate(cx, globalObj, parentObj);
10605 NS_IMETHODIMP
10606 nsDOMConstructorSH::Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10607 JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
10608 PRBool *_retval)
10610 nsDOMConstructor *wrapped =
10611 static_cast<nsDOMConstructor *>(wrapper->Native());
10613 #ifdef DEBUG
10615 nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10616 do_QueryWrappedNative(wrapper);
10617 NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10619 #endif
10621 return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
10624 NS_IMETHODIMP
10625 nsDOMConstructorSH::Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
10626 JSObject *obj, PRUint32 argc, jsval *argv,
10627 jsval *vp, PRBool *_retval)
10629 nsDOMConstructor *wrapped =
10630 static_cast<nsDOMConstructor *>(wrapper->Native());
10632 #ifdef DEBUG
10634 nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10635 do_QueryWrappedNative(wrapper);
10636 NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10638 #endif
10640 return wrapped->Construct(wrapper, cx, obj, argc, argv, vp, _retval);
10643 NS_IMETHODIMP
10644 nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
10645 JSContext *cx, JSObject *obj, const jsval &val,
10646 PRBool *bp, PRBool *_retval)
10648 nsDOMConstructor *wrapped =
10649 static_cast<nsDOMConstructor *>(wrapper->Native());
10651 #ifdef DEBUG
10653 nsCOMPtr<nsIDOMDOMConstructor> is_constructor =
10654 do_QueryWrappedNative(wrapper);
10655 NS_ASSERTION(is_constructor, "How did we not get a constructor?");
10657 #endif
10659 return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
10662 NS_IMETHODIMP
10663 nsNonDOMObjectSH::GetFlags(PRUint32 *aFlags)
10665 // This is NOT a DOM Object. Use this helper class for cases when you need
10666 // to do something like implement nsISecurityCheckedComponent in a meaningful
10667 // way.
10668 *aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
10669 return NS_OK;
10672 NS_IMETHODIMP
10673 nsAttributeSH::GetFlags(PRUint32 *aFlags)
10675 // Just like nsNodeSH, but without CONTENT_NODE
10676 *aFlags = DOMCLASSINFO_STANDARD_FLAGS;
10678 return NS_OK;
10681 // nsOfflineResourceListSH
10682 nsresult
10683 nsOfflineResourceListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
10684 nsAString& aResult)
10686 nsCOMPtr<nsIDOMOfflineResourceList> list(do_QueryInterface(aNative));
10687 NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
10689 return list->MozItem(aIndex, aResult);
10692 // nsFileListSH
10693 nsISupports*
10694 nsFileListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
10695 nsWrapperCache **aCache, nsresult *aResult)
10697 nsDOMFileList* list = nsDOMFileList::FromSupports(aNative);
10699 return list->GetItemAt(aIndex);