Fix for bug 560462 (Use fast unwrapping for more quickstubs), part 3a. r=jst.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 19 Apr 2010 17:41:39 +0200
changeset 42984 5005d2023e66220ae7ab0711e81be20a0e272602
parent 42983 633756e2a580e67791449a827dbdf488025c8ec9
child 42985 2afbac619d826349462d5c5b9e7c6da501478ec7
push id13554
push userpvanderbeken@mozilla.com
push dateTue, 01 Jun 2010 10:50:52 +0000
treeherdermozilla-central@5005d2023e66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs560462
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
nightly win64
Fix for bug 560462 (Use fast unwrapping for more quickstubs), part 3a. r=jst.
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
dom/base/nsDOMClassInfoID.h
js/src/xpconnect/src/Makefile.in
js/src/xpconnect/src/dom_quickstubs.qsconf
js/src/xpconnect/src/nsDOMQS.h
layout/style/nsStyleSet.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -188,16 +188,18 @@ static NS_DEFINE_CID(kDOMEventGroupCID, 
 #ifdef MOZ_SMIL
 #include "nsSMILAnimationController.h"
 #include "imgIContainer.h"
 #include "nsSVGUtils.h"
 #endif // MOZ_SMIL
 
 // FOR CSP (autogenerated by xpidl)
 #include "nsIContentSecurityPolicy.h"
+#include "nsHTMLStyleSheet.h"
+#include "nsHTMLCSSStyleSheet.h"
 
 #include "mozilla/dom/Link.h"
 using namespace mozilla::dom;
 
 
 /* Keeps track of whether or not CSP is enabled */
 static PRBool gCSPEnabled = PR_TRUE;
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -90,23 +90,17 @@
 #include "nsTObserverArray.h"
 #include "nsStubMutationObserver.h"
 #include "nsIChannel.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsContentList.h"
 #include "nsGkAtoms.h"
 #include "nsIApplicationCache.h"
 #include "nsIApplicationCacheContainer.h"
-
-// Put these here so all document impls get them automatically
-#include "nsHTMLStyleSheet.h"
-#include "nsHTMLCSSStyleSheet.h"
-
 #include "nsStyleSet.h"
-#include "nsXMLEventsManager.h"
 #include "pldhash.h"
 #include "nsAttrAndChildArray.h"
 #include "nsDOMAttributeMap.h"
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "nsIDocumentViewer.h"
 #include "nsIDOMXPathNSResolver.h"
 #include "nsIInterfaceRequestor.h"
@@ -130,16 +124,19 @@ class nsIOutputStream;
 class nsDocument;
 class nsIDTD;
 class nsIRadioVisitor;
 class nsIFormControl;
 struct nsRadioGroupStruct;
 class nsOnloadBlocker;
 class nsUnblockOnloadEvent;
 class nsChildContentList;
+class nsXMLEventsManager;
+class nsHTMLStyleSheet;
+class nsHTMLCSSStyleSheet;
 
 /**
  * Right now our identifier map entries contain information for 'name'
  * and 'id' mappings of a given string. This is so that
  * nsHTMLDocument::ResolveName only has to do one hash lookup instead
  * of two. It's not clear whether this still matters for performance.
  * 
  * We also store the document.all result list here. This is mainly so that
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -69,26 +69,30 @@ enum nsDOMClassInfoID {
  * call to DOMCI_CASTABLE_INTERFACE with the bit that it corresponds to and
  * the extra argument that was passed in to DOMCI_CASTABLE_INTERFACES.
  *
  * WARNING: Be very careful when adding interfaces to this list. Every object
  *          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(nsGenericTextNode, 5, _extra)
+DOMCI_CASTABLE_INTERFACE(nsINode, nsINode, 0, _extra)                         \
+DOMCI_CASTABLE_INTERFACE(nsIContent, nsIContent, 1, _extra)                   \
+DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 2, _extra)                 \
+DOMCI_CASTABLE_INTERFACE(nsINodeList, nsINodeList, 3, _extra)                 \
+DOMCI_CASTABLE_INTERFACE(nsICSSDeclaration, nsICSSDeclaration, 4, _extra)     \
+DOMCI_CASTABLE_INTERFACE(nsGenericTextNode, nsGenericTextNode, 5, _extra)     \
+DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 6, _extra)                  \
+DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsGenericHTMLElement, 7,       \
+                         _extra)                                              \
+DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 8, _extra)
 
 // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
 // have been declared.
-#define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2) class _interface;
+#define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
 DOMCI_CASTABLE_INTERFACES(unused)
 #undef DOMCI_CASTABLE_INTERFACE
 
 #ifdef _IMPL_NS_LAYOUT
 
 #define DOMCI_CLASS(_dom_class)                                               \
   extern const PRUint32 kDOMClassInfo_##_dom_class##_interfaces;
 
@@ -130,17 +134,17 @@ template <typename Interface> struct DOM
   (sizeof(DOMCI_CastableTo<_interface>::p(static_cast<_class*>(0))) ==        \
    sizeof(DOMCI_CastableTo<_interface>::true_type))
 
 #endif
 
 /**
  * Here we calculate the bitmap for a given class.
  */
-#define DOMCI_CASTABLE_INTERFACE(_interface, _bit, _class)                    \
+#define DOMCI_CASTABLE_INTERFACE(_interface, _base, _bit, _class)             \
   (DOMCI_CASTABLE_TO(_interface, _class) ? 1 << _bit : 0) +
 
 #define DOMCI_DATA(_dom_class, _class)                                        \
 const PRUint32 kDOMClassInfo_##_dom_class##_interfaces =                      \
   DOMCI_CASTABLE_INTERFACES(_class)                                           \
   0;
 
 class nsIClassInfo;
--- a/js/src/xpconnect/src/Makefile.in
+++ b/js/src/xpconnect/src/Makefile.in
@@ -116,16 +116,19 @@ 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 \
+		-I$(topsrcdir)/content/html/content/src \
+		-I$(topsrcdir)/content/html/document/src \
+		-I$(topsrcdir)/layout/style \
 		$(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
@@ -496,18 +496,21 @@ irregularFilenames = {
     }
 
 customIncludes = [
     'nsINode.h',
     'nsIContent.h',
     'nsIDocument.h',
     'nsINodeList.h',
     'nsCSSPropertiesQS.h',
+    'nsDocument.h',
     'nsGenericDOMDataNode.h',
     'nsGenericElement.h',
+    'nsGenericHTMLElement.h',
+    'nsHTMLDocument.h',
     'nsDOMQS.h',
     ]
 
 customQuickStubs = [
     'CustomQS_WebGL.h',
     'CustomQS_Canvas2D.h'
     ]
 
--- a/js/src/xpconnect/src/nsDOMQS.h
+++ b/js/src/xpconnect/src/nsDOMQS.h
@@ -34,55 +34,55 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsDOMQS_h__
 #define nsDOMQS_h__
 
 #include "nsDOMClassInfoID.h"
 
-#define DEFINE_UNWRAP_CAST(_interface, _bit)                                  \
+#define DEFINE_UNWRAP_CAST(_interface, _base, _bit)                           \
 NS_SPECIALIZE_TEMPLATE                                                        \
 inline JSBool                                                                 \
 xpc_qsUnwrapThis<_interface>(JSContext *cx,                                   \
                              JSObject *obj,                                   \
                              JSObject *callee,                                \
                              _interface **ppThis,                             \
                              nsISupports **pThisRef,                          \
                              jsval *pThisVal,                                 \
                              XPCLazyCallContext *lccx)                        \
 {                                                                             \
     nsresult rv;                                                              \
     nsISupports *native = castNativeFromWrapper(cx, obj, callee, _bit,        \
                                                 pThisRef, pThisVal, lccx,     \
                                                 &rv);                         \
     if(!native)                                                               \
         return xpc_qsThrow(cx, rv);                                           \
-    *ppThis = static_cast<_interface*>(native);                               \
+    *ppThis = static_cast<_interface*>(static_cast<_base*>(native));          \
     return JS_TRUE;                                                           \
 }                                                                             \
                                                                               \
 NS_SPECIALIZE_TEMPLATE                                                        \
 inline nsresult                                                               \
 xpc_qsUnwrapArg<_interface>(JSContext *cx,                                    \
                             jsval v,                                          \
                             _interface **ppArg,                               \
                             nsISupports **ppArgRef,                           \
                             jsval *vp)                                        \
 {                                                                             \
     nsresult rv;                                                              \
     nsISupports *native = castNativeArgFromWrapper(cx, v, _bit, ppArgRef, vp, \
                                                    &rv);                      \
     if(NS_SUCCEEDED(rv))                                                      \
-        *ppArg = static_cast<_interface*>(native);                            \
+        *ppArg = static_cast<_interface*>(static_cast<_base*>(native));       \
     return rv;                                                                \
 }
 
-#define DOMCI_CASTABLE_INTERFACE(_interface, _bit, _extra)                    \
-  DEFINE_UNWRAP_CAST(_interface, _bit)
+#define DOMCI_CASTABLE_INTERFACE(_interface, _base, _bit, _extra)             \
+  DEFINE_UNWRAP_CAST(_interface, _base, _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
@@ -134,9 +134,15 @@ xpc_qsUnwrapArg<nsGenericElement>(JSCont
     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;
 }
 
+inline nsISupports*
+ToSupports(nsContentList *p)
+{
+    return static_cast<nsINodeList*>(p);
+}
+
 #endif /* nsDOMQS_h__ */
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -384,24 +384,27 @@ class nsStyleSet
 
   unsigned mInShutdown : 1;
   unsigned mAuthorStyleDisabled: 1;
   unsigned mInReconstruct : 1;
   unsigned mDirty : 8;  // one dirty bit is used per sheet type
 
 };
 
+#ifdef _IMPL_NS_LAYOUT
 inline
 void nsRuleNode::AddRef()
 {
   if (mRefCnt++ == 0 && !IsRoot()) {
     mPresContext->StyleSet()->RuleNodeInUse();
   }
 }
 
 inline
 void nsRuleNode::Release()
 {
   if (--mRefCnt == 0 && !IsRoot()) {
     mPresContext->StyleSet()->RuleNodeUnused();
   }
 }
 #endif
+
+#endif