Comment 7 for bug 62815

Revision history for this message
In , Jst (jst) wrote :

Comment on attachment 200882
patch, v1

+ nsCOMPtr<nsIDOMDocument> document(do_QueryInterface(mStartParent));
+ if (!document) {
+ res = mStartParent->GetOwnerDocument(getter_AddRefs(document));
+ if (NS_FAILED(res)) return res;
+ }

The common case here is that mStartParent is *not* a document, so this would be faster over all if you flipped this around (since you wouldn't be trying to QI to nsIDOMDocument when you know it will fail in most cases), i.e.:

+ nsCOMPtr<nsIDOMDocument> document;
+ res = mStartParent->GetOwnerDocument(getter_AddRefs(document));
+ if (NS_FAILED(res)) return res;
+ if (!document) {
+ document = do_QueryInterface(mStartParent);
+ }

r+sr=jst either way though.