From 166047cba5d58e43ce6de9fa1eb384a2942c6c3e Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Wed, 31 Dec 2008 18:21:52 -0800 Subject: [PATCH] Backed out changeset e0cce6a738c9 (Bug 466224 - Make quickstubs call nsINode/nsINodeList methods) for failing mochitest --- content/base/public/nsIDocument.h | 8 - content/base/public/nsINode.h | 43 +---- content/base/public/nsINodeList.h | 3 +- content/base/src/nsDOMAttribute.cpp | 19 +- content/base/src/nsDocument.cpp | 34 +++- content/base/src/nsGenericDOMDataNode.cpp | 71 ++++++++ content/base/src/nsGenericDOMDataNode.h | 17 ++ content/base/src/nsGenericElement.cpp | 200 +++++++++++---------- content/base/src/nsGenericElement.h | 7 + js/src/xpconnect/src/Makefile.in | 1 - js/src/xpconnect/src/dom_quickstubs.qsconf | 48 ----- js/src/xpconnect/src/nsXPConnect.cpp | 6 +- js/src/xpconnect/src/qsgen.py | 127 +++++-------- js/src/xpconnect/src/xpcconvert.cpp | 7 +- js/src/xpconnect/src/xpcprivate.h | 2 - js/src/xpconnect/src/xpcquickstubs.cpp | 5 +- js/src/xpconnect/src/xpcquickstubs.h | 19 -- js/src/xpconnect/src/xpcwrappedjsclass.cpp | 2 +- 18 files changed, 303 insertions(+), 316 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index a47b28488b27..cd94d43fa02c 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -1299,12 +1299,4 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult, nsresult NS_NewPluginDocument(nsIDocument** aInstancePtrResult); -inline nsIDocument* -nsINode::GetOwnerDocument() const -{ - nsIDocument* ownerDoc = GetOwnerDoc(); - - return ownerDoc != this ? ownerDoc : nsnull; -} - #endif /* nsIDocument_h___ */ diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 57f4e74b6df1..0c525a021de7 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -49,8 +49,6 @@ class nsIContent; class nsIDocument; class nsIDOMEvent; -class nsIDOMNode; -class nsIDOMNodeList; class nsIPresShell; class nsPresContext; class nsEventChainVisitor; @@ -153,9 +151,9 @@ inline nsINode* NODE_FROM(C& aContent, D& aDocument) // IID for the nsINode interface #define NS_INODE_IID \ -{ 0x0dc8fad3, 0xcb3f, 0x4f14, \ - { 0x8e, 0x7e, 0x4f, 0x62, 0xab, 0x74, 0xb8, 0x1e } } - +{ 0xb4125da4, 0x6f86, 0x45aa, \ + { 0xbb, 0x55, 0x80, 0x70, 0x44, 0x24, 0xe2, 0x47 } } + /** * An internal interface that abstracts some DOMNode-related parts that both * nsIContent and nsIDocument share. An instance of this interface has a list @@ -690,30 +688,6 @@ public: */ nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell); - virtual nsIDOMNodeList* GetChildNodesList(); - nsIContent* GetSibling(PRInt32 aOffset) - { - nsINode *parent = GetNodeParent(); - if (!parent) { - return nsnull; - } - - return parent->GetChildAt(parent->IndexOf(this) + aOffset); - } - nsIContent* GetLastChild() const - { - PRUint32 count; - nsIContent* const* children = GetChildArray(&count); - - return count > 0 ? children[count - 1] : nsnull; - } - - /** - * Implementation is in nsIDocument.h, because it needs to cast from - * nsIDocument* to nsINode*. - */ - nsIDocument* GetOwnerDocument() const; - protected: // Override this function to create a custom slots class. @@ -760,14 +734,6 @@ protected: return IsEditableInternal(); } - nsresult GetParentNode(nsIDOMNode** aParentNode); - nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); - nsresult GetFirstChild(nsIDOMNode** aFirstChild); - nsresult GetLastChild(nsIDOMNode** aLastChild); - nsresult GetPreviousSibling(nsIDOMNode** aPrevSibling); - nsresult GetNextSibling(nsIDOMNode** aNextSibling); - nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument); - nsCOMPtr mNodeInfo; enum { PARENT_BIT_INDOCUMENT = 1 << 0, PARENT_BIT_PARENT_IS_CONTENT = 1 << 1 }; @@ -811,8 +777,7 @@ extern const nsIID kThisPtrOffsetsSID; // nsINode, so if you change the nsISupports line below, make sure // nsNodeSH::PreCreate() still does the right thing! #define NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \ - NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode) \ - NS_INTERFACE_TABLE_ENTRY(_class, nsINode) + NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode) #define NS_NODE_INTERFACE_TABLE2(_class, _i1, _i2) \ NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \ diff --git a/content/base/public/nsINodeList.h b/content/base/public/nsINodeList.h index 2103e9cb9991..10c4cc99d1ea 100644 --- a/content/base/public/nsINodeList.h +++ b/content/base/public/nsINodeList.h @@ -38,9 +38,8 @@ #ifndef nsINodeList_h___ #define nsINodeList_h___ -#include "nsIDOMNodeList.h" - class nsINode; +class nsIDOMNodeList; // IID for the nsINodeList interface #define NS_INODELIST_IID \ diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp index a2bacf0a0f25..f11621098000 100644 --- a/content/base/src/nsDOMAttribute.cpp +++ b/content/base/src/nsDOMAttribute.cpp @@ -260,7 +260,18 @@ nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode) NS_IMETHODIMP nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes) { - return nsINode::GetChildNodes(aChildNodes); + nsSlots *slots = GetSlots(); + NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY); + + if (!slots->mChildNodes) { + slots->mChildNodes = new nsChildContentList(this); + NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(slots->mChildNodes); + } + + NS_ADDREF(*aChildNodes = slots->mChildNodes); + + return NS_OK; } NS_IMETHODIMP @@ -386,7 +397,11 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aResult) NS_IMETHODIMP nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { - return nsINode::GetOwnerDocument(aOwnerDocument); + *aOwnerDocument = nsnull; + + nsIDocument *document = GetOwnerDoc(); + + return document ? CallQueryInterface(document, aOwnerDocument) : NS_OK; } NS_IMETHODIMP diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 343beab87aef..058085e04c41 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5333,7 +5333,18 @@ nsDocument::GetParentNode(nsIDOMNode** aParentNode) NS_IMETHODIMP nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes) { - return nsINode::GetChildNodes(aChildNodes); + nsSlots *slots = GetSlots(); + NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY); + + if (!slots->mChildNodes) { + slots->mChildNodes = new nsChildContentList(this); + NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(slots->mChildNodes); + } + + NS_ADDREF(*aChildNodes = slots->mChildNodes); + + return NS_OK; } NS_IMETHODIMP @@ -5359,13 +5370,26 @@ nsDocument::HasAttributes(PRBool* aHasAttributes) NS_IMETHODIMP nsDocument::GetFirstChild(nsIDOMNode** aFirstChild) { - return nsINode::GetFirstChild(aFirstChild); + if (mChildren.ChildCount()) { + return CallQueryInterface(mChildren.ChildAt(0), aFirstChild); + } + + *aFirstChild = nsnull; + + return NS_OK; } NS_IMETHODIMP nsDocument::GetLastChild(nsIDOMNode** aLastChild) { - return nsINode::GetLastChild(aLastChild); + PRInt32 count = mChildren.ChildCount(); + if (count) { + return CallQueryInterface(mChildren.ChildAt(count-1), aLastChild); + } + + *aLastChild = nsnull; + + return NS_OK; } NS_IMETHODIMP @@ -5967,7 +5991,9 @@ nsDocument::RenameNode(nsIDOMNode *aNode, NS_IMETHODIMP nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { - return nsINode::GetOwnerDocument(aOwnerDocument); + *aOwnerDocument = nsnull; + + return NS_OK; } nsresult diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 6c75130402ac..43c930710c53 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -145,6 +145,77 @@ nsGenericDOMDataNode::SetNodeValue(const nsAString& aNodeValue) aNodeValue.Length(), PR_TRUE); } +nsresult +nsGenericDOMDataNode::GetParentNode(nsIDOMNode** aParentNode) +{ + *aParentNode = nsnull; + nsINode *parent = GetNodeParent(); + + return parent ? CallQueryInterface(parent, aParentNode) : NS_OK; +} + +nsresult +nsGenericDOMDataNode::GetPreviousSibling(nsIDOMNode** aPrevSibling) +{ + *aPrevSibling = nsnull; + + nsINode *parent = GetNodeParent(); + if (!parent) { + return NS_OK; + } + + PRInt32 pos = parent->IndexOf(this); + nsIContent *sibling = parent->GetChildAt(pos - 1); + + return sibling ? CallQueryInterface(sibling, aPrevSibling) : NS_OK; +} + +nsresult +nsGenericDOMDataNode::GetNextSibling(nsIDOMNode** aNextSibling) +{ + *aNextSibling = nsnull; + + nsINode *parent = GetNodeParent(); + if (!parent) { + return NS_OK; + } + + PRInt32 pos = parent->IndexOf(this); + nsIContent *sibling = parent->GetChildAt(pos + 1); + + return sibling ? CallQueryInterface(sibling, aNextSibling) : NS_OK; +} + +nsresult +nsGenericDOMDataNode::GetChildNodes(nsIDOMNodeList** aChildNodes) +{ + *aChildNodes = nsnull; + nsDataSlots *slots = GetDataSlots(); + NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY); + + if (!slots->mChildNodes) { + slots->mChildNodes = new nsChildContentList(this); + NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY); + NS_ADDREF(slots->mChildNodes); + } + + NS_ADDREF(*aChildNodes = slots->mChildNodes); + return NS_OK; +} + +nsresult +nsGenericDOMDataNode::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) +{ + nsIDocument *document = GetOwnerDoc(); + if (document) { + return CallQueryInterface(document, aOwnerDocument); + } + + *aOwnerDocument = nsnull; + + return NS_OK; +} + nsresult nsGenericDOMDataNode::GetNamespaceURI(nsAString& aNamespaceURI) { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index b24739e2e914..399fcca60be6 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -73,12 +73,16 @@ public: // Implementation for nsIDOMNode nsresult GetNodeValue(nsAString& aNodeValue); nsresult SetNodeValue(const nsAString& aNodeValue); + nsresult GetParentNode(nsIDOMNode** aParentNode); nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes) { NS_ENSURE_ARG_POINTER(aAttributes); *aAttributes = nsnull; return NS_OK; } + nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling); + nsresult GetNextSibling(nsIDOMNode** aNextSibling); + nsresult GetChildNodes(nsIDOMNodeList** aChildNodes); nsresult HasChildNodes(PRBool* aHasChildNodes) { NS_ENSURE_ARG_POINTER(aHasChildNodes); @@ -91,6 +95,18 @@ public: *aHasAttributes = PR_FALSE; return NS_OK; } + nsresult GetFirstChild(nsIDOMNode** aFirstChild) + { + NS_ENSURE_ARG_POINTER(aFirstChild); + *aFirstChild = nsnull; + return NS_OK; + } + nsresult GetLastChild(nsIDOMNode** aLastChild) + { + NS_ENSURE_ARG_POINTER(aLastChild); + *aLastChild = nsnull; + return NS_OK; + } nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn) { @@ -126,6 +142,7 @@ public: *aReturn = nsnull; return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } + nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument); nsresult GetNamespaceURI(nsAString& aNamespaceURI); nsresult GetLocalName(nsAString& aLocalName); nsresult GetPrefix(nsAString& aPrefix); diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index f208c75e41d1..2adb3dff75ae 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -424,103 +424,6 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell) return doc->GetRootContent(); } -nsIDOMNodeList* -nsINode::GetChildNodesList() -{ - nsSlots *slots = GetSlots(); - if (!slots) { - return nsnull; - } - - if (!slots->mChildNodes) { - slots->mChildNodes = new nsChildContentList(this); - if (slots->mChildNodes) { - NS_ADDREF(slots->mChildNodes); - } - } - - return slots->mChildNodes; -} - -nsresult -nsINode::GetParentNode(nsIDOMNode** aParentNode) -{ - *aParentNode = nsnull; - - nsINode *parent = GetNodeParent(); - - return parent ? CallQueryInterface(parent, aParentNode) : NS_OK; -} - -nsresult -nsINode::GetChildNodes(nsIDOMNodeList** aChildNodes) -{ - *aChildNodes = GetChildNodesList(); - if (!*aChildNodes) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aChildNodes); - - return NS_OK; -} - -nsresult -nsINode::GetFirstChild(nsIDOMNode** aNode) -{ - nsIContent* child = GetChildAt(0); - if (child) { - return CallQueryInterface(child, aNode); - } - - *aNode = nsnull; - - return NS_OK; -} - -nsresult -nsINode::GetLastChild(nsIDOMNode** aNode) -{ - nsIContent* child = GetLastChild(); - if (child) { - return CallQueryInterface(child, aNode); - } - - *aNode = nsnull; - - return NS_OK; -} - -nsresult -nsINode::GetPreviousSibling(nsIDOMNode** aPrevSibling) -{ - *aPrevSibling = nsnull; - - nsIContent *sibling = GetSibling(-1); - - return sibling ? CallQueryInterface(sibling, aPrevSibling) : NS_OK; -} - -nsresult -nsINode::GetNextSibling(nsIDOMNode** aNextSibling) -{ - *aNextSibling = nsnull; - - nsIContent *sibling = GetSibling(1); - - return sibling ? CallQueryInterface(sibling, aNextSibling) : NS_OK; -} - -nsresult -nsINode::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) -{ - *aOwnerDocument = nsnull; - - nsIDocument *ownerDoc = GetOwnerDocument(); - - return ownerDoc ? CallQueryInterface(ownerDoc, aOwnerDocument) : NS_OK; -} - //---------------------------------------------------------------------- PRInt32 @@ -1798,6 +1701,60 @@ nsGenericElement::GetNodeType(PRUint16* aNodeType) return NS_OK; } +NS_IMETHODIMP +nsGenericElement::GetParentNode(nsIDOMNode** aParentNode) +{ + *aParentNode = nsnull; + nsINode *parent = GetNodeParent(); + + return parent ? CallQueryInterface(parent, aParentNode) : NS_OK; +} + +NS_IMETHODIMP +nsGenericElement::GetPreviousSibling(nsIDOMNode** aPrevSibling) +{ + *aPrevSibling = nsnull; + + nsINode *parent = GetNodeParent(); + if (!parent) { + return NS_OK; + } + + PRInt32 pos = parent->IndexOf(this); + nsIContent *sibling = parent->GetChildAt(pos - 1); + + return sibling ? CallQueryInterface(sibling, aPrevSibling) : NS_OK; +} + +NS_IMETHODIMP +nsGenericElement::GetNextSibling(nsIDOMNode** aNextSibling) +{ + *aNextSibling = nsnull; + + nsINode *parent = GetNodeParent(); + if (!parent) { + return NS_OK; + } + + PRInt32 pos = parent->IndexOf(this); + nsIContent *sibling = parent->GetChildAt(pos + 1); + + return sibling ? CallQueryInterface(sibling, aNextSibling) : NS_OK; +} + +NS_IMETHODIMP +nsGenericElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) +{ + nsIDocument *doc = GetOwnerDoc(); + if (doc) { + return CallQueryInterface(doc, aOwnerDocument); + } + + *aOwnerDocument = nsnull; + + return NS_OK; +} + NS_IMETHODIMP nsGenericElement::GetNamespaceURI(nsAString& aNamespaceURI) { @@ -1989,6 +1946,28 @@ nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes) return NS_OK; } +nsresult +nsGenericElement::GetChildNodes(nsIDOMNodeList** aChildNodes) +{ + nsSlots *slots = GetSlots(); + + if (!slots) { + return NS_ERROR_OUT_OF_MEMORY; + } + + if (!slots->mChildNodes) { + slots->mChildNodes = new nsChildContentList(this); + if (!slots->mChildNodes) { + return NS_ERROR_OUT_OF_MEMORY; + } + NS_ADDREF(slots->mChildNodes); + } + + NS_ADDREF(*aChildNodes = slots->mChildNodes); + + return NS_OK; +} + nsresult nsGenericElement::HasChildNodes(PRBool* aReturn) { @@ -1997,6 +1976,33 @@ nsGenericElement::HasChildNodes(PRBool* aReturn) return NS_OK; } +nsresult +nsGenericElement::GetFirstChild(nsIDOMNode** aNode) +{ + nsIContent* child = GetChildAt(0); + if (child) { + return CallQueryInterface(child, aNode); + } + + *aNode = nsnull; + + return NS_OK; +} + +nsresult +nsGenericElement::GetLastChild(nsIDOMNode** aNode) +{ + PRUint32 count = GetChildCount(); + + if (count > 0) { + return CallQueryInterface(GetChildAt(count - 1), aNode); + } + + *aNode = nsnull; + + return NS_OK; +} + NS_IMETHODIMP nsGenericElement::GetTagName(nsAString& aTagName) { diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index 4ee9a8fb64ae..41d95e6e2222 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -470,7 +470,11 @@ public: NS_IMETHOD GetNodeValue(nsAString& aNodeValue); NS_IMETHOD SetNodeValue(const nsAString& aNodeValue); NS_IMETHOD GetNodeType(PRUint16* aNodeType); + NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode); NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes); + NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling); + NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling); + NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument); NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI); NS_IMETHOD GetPrefix(nsAString& aPrefix); NS_IMETHOD SetPrefix(const nsAString& aPrefix); @@ -478,7 +482,10 @@ public: NS_IMETHOD IsSupported(const nsAString& aFeature, const nsAString& aVersion, PRBool* aReturn); NS_IMETHOD HasAttributes(PRBool* aHasAttributes); + NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes); NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes); + NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild); + NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild); NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn); NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, diff --git a/js/src/xpconnect/src/Makefile.in b/js/src/xpconnect/src/Makefile.in index 17c627b67121..dba9458d8f6a 100644 --- a/js/src/xpconnect/src/Makefile.in +++ b/js/src/xpconnect/src/Makefile.in @@ -74,7 +74,6 @@ REQUIRES += content \ svg \ xuldoc \ xultmpl \ - widget \ $(NULL) diff --git a/js/src/xpconnect/src/dom_quickstubs.qsconf b/js/src/xpconnect/src/dom_quickstubs.qsconf index 755975731c46..7673f635475c 100644 --- a/js/src/xpconnect/src/dom_quickstubs.qsconf +++ b/js/src/xpconnect/src/dom_quickstubs.qsconf @@ -512,51 +512,3 @@ irregularFilenames = { 'nsIDOMNSCSS2Properties': 'nsIDOMCSS2Properties', 'nsIXPointerResult': 'nsIXPointer', } - -customIncludes = [ - 'nsINode.h', - 'nsIContent.h', - 'nsIDocument.h', - 'nsINodeList.h' - ] - -nsIDOMNode_GetChildNodes_customMethodCallCode = """ - nsIDOMNodeList* result = self->GetChildNodesList(); - if (!result) - return xpc_qsThrowGetterSetterFailed(cx, NS_ERROR_OUT_OF_MEMORY, JSVAL_TO_OBJECT(*vp), id); -""" - -customMethodCalls = { - 'nsIDOMNode_GetNextSibling': { - 'thisType': 'nsINode', - 'code': ' nsINode* result = self->GetSibling(1);' - }, - 'nsIDOMNode_GetFirstChild': { - 'thisType': 'nsINode', - 'code': ' nsINode* result = self->GetChildAt(0);' - }, - 'nsIDOMNode_GetChildNodes': { - 'thisType': 'nsINode', - 'code': nsIDOMNode_GetChildNodes_customMethodCallCode - }, - 'nsIDOMNode_GetPreviousSibling': { - 'thisType': 'nsINode', - 'code': ' nsINode* result = self->GetSibling(-1);' - }, - 'nsIDOMNode_GetLastChild': { - 'thisType': 'nsINode', - 'code': ' nsINode* result = self->GetLastChild();' - }, - 'nsIDOMNode_GetOwnerDocument': { - 'thisType': 'nsINode', - 'code': ' nsIDocument* result = self->GetOwnerDocument();' - }, - 'nsIDOMNode_GetParentNode': { - 'thisType': 'nsINode', - 'code': ' nsINode* result = self->GetNodeParent();' - }, - 'nsIDOMNodeList_Item': { - 'thisType': 'nsINodeList', - 'code': ' nsINode* result = self->GetNodeAt(arg0);' - } - } diff --git a/js/src/xpconnect/src/nsXPConnect.cpp b/js/src/xpconnect/src/nsXPConnect.cpp index 0c7bb816954f..bcfe3130c65b 100644 --- a/js/src/xpconnect/src/nsXPConnect.cpp +++ b/js/src/xpconnect/src/nsXPConnect.cpp @@ -1113,8 +1113,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, if(!XPCConvert::NativeInterface2JSObject(ccx, &v, getter_AddRefs(holder), aCOMObj, &aIID, nsnull, - nsnull, tempGlobal, - PR_FALSE, OBJ_IS_GLOBAL, &rv)) + tempGlobal, PR_FALSE, + OBJ_IS_GLOBAL, &rv)) return UnexpectedFailure(rv); NS_ASSERTION(NS_SUCCEEDED(rv) && holder, "Didn't wrap properly"); @@ -1213,7 +1213,7 @@ nsXPConnect::WrapNativeToJSVal(JSContext * aJSContext, nsresult rv; if(!XPCConvert::NativeInterface2JSObject(ccx, aVal, aHolder, aCOMObj, aIID, - nsnull, nsnull, aScope, PR_FALSE, + nsnull, aScope, PR_FALSE, OBJ_IS_NOT_GLOBAL, &rv)) return rv; diff --git a/js/src/xpconnect/src/qsgen.py b/js/src/xpconnect/src/qsgen.py index 4f87ecdccc25..0cf5c273eaea 100644 --- a/js/src/xpconnect/src/qsgen.py +++ b/js/src/xpconnect/src/qsgen.py @@ -263,8 +263,6 @@ class Configuration: setattr(self, name, config[name]) # optional settings self.irregularFilenames = config.get('irregularFilenames', {}) - self.customIncludes = config.get('customIncludes', []) - self.customMethodCalls = config.get('customMethodCalls', {}) def readConfigFile(filename, includePath, cachedir): # Read the config file. @@ -425,7 +423,7 @@ argumentUnboxingTemplates = { # Omitted optional arguments are treated as though the caller had passed JS # `null`; this behavior is from XPCWrappedNative::CallMethod. # -def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): +def writeArgumentUnboxing(f, i, name, type, haveCcx, optional): # f - file to write to # i - int or None - Indicates the source jsval. If i is an int, the source # jsval is argv[i]; otherwise it is *vp. But if Python i >= C++ argc, @@ -434,7 +432,6 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): # name - str - name of the native C++ variable to create. # type - xpidl.{Interface,Native,Builtin} - IDL type of argument # optional - bool - True if the parameter is optional. - # rvdeclared - bool - False if no |nsresult rv| has been declared earlier. isSetter = (i is None) @@ -462,7 +459,7 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): warn("Optional parameters of type %s are not supported." % type.name) f.write(substitute(template, params)) - return rvdeclared + return # else fall through; the type isn't supported yet. elif isInterfaceType(type): if type.name == 'nsIVariant': @@ -474,13 +471,11 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): " if (!${name})\n" " return JS_FALSE;\n") f.write(substitute(template, params)) - return rvdeclared + return elif type.name == 'nsIAtom': # Should have special atomizing behavior. Fall through. pass else: - if not rvdeclared: - f.write(" nsresult rv;\n"); f.write(" nsCOMPtr<%s> %s;\n" % (type.name, name)) f.write(" rv = xpc_qsUnwrapArg<%s>(" "cx, %s, getter_AddRefs(%s));\n" @@ -495,7 +490,7 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): f.write(" xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i) f.write(" return JS_FALSE;\n" " }\n") - return True + return warn("Unable to unbox argument of type %s" % type.name) if i is None: @@ -503,9 +498,8 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared): else: src = 'argv[%d]' % i f.write(" !; // TODO - Unbox argument %s = %s\n" % (name, src)) - return rvdeclared -def writeResultDecl(f, type, varname): +def writeResultDecl(f, type): if isVoidType(type): return # nothing to declare @@ -516,19 +510,19 @@ def writeResultDecl(f, type, varname): typeName = type.name # use it else: typeName = t.nativename - f.write(" %s %s;\n" % (typeName, varname)) + f.write(" %s result;\n" % typeName) return elif t.kind == 'native': name = getBuiltinOrNativeTypeName(t) if name in ('[domstring]', '[astring]'): - f.write(" nsString %s;\n" % varname) + f.write(" nsString result;\n") return elif t.kind in ('interface', 'forward'): - f.write(" nsCOMPtr<%s> %s;\n" % (type.name, varname)) + f.write(" nsCOMPtr<%s> result;\n" % type.name) return warn("Unable to declare result of type %s" % type.name) - f.write(" !; // TODO - Declare out parameter `%s`.\n" % varname) + f.write(" !; // TODO - Declare out parameter `result`.\n") def outParamForm(name, type): type = unaliasType(type) @@ -613,8 +607,7 @@ def writeResultConv(f, type, paramNum, jsvalPtr, jsvalRef): f.write(" AutoMarkingNativeInterfacePtr resultiface(ccx, " "%s_Interface(ccx));\n" % type.name) f.write(" return xpc_qsXPCOMObjectToJsval(ccx, result, " - "xpc_qsGetWrapperCache(result), resultiface, %s);\n" - % jsvalPtr) + "resultiface, %s);\n" % jsvalPtr) return warn("Unable to convert result of type %s" % type.name) @@ -628,7 +621,7 @@ def anyParamRequiresCcx(member): return True return False -def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): +def writeQuickStub(f, member, stubName, isSetter=False): """ Write a single quick stub (a custom SpiderMonkey getter/setter/method) for the specified XPCOM interface-member. """ @@ -637,8 +630,6 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): assert isAttr or isMethod isGetter = isAttr and not isSetter - customMethodCall = customMethodCalls.get(stubName, None) - # Function prolog. f.write("static JSBool\n") if isAttr: @@ -670,10 +661,8 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): f.write(" XPCCallContext ccx(JS_CALLER, cx, obj);\n") # Get the 'self' pointer. - if customMethodCall is None or not 'thisType' in customMethodCall: - f.write(" %s *self;\n" % member.iface.name) - else: - f.write(" %s *self;\n" % customMethodCall['thisType']) + thisType = member.iface.name + f.write(" %s *self;\n" % thisType) f.write(" xpc_qsSelfRef selfref;\n") # Don't use FromCcx for getters or setters; the way we construct the ccx in # a getter/setter causes it to find the wrong wrapper in some cases. @@ -712,7 +701,7 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): "parameter " + param.name + ": " + msg) # Convert in-parameters. - rvdeclared = False + f.write(" nsresult rv;\n") if isMethod: if len(member.params) > 0: f.write(" jsval *argv = JS_ARGV(cx, vp);\n") @@ -728,74 +717,48 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): if param.const or param.array or param.shared: pfail("I am a simple caveman.") # Emit code to convert this argument from jsval. - rvdeclared = writeArgumentUnboxing( + writeArgumentUnboxing( f, i, 'arg%d' % i, param.realtype, haveCcx=haveCcx, - optional=param.optional, - rvdeclared=rvdeclared) + optional=param.optional) elif isSetter: - rvdeclared = writeArgumentUnboxing(f, None, 'arg0', member.realtype, - haveCcx=False, optional=False, - rvdeclared=rvdeclared) - - if customMethodCall is not None: - f.write("%s\n" % customMethodCall['code']) - f.write("#ifdef DEBUG\n") - f.write(" nsCOMPtr<%s> debug_self = do_QueryInterface(self);\n" - % member.iface.name); - prefix = 'debug_' - else: - prefix = '' - - resultname = prefix + 'result' - selfname = prefix + 'self' + writeArgumentUnboxing(f, None, 'arg0', member.realtype, + haveCcx=False, optional=False) # Prepare out-parameter. if isMethod or isGetter: - writeResultDecl(f, member.realtype, resultname) + writeResultDecl(f, member.realtype) # Call the method. if isMethod: comName = header.methodNativeName(member) argv = ['arg' + str(i) for i, p in enumerate(member.params)] if not isVoidType(member.realtype): - argv.append(outParamForm(resultname, member.realtype)) + argv.append(outParamForm('result', member.realtype)) args = ', '.join(argv) else: comName = header.attributeNativeName(member, isGetter) if isGetter: - args = outParamForm(resultname, member.realtype) + args = outParamForm("result", member.realtype) else: args = "arg0" + f.write(" rv = self->%s(%s);\n" % (comName, args)) - if not rvdeclared: - f.write(" nsresult rv;\n") - rvdeclared = True - f.write(" rv = %s->%s(%s);\n" % (selfname, comName, args)) - - if customMethodCall is None: - # Check for errors. - f.write(" if (NS_FAILED(rv))\n") - if isMethod: - if haveCcx: - f.write(" return xpc_qsThrowMethodFailedWithCcx(" - "ccx, rv);\n") - else: - f.write(" return xpc_qsThrowMethodFailed(" - "cx, rv, vp);\n") + # Check for errors. + f.write(" if (NS_FAILED(rv))\n") + if isMethod: + if haveCcx: + f.write(" return xpc_qsThrowMethodFailedWithCcx(ccx, rv);\n") else: - if isGetter: - thisval = '*vp' - else: - thisval = '*tvr.addr()' - f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " + - "JSVAL_TO_OBJECT(%s), id);\n" % thisval) + f.write(" return xpc_qsThrowMethodFailed(" + "cx, rv, vp);\n") else: - if isMethod or isGetter: - f.write(" NS_ASSERTION(xpc_qsSameResult(debug_result, result),\n" - " \"Got the wrong answer from the custom " - "method call!\");\n") - f.write("#endif\n") + if isGetter: + thisval = '*vp' + else: + thisval = '*tvr.addr()' + f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " + + "JSVAL_TO_OBJECT(%s), id);\n" % thisval) # Convert the return value. if isMethod: @@ -808,38 +771,38 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): # Epilog. f.write("}\n\n") -def writeAttrStubs(f, customMethodCalls, attr): +def writeAttrStubs(f, attr): getterName = (attr.iface.name + '_' + header.attributeNativeName(attr, True)) - writeQuickStub(f, customMethodCalls, attr, getterName) + writeQuickStub(f, attr, getterName) if attr.readonly: setterName = 'xpc_qsReadOnlySetter' else: setterName = (attr.iface.name + '_' + header.attributeNativeName(attr, False)) - writeQuickStub(f, customMethodCalls, attr, setterName, isSetter=True) + writeQuickStub(f, attr, setterName, isSetter=True) ps = ('{"%s", %s, %s}' % (attr.name, getterName, setterName)) return ps -def writeMethodStub(f, customMethodCalls, method): +def writeMethodStub(f, method): """ Write a method stub to `f`. Return an xpc_qsFunctionSpec initializer. """ stubName = method.iface.name + '_' + header.methodNativeName(method) - writeQuickStub(f, customMethodCalls, method, stubName) + writeQuickStub(f, method, stubName) fs = '{"%s", %s, %d}' % (method.name, stubName, len(method.params)) return fs -def writeStubsForInterface(f, customMethodCalls, iface): +def writeStubsForInterface(f, iface): f.write("// === interface %s\n\n" % iface.name) propspecs = [] funcspecs = [] for member in iface.stubMembers: if member.kind == 'attribute': - ps = writeAttrStubs(f, customMethodCalls, member) + ps = writeAttrStubs(f, member) propspecs.append(ps) elif member.kind == 'method': - fs = writeMethodStub(f, customMethodCalls, member) + fs = writeMethodStub(f, member) funcspecs.append(fs) else: raise TypeError('expected attribute or method, not %r' @@ -1038,15 +1001,13 @@ def writeStubFile(filename, headerFilename, conf, interfaces): try: f.write(stubTopTemplate % os.path.basename(headerFilename)) N = 256 - for customInclude in conf.customIncludes: - f.write('#include "%s"\n' % customInclude) resulttypes = [] for iface in interfaces: resulttypes.extend(writeIncludesForInterface(iface)) f.write("\n\n") writeResultXPCInterfacesArray(f, conf, sets.ImmutableSet(resulttypes)) for iface in interfaces: - writeStubsForInterface(f, conf.customMethodCalls, iface) + writeStubsForInterface(f, iface) writeDefiner(f, conf, interfaces) finally: f.close() diff --git a/js/src/xpconnect/src/xpcconvert.cpp b/js/src/xpconnect/src/xpcconvert.cpp index a8799a23254d..b304c7a13071 100644 --- a/js/src/xpconnect/src/xpcconvert.cpp +++ b/js/src/xpconnect/src/xpcconvert.cpp @@ -468,7 +468,7 @@ XPCConvert::NativeData2JS(XPCCallContext& ccx, jsval* d, const void* s, // therefore this NativeInterface2JSObject will not end up // creating a new XPCNativeScriptableShared. if(!NativeInterface2JSObject(ccx, d, nsnull, iface, iid, - nsnull, nsnull, scope, PR_TRUE, + nsnull, scope, PR_TRUE, OBJ_IS_NOT_GLOBAL, pErr)) return JS_FALSE; @@ -1053,7 +1053,6 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx, nsISupports* src, const nsID* iid, XPCNativeInterface* Interface, - nsWrapperCache *cache, JSObject* scope, PRBool allowNativeWrapper, PRBool isGlobal, @@ -1124,8 +1123,8 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx, nsresult rv; XPCWrappedNative* wrapper; nsRefPtr strongWrapper; - if(!cache) - CallQueryInterface(src, &cache); + nsWrapperCache* cache = nsnull; + CallQueryInterface(src, &cache); if(cache && (wrapper = static_cast(cache->GetWrapper()))) { diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index dad95922f984..0bf205e45086 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -113,7 +113,6 @@ #include "nsTArray.h" #include "nsBaseHashtable.h" #include "nsHashKeys.h" -#include "nsWrapperCache.h" #include "nsIXPCScriptNotify.h" // used to notify: ScriptEvaluated @@ -2765,7 +2764,6 @@ public: nsISupports* src, const nsID* iid, XPCNativeInterface* Interface, - nsWrapperCache *cache, JSObject* scope, PRBool allowNativeWrapper, PRBool isGlobal, diff --git a/js/src/xpconnect/src/xpcquickstubs.cpp b/js/src/xpconnect/src/xpcquickstubs.cpp index e8c5c64cb2ba..67b36a78d24e 100644 --- a/js/src/xpconnect/src/xpcquickstubs.cpp +++ b/js/src/xpconnect/src/xpcquickstubs.cpp @@ -743,8 +743,7 @@ xpc_qsStringToJsval(JSContext *cx, const nsAString &str, jsval *rval) JSBool xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p, - nsWrapperCache *cache, XPCNativeInterface *iface, - jsval *rval) + XPCNativeInterface *iface, jsval *rval) { // From the T_INTERFACE case in XPCConvert::NativeData2JS. // This is one of the slowest things quick stubs do. @@ -762,7 +761,7 @@ xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p, // creating a new XPCNativeScriptableShared. nsresult rv; if(!XPCConvert::NativeInterface2JSObject(ccx, rval, nsnull, p, nsnull, - iface, cache, scope, PR_TRUE, + iface, scope, PR_TRUE, OBJ_IS_NOT_GLOBAL, &rv)) { // I can't tell if NativeInterface2JSObject throws JS exceptions diff --git a/js/src/xpconnect/src/xpcquickstubs.h b/js/src/xpconnect/src/xpcquickstubs.h index bf8e93f82d01..0a0761f93c84 100644 --- a/js/src/xpconnect/src/xpcquickstubs.h +++ b/js/src/xpconnect/src/xpcquickstubs.h @@ -394,23 +394,10 @@ xpc_qsUnwrapArg(JSContext *cx, jsval v, T **ppArg) reinterpret_cast(ppArg)); } -inline nsWrapperCache* -xpc_qsGetWrapperCache(nsWrapperCache *cache) -{ - return cache; -} - -inline nsWrapperCache* -xpc_qsGetWrapperCache(void *p) -{ - return nsnull; -} - /** Convert an XPCOM pointer to jsval. Return JS_TRUE on success. */ JSBool xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p, - nsWrapperCache *cache, XPCNativeInterface *iface, jsval *rval); @@ -440,12 +427,6 @@ xpc_qsReadOnlySetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp); void xpc_qsAssertContextOK(JSContext *cx); -inline PRBool -xpc_qsSameResult(nsISupports *result1, nsISupports *result2) -{ - return SameCOMIdentity(result1, result2); -} - #define XPC_QS_ASSERT_CONTEXT_OK(cx) xpc_qsAssertContextOK(cx) #else #define XPC_QS_ASSERT_CONTEXT_OK(cx) ((void) 0) diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 3ef5e0e9cf26..c4447ebd7f8c 100644 --- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -1346,7 +1346,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex, JSBool ok = XPCConvert::NativeInterface2JSObject(ccx, &v, nsnull, newThis, newWrapperIID, - nsnull, nsnull, obj, PR_FALSE, PR_FALSE, + nsnull, obj, PR_FALSE, PR_FALSE, nsnull); if(newWrapperIID) nsMemory::Free(newWrapperIID);