Part 13 of fix for bug 560273 (Stop using DOM tearoffs from quickstubs) - stop using tearoffs from quickstubs for nsIDOM3Node, nsIDOM3Text, nsIDOMNodeSelector and nsIDOMNSElement. r=jst.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 19 Apr 2010 17:41:38 +0200
changeset 41912 00955067e4b5571c905fcee2ad1a2524dbd02ed8
parent 41911 74e30687716128727b0a06f5fd4c34028f3d5490
child 41913 2c98eeb202b9bd5e3bd2b7a5399d2d019d88d20c
push id13135
push userpvanderbeken@mozilla.com
push dateWed, 05 May 2010 11:49:27 +0000
treeherdermozilla-central@00955067e4b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs560273
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Part 13 of fix for bug 560273 (Stop using DOM tearoffs from quickstubs) - stop using tearoffs from quickstubs for nsIDOM3Node, nsIDOM3Text, nsIDOMNodeSelector and nsIDOMNSElement. r=jst.
dom/base/nsDOMClassInfoID.h
js/src/xpconnect/src/Makefile.in
js/src/xpconnect/src/dom_quickstubs.qsconf
js/src/xpconnect/src/nsDOMQS.h
js/src/xpconnect/src/xpcquickstubs.h
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -73,17 +73,18 @@ enum nsDOMClassInfoID {
  *          that implements one of these interfaces must be directly castable
  *          to that interface from the *canonical* nsISupports!
  */
 #define DOMCI_CASTABLE_INTERFACES(_extra)                                     \
 DOMCI_CASTABLE_INTERFACE(nsINode, 0, _extra)                                  \
 DOMCI_CASTABLE_INTERFACE(nsIContent, 1, _extra)                               \
 DOMCI_CASTABLE_INTERFACE(nsIDocument, 2, _extra)                              \
 DOMCI_CASTABLE_INTERFACE(nsINodeList, 3, _extra)                              \
-DOMCI_CASTABLE_INTERFACE(nsICSSDeclaration, 4, _extra)
+DOMCI_CASTABLE_INTERFACE(nsICSSDeclaration, 4, _extra)                        \
+DOMCI_CASTABLE_INTERFACE(nsGenericTextNode, 5, _extra)
 
 // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
 // have been declared.
 #define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2) class _interface;
 DOMCI_CASTABLE_INTERFACES(unused)
 #undef DOMCI_CASTABLE_INTERFACE
 
 #ifdef _IMPL_NS_LAYOUT
--- a/js/src/xpconnect/src/Makefile.in
+++ b/js/src/xpconnect/src/Makefile.in
@@ -115,16 +115,17 @@ endif
 
 include $(topsrcdir)/config/config.mk
 
 LOCAL_INCLUDES = \
 		-I$(srcdir)/../loader \
 		-I$(topsrcdir)/js/src \
 		-I$(topsrcdir)/js/src/nanojit \
 		-I$(topsrcdir)/caps/include \
+		-I$(topsrcdir)/content/base/src \
 		$(NULL)
 
 EXTRA_DSO_LDOPTS += \
 		$(MOZ_COMPONENT_LIBS) \
 		$(MOZ_JS_LIBS) \
 		$(NULL)
 
 ifdef MOZ_JSLOADER
--- a/js/src/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/src/xpconnect/src/dom_quickstubs.qsconf
@@ -144,29 +144,17 @@ members = [
     'nsIDOMNodeList.item',
     'nsIDOMNodeList.length',
     'nsIDOMNodeSelector.querySelector',
     'nsIDOMNodeSelector.querySelectorAll',
     'nsIDOMText.splitText',
     'nsIDOM3Document.documentURI',
     'nsIDOM3Document.adoptNode',
     'nsIDOM3Document.renameNode',
-    'nsIDOM3Node.compareDocumentPosition',
-    'nsIDOM3Node.getUserData',
-    'nsIDOM3Node.baseURI',
-    'nsIDOM3Node.textContent',
-    'nsIDOM3Node.isSameNode',
-    'nsIDOM3Node.lookupNamespaceURI',
-    'nsIDOM3Node.setUserData',
-    'nsIDOM3Node.lookupPrefix',
-    'nsIDOM3Node.isDefaultNamespace',
-    'nsIDOM3Node.isEqualNode',
-    'nsIDOM3Text.isElementContentWhitespace',
-    'nsIDOM3Text.replaceWholeText',
-    'nsIDOM3Text.wholeText',
+    'nsIDOM3Node.*',
     'nsIDOMDOMStringList.item',
     'nsIDOMDOMStringList.length',
     'nsIDOMDOMStringList.contains',
     'nsIDOMDOMTokenList.*',
     'nsIDOMDOMSettableTokenList.*',
     'nsIDOMNameList.getName',
     'nsIDOMNameList.contains',
     'nsIDOMNameList.containsNS',
@@ -508,16 +496,18 @@ irregularFilenames = {
     }
 
 customIncludes = [
     'nsINode.h',
     'nsIContent.h',
     'nsIDocument.h',
     'nsINodeList.h',
     'nsCSSPropertiesQS.h',
+    'nsGenericDOMDataNode.h',
+    'nsGenericElement.h',
     'nsDOMQS.h',
     ]
 
 customQuickStubs = [
     'CustomQS_WebGL.h',
     'CustomQS_Canvas2D.h'
     ]
 
@@ -651,16 +641,140 @@ customMethodCalls = {
         'code': nsIDOMStorage_Clear_customMethodCallCode
         },
     'nsIDOMCanvasRenderingContext2D_StrokeStyle': { 'skipgen': True },
     'nsIDOMCanvasRenderingContext2D_StrokeStyle': { 'skipgen': True },
     'nsIDOMCanvasRenderingContext2D_FillStyle': { 'skipgen': True },
     'nsIDOMCanvasRenderingContext2D_FillStyle': { 'skipgen': True },
     'nsIDOMCSS2Properties_': CSS2Properties_,
     'nsIDOMNSCSS2Properties_': CSS2Properties_,
+    'nsIDOMNSElement_GetClientRects': {
+        'thisType': 'nsGenericElement'
+        },
+    'nsIDOMNSElement_GetBoundingClientRect': {
+        'thisType': 'nsGenericElement'
+        },
+    'nsIDOMNSElement_GetElementsByClassName': {
+        'thisType': 'nsGenericElement'
+        },
+    'nsIDOMNSElement_GetScrollWidth': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRInt32 result = self->GetScrollWidth();',
+        'canFail': False
+        },
+    'nsIDOMNSElement_GetClientTop': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRInt32 result = self->GetClientTop();',
+        'canFail': False
+        },
+    'nsIDOMNSElement_SetClientTop': {
+        'thisType': 'nsGenericElement',
+        'canFail': False
+        },
+    'nsIDOMNSElement_GetClientLeft': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRInt32 result = self->GetClientLeft();',
+        'canFail': False
+        },
+    'nsIDOMNSElement_SetClientLeft': {
+        'thisType': 'nsGenericElement',
+        'canFail': False
+        },
+    'nsIDOMNSElement_GetClientHeight': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRInt32 result = self->GetClientHeight();',
+        'canFail': False
+        },
+    'nsIDOMNSElement_GetClientWidth': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRInt32 result = self->GetClientWidth();',
+        'canFail': False
+        },
+    'nsIDOMNSElement_MozMatchesSelector': {
+        'thisType': 'nsGenericElement',
+        'code': '    PRBool result = self->MozMatchesSelector(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Text_IsElementContentWhitespace': {
+        'thisType': 'nsGenericTextNode',
+        'code': '    PRBool result = self->IsElementContentWhitespace();',
+        'canFail': False
+        },
+    'nsIDOM3Text_ReplaceWholeText': {
+        'thisType': 'nsGenericTextNode',
+        'code': '    nsIContent* result = '
+                'self->ReplaceWholeText(PromiseFlatString(arg0), &rv);'
+        },
+    'nsIDOM3Text_WholeText': {
+        'thisType': 'nsGenericTextNode'
+        },
+    'nsIDOMNodeSelector_QuerySelector': {
+        'thisType': 'nsINode',
+        'code': '    nsIContent* result = '
+                'nsGenericElement::doQuerySelector(self, arg0, &rv);'
+        },
+    'nsIDOMNodeSelector_QuerySelectorAll': {
+        'thisType': 'nsINode',
+        'code': '    nsCOMPtr<nsIDOMNodeList> result;\n'
+                '    rv = nsGenericElement::doQuerySelectorAll(self, '
+                'arg0, getter_AddRefs(result));'
+        },
+    'nsIDOM3Node_GetBaseURI': {
+        'thisType': 'nsINode',
+        'canFail': False
+        },
+    'nsIDOM3Node_CompareDocumentPosition': {
+        'thisType': 'nsINode',
+        'arg0Type': 'nsINode',
+        'code': '    PRUint16 result = self->CompareDocumentPosition(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Node_GetTextContent': {
+        'thisType': 'nsINode',
+        'canFail': False
+        },
+    'nsIDOM3Node_SetTextContent': {
+        'thisType': 'nsINode'
+        },
+    'nsIDOM3Node_IsSameNode': {
+        'thisType': 'nsINode',
+        'arg0Type': 'nsINode',
+        'code': '    PRBool result = self->IsSameNode(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Node_LookupPrefix': {
+        'thisType': 'nsINode',
+        'canFail': False
+        },
+    'nsIDOM3Node_IsDefaultNamespace': {
+        'thisType': 'nsINode',
+        'code': '    PRBool result = self->IsDefaultNamespace(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Node_LookupNamespaceURI': {
+        'thisType': 'nsINode',
+        'canFail': False
+        },
+    'nsIDOM3Node_IsEqualNode': {
+        'thisType': 'nsINode',
+        'arg0Type': 'nsINode',
+        'code': '    PRBool result = self->IsEqualNode(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Node_GetFeature': {
+        'thisType': 'nsINode'
+        },
+    'nsIDOM3Node_GetUserData': {
+        'thisType': 'nsINode',
+        'code': '    nsIVariant *result = self->GetUserData(arg0);',
+        'canFail': False
+        },
+    'nsIDOM3Node_SetUserData': {
+        'thisType': 'nsINode'
+        },
     # WebGL
     'nsICanvasRenderingContextWebGL_BufferData': CUSTOM_QS,
     'nsICanvasRenderingContextWebGL_BufferSubData': CUSTOM_QS,
     'nsICanvasRenderingContextWebGL_TexImage2D': CUSTOM_QS,
     'nsICanvasRenderingContextWebGL_TexSubImage2D': CUSTOM_QS,
     'nsICanvasRenderingContextWebGL_Uniform1iv': CUSTOM_QS_TN,
     'nsICanvasRenderingContextWebGL_Uniform2iv': CUSTOM_QS_TN,
     'nsICanvasRenderingContextWebGL_Uniform3iv': CUSTOM_QS_TN,
--- a/js/src/xpconnect/src/nsDOMQS.h
+++ b/js/src/xpconnect/src/nsDOMQS.h
@@ -78,9 +78,65 @@ xpc_qsUnwrapArg<_interface>(JSContext *c
 
 #define DOMCI_CASTABLE_INTERFACE(_interface, _bit, _extra)                    \
   DEFINE_UNWRAP_CAST(_interface, _bit)
 
 DOMCI_CASTABLE_INTERFACES(unused)
 
 #undef DOMCI_CASTABLE_INTERFACE
 
+// Ideally we'd just add nsGenericElement to the castable interfaces, but for
+// now nsDocumentFragment inherits from nsGenericElement (even though it's not
+// an Element) so we have to special-case nsGenericElement and use
+// nsIContent::IsElement().
+// FIXME: bug 563659.
+inline JSBool
+castToElement(nsIContent *content, jsval val, nsGenericElement **ppInterface,
+              jsval *pVal)
+{
+    if(!content->IsElement())
+        return JS_FALSE;
+    *ppInterface = static_cast<nsGenericElement*>(content->AsElement());
+    *pVal = val;
+    return JS_TRUE;
+}
+
+NS_SPECIALIZE_TEMPLATE
+inline JSBool
+xpc_qsUnwrapThis<nsGenericElement>(JSContext *cx,
+                                   JSObject *obj,
+                                   JSObject *callee,
+                                   nsGenericElement **ppThis,
+                                   nsISupports **pThisRef,
+                                   jsval *pThisVal,
+                                   XPCLazyCallContext *lccx)
+{
+    nsIContent *content;
+    jsval val;
+    JSBool ok = xpc_qsUnwrapThis<nsIContent>(cx, obj, callee, &content,
+                                             pThisRef, &val, lccx);
+    if(ok)
+    {
+        ok = castToElement(content, val, ppThis, pThisVal);
+        if(!ok)
+            xpc_qsThrow(cx, NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
+    }
+
+    return ok;
+}
+
+NS_SPECIALIZE_TEMPLATE
+inline nsresult
+xpc_qsUnwrapArg<nsGenericElement>(JSContext *cx,
+                                  jsval v,
+                                  nsGenericElement **ppArg,
+                                  nsISupports **ppArgRef,
+                                  jsval *vp)
+{
+    nsIContent *content;
+    jsval val;
+    nsresult rv = xpc_qsUnwrapArg<nsIContent>(cx, v, &content, ppArgRef, &val);
+    if(NS_SUCCEEDED(rv) && !castToElement(content, val, ppArg, vp))
+        rv = NS_ERROR_XPC_BAD_CONVERT_JS;
+    return rv;
+}
+
 #endif /* nsDOMQS_h__ */
--- a/js/src/xpconnect/src/xpcquickstubs.h
+++ b/js/src/xpconnect/src/xpcquickstubs.h
@@ -565,14 +565,26 @@ void
 xpc_qsAssertContextOK(JSContext *cx);
 
 inline PRBool
 xpc_qsSameResult(nsISupports *result1, nsISupports *result2)
 {
     return SameCOMIdentity(result1, result2);
 }
 
+inline PRBool
+xpc_qsSameResult(const nsString &result1, const nsString &result2)
+{
+    return result1.Equals(result2);
+}
+
+inline PRBool
+xpc_qsSameResult(PRInt32 result1, PRInt32 result2)
+{
+    return result1 == result2;
+}
+
 #define XPC_QS_ASSERT_CONTEXT_OK(cx) xpc_qsAssertContextOK(cx)
 #else
 #define XPC_QS_ASSERT_CONTEXT_OK(cx) ((void) 0)
 #endif
 
 #endif /* xpcquickstubs_h___ */