Fixing bug 407812. Don't waste time calling QI in nsNodeSH::PreCreate() and nsElementSH::PostCreate(). r+sr=jonas@sicking.cc

This commit is contained in:
jst@mozilla.org 2007-12-10 17:19:18 -08:00
parent 1a7c95afcf
commit b23a26124d
6 changed files with 47 additions and 13 deletions

View File

@ -99,7 +99,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMAttribute)
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMAttr)
// nsNodeSH::PreCreate() depends on the identity pointer being the
// same as nsINode (which nsIAttribute inherits), so if you change
// the below line, make sure nsNodeSH::PreCreate() still does the
// right thing!
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAttribute)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Attr)
NS_INTERFACE_MAP_END

View File

@ -896,6 +896,7 @@ nsDocument::~nsDocument()
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocument)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsIDocument)
NS_INTERFACE_MAP_ENTRY(nsIDOMDocument)
NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocument)
@ -917,8 +918,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocument)
NS_INTERFACE_MAP_ENTRY(nsIDOM3Document)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
// nsNodeSH::PreCreate() depends on the identity pointer being the
// same as nsINode (which nsIDocument inherits), so if you change
// the below line, make sure nsNodeSH::PreCreate() still does the
// right thing!
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocument)
if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator)) ||
aIID.Equals(NS_GET_IID(nsIXPathEvaluatorInternal))) {

View File

@ -103,6 +103,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericDOMDataNode)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
// nsNodeSH::PreCreate() depends on the identity pointer being the
// same as nsINode (which nsIContent inherits), so if you change the
// below line, make sure nsNodeSH::PreCreate() still does the right
// thing!
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
NS_INTERFACE_MAP_END

View File

@ -3434,6 +3434,10 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement)
nsDOMEventRTTearoff::Create(this))
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
// nsNodeSH::PreCreate() depends on the identity pointer being the
// same as nsINode (which nsIContent inherits), so if you change the
// below line, make sure nsNodeSH::PreCreate() still does the right
// thing!
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
NS_INTERFACE_MAP_END

View File

@ -266,13 +266,11 @@ nsImageDocument::~nsImageDocument()
NS_IMPL_ADDREF_INHERITED(nsImageDocument, nsMediaDocument)
NS_IMPL_RELEASE_INHERITED(nsImageDocument, nsMediaDocument)
NS_INTERFACE_TABLE_HEAD(nsImageDocument)
NS_INTERFACE_TABLE4(nsImageDocument,
nsIImageDocument,
imgIDecoderObserver,
imgIContainerObserver,
nsIDOMEventListener)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_MAP_BEGIN(nsImageDocument)
NS_INTERFACE_MAP_ENTRY(nsIImageDocument)
NS_INTERFACE_MAP_ENTRY(imgIDecoderObserver)
NS_INTERFACE_MAP_ENTRY(imgIContainerObserver)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ImageDocument)
NS_INTERFACE_MAP_END_INHERITING(nsMediaDocument)

View File

@ -6444,9 +6444,19 @@ NS_IMETHODIMP
nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
JSObject **parentObj)
{
nsCOMPtr<nsINode> node(do_QueryInterface(nativeObj));
NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
nsINode *node = static_cast<nsINode*>(nativeObj);
#ifdef DEBUG
{
nsCOMPtr<nsINode> node_qi(do_QueryInterface(nativeObj));
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsINode pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(node_qi == node, "Uh, fix QI!");
}
#endif
// Make sure that we get the owner document of the content node, in case
// we're in document teardown. If we are, it's important to *not* use
// globalObj as the nodes parent since that would give the node the
@ -6964,8 +6974,18 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
nsresult rv = nsNodeSH::PostCreate(wrapper, cx, obj);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> content(do_QueryWrappedNative(wrapper));
NS_ENSURE_TRUE(content, NS_ERROR_UNEXPECTED);
nsIContent *content = static_cast<nsIContent*>(wrapper->Native());
#ifdef DEBUG
{
nsCOMPtr<nsIContent> content_qi(do_QueryWrappedNative(wrapper));
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIContent pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(content_qi == content, "Uh, fix QI!");
}
#endif
nsCOMPtr<nsIDocument> doc;
if (content->HasFlag(NODE_FORCE_XBL_BINDINGS)) {