mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
Backed out changeset e0cce6a738c9 (Bug 466224 - Make quickstubs call nsINode/nsINodeList methods) for failing mochitest
This commit is contained in:
parent
a76598678b
commit
166047cba5
@ -1299,12 +1299,4 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||||||
nsresult
|
nsresult
|
||||||
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
|
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
|
||||||
|
|
||||||
inline nsIDocument*
|
|
||||||
nsINode::GetOwnerDocument() const
|
|
||||||
{
|
|
||||||
nsIDocument* ownerDoc = GetOwnerDoc();
|
|
||||||
|
|
||||||
return ownerDoc != this ? ownerDoc : nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* nsIDocument_h___ */
|
#endif /* nsIDocument_h___ */
|
||||||
|
@ -49,8 +49,6 @@
|
|||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsIDOMEvent;
|
class nsIDOMEvent;
|
||||||
class nsIDOMNode;
|
|
||||||
class nsIDOMNodeList;
|
|
||||||
class nsIPresShell;
|
class nsIPresShell;
|
||||||
class nsPresContext;
|
class nsPresContext;
|
||||||
class nsEventChainVisitor;
|
class nsEventChainVisitor;
|
||||||
@ -153,9 +151,9 @@ inline nsINode* NODE_FROM(C& aContent, D& aDocument)
|
|||||||
|
|
||||||
// IID for the nsINode interface
|
// IID for the nsINode interface
|
||||||
#define NS_INODE_IID \
|
#define NS_INODE_IID \
|
||||||
{ 0x0dc8fad3, 0xcb3f, 0x4f14, \
|
{ 0xb4125da4, 0x6f86, 0x45aa, \
|
||||||
{ 0x8e, 0x7e, 0x4f, 0x62, 0xab, 0x74, 0xb8, 0x1e } }
|
{ 0xbb, 0x55, 0x80, 0x70, 0x44, 0x24, 0xe2, 0x47 } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An internal interface that abstracts some DOMNode-related parts that both
|
* An internal interface that abstracts some DOMNode-related parts that both
|
||||||
* nsIContent and nsIDocument share. An instance of this interface has a list
|
* nsIContent and nsIDocument share. An instance of this interface has a list
|
||||||
@ -690,30 +688,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell);
|
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:
|
protected:
|
||||||
|
|
||||||
// Override this function to create a custom slots class.
|
// Override this function to create a custom slots class.
|
||||||
@ -760,14 +734,6 @@ protected:
|
|||||||
return IsEditableInternal();
|
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<nsINodeInfo> mNodeInfo;
|
nsCOMPtr<nsINodeInfo> mNodeInfo;
|
||||||
|
|
||||||
enum { PARENT_BIT_INDOCUMENT = 1 << 0, PARENT_BIT_PARENT_IS_CONTENT = 1 << 1 };
|
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
|
// nsINode, so if you change the nsISupports line below, make sure
|
||||||
// nsNodeSH::PreCreate() still does the right thing!
|
// nsNodeSH::PreCreate() still does the right thing!
|
||||||
#define NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
#define NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
||||||
NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode) \
|
NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode)
|
||||||
NS_INTERFACE_TABLE_ENTRY(_class, nsINode)
|
|
||||||
|
|
||||||
#define NS_NODE_INTERFACE_TABLE2(_class, _i1, _i2) \
|
#define NS_NODE_INTERFACE_TABLE2(_class, _i1, _i2) \
|
||||||
NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
|
||||||
|
@ -38,9 +38,8 @@
|
|||||||
#ifndef nsINodeList_h___
|
#ifndef nsINodeList_h___
|
||||||
#define nsINodeList_h___
|
#define nsINodeList_h___
|
||||||
|
|
||||||
#include "nsIDOMNodeList.h"
|
|
||||||
|
|
||||||
class nsINode;
|
class nsINode;
|
||||||
|
class nsIDOMNodeList;
|
||||||
|
|
||||||
// IID for the nsINodeList interface
|
// IID for the nsINodeList interface
|
||||||
#define NS_INODELIST_IID \
|
#define NS_INODELIST_IID \
|
||||||
|
@ -260,7 +260,18 @@ nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
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
|
NS_IMETHODIMP
|
||||||
@ -386,7 +397,11 @@ nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aResult)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||||
{
|
{
|
||||||
return nsINode::GetOwnerDocument(aOwnerDocument);
|
*aOwnerDocument = nsnull;
|
||||||
|
|
||||||
|
nsIDocument *document = GetOwnerDoc();
|
||||||
|
|
||||||
|
return document ? CallQueryInterface(document, aOwnerDocument) : NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -5333,7 +5333,18 @@ nsDocument::GetParentNode(nsIDOMNode** aParentNode)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
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
|
NS_IMETHODIMP
|
||||||
@ -5359,13 +5370,26 @@ nsDocument::HasAttributes(PRBool* aHasAttributes)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
nsDocument::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||||
{
|
{
|
||||||
return nsINode::GetFirstChild(aFirstChild);
|
if (mChildren.ChildCount()) {
|
||||||
|
return CallQueryInterface(mChildren.ChildAt(0), aFirstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
*aFirstChild = nsnull;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetLastChild(nsIDOMNode** aLastChild)
|
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
|
NS_IMETHODIMP
|
||||||
@ -5967,7 +5991,9 @@ nsDocument::RenameNode(nsIDOMNode *aNode,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
nsDocument::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||||
{
|
{
|
||||||
return nsINode::GetOwnerDocument(aOwnerDocument);
|
*aOwnerDocument = nsnull;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -145,6 +145,77 @@ nsGenericDOMDataNode::SetNodeValue(const nsAString& aNodeValue)
|
|||||||
aNodeValue.Length(), PR_TRUE);
|
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
|
nsresult
|
||||||
nsGenericDOMDataNode::GetNamespaceURI(nsAString& aNamespaceURI)
|
nsGenericDOMDataNode::GetNamespaceURI(nsAString& aNamespaceURI)
|
||||||
{
|
{
|
||||||
|
@ -73,12 +73,16 @@ public:
|
|||||||
// Implementation for nsIDOMNode
|
// Implementation for nsIDOMNode
|
||||||
nsresult GetNodeValue(nsAString& aNodeValue);
|
nsresult GetNodeValue(nsAString& aNodeValue);
|
||||||
nsresult SetNodeValue(const nsAString& aNodeValue);
|
nsresult SetNodeValue(const nsAString& aNodeValue);
|
||||||
|
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aAttributes);
|
NS_ENSURE_ARG_POINTER(aAttributes);
|
||||||
*aAttributes = nsnull;
|
*aAttributes = nsnull;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||||
|
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||||
|
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||||
nsresult HasChildNodes(PRBool* aHasChildNodes)
|
nsresult HasChildNodes(PRBool* aHasChildNodes)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aHasChildNodes);
|
NS_ENSURE_ARG_POINTER(aHasChildNodes);
|
||||||
@ -91,6 +95,18 @@ public:
|
|||||||
*aHasAttributes = PR_FALSE;
|
*aHasAttributes = PR_FALSE;
|
||||||
return NS_OK;
|
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,
|
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||||
nsIDOMNode** aReturn)
|
nsIDOMNode** aReturn)
|
||||||
{
|
{
|
||||||
@ -126,6 +142,7 @@ public:
|
|||||||
*aReturn = nsnull;
|
*aReturn = nsnull;
|
||||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||||
}
|
}
|
||||||
|
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||||
nsresult GetNamespaceURI(nsAString& aNamespaceURI);
|
nsresult GetNamespaceURI(nsAString& aNamespaceURI);
|
||||||
nsresult GetLocalName(nsAString& aLocalName);
|
nsresult GetLocalName(nsAString& aLocalName);
|
||||||
nsresult GetPrefix(nsAString& aPrefix);
|
nsresult GetPrefix(nsAString& aPrefix);
|
||||||
|
@ -424,103 +424,6 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
|
|||||||
return doc->GetRootContent();
|
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
|
PRInt32
|
||||||
@ -1798,6 +1701,60 @@ nsGenericElement::GetNodeType(PRUint16* aNodeType)
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsGenericElement::GetNamespaceURI(nsAString& aNamespaceURI)
|
nsGenericElement::GetNamespaceURI(nsAString& aNamespaceURI)
|
||||||
{
|
{
|
||||||
@ -1989,6 +1946,28 @@ nsGenericElement::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
|||||||
return NS_OK;
|
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
|
nsresult
|
||||||
nsGenericElement::HasChildNodes(PRBool* aReturn)
|
nsGenericElement::HasChildNodes(PRBool* aReturn)
|
||||||
{
|
{
|
||||||
@ -1997,6 +1976,33 @@ nsGenericElement::HasChildNodes(PRBool* aReturn)
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsGenericElement::GetTagName(nsAString& aTagName)
|
nsGenericElement::GetTagName(nsAString& aTagName)
|
||||||
{
|
{
|
||||||
|
@ -470,7 +470,11 @@ public:
|
|||||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue);
|
NS_IMETHOD GetNodeValue(nsAString& aNodeValue);
|
||||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue);
|
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue);
|
||||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||||
|
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode);
|
||||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
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 GetNamespaceURI(nsAString& aNamespaceURI);
|
||||||
NS_IMETHOD GetPrefix(nsAString& aPrefix);
|
NS_IMETHOD GetPrefix(nsAString& aPrefix);
|
||||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
||||||
@ -478,7 +482,10 @@ public:
|
|||||||
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
||||||
const nsAString& aVersion, PRBool* aReturn);
|
const nsAString& aVersion, PRBool* aReturn);
|
||||||
NS_IMETHOD HasAttributes(PRBool* aHasAttributes);
|
NS_IMETHOD HasAttributes(PRBool* aHasAttributes);
|
||||||
|
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
||||||
|
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild);
|
||||||
|
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild);
|
||||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||||
nsIDOMNode** aReturn);
|
nsIDOMNode** aReturn);
|
||||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||||
|
@ -74,7 +74,6 @@ REQUIRES += content \
|
|||||||
svg \
|
svg \
|
||||||
xuldoc \
|
xuldoc \
|
||||||
xultmpl \
|
xultmpl \
|
||||||
widget \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
||||||
|
@ -512,51 +512,3 @@ irregularFilenames = {
|
|||||||
'nsIDOMNSCSS2Properties': 'nsIDOMCSS2Properties',
|
'nsIDOMNSCSS2Properties': 'nsIDOMCSS2Properties',
|
||||||
'nsIXPointerResult': 'nsIXPointer',
|
'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);'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1113,8 +1113,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
|||||||
if(!XPCConvert::NativeInterface2JSObject(ccx, &v,
|
if(!XPCConvert::NativeInterface2JSObject(ccx, &v,
|
||||||
getter_AddRefs(holder),
|
getter_AddRefs(holder),
|
||||||
aCOMObj, &aIID, nsnull,
|
aCOMObj, &aIID, nsnull,
|
||||||
nsnull, tempGlobal,
|
tempGlobal, PR_FALSE,
|
||||||
PR_FALSE, OBJ_IS_GLOBAL, &rv))
|
OBJ_IS_GLOBAL, &rv))
|
||||||
return UnexpectedFailure(rv);
|
return UnexpectedFailure(rv);
|
||||||
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv) && holder, "Didn't wrap properly");
|
NS_ASSERTION(NS_SUCCEEDED(rv) && holder, "Didn't wrap properly");
|
||||||
@ -1213,7 +1213,7 @@ nsXPConnect::WrapNativeToJSVal(JSContext * aJSContext,
|
|||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if(!XPCConvert::NativeInterface2JSObject(ccx, aVal, aHolder, aCOMObj, aIID,
|
if(!XPCConvert::NativeInterface2JSObject(ccx, aVal, aHolder, aCOMObj, aIID,
|
||||||
nsnull, nsnull, aScope, PR_FALSE,
|
nsnull, aScope, PR_FALSE,
|
||||||
OBJ_IS_NOT_GLOBAL, &rv))
|
OBJ_IS_NOT_GLOBAL, &rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
@ -263,8 +263,6 @@ class Configuration:
|
|||||||
setattr(self, name, config[name])
|
setattr(self, name, config[name])
|
||||||
# optional settings
|
# optional settings
|
||||||
self.irregularFilenames = config.get('irregularFilenames', {})
|
self.irregularFilenames = config.get('irregularFilenames', {})
|
||||||
self.customIncludes = config.get('customIncludes', [])
|
|
||||||
self.customMethodCalls = config.get('customMethodCalls', {})
|
|
||||||
|
|
||||||
def readConfigFile(filename, includePath, cachedir):
|
def readConfigFile(filename, includePath, cachedir):
|
||||||
# Read the config file.
|
# Read the config file.
|
||||||
@ -425,7 +423,7 @@ argumentUnboxingTemplates = {
|
|||||||
# Omitted optional arguments are treated as though the caller had passed JS
|
# Omitted optional arguments are treated as though the caller had passed JS
|
||||||
# `null`; this behavior is from XPCWrappedNative::CallMethod.
|
# `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
|
# f - file to write to
|
||||||
# i - int or None - Indicates the source jsval. If i is an int, the source
|
# 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,
|
# 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.
|
# name - str - name of the native C++ variable to create.
|
||||||
# type - xpidl.{Interface,Native,Builtin} - IDL type of argument
|
# type - xpidl.{Interface,Native,Builtin} - IDL type of argument
|
||||||
# optional - bool - True if the parameter is optional.
|
# optional - bool - True if the parameter is optional.
|
||||||
# rvdeclared - bool - False if no |nsresult rv| has been declared earlier.
|
|
||||||
|
|
||||||
isSetter = (i is None)
|
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."
|
warn("Optional parameters of type %s are not supported."
|
||||||
% type.name)
|
% type.name)
|
||||||
f.write(substitute(template, params))
|
f.write(substitute(template, params))
|
||||||
return rvdeclared
|
return
|
||||||
# else fall through; the type isn't supported yet.
|
# else fall through; the type isn't supported yet.
|
||||||
elif isInterfaceType(type):
|
elif isInterfaceType(type):
|
||||||
if type.name == 'nsIVariant':
|
if type.name == 'nsIVariant':
|
||||||
@ -474,13 +471,11 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared):
|
|||||||
" if (!${name})\n"
|
" if (!${name})\n"
|
||||||
" return JS_FALSE;\n")
|
" return JS_FALSE;\n")
|
||||||
f.write(substitute(template, params))
|
f.write(substitute(template, params))
|
||||||
return rvdeclared
|
return
|
||||||
elif type.name == 'nsIAtom':
|
elif type.name == 'nsIAtom':
|
||||||
# Should have special atomizing behavior. Fall through.
|
# Should have special atomizing behavior. Fall through.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if not rvdeclared:
|
|
||||||
f.write(" nsresult rv;\n");
|
|
||||||
f.write(" nsCOMPtr<%s> %s;\n" % (type.name, name))
|
f.write(" nsCOMPtr<%s> %s;\n" % (type.name, name))
|
||||||
f.write(" rv = xpc_qsUnwrapArg<%s>("
|
f.write(" rv = xpc_qsUnwrapArg<%s>("
|
||||||
"cx, %s, getter_AddRefs(%s));\n"
|
"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(" xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i)
|
||||||
f.write(" return JS_FALSE;\n"
|
f.write(" return JS_FALSE;\n"
|
||||||
" }\n")
|
" }\n")
|
||||||
return True
|
return
|
||||||
|
|
||||||
warn("Unable to unbox argument of type %s" % type.name)
|
warn("Unable to unbox argument of type %s" % type.name)
|
||||||
if i is None:
|
if i is None:
|
||||||
@ -503,9 +498,8 @@ def writeArgumentUnboxing(f, i, name, type, haveCcx, optional, rvdeclared):
|
|||||||
else:
|
else:
|
||||||
src = 'argv[%d]' % i
|
src = 'argv[%d]' % i
|
||||||
f.write(" !; // TODO - Unbox argument %s = %s\n" % (name, src))
|
f.write(" !; // TODO - Unbox argument %s = %s\n" % (name, src))
|
||||||
return rvdeclared
|
|
||||||
|
|
||||||
def writeResultDecl(f, type, varname):
|
def writeResultDecl(f, type):
|
||||||
if isVoidType(type):
|
if isVoidType(type):
|
||||||
return # nothing to declare
|
return # nothing to declare
|
||||||
|
|
||||||
@ -516,19 +510,19 @@ def writeResultDecl(f, type, varname):
|
|||||||
typeName = type.name # use it
|
typeName = type.name # use it
|
||||||
else:
|
else:
|
||||||
typeName = t.nativename
|
typeName = t.nativename
|
||||||
f.write(" %s %s;\n" % (typeName, varname))
|
f.write(" %s result;\n" % typeName)
|
||||||
return
|
return
|
||||||
elif t.kind == 'native':
|
elif t.kind == 'native':
|
||||||
name = getBuiltinOrNativeTypeName(t)
|
name = getBuiltinOrNativeTypeName(t)
|
||||||
if name in ('[domstring]', '[astring]'):
|
if name in ('[domstring]', '[astring]'):
|
||||||
f.write(" nsString %s;\n" % varname)
|
f.write(" nsString result;\n")
|
||||||
return
|
return
|
||||||
elif t.kind in ('interface', 'forward'):
|
elif t.kind in ('interface', 'forward'):
|
||||||
f.write(" nsCOMPtr<%s> %s;\n" % (type.name, varname))
|
f.write(" nsCOMPtr<%s> result;\n" % type.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
warn("Unable to declare result of type %s" % type.name)
|
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):
|
def outParamForm(name, type):
|
||||||
type = unaliasType(type)
|
type = unaliasType(type)
|
||||||
@ -613,8 +607,7 @@ def writeResultConv(f, type, paramNum, jsvalPtr, jsvalRef):
|
|||||||
f.write(" AutoMarkingNativeInterfacePtr resultiface(ccx, "
|
f.write(" AutoMarkingNativeInterfacePtr resultiface(ccx, "
|
||||||
"%s_Interface(ccx));\n" % type.name)
|
"%s_Interface(ccx));\n" % type.name)
|
||||||
f.write(" return xpc_qsXPCOMObjectToJsval(ccx, result, "
|
f.write(" return xpc_qsXPCOMObjectToJsval(ccx, result, "
|
||||||
"xpc_qsGetWrapperCache(result), resultiface, %s);\n"
|
"resultiface, %s);\n" % jsvalPtr)
|
||||||
% jsvalPtr)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
warn("Unable to convert result of type %s" % type.name)
|
warn("Unable to convert result of type %s" % type.name)
|
||||||
@ -628,7 +621,7 @@ def anyParamRequiresCcx(member):
|
|||||||
return True
|
return True
|
||||||
return False
|
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)
|
""" Write a single quick stub (a custom SpiderMonkey getter/setter/method)
|
||||||
for the specified XPCOM interface-member.
|
for the specified XPCOM interface-member.
|
||||||
"""
|
"""
|
||||||
@ -637,8 +630,6 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||||||
assert isAttr or isMethod
|
assert isAttr or isMethod
|
||||||
isGetter = isAttr and not isSetter
|
isGetter = isAttr and not isSetter
|
||||||
|
|
||||||
customMethodCall = customMethodCalls.get(stubName, None)
|
|
||||||
|
|
||||||
# Function prolog.
|
# Function prolog.
|
||||||
f.write("static JSBool\n")
|
f.write("static JSBool\n")
|
||||||
if isAttr:
|
if isAttr:
|
||||||
@ -670,10 +661,8 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||||||
f.write(" XPCCallContext ccx(JS_CALLER, cx, obj);\n")
|
f.write(" XPCCallContext ccx(JS_CALLER, cx, obj);\n")
|
||||||
|
|
||||||
# Get the 'self' pointer.
|
# Get the 'self' pointer.
|
||||||
if customMethodCall is None or not 'thisType' in customMethodCall:
|
thisType = member.iface.name
|
||||||
f.write(" %s *self;\n" % member.iface.name)
|
f.write(" %s *self;\n" % thisType)
|
||||||
else:
|
|
||||||
f.write(" %s *self;\n" % customMethodCall['thisType'])
|
|
||||||
f.write(" xpc_qsSelfRef selfref;\n")
|
f.write(" xpc_qsSelfRef selfref;\n")
|
||||||
# Don't use FromCcx for getters or setters; the way we construct the ccx in
|
# 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.
|
# 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)
|
"parameter " + param.name + ": " + msg)
|
||||||
|
|
||||||
# Convert in-parameters.
|
# Convert in-parameters.
|
||||||
rvdeclared = False
|
f.write(" nsresult rv;\n")
|
||||||
if isMethod:
|
if isMethod:
|
||||||
if len(member.params) > 0:
|
if len(member.params) > 0:
|
||||||
f.write(" jsval *argv = JS_ARGV(cx, vp);\n")
|
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:
|
if param.const or param.array or param.shared:
|
||||||
pfail("I am a simple caveman.")
|
pfail("I am a simple caveman.")
|
||||||
# Emit code to convert this argument from jsval.
|
# Emit code to convert this argument from jsval.
|
||||||
rvdeclared = writeArgumentUnboxing(
|
writeArgumentUnboxing(
|
||||||
f, i, 'arg%d' % i, param.realtype,
|
f, i, 'arg%d' % i, param.realtype,
|
||||||
haveCcx=haveCcx,
|
haveCcx=haveCcx,
|
||||||
optional=param.optional,
|
optional=param.optional)
|
||||||
rvdeclared=rvdeclared)
|
|
||||||
elif isSetter:
|
elif isSetter:
|
||||||
rvdeclared = writeArgumentUnboxing(f, None, 'arg0', member.realtype,
|
writeArgumentUnboxing(f, None, 'arg0', member.realtype,
|
||||||
haveCcx=False, optional=False,
|
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'
|
|
||||||
|
|
||||||
# Prepare out-parameter.
|
# Prepare out-parameter.
|
||||||
if isMethod or isGetter:
|
if isMethod or isGetter:
|
||||||
writeResultDecl(f, member.realtype, resultname)
|
writeResultDecl(f, member.realtype)
|
||||||
|
|
||||||
# Call the method.
|
# Call the method.
|
||||||
if isMethod:
|
if isMethod:
|
||||||
comName = header.methodNativeName(member)
|
comName = header.methodNativeName(member)
|
||||||
argv = ['arg' + str(i) for i, p in enumerate(member.params)]
|
argv = ['arg' + str(i) for i, p in enumerate(member.params)]
|
||||||
if not isVoidType(member.realtype):
|
if not isVoidType(member.realtype):
|
||||||
argv.append(outParamForm(resultname, member.realtype))
|
argv.append(outParamForm('result', member.realtype))
|
||||||
args = ', '.join(argv)
|
args = ', '.join(argv)
|
||||||
else:
|
else:
|
||||||
comName = header.attributeNativeName(member, isGetter)
|
comName = header.attributeNativeName(member, isGetter)
|
||||||
if isGetter:
|
if isGetter:
|
||||||
args = outParamForm(resultname, member.realtype)
|
args = outParamForm("result", member.realtype)
|
||||||
else:
|
else:
|
||||||
args = "arg0"
|
args = "arg0"
|
||||||
|
f.write(" rv = self->%s(%s);\n" % (comName, args))
|
||||||
|
|
||||||
if not rvdeclared:
|
# Check for errors.
|
||||||
f.write(" nsresult rv;\n")
|
f.write(" if (NS_FAILED(rv))\n")
|
||||||
rvdeclared = True
|
if isMethod:
|
||||||
f.write(" rv = %s->%s(%s);\n" % (selfname, comName, args))
|
if haveCcx:
|
||||||
|
f.write(" return xpc_qsThrowMethodFailedWithCcx(ccx, rv);\n")
|
||||||
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")
|
|
||||||
else:
|
else:
|
||||||
if isGetter:
|
f.write(" return xpc_qsThrowMethodFailed("
|
||||||
thisval = '*vp'
|
"cx, rv, vp);\n")
|
||||||
else:
|
|
||||||
thisval = '*tvr.addr()'
|
|
||||||
f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " +
|
|
||||||
"JSVAL_TO_OBJECT(%s), id);\n" % thisval)
|
|
||||||
else:
|
else:
|
||||||
if isMethod or isGetter:
|
if isGetter:
|
||||||
f.write(" NS_ASSERTION(xpc_qsSameResult(debug_result, result),\n"
|
thisval = '*vp'
|
||||||
" \"Got the wrong answer from the custom "
|
else:
|
||||||
"method call!\");\n")
|
thisval = '*tvr.addr()'
|
||||||
f.write("#endif\n")
|
f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " +
|
||||||
|
"JSVAL_TO_OBJECT(%s), id);\n" % thisval)
|
||||||
|
|
||||||
# Convert the return value.
|
# Convert the return value.
|
||||||
if isMethod:
|
if isMethod:
|
||||||
@ -808,38 +771,38 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
|||||||
# Epilog.
|
# Epilog.
|
||||||
f.write("}\n\n")
|
f.write("}\n\n")
|
||||||
|
|
||||||
def writeAttrStubs(f, customMethodCalls, attr):
|
def writeAttrStubs(f, attr):
|
||||||
getterName = (attr.iface.name + '_'
|
getterName = (attr.iface.name + '_'
|
||||||
+ header.attributeNativeName(attr, True))
|
+ header.attributeNativeName(attr, True))
|
||||||
writeQuickStub(f, customMethodCalls, attr, getterName)
|
writeQuickStub(f, attr, getterName)
|
||||||
if attr.readonly:
|
if attr.readonly:
|
||||||
setterName = 'xpc_qsReadOnlySetter'
|
setterName = 'xpc_qsReadOnlySetter'
|
||||||
else:
|
else:
|
||||||
setterName = (attr.iface.name + '_'
|
setterName = (attr.iface.name + '_'
|
||||||
+ header.attributeNativeName(attr, False))
|
+ header.attributeNativeName(attr, False))
|
||||||
writeQuickStub(f, customMethodCalls, attr, setterName, isSetter=True)
|
writeQuickStub(f, attr, setterName, isSetter=True)
|
||||||
|
|
||||||
ps = ('{"%s", %s, %s}'
|
ps = ('{"%s", %s, %s}'
|
||||||
% (attr.name, getterName, setterName))
|
% (attr.name, getterName, setterName))
|
||||||
return ps
|
return ps
|
||||||
|
|
||||||
def writeMethodStub(f, customMethodCalls, method):
|
def writeMethodStub(f, method):
|
||||||
""" Write a method stub to `f`. Return an xpc_qsFunctionSpec initializer. """
|
""" Write a method stub to `f`. Return an xpc_qsFunctionSpec initializer. """
|
||||||
stubName = method.iface.name + '_' + header.methodNativeName(method)
|
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))
|
fs = '{"%s", %s, %d}' % (method.name, stubName, len(method.params))
|
||||||
return fs
|
return fs
|
||||||
|
|
||||||
def writeStubsForInterface(f, customMethodCalls, iface):
|
def writeStubsForInterface(f, iface):
|
||||||
f.write("// === interface %s\n\n" % iface.name)
|
f.write("// === interface %s\n\n" % iface.name)
|
||||||
propspecs = []
|
propspecs = []
|
||||||
funcspecs = []
|
funcspecs = []
|
||||||
for member in iface.stubMembers:
|
for member in iface.stubMembers:
|
||||||
if member.kind == 'attribute':
|
if member.kind == 'attribute':
|
||||||
ps = writeAttrStubs(f, customMethodCalls, member)
|
ps = writeAttrStubs(f, member)
|
||||||
propspecs.append(ps)
|
propspecs.append(ps)
|
||||||
elif member.kind == 'method':
|
elif member.kind == 'method':
|
||||||
fs = writeMethodStub(f, customMethodCalls, member)
|
fs = writeMethodStub(f, member)
|
||||||
funcspecs.append(fs)
|
funcspecs.append(fs)
|
||||||
else:
|
else:
|
||||||
raise TypeError('expected attribute or method, not %r'
|
raise TypeError('expected attribute or method, not %r'
|
||||||
@ -1038,15 +1001,13 @@ def writeStubFile(filename, headerFilename, conf, interfaces):
|
|||||||
try:
|
try:
|
||||||
f.write(stubTopTemplate % os.path.basename(headerFilename))
|
f.write(stubTopTemplate % os.path.basename(headerFilename))
|
||||||
N = 256
|
N = 256
|
||||||
for customInclude in conf.customIncludes:
|
|
||||||
f.write('#include "%s"\n' % customInclude)
|
|
||||||
resulttypes = []
|
resulttypes = []
|
||||||
for iface in interfaces:
|
for iface in interfaces:
|
||||||
resulttypes.extend(writeIncludesForInterface(iface))
|
resulttypes.extend(writeIncludesForInterface(iface))
|
||||||
f.write("\n\n")
|
f.write("\n\n")
|
||||||
writeResultXPCInterfacesArray(f, conf, sets.ImmutableSet(resulttypes))
|
writeResultXPCInterfacesArray(f, conf, sets.ImmutableSet(resulttypes))
|
||||||
for iface in interfaces:
|
for iface in interfaces:
|
||||||
writeStubsForInterface(f, conf.customMethodCalls, iface)
|
writeStubsForInterface(f, iface)
|
||||||
writeDefiner(f, conf, interfaces)
|
writeDefiner(f, conf, interfaces)
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -468,7 +468,7 @@ XPCConvert::NativeData2JS(XPCCallContext& ccx, jsval* d, const void* s,
|
|||||||
// therefore this NativeInterface2JSObject will not end up
|
// therefore this NativeInterface2JSObject will not end up
|
||||||
// creating a new XPCNativeScriptableShared.
|
// creating a new XPCNativeScriptableShared.
|
||||||
if(!NativeInterface2JSObject(ccx, d, nsnull, iface, iid,
|
if(!NativeInterface2JSObject(ccx, d, nsnull, iface, iid,
|
||||||
nsnull, nsnull, scope, PR_TRUE,
|
nsnull, scope, PR_TRUE,
|
||||||
OBJ_IS_NOT_GLOBAL, pErr))
|
OBJ_IS_NOT_GLOBAL, pErr))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
|
|
||||||
@ -1053,7 +1053,6 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
|||||||
nsISupports* src,
|
nsISupports* src,
|
||||||
const nsID* iid,
|
const nsID* iid,
|
||||||
XPCNativeInterface* Interface,
|
XPCNativeInterface* Interface,
|
||||||
nsWrapperCache *cache,
|
|
||||||
JSObject* scope,
|
JSObject* scope,
|
||||||
PRBool allowNativeWrapper,
|
PRBool allowNativeWrapper,
|
||||||
PRBool isGlobal,
|
PRBool isGlobal,
|
||||||
@ -1124,8 +1123,8 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
XPCWrappedNative* wrapper;
|
XPCWrappedNative* wrapper;
|
||||||
nsRefPtr<XPCWrappedNative> strongWrapper;
|
nsRefPtr<XPCWrappedNative> strongWrapper;
|
||||||
if(!cache)
|
nsWrapperCache* cache = nsnull;
|
||||||
CallQueryInterface(src, &cache);
|
CallQueryInterface(src, &cache);
|
||||||
if(cache &&
|
if(cache &&
|
||||||
(wrapper = static_cast<XPCWrappedNative*>(cache->GetWrapper())))
|
(wrapper = static_cast<XPCWrappedNative*>(cache->GetWrapper())))
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,6 @@
|
|||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsBaseHashtable.h"
|
#include "nsBaseHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "nsWrapperCache.h"
|
|
||||||
|
|
||||||
#include "nsIXPCScriptNotify.h" // used to notify: ScriptEvaluated
|
#include "nsIXPCScriptNotify.h" // used to notify: ScriptEvaluated
|
||||||
|
|
||||||
@ -2765,7 +2764,6 @@ public:
|
|||||||
nsISupports* src,
|
nsISupports* src,
|
||||||
const nsID* iid,
|
const nsID* iid,
|
||||||
XPCNativeInterface* Interface,
|
XPCNativeInterface* Interface,
|
||||||
nsWrapperCache *cache,
|
|
||||||
JSObject* scope,
|
JSObject* scope,
|
||||||
PRBool allowNativeWrapper,
|
PRBool allowNativeWrapper,
|
||||||
PRBool isGlobal,
|
PRBool isGlobal,
|
||||||
|
@ -743,8 +743,7 @@ xpc_qsStringToJsval(JSContext *cx, const nsAString &str, jsval *rval)
|
|||||||
|
|
||||||
JSBool
|
JSBool
|
||||||
xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p,
|
xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p,
|
||||||
nsWrapperCache *cache, XPCNativeInterface *iface,
|
XPCNativeInterface *iface, jsval *rval)
|
||||||
jsval *rval)
|
|
||||||
{
|
{
|
||||||
// From the T_INTERFACE case in XPCConvert::NativeData2JS.
|
// From the T_INTERFACE case in XPCConvert::NativeData2JS.
|
||||||
// This is one of the slowest things quick stubs do.
|
// This is one of the slowest things quick stubs do.
|
||||||
@ -762,7 +761,7 @@ xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx, nsISupports *p,
|
|||||||
// creating a new XPCNativeScriptableShared.
|
// creating a new XPCNativeScriptableShared.
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if(!XPCConvert::NativeInterface2JSObject(ccx, rval, nsnull, p, nsnull,
|
if(!XPCConvert::NativeInterface2JSObject(ccx, rval, nsnull, p, nsnull,
|
||||||
iface, cache, scope, PR_TRUE,
|
iface, scope, PR_TRUE,
|
||||||
OBJ_IS_NOT_GLOBAL, &rv))
|
OBJ_IS_NOT_GLOBAL, &rv))
|
||||||
{
|
{
|
||||||
// I can't tell if NativeInterface2JSObject throws JS exceptions
|
// I can't tell if NativeInterface2JSObject throws JS exceptions
|
||||||
|
@ -394,23 +394,10 @@ xpc_qsUnwrapArg(JSContext *cx, jsval v, T **ppArg)
|
|||||||
reinterpret_cast<void **>(ppArg));
|
reinterpret_cast<void **>(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. */
|
/** Convert an XPCOM pointer to jsval. Return JS_TRUE on success. */
|
||||||
JSBool
|
JSBool
|
||||||
xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx,
|
xpc_qsXPCOMObjectToJsval(XPCCallContext &ccx,
|
||||||
nsISupports *p,
|
nsISupports *p,
|
||||||
nsWrapperCache *cache,
|
|
||||||
XPCNativeInterface *iface,
|
XPCNativeInterface *iface,
|
||||||
jsval *rval);
|
jsval *rval);
|
||||||
|
|
||||||
@ -440,12 +427,6 @@ xpc_qsReadOnlySetter(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
|||||||
void
|
void
|
||||||
xpc_qsAssertContextOK(JSContext *cx);
|
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)
|
#define XPC_QS_ASSERT_CONTEXT_OK(cx) xpc_qsAssertContextOK(cx)
|
||||||
#else
|
#else
|
||||||
#define XPC_QS_ASSERT_CONTEXT_OK(cx) ((void) 0)
|
#define XPC_QS_ASSERT_CONTEXT_OK(cx) ((void) 0)
|
||||||
|
@ -1346,7 +1346,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||||||
JSBool ok =
|
JSBool ok =
|
||||||
XPCConvert::NativeInterface2JSObject(ccx,
|
XPCConvert::NativeInterface2JSObject(ccx,
|
||||||
&v, nsnull, newThis, newWrapperIID,
|
&v, nsnull, newThis, newWrapperIID,
|
||||||
nsnull, nsnull, obj, PR_FALSE, PR_FALSE,
|
nsnull, obj, PR_FALSE, PR_FALSE,
|
||||||
nsnull);
|
nsnull);
|
||||||
if(newWrapperIID)
|
if(newWrapperIID)
|
||||||
nsMemory::Free(newWrapperIID);
|
nsMemory::Free(newWrapperIID);
|
||||||
|
Loading…
Reference in New Issue
Block a user